FillGasCommand.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Content.Server.Administration;
  2. using Content.Server.Atmos.EntitySystems;
  3. using Content.Shared.Administration;
  4. using Content.Shared.Atmos;
  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 FillGas : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _entManager = default!;
  13. public string Command => "fillgas";
  14. public string Description => "Adds gas to all tiles in a grid.";
  15. public string Help => "fillgas <GridEid> <Gas> <moles>";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length < 3)
  19. return;
  20. if (!NetEntity.TryParse(args[0], out var gridIdNet)
  21. || !_entManager.TryGetEntity(gridIdNet, out var gridId)
  22. || !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
  23. || !float.TryParse(args[2], out var moles))
  24. {
  25. return;
  26. }
  27. if (!_entManager.HasComponent<MapGridComponent>(gridId))
  28. {
  29. shell.WriteLine("Invalid grid ID.");
  30. return;
  31. }
  32. var atmosphereSystem = _entManager.System<AtmosphereSystem>();
  33. foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
  34. {
  35. tile.AdjustMoles(gasId, moles);
  36. }
  37. }
  38. }
  39. }