Files
RobustToolbox/Robust.Shared/Toolshed/Commands/Entities/World/TpCommand.cs
Leon Friedrich 9af119f57a Toolshed Rejig (#5455)
* Toolshed Rejig

* shorten hint string

* Try fix conflicts. Ill make with work later

* bodge

* Fix ProtoIdTypeParser assert

* comment

* AllEntities

* Remove more linq from WhereCommand

* better help strings

* Add ContainsCommand

* loc strings

* Add contains command description

* Add $self variable

* Errors for writing to readonly variables

* A
2024-12-21 17:49:11 +11:00

50 lines
1.7 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Robust.Shared.Toolshed.Commands.Entities.World;
[ToolshedCommand]
internal sealed class TpCommand : ToolshedCommand
{
private SharedTransformSystem? _xform;
[CommandImplementation("coords")]
public EntityUid TpCoords([PipedArgument] EntityUid teleporter, EntityCoordinates target)
{
_xform ??= GetSys<SharedTransformSystem>();
_xform.SetCoordinates(teleporter, target);
return teleporter;
}
[CommandImplementation("coords")]
public IEnumerable<EntityUid> TpCoords([PipedArgument] IEnumerable<EntityUid> teleporters, EntityCoordinates target)
=> teleporters.Select(x => TpCoords(x, target));
[CommandImplementation("to")]
public EntityUid TpTo([PipedArgument] EntityUid teleporter, EntityUid target)
{
_xform ??= GetSys<SharedTransformSystem>();
_xform.SetCoordinates(teleporter, Transform(target).Coordinates);
return teleporter;
}
[CommandImplementation("to")]
public IEnumerable<EntityUid> TpTo([PipedArgument] IEnumerable<EntityUid> teleporters, EntityUid target)
=> teleporters.Select(x => TpTo(x, target));
[CommandImplementation("into")]
public EntityUid TpInto([PipedArgument] EntityUid teleporter, EntityUid target)
{
_xform ??= GetSys<SharedTransformSystem>();
_xform.SetCoordinates(teleporter, new EntityCoordinates(target, Vector2.Zero));
return teleporter;
}
[CommandImplementation("into")]
public IEnumerable<EntityUid> TpInto([PipedArgument] IEnumerable<EntityUid> teleporters, EntityUid target)
=> teleporters.Select(x => TpInto(x, target));
}