UnpolymorphCommand.cs 867 B

12345678910111213141516171819202122232425262728
  1. using System.Linq;
  2. using Content.Server.Administration;
  3. using Content.Server.Polymorph.Systems;
  4. using Content.Shared.Administration;
  5. using Robust.Shared.Toolshed;
  6. namespace Content.Server.Polymorph.Toolshed;
  7. /// <summary>
  8. /// Undoes a polymorph, reverting the target to it's original form.
  9. /// </summary>
  10. [ToolshedCommand, AdminCommand(AdminFlags.Fun)]
  11. public sealed class UnpolymorphCommand : ToolshedCommand
  12. {
  13. private PolymorphSystem? _system;
  14. [CommandImplementation]
  15. public EntityUid? Unpolymorph([PipedArgument] EntityUid input)
  16. {
  17. _system ??= GetSys<PolymorphSystem>();
  18. return _system.Revert(input);
  19. }
  20. [CommandImplementation]
  21. public IEnumerable<EntityUid> Unpolymorph([PipedArgument] IEnumerable<EntityUid> input)
  22. => input.Select(Unpolymorph).Where(x => x is not null).Select(x => (EntityUid)x!);
  23. }