2021-07-17 02:37:09 +02:00
|
|
|
|
using Content.Server.Administration;
|
2021-06-19 13:25:05 +02:00
|
|
|
|
using Content.Server.Atmos.Components;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Shared.Administration;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
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 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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!int.TryParse(args[0], out var id))
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"{args[0]} is not a valid integer.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var gridId = new GridId(id);
|
|
|
|
|
|
|
|
|
|
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
|
|
|
|
|
|
|
|
|
|
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"{gridId} is not a valid grid id.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
|
if (!_entities.EntityExists(gridComp.GridEntityId))
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Failed to get grid entity.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
|
if (_entities.HasComponent<IAtmosphereComponent>(gridComp.GridEntityId))
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
|
_entities.AddComponent<GridAtmosphereComponent>(gridComp.GridEntityId);
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"Added atmosphere to grid {id}.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|