Refactors the AtmosphereSystem public-facing API to allow for multiple atmos backends. (#8134)

* Refactors the entirety of the AtmosphereSystem public-facing API to allow for multiple atmos backends.

* actually compiles

* Remove commented out code

* funny bracket

* Move archived moles, temperature from GasMixture to TileAtmosphere.

* WIP customizable map default mixture
still VERY buggy

* broken mess
aaaaaaaaaaaaa

* Fix lattice, etc not being considered space

* visualization for "IsSpace"

* help

* Update Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs

Co-authored-by: Moony <moonheart08@users.noreply.github.com>

* Holy SHIT it compiles AGAIN

* Fix AtmosDeviceSystem crash at shutdown

* Fix immutable tiles on map blueprints not being fixed by fixgridatmos/revalidate.

* Use space instead of gasmixture immutable for heat capacity calculations

* Remove all LINDA-specific code from GasMixture, move it to TileAtmosphere/AtmosphereSystem instead.

* Fix roundstart tiles not processing

* Update Content.Server/Atmos/Commands/SetTemperatureCommand.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs

Changed Files tab is so large I can't commit both suggestions at once mfw

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

Co-authored-by: Moony <moonheart08@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Vera Aguilera Puerto
2022-07-04 16:51:34 +02:00
committed by GitHub
parent 43216a000f
commit aa9281d667
74 changed files with 1764 additions and 2141 deletions

View File

@@ -10,8 +10,6 @@ namespace Content.Server.Atmos.EntitySystems
{
public sealed partial class AtmosphereSystem
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
private readonly TileAtmosphereComparer _monstermosComparer = new();
private readonly TileAtmosphere?[] _equalizeTiles = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit];
@@ -81,7 +79,7 @@ namespace Content.Server.Atmos.EntitySystems
if(tileCount < Atmospherics.MonstermosHardTileLimit)
_equalizeTiles[tileCount++] = adj;
if (adj.Air.Immutable && MonstermosDepressurization)
if (adj.Space && MonstermosDepressurization)
{
// Looks like someone opened an airlock to space!
@@ -146,6 +144,7 @@ namespace Content.Server.Atmos.EntitySystems
var direction = (AtmosDirection) (1 << j);
if (!otherTile.AdjacentBits.IsFlagSet(direction)) continue;
var tile2 = otherTile.AdjacentTiles[j]!;
DebugTools.Assert(tile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
// skip anything that isn't part of our current processing block.
if (tile2.MonstermosInfo.FastDone || tile2.MonstermosInfo.LastQueueCycle != queueCycle)
@@ -213,8 +212,8 @@ namespace Content.Server.Atmos.EntitySystems
var otherTile2 = otherTile.AdjacentTiles[k];
if (giver.MonstermosInfo.MoleDelta <= 0) break; // We're done here now. Let's not do more work than needed.
if (otherTile2 == null || otherTile2.MonstermosInfo.LastQueueCycle != queueCycle) continue;
DebugTools.Assert(otherTile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (otherTile2.MonstermosInfo.LastSlowQueueCycle == queueCycleSlow) continue;
_equalizeQueue[queueLength++] = otherTile2;
otherTile2.MonstermosInfo.LastSlowQueueCycle = queueCycleSlow;
otherTile2.MonstermosInfo.CurrentTransferDirection = direction.GetOpposite();
@@ -279,6 +278,7 @@ namespace Content.Server.Atmos.EntitySystems
if (taker.MonstermosInfo.MoleDelta >= 0) break; // We're done here now. Let's not do more work than needed.
if (otherTile2 == null || otherTile2.MonstermosInfo.LastQueueCycle != queueCycle) continue;
DebugTools.Assert(otherTile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (otherTile2.MonstermosInfo.LastSlowQueueCycle == queueCycleSlow) continue;
_equalizeQueue[queueLength++] = otherTile2;
otherTile2.MonstermosInfo.LastSlowQueueCycle = queueCycleSlow;
@@ -335,7 +335,8 @@ namespace Content.Server.Atmos.EntitySystems
var direction = (AtmosDirection) (1 << j);
if (!otherTile.AdjacentBits.IsFlagSet(direction)) continue;
var otherTile2 = otherTile.AdjacentTiles[j]!;
if (otherTile2.Air?.Compare(tile.Air) == GasMixture.GasCompareResult.NoExchange) continue;
DebugTools.Assert(otherTile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (otherTile2.Air != null && CompareExchange(otherTile2.Air, tile.Air) == GasCompareResult.NoExchange) continue;
AddActiveTile(gridAtmosphere, otherTile2);
break;
}
@@ -372,7 +373,7 @@ namespace Content.Server.Atmos.EntitySystems
otherTile.MonstermosInfo.LastCycle = cycleNum;
otherTile.MonstermosInfo.CurrentTransferDirection = AtmosDirection.Invalid;
// Tiles in the _depressurizeTiles array cannot have null air.
if (!otherTile.Air!.Immutable)
if (!otherTile.Space)
{
for (var j = 0; j < Atmospherics.Directions; j++)
{
@@ -380,6 +381,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!otherTile.AdjacentBits.IsFlagSet(direction)) continue;
var otherTile2 = otherTile.AdjacentTiles[j];
if (otherTile2?.Air == null) continue;
DebugTools.Assert(otherTile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (otherTile2.MonstermosInfo.LastQueueCycle == queueCycle) continue;
ConsiderFirelocks(gridAtmosphere, otherTile, otherTile2);
@@ -421,11 +423,12 @@ namespace Content.Server.Atmos.EntitySystems
{
var direction = (AtmosDirection) (1 << j);
// Tiles in _depressurizeProgressionOrder cannot have null air.
if (!otherTile.AdjacentBits.IsFlagSet(direction) && !otherTile.Air!.Immutable) continue;
if (!otherTile.AdjacentBits.IsFlagSet(direction) && !otherTile.Space) continue;
var tile2 = otherTile.AdjacentTiles[j];
if (tile2?.MonstermosInfo.LastQueueCycle != queueCycle) continue;
DebugTools.Assert(tile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (tile2.MonstermosInfo.LastSlowQueueCycle == queueCycleSlow) continue;
if(tile2.Air?.Immutable ?? false) continue;
if(tile2.Space) continue;
tile2.MonstermosInfo.CurrentTransferDirection = direction.GetOpposite();
tile2.MonstermosInfo.CurrentTransferAmount = 0;
tile2.PressureSpecificTarget = otherTile.PressureSpecificTarget;
@@ -479,7 +482,7 @@ namespace Content.Server.Atmos.EntitySystems
}
if(tileCount > 10 && (totalMolesRemoved / tileCount) > 20)
_adminLogger.Add(LogType.ExplosiveDepressurization, LogImpact.High,
_adminLog.Add(LogType.ExplosiveDepressurization, LogImpact.High,
$"Explosive depressurization removed {totalMolesRemoved} moles from {tileCount} tiles starting from position {tile.GridIndices:position} on grid ID {tile.GridIndex:grid}");
Array.Clear(_depressurizeTiles, 0, Atmospherics.MonstermosHardTileLimit);
@@ -513,8 +516,10 @@ namespace Content.Server.Atmos.EntitySystems
if (!reconsiderAdjacent)
return;
UpdateAdjacent(mapGrid, gridAtmosphere, tile);
UpdateAdjacent(mapGrid, gridAtmosphere, other);
var tileEv = new UpdateAdjacentMethodEvent(mapGrid.GridEntityId, tile.GridIndices);
var otherEv = new UpdateAdjacentMethodEvent(mapGrid.GridEntityId, other.GridIndices);
GridUpdateAdjacent(mapGrid.GridEntityId, gridAtmosphere, ref tileEv);
GridUpdateAdjacent(mapGrid.GridEntityId, gridAtmosphere, ref otherEv);
InvalidateVisuals(tile.GridIndex, tile.GridIndices);
InvalidateVisuals(other.GridIndex, other.GridIndices);
}
@@ -541,6 +546,7 @@ namespace Content.Server.Atmos.EntitySystems
var amount = transferDirections[i];
var otherTile = tile.AdjacentTiles[i];
if (otherTile?.Air == null) continue;
DebugTools.Assert(otherTile.AdjacentBits.IsFlagSet(direction.GetOpposite()));
if (amount <= 0) continue;
// Everything that calls this method already ensures that Air will not be null.
@@ -569,6 +575,7 @@ namespace Content.Server.Atmos.EntitySystems
private void AdjustEqMovement(TileAtmosphere tile, AtmosDirection direction, float amount)
{
DebugTools.AssertNotNull(tile);
DebugTools.Assert(tile.AdjacentBits.IsFlagSet(direction));
DebugTools.Assert(tile.AdjacentTiles[direction.ToIndex()] != null);
tile.MonstermosInfo[direction] += amount;