Teleport fixes (#24064)
- Teleport to physics center not transform center. - Fix NetEntity not being passed in.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user