Remove transform methods from mapgrid (#12233)

This commit is contained in:
metalgearsloth
2022-11-01 11:27:18 +11:00
committed by GitHub
parent 297686c4ff
commit c9a2ab1cee
25 changed files with 144 additions and 78 deletions

View File

@@ -250,19 +250,23 @@ namespace Content.Shared.Maps
/// <summary>
/// Creates a box the size of a tile, at the same position in the world as the tile.
/// </summary>
[Obsolete]
private static bool GetWorldTileBox(TileRef turf, out Box2Rotated res)
{
var entManager = IoCManager.Resolve<IEntityManager>();
var map = IoCManager.Resolve<IMapManager>();
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
{
var gridRot = entManager.GetComponent<TransformComponent>(tileGrid.GridEntityId).WorldRotation;
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
var tileBox = Box2.UnitCentered.Scale(0.9f);
tileBox = tileBox.Scale(tileGrid.TileSize);
var worldPos = tileGrid.GridTileToWorldPos(turf.GridIndices);
tileBox = tileBox.Translated(worldPos);
// Now tileBox needs to be rotated to match grid rotation
res = new Box2Rotated(tileBox, tileGrid.WorldRotation, worldPos);
res = new Box2Rotated(tileBox, gridRot, worldPos);
return true;
}