Teleport fixes (#24064)

- Teleport to physics center not transform center.
- Fix NetEntity not being passed in.
This commit is contained in:
metalgearsloth
2024-01-14 17:43:53 +11:00
committed by GitHub
parent 5ec4fbe909
commit db175fd9ba

View File

@@ -34,6 +34,8 @@ using Robust.Shared.Timing;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using System.Linq; using System.Linq;
using System.Numerics;
using Robust.Shared.Physics.Components;
using static Content.Shared.Configurable.ConfigurationComponent; using static Content.Shared.Configurable.ConfigurationComponent;
namespace Content.Server.Administration.Systems namespace Content.Server.Administration.Systems
@@ -251,7 +253,10 @@ namespace Content.Server.Administration.Systems
Text = Loc.GetString("admin-verbs-teleport-to"), Text = Loc.GetString("admin-verbs-teleport-to"),
Category = VerbCategory.Admin, Category = VerbCategory.Admin,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/open.svg.192dpi.png")), Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/open.svg.192dpi.png")),
Act = () => _console.ExecuteCommand(player, $"tpto {args.Target}"), Act = () =>
{
_console.ExecuteCommand(player, $"tpto {GetNetEntity(args.Target)}");
},
Impact = LogImpact.Low Impact = LogImpact.Low
}); });
@@ -267,8 +272,17 @@ namespace Content.Server.Administration.Systems
{ {
if (player.AttachedEntity != null) if (player.AttachedEntity != null)
{ {
var mapPos = Transform(player.AttachedEntity.Value).MapPosition; var mapPos = _transformSystem.GetMapCoordinates(player.AttachedEntity.Value);
_console.ExecuteCommand(player, $"tpgrid {args.Target} {mapPos.X} {mapPos.Y} {mapPos.MapId}"); if (TryComp(args.Target, out PhysicsComponent? targetPhysics))
{
var offset = targetPhysics.LocalCenter;
var rotation = _transformSystem.GetWorldRotation(args.Target);
offset = rotation.RotateVec(offset);
mapPos = mapPos.Offset(-offset);
}
_console.ExecuteCommand(player, $"tpgrid {GetNetEntity(args.Target)} {mapPos.X} {mapPos.Y} {mapPos.MapId}");
} }
} }
else else