Skip to content

Commit 462519b

Browse files
authored
Cleanup WarpCommand (space-wizards#36088)
* EntityCoordinates.GetGridUid -> SharedTransformSystem.GetGrid * EntityCoordinates.GetMapId -> SharedTransformSystem.GetMapId * Hey look, there's been a bug here this whole time * TransformComponent.Coordinates.set -> SharedTransformSystem.SetCoordinates * Now actually working! * Formatting why not * Remove unneeded GetComponent
1 parent 9ca6353 commit 462519b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Content.Server/Administration/Commands/WarpCommand.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
4848
}
4949
else
5050
{
51-
if (player.Status != SessionStatus.InGame || player.AttachedEntity is not {Valid: true} playerEntity)
51+
if (player.Status != SessionStatus.InGame || player.AttachedEntity is not { Valid: true } playerEntity)
5252
{
5353
shell.WriteLine("You are not in-game!");
5454
return;
@@ -57,14 +57,16 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
5757
var currentMap = _entManager.GetComponent<TransformComponent>(playerEntity).MapID;
5858
var currentGrid = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
5959

60+
var xformSystem = _entManager.System<SharedTransformSystem>();
61+
6062
var found = GetWarpPointByName(location)
6163
.OrderBy(p => p.Item1, Comparer<EntityCoordinates>.Create((a, b) =>
6264
{
6365
// Sort so that warp points on the same grid/map are first.
6466
// So if you have two maps loaded with the same warp points,
6567
// it will prefer the warp points on the map you're currently on.
66-
var aGrid = a.GetGridUid(_entManager);
67-
var bGrid = b.GetGridUid(_entManager);
68+
var aGrid = xformSystem.GetGrid(a);
69+
var bGrid = xformSystem.GetGrid(b);
6870

6971
if (aGrid == bGrid)
7072
{
@@ -81,8 +83,8 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
8183
return 1;
8284
}
8385

84-
var mapA = a.GetMapId(_entManager);
85-
var mapB = a.GetMapId(_entManager);
86+
var mapA = xformSystem.GetMapId(a);
87+
var mapB = xformSystem.GetMapId(b);
8688

8789
if (mapA == mapB)
8890
{
@@ -117,10 +119,8 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
117119
return;
118120
}
119121

120-
var xform = _entManager.GetComponent<TransformComponent>(playerEntity);
121-
var xformSystem = _entManager.System<SharedTransformSystem>();
122-
xform.Coordinates = coords;
123-
xformSystem.AttachToGridOrMap(playerEntity, xform);
122+
xformSystem.SetCoordinates(playerEntity, coords);
123+
xformSystem.AttachToGridOrMap(playerEntity);
124124
if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics))
125125
{
126126
_entManager.System<SharedPhysicsSystem>().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics);

0 commit comments

Comments
 (0)