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;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Robust.Shared.Map;
|
2022-11-22 13:12:04 +11: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 AddGasCommand : 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 => "addgas";
|
|
|
|
|
public string Description => "Adds gas at a certain position.";
|
2022-06-11 18:54:41 -07:00
|
|
|
public string Help => "addgas <X> <Y> <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 < 5)
|
|
|
|
|
return;
|
2022-06-11 18:54:41 -07:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!int.TryParse(args[0], out var x)
|
|
|
|
|
|| !int.TryParse(args[1], out var y)
|
|
|
|
|
|| !NetEntity.TryParse(args[2], out var netEnt)
|
|
|
|
|
|| !_entManager.TryGetEntity(netEnt, out var euid)
|
|
|
|
|
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|
|
|
|
|
|| !float.TryParse(args[4], out var moles))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!_entManager.HasComponent<MapGridComponent>(euid))
|
2022-06-11 18:54:41 -07:00
|
|
|
{
|
|
|
|
|
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var atmosphereSystem = _entManager.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
2020-12-03 03:40:47 +01:00
|
|
|
var indices = new Vector2i(x, y);
|
2022-07-04 16:51:34 +02:00
|
|
|
var tile = atmosphereSystem.GetTileMixture(euid, null, indices, true);
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
|
|
|
if (tile == null)
|
|
|
|
|
{
|
2021-07-19 12:07:37 +02:00
|
|
|
shell.WriteLine("Invalid coordinates or tile.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 12:07:37 +02:00
|
|
|
tile.AdjustMoles(gasId, moles);
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|