Add UnsimulatedGridAtmosphereComponent and a command to add it (#2019)

* Add UnsimulatedGridAtmosphereComponent

* Override prytile, repopulate, invalidate and revalidate

* Attributes
This commit is contained in:
DrSmugleaf
2020-09-04 12:22:33 +02:00
committed by GitHub
parent 313730e1b8
commit 97a603b0b6
3 changed files with 206 additions and 46 deletions

View File

@@ -17,11 +17,21 @@ namespace Content.Server.Atmos
{
public string Command => "addatmos";
public string Description => "Adds atmos support to a grid.";
public string Help => "addatmos <GridId>";
public string Help => $"{Command} <GridId>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
{
if (args.Length < 1) return;
if(!int.TryParse(args[0], out var id)) return;
if (args.Length < 1)
{
shell.SendText(player, Help);
return;
}
if (!int.TryParse(args[0], out var id))
{
shell.SendText(player, $"{args[0]} is not a valid integer.");
return;
}
var gridId = new GridId(id);
@@ -29,7 +39,7 @@ namespace Content.Server.Atmos
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{
shell.SendText(player, "Invalid grid ID.");
shell.SendText(player, $"{gridId} is not a valid grid id.");
return;
}
@@ -41,7 +51,7 @@ namespace Content.Server.Atmos
return;
}
if (grid.HasComponent<GridAtmosphereComponent>())
if (grid.HasComponent<IGridAtmosphereComponent>())
{
shell.SendText(player, "Grid already has an atmosphere.");
return;
@@ -53,6 +63,56 @@ namespace Content.Server.Atmos
}
}
public class AddUnsimulatedAtmos : IClientCommand
{
public string Command => "addunsimulatedatmos";
public string Description => "Adds unimulated atmos support to a grid.";
public string Help => $"{Command} <GridId>";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
{
if (args.Length < 1)
{
shell.SendText(player, Help);
return;
}
if (!int.TryParse(args[0], out var id))
{
shell.SendText(player, $"{args[0]} is not a valid integer.");
return;
}
var gridId = new GridId(id);
var mapMan = IoCManager.Resolve<IMapManager>();
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
{
shell.SendText(player, $"{gridId} is not a valid grid id.");
return;
}
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
{
shell.SendText(player, "Failed to get grid entity.");
return;
}
if (grid.HasComponent<IGridAtmosphereComponent>())
{
shell.SendText(player, "Grid already has an atmosphere.");
return;
}
grid.AddComponent<UnsimulatedGridAtmosphereComponent>();
shell.SendText(player, $"Added unsimulated atmosphere to grid {id}.");
}
}
public class ListGases : IClientCommand
{
public string Command => "listgases";