2022-06-11 18:54:41 -07:00
|
|
|
using Content.Server.Administration;
|
2021-07-19 12:07:37 +02:00
|
|
|
using Content.Server.Atmos.EntitySystems;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Content.Shared.Administration;
|
|
|
|
|
using Content.Shared.Atmos;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2023-10-19 12:34:31 -07:00
|
|
|
using Robust.Shared.Map.Components;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2021-07-25 09:04:58 +02:00
|
|
|
namespace Content.Server.Atmos.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Debug)]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class FillGas : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
public string Command => "fillgas";
|
|
|
|
|
public string Description => "Adds gas to all tiles in a grid.";
|
2022-06-11 18:54:41 -07:00
|
|
|
public string Help => "fillgas <GridEid> <Gas> <moles>";
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
if (args.Length < 3)
|
|
|
|
|
return;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!NetEntity.TryParse(args[0], out var gridIdNet)
|
|
|
|
|
|| !_entManager.TryGetEntity(gridIdNet, out var gridId)
|
|
|
|
|
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|
|
|
|
|
|| !float.TryParse(args[2], out var moles))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-10-19 12:34:31 -07:00
|
|
|
if (!_entManager.HasComponent<MapGridComponent>(gridId))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Invalid grid ID.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-10-19 12:34:31 -07:00
|
|
|
foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-07-19 12:07:37 +02:00
|
|
|
tile.AdjustMoles(gasId, moles);
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|