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;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
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 RemoveGasCommand : 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 => "removegas";
|
|
|
|
|
public string Description => "Removes an amount of gases.";
|
|
|
|
|
public string Help => "removegas <X> <Y> <GridId> <amount> <ratio>\nIf <ratio> is true, amount will be treated as the ratio of gas to be removed.";
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(args[0], out var x)
|
2020-12-03 03:40:47 +01:00
|
|
|
|| !int.TryParse(args[1], out var y)
|
2023-09-11 09:42:41 +10:00
|
|
|
|| !NetEntity.TryParse(args[2], out var idNet)
|
|
|
|
|
|| !_entManager.TryGetEntity(idNet, out var id)
|
2020-12-03 03:40:47 +01:00
|
|
|
|| !float.TryParse(args[3], out var amount)
|
2023-09-11 09:42:41 +10:00
|
|
|
|| !bool.TryParse(args[4], out var ratio))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var atmosphereSystem = _entManager.System<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(id, 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ratio)
|
2021-07-19 12:07:37 +02:00
|
|
|
tile.RemoveRatio(amount);
|
2020-12-03 03:40:47 +01:00
|
|
|
else
|
2021-07-19 12:07:37 +02:00
|
|
|
tile.Remove(amount);
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|