From db175fd9ba425a7c87eff3ae8bb9cd1d2fdf2b98 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:43:53 +1100 Subject: [PATCH] Teleport fixes (#24064) - Teleport to physics center not transform center. - Fix NetEntity not being passed in. --- .../Administration/Systems/AdminVerbSystem.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index b476477ab7..e678abb0c4 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -34,6 +34,8 @@ using Robust.Shared.Timing; using Robust.Shared.Toolshed; using Robust.Shared.Utility; using System.Linq; +using System.Numerics; +using Robust.Shared.Physics.Components; using static Content.Shared.Configurable.ConfigurationComponent; namespace Content.Server.Administration.Systems @@ -251,7 +253,10 @@ namespace Content.Server.Administration.Systems Text = Loc.GetString("admin-verbs-teleport-to"), Category = VerbCategory.Admin, 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 }); @@ -267,8 +272,17 @@ namespace Content.Server.Administration.Systems { if (player.AttachedEntity != null) { - var mapPos = Transform(player.AttachedEntity.Value).MapPosition; - _console.ExecuteCommand(player, $"tpgrid {args.Target} {mapPos.X} {mapPos.Y} {mapPos.MapId}"); + var mapPos = _transformSystem.GetMapCoordinates(player.AttachedEntity.Value); + 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