1
0

SetAtmosTemperatureCommand.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 SetAtmosTemperatureCommand : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _entManager = default!;
  13. public string Command => "setatmostemp";
  14. public string Description => "Sets a grid's temperature (in kelvin).";
  15. public string Help => "Usage: setatmostemp <GridId> <Temperature>";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length < 2)
  19. return;
  20. if (!_entManager.TryParseNetEntity(args[0], out var gridId)
  21. || !float.TryParse(args[1], out var temperature))
  22. {
  23. return;
  24. }
  25. if (temperature < Atmospherics.TCMB)
  26. {
  27. shell.WriteLine("Invalid temperature.");
  28. return;
  29. }
  30. if (!gridId.Value.IsValid() || !_entManager.HasComponent<MapGridComponent>(gridId))
  31. {
  32. shell.WriteLine("Invalid grid ID.");
  33. return;
  34. }
  35. var atmosphereSystem = _entManager.System<AtmosphereSystem>();
  36. var tiles = 0;
  37. foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
  38. {
  39. tiles++;
  40. tile.Temperature = temperature;
  41. }
  42. shell.WriteLine($"Changed the temperature of {tiles} tiles.");
  43. }
  44. }
  45. }