]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cleanup WarpCommand (#36088)
authorTayrtahn <tayrtahn@gmail.com>
Wed, 26 Mar 2025 02:17:46 +0000 (22:17 -0400)
committerGitHub <noreply@github.com>
Wed, 26 Mar 2025 02:17:46 +0000 (03:17 +0100)
* 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

Content.Server/Administration/Commands/WarpCommand.cs

index c4aa41db20a0cffd016a4e4be35af8cd9acbf1de..afc42c7e19f9844f2e38d719db01f3833fc4cbf0 100644 (file)
@@ -48,7 +48,7 @@ namespace Content.Server.Administration.Commands
             }
             else
             {
-                if (player.Status != SessionStatus.InGame || player.AttachedEntity is not {Valid: true} playerEntity)
+                if (player.Status != SessionStatus.InGame || player.AttachedEntity is not { Valid: true } playerEntity)
                 {
                     shell.WriteLine("You are not in-game!");
                     return;
@@ -57,14 +57,16 @@ namespace Content.Server.Administration.Commands
                 var currentMap = _entManager.GetComponent<TransformComponent>(playerEntity).MapID;
                 var currentGrid = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
 
+                var xformSystem = _entManager.System<SharedTransformSystem>();
+
                 var found = GetWarpPointByName(location)
                     .OrderBy(p => p.Item1, Comparer<EntityCoordinates>.Create((a, b) =>
                     {
                         // Sort so that warp points on the same grid/map are first.
                         // So if you have two maps loaded with the same warp points,
                         // it will prefer the warp points on the map you're currently on.
-                        var aGrid = a.GetGridUid(_entManager);
-                        var bGrid = b.GetGridUid(_entManager);
+                        var aGrid = xformSystem.GetGrid(a);
+                        var bGrid = xformSystem.GetGrid(b);
 
                         if (aGrid == bGrid)
                         {
@@ -81,8 +83,8 @@ namespace Content.Server.Administration.Commands
                             return 1;
                         }
 
-                        var mapA = a.GetMapId(_entManager);
-                        var mapB = a.GetMapId(_entManager);
+                        var mapA = xformSystem.GetMapId(a);
+                        var mapB = xformSystem.GetMapId(b);
 
                         if (mapA == mapB)
                         {
@@ -117,10 +119,8 @@ namespace Content.Server.Administration.Commands
                     return;
                 }
 
-                var xform = _entManager.GetComponent<TransformComponent>(playerEntity);
-                var xformSystem = _entManager.System<SharedTransformSystem>();
-                xform.Coordinates = coords;
-                xformSystem.AttachToGridOrMap(playerEntity, xform);
+                xformSystem.SetCoordinates(playerEntity, coords);
+                xformSystem.AttachToGridOrMap(playerEntity);
                 if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics))
                 {
                     _entManager.System<SharedPhysicsSystem>().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics);