1
0

SetTemperatureCommand.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 SetTemperatureCommand : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _entities = default!;
  13. public string Command => "settemp";
  14. public string Description => "Sets a tile's temperature (in kelvin).";
  15. public string Help => "Usage: settemp <X> <Y> <GridId> <Temperature>";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length < 4)
  19. return;
  20. if (!int.TryParse(args[0], out var x)
  21. || !int.TryParse(args[1], out var y)
  22. || !NetEntity.TryParse(args[2], out var gridIdNet)
  23. || !_entities.TryGetEntity(gridIdNet, out var gridId)
  24. || !float.TryParse(args[3], out var temperature))
  25. {
  26. return;
  27. }
  28. if (temperature < Atmospherics.TCMB)
  29. {
  30. shell.WriteLine("Invalid temperature.");
  31. return;
  32. }
  33. if (!_entities.HasComponent<MapGridComponent>(gridId))
  34. {
  35. shell.WriteError("Invalid grid.");
  36. return;
  37. }
  38. var atmospheres = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
  39. var indices = new Vector2i(x, y);
  40. var tile = atmospheres.GetTileMixture(gridId, null, indices, true);
  41. if (tile == null)
  42. {
  43. shell.WriteLine("Invalid coordinates or tile.");
  44. return;
  45. }
  46. tile.Temperature = temperature;
  47. }
  48. }
  49. }