RemoveGasCommand.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Content.Server.Administration;
  2. using Content.Server.Atmos.EntitySystems;
  3. using Content.Shared.Administration;
  4. using Robust.Shared.Console;
  5. using Robust.Shared.Map;
  6. namespace Content.Server.Atmos.Commands
  7. {
  8. [AdminCommand(AdminFlags.Debug)]
  9. public sealed class RemoveGasCommand : IConsoleCommand
  10. {
  11. [Dependency] private readonly IEntityManager _entManager = default!;
  12. public string Command => "removegas";
  13. public string Description => "Removes an amount of gases.";
  14. public string Help => "removegas <X> <Y> <GridId> <amount> <ratio>\nIf <ratio> is true, amount will be treated as the ratio of gas to be removed.";
  15. public void Execute(IConsoleShell shell, string argStr, string[] args)
  16. {
  17. if (args.Length < 5)
  18. return;
  19. if (!int.TryParse(args[0], out var x)
  20. || !int.TryParse(args[1], out var y)
  21. || !NetEntity.TryParse(args[2], out var idNet)
  22. || !_entManager.TryGetEntity(idNet, out var id)
  23. || !float.TryParse(args[3], out var amount)
  24. || !bool.TryParse(args[4], out var ratio))
  25. {
  26. return;
  27. }
  28. var atmosphereSystem = _entManager.System<AtmosphereSystem>();
  29. var indices = new Vector2i(x, y);
  30. var tile = atmosphereSystem.GetTileMixture(id, null, indices, true);
  31. if (tile == null)
  32. {
  33. shell.WriteLine("Invalid coordinates or tile.");
  34. return;
  35. }
  36. if (ratio)
  37. tile.RemoveRatio(amount);
  38. else
  39. tile.Remove(amount);
  40. }
  41. }
  42. }