Makes Airtight ECS. (#4351)
* Makes Airtight ECS. * Remove atmos holdovers while at it!
This commit is contained in:
committed by
GitHub
parent
0aaa2727c8
commit
93acc565f0
61
Content.Server/Atmos/Commands/AddAtmosCommand.cs
Normal file
61
Content.Server/Atmos/Commands/AddAtmosCommand.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class AddAtmosCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "addatmos";
|
||||
public string Description => "Adds atmos support to a grid.";
|
||||
public string Help => $"{Command} <GridId>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.WriteLine($"{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.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (grid.HasComponent<IGridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid already has an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
grid.AddComponent<GridAtmosphereComponent>();
|
||||
|
||||
shell.WriteLine($"Added atmosphere to grid {id}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Content.Server/Atmos/Commands/AddGasCommand.cs
Normal file
43
Content.Server/Atmos/Commands/AddGasCommand.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class AddGasCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "addgas";
|
||||
public string Description => "Adds gas at a certain position.";
|
||||
public string Help => "addgas <X> <Y> <GridId> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 5) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|
||||
|| !float.TryParse(args[4], out var moles)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
tile.AdjustMoles(gasId, moles);
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs
Normal file
62
Content.Server/Atmos/Commands/AddUnsimulatedAtmosCommand.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class AddUnsimulatedAtmosCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "addunsimulatedatmos";
|
||||
public string Description => "Adds unimulated atmos support to a grid.";
|
||||
public string Help => $"{Command} <GridId>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.WriteLine($"{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.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (grid.HasComponent<IGridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid already has an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
grid.AddComponent<UnsimulatedGridAtmosphereComponent>();
|
||||
|
||||
shell.WriteLine($"Added unsimulated atmosphere to grid {id}.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
176
Content.Server/Atmos/Commands/DeleteGasCommand.cs
Normal file
176
Content.Server/Atmos/Commands/DeleteGasCommand.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using System;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class DeleteGasCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "deletegas";
|
||||
public string Description => "Removes all gases from a grid, or just of one type if specified.";
|
||||
public string Help => $"Usage: {Command} <GridId> <Gas> / {Command} <GridId> / {Command} <Gas> / {Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
GridId gridId;
|
||||
Gas? gas = null;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine("A grid must be specified when the command isn't used by a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.WriteLine("You have no entity to get a grid from.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = player.AttachedEntity.Transform.GridID;
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
if (!int.TryParse(args[0], out var number))
|
||||
{
|
||||
// Argument is a gas
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine("A grid id must be specified if not using this command as a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.WriteLine("You have no entity from which to get a grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = player.AttachedEntity.Transform.GridID;
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<Gas>(args[0], true, out var parsedGas))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid gas name.");
|
||||
return;
|
||||
}
|
||||
|
||||
gas = parsedGas;
|
||||
break;
|
||||
}
|
||||
|
||||
// Argument is a grid
|
||||
gridId = new GridId(number);
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!int.TryParse(args[0], out var first))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = new GridId(first);
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<Gas>(args[1], true, out var parsedGas))
|
||||
{
|
||||
shell.WriteLine($"{args[1]} is not a valid gas.");
|
||||
return;
|
||||
}
|
||||
|
||||
gas = parsedGas;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
var moles = 0f;
|
||||
|
||||
if (gas == null)
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.TotalMoles;
|
||||
|
||||
tile.Clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.TotalMoles;
|
||||
|
||||
tile.SetMoles(gas.Value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (gas == null)
|
||||
{
|
||||
shell.WriteLine($"Removed {moles} moles from {tiles} tiles.");
|
||||
return;
|
||||
}
|
||||
|
||||
shell.WriteLine($"Removed {moles} moles of gas {gas} from {tiles} tiles.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
45
Content.Server/Atmos/Commands/FillGasCommand.cs
Normal file
45
Content.Server/Atmos/Commands/FillGasCommand.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
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.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class FillGas : IConsoleCommand
|
||||
{
|
||||
public string Command => "fillgas";
|
||||
public string Description => "Adds gas to all tiles in a grid.";
|
||||
public string Help => "fillgas <GridId> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 3) return;
|
||||
if(!int.TryParse(args[0], out var id)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|
||||
|| !float.TryParse(args[2], out var moles)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
tile.AdjustMoles(gasId, moles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
59
Content.Server/Atmos/Commands/FixGridAtmos.cs
Normal file
59
Content.Server/Atmos/Commands/FixGridAtmos.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
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.Atmos.Commands
|
||||
{
|
||||
[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 atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
var gridId = new GridId(i);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteError($"Grid \"{i}\" doesn't exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
tile.Clear();
|
||||
atmosphereSystem.Merge(tile, mixture);
|
||||
tile.Temperature = mixture.Temperature;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Content.Server/Atmos/Commands/ListGasesCommand.cs
Normal file
27
Content.Server/Atmos/Commands/ListGasesCommand.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class ListGasesCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "listgases";
|
||||
public string Description => "Prints a list of gases and their indices.";
|
||||
public string Help => "listgases";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
foreach (var gasPrototype in atmosSystem.Gases)
|
||||
{
|
||||
shell.WriteLine($"{gasPrototype.Name} ID: {gasPrototype.ID}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
Content.Server/Atmos/Commands/RemoveGasCommand.cs
Normal file
46
Content.Server/Atmos/Commands/RemoveGasCommand.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class RemoveGasCommand : IConsoleCommand
|
||||
{
|
||||
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.";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 5) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !float.TryParse(args[3], out var amount)
|
||||
|| !bool.TryParse(args[4], out var ratio)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ratio)
|
||||
tile.RemoveRatio(amount);
|
||||
else
|
||||
tile.Remove(amount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
53
Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs
Normal file
53
Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
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.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class SetAtmosTemperatureCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "setatmostemp";
|
||||
public string Description => "Sets a grid's temperature (in kelvin).";
|
||||
public string Help => "Usage: setatmostemp <GridId> <Temperature>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 2) return;
|
||||
if(!int.TryParse(args[0], out var id)
|
||||
|| !float.TryParse(args[1], out var temperature)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
shell.WriteLine("Invalid temperature.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
tiles++;
|
||||
tile.Temperature = temperature;
|
||||
}
|
||||
|
||||
shell.WriteLine($"Changed the temperature of {tiles} tiles.");
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Content.Server/Atmos/Commands/SetTemperatureCommand.cs
Normal file
48
Content.Server/Atmos/Commands/SetTemperatureCommand.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class SetTemperatureCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "settemp";
|
||||
public string Description => "Sets a tile's temperature (in kelvin).";
|
||||
public string Help => "Usage: settemp <X> <Y> <GridId> <Temperature>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 4) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !float.TryParse(args[3], out var temperature)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
shell.WriteLine("Invalid temperature.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
tile.Temperature = temperature;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Content.Server/Atmos/Commands/ShowAtmosCommand.cs
Normal file
34
Content.Server/Atmos/Commands/ShowAtmosCommand.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public class ShowAtmos : IConsoleCommand
|
||||
{
|
||||
public string Command => "showatmos";
|
||||
public string Description => "Toggles seeing atmos debug overlay.";
|
||||
public string Help => $"Usage: {Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine("You must be a player to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosDebug = EntitySystem.Get<AtmosDebugOverlaySystem>();
|
||||
var enabled = atmosDebug.ToggleObserver(player);
|
||||
|
||||
shell.WriteLine(enabled
|
||||
? "Enabled the atmospherics debug overlay."
|
||||
: "Disabled the atmospherics debug overlay.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user