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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user