RemoveDecalCommand.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Content.Server.Administration;
  2. using Content.Shared.Administration;
  3. using Robust.Shared.Console;
  4. using Robust.Shared.Map.Components;
  5. namespace Content.Server.Decals.Commands
  6. {
  7. [AdminCommand(AdminFlags.Mapping)]
  8. public sealed class RemoveDecalCommand : IConsoleCommand
  9. {
  10. [Dependency] private readonly IEntityManager _entManager = default!;
  11. public string Command => "rmdecal";
  12. public string Description => "removes a decal";
  13. public string Help => $"{Command} <uid> <gridId>";
  14. public void Execute(IConsoleShell shell, string argStr, string[] args)
  15. {
  16. if (args.Length != 2)
  17. {
  18. shell.WriteError($"Unexpected number of arguments.\nExpected two: {Help}");
  19. return;
  20. }
  21. if (!uint.TryParse(args[0], out var uid))
  22. {
  23. shell.WriteError($"Failed parsing uid.");
  24. return;
  25. }
  26. if (!NetEntity.TryParse(args[1], out var rawGridIdNet) ||
  27. !_entManager.TryGetEntity(rawGridIdNet, out var rawGridId) ||
  28. !_entManager.HasComponent<MapGridComponent>(rawGridId))
  29. {
  30. shell.WriteError("Failed parsing gridId.");
  31. return;
  32. }
  33. var decalSystem = _entManager.System<DecalSystem>();
  34. if (decalSystem.RemoveDecal(rawGridId.Value, uid))
  35. {
  36. shell.WriteLine($"Successfully removed decal {uid}.");
  37. return;
  38. }
  39. shell.WriteError($"Failed trying to remove decal {uid}.");
  40. }
  41. }
  42. }