RemoveMechanismCommand.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Content.Server.Body.Systems;
  2. using Content.Shared.Administration;
  3. using Robust.Shared.Console;
  4. namespace Content.Server.Administration.Commands
  5. {
  6. [AdminCommand(AdminFlags.Admin)]
  7. public sealed class RemoveMechanismCommand : IConsoleCommand
  8. {
  9. [Dependency] private readonly IEntityManager _entManager = default!;
  10. public string Command => "rmmechanism";
  11. public string Description => "Removes a given entity from it's containing bodypart, if any.";
  12. public string Help => "Usage: rmmechanism <uid>";
  13. public void Execute(IConsoleShell shell, string argStr, string[] args)
  14. {
  15. if (args.Length != 1)
  16. {
  17. shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
  18. return;
  19. }
  20. if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid))
  21. {
  22. shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
  23. return;
  24. }
  25. var xformSystem = _entManager.System<SharedTransformSystem>();
  26. xformSystem.AttachToGridOrMap(entityUid.Value);
  27. shell.WriteLine($"Removed organ {_entManager.ToPrettyString(entityUid.Value)}");
  28. }
  29. }
  30. }