From 462519b7dacd13dff2f48dc0add56bba6b61da11 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 25 Mar 2025 22:17:46 -0400 Subject: [PATCH] Cleanup WarpCommand (#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 --- .../Administration/Commands/WarpCommand.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index c4aa41db20..afc42c7e19 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -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(playerEntity).MapID; var currentGrid = _entManager.GetComponent(playerEntity).GridUid; + var xformSystem = _entManager.System(); + var found = GetWarpPointByName(location) .OrderBy(p => p.Item1, Comparer.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(playerEntity); - var xformSystem = _entManager.System(); - xform.Coordinates = coords; - xformSystem.AttachToGridOrMap(playerEntity, xform); + xformSystem.SetCoordinates(playerEntity, coords); + xformSystem.AttachToGridOrMap(playerEntity); if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics)) { _entManager.System().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics); -- 2.51.2