AddAtmosCommand.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Server.Administration;
  2. using Content.Server.Atmos.Components;
  3. using Content.Server.Atmos.EntitySystems;
  4. using Content.Shared.Administration;
  5. using Robust.Shared.Console;
  6. using Robust.Shared.Map.Components;
  7. namespace Content.Server.Atmos.Commands
  8. {
  9. [AdminCommand(AdminFlags.Debug)]
  10. public sealed class AddAtmosCommand : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _entities = default!;
  13. public string Command => "addatmos";
  14. public string Description => "Adds atmos support to a grid.";
  15. public string Help => $"{Command} <GridId>";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length < 1)
  19. {
  20. shell.WriteLine(Help);
  21. return;
  22. }
  23. if (!NetEntity.TryParse(args[0], out var eNet) || !_entities.TryGetEntity(eNet, out var euid))
  24. {
  25. shell.WriteError($"Failed to parse euid '{args[0]}'.");
  26. return;
  27. }
  28. if (!_entities.HasComponent<MapGridComponent>(euid))
  29. {
  30. shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
  31. return;
  32. }
  33. var atmos = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
  34. if (atmos.HasAtmosphere(euid.Value))
  35. {
  36. shell.WriteLine("Grid already has an atmosphere.");
  37. return;
  38. }
  39. _entities.AddComponent<GridAtmosphereComponent>(euid.Value);
  40. shell.WriteLine($"Added atmosphere to grid {euid}.");
  41. }
  42. }
  43. }