2022-06-11 18:54:41 -07:00
|
|
|
using Content.Server.Administration;
|
2021-06-19 13:25:05 +02:00
|
|
|
using Content.Server.Atmos.Components;
|
2022-07-04 16:51:34 +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;
|
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 AddAtmosCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
[Dependency] private readonly IEntityManager _entities = default!;
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
public string Command => "addatmos";
|
|
|
|
|
public string Description => "Adds atmos support to a grid.";
|
|
|
|
|
public string Help => $"{Command} <GridId>";
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine(Help);
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!NetEntity.TryParse(args[0], out var eNet) || !_entities.TryGetEntity(eNet, out var euid))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2022-06-11 18:54:41 -07:00
|
|
|
shell.WriteError($"Failed to parse euid '{args[0]}'.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (!_entities.HasComponent<MapGridComponent>(euid))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2022-06-11 18:54:41 -07:00
|
|
|
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
var atmos = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
2022-07-04 16:51:34 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
if (atmos.HasAtmosphere(euid.Value))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Grid already has an atmosphere.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
_entities.AddComponent<GridAtmosphereComponent>(euid.Value);
|
2020-12-03 03:40:47 +01:00
|
|
|
|
2022-06-11 18:54:41 -07:00
|
|
|
shell.WriteLine($"Added atmosphere to grid {euid}.");
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|