Adds fixgridatmos command for mapping and admining
This commit is contained in:
@@ -155,6 +155,8 @@ namespace Content.Server.Atmos
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
float GetVolumeForCells(int cellCount);
|
float GetVolumeForCells(int cellCount);
|
||||||
|
|
||||||
|
void RepopulateTiles();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a dictionary of adjacent TileAtmospheres.
|
/// Returns a dictionary of adjacent TileAtmospheres.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
|
using Content.Server.Atmos;
|
||||||
using Content.Server.GameObjects.Components.Atmos;
|
using Content.Server.GameObjects.Components.Atmos;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
@@ -42,13 +43,13 @@ namespace Content.Server.Commands.Atmos
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!grid.HasComponent<GridAtmosphereComponent>())
|
if (!grid.HasComponent<IGridAtmosphereComponent>())
|
||||||
{
|
{
|
||||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
var gam = grid.GetComponent<IGridAtmosphereComponent>();
|
||||||
|
|
||||||
foreach (var tile in gam)
|
foreach (var tile in gam)
|
||||||
{
|
{
|
||||||
|
|||||||
74
Content.Server/Commands/Atmos/FixGridAtmos.cs
Normal file
74
Content.Server/Commands/Atmos/FixGridAtmos.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Server.Administration;
|
||||||
|
using Content.Server.Atmos;
|
||||||
|
using Content.Server.GameObjects.Components.Atmos;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Atmos;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
|
namespace Content.Server.Commands.Atmos
|
||||||
|
{
|
||||||
|
[AdminCommand(AdminFlags.Debug)]
|
||||||
|
public class FixGridAtmos : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "fixgridatmos";
|
||||||
|
public string Description => "Makes every tile on a grid have a roundstart gas mix.";
|
||||||
|
public string Help => $"{Command} <grid Ids>";
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
shell.WriteError("Not enough arguments.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
|
var mixture = new GasMixture(Atmospherics.CellVolume) { Temperature = Atmospherics.T20C };
|
||||||
|
mixture.AdjustMoles(Gas.Oxygen, Atmospherics.OxygenMolesStandard);
|
||||||
|
mixture.AdjustMoles(Gas.Nitrogen, Atmospherics.NitrogenMolesStandard);
|
||||||
|
|
||||||
|
foreach (var gid in args)
|
||||||
|
{
|
||||||
|
// I like offering detailed error messages, that's why I don't use one of the extension methods.
|
||||||
|
if (!int.TryParse(gid, out var i) || i <= 0)
|
||||||
|
{
|
||||||
|
shell.WriteError($"Invalid grid ID \"{gid}\".");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mapManager.TryGetGrid(new GridId(i), out var grid))
|
||||||
|
{
|
||||||
|
shell.WriteError($"Grid \"{i}\" doesn't exist.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entityManager.TryGetEntity(grid.GridEntityId, out var entity))
|
||||||
|
{
|
||||||
|
shell.WriteError($"Grid entity for grid \"{i}\" doesn't exist.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var gridAtmosphere = new GridAtmosphereComponent() {Owner = entity};
|
||||||
|
|
||||||
|
// Inject dependencies manually or a NRE will eat your face.
|
||||||
|
IoCManager.InjectDependencies(gridAtmosphere);
|
||||||
|
|
||||||
|
entityManager.ComponentManager.AddComponent(entity, gridAtmosphere, true);
|
||||||
|
|
||||||
|
gridAtmosphere.RepopulateTiles();
|
||||||
|
|
||||||
|
foreach (var tile in gridAtmosphere)
|
||||||
|
{
|
||||||
|
tile.Air = (GasMixture) mixture.Clone();
|
||||||
|
tile.Air.Volume = gridAtmosphere.GetVolumeForCells(1);
|
||||||
|
tile.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user