Files
tbd-station-14/Content.Server/Atmos/Commands/FillGasCommand.cs
2023-10-19 12:34:31 -07:00

48 lines
1.5 KiB
C#

using Content.Server.Administration;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Atmos;
using Robust.Shared.Console;
using Robust.Shared.Map.Components;
namespace Content.Server.Atmos.Commands
{
[AdminCommand(AdminFlags.Debug)]
public sealed class FillGas : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
public string Command => "fillgas";
public string Description => "Adds gas to all tiles in a grid.";
public string Help => "fillgas <GridEid> <Gas> <moles>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 3)
return;
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;
}
if (!_entManager.HasComponent<MapGridComponent>(gridId))
{
shell.WriteLine("Invalid grid ID.");
return;
}
var atmosphereSystem = _entManager.System<AtmosphereSystem>();
foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
{
tile.AdjustMoles(gasId, moles);
}
}
}
}