]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Teleport fixes (#24064)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 14 Jan 2024 06:43:53 +0000 (17:43 +1100)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 06:43:53 +0000 (17:43 +1100)
- Teleport to physics center not transform center.
- Fix NetEntity not being passed in.

Content.Server/Administration/Systems/AdminVerbSystem.cs

index b476477ab710491d190328c6b3faa1d884c327db..e678abb0c45cb854657972a4419d259b1662d1ce 100644 (file)
@@ -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