Atmos device performance improvements (#26493)
* Atmos device performance improvements * AtmosDirection perf improvements * Fix errors * Add GasTileOverlayComponent arguments * Make excite no longer invalidate a tile
This commit is contained in:
@@ -230,7 +230,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if (otherTile2.MonstermosInfo.LastSlowQueueCycle == queueCycleSlow) continue;
|
||||
_equalizeQueue[queueLength++] = otherTile2;
|
||||
otherTile2.MonstermosInfo.LastSlowQueueCycle = queueCycleSlow;
|
||||
otherTile2.MonstermosInfo.CurrentTransferDirection = direction.GetOpposite();
|
||||
otherTile2.MonstermosInfo.CurrentTransferDirection = k.ToOppositeDir();
|
||||
otherTile2.MonstermosInfo.CurrentTransferAmount = 0;
|
||||
if (otherTile2.MonstermosInfo.MoleDelta < 0)
|
||||
{
|
||||
@@ -296,7 +296,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if (otherTile2.MonstermosInfo.LastSlowQueueCycle == queueCycleSlow) continue;
|
||||
_equalizeQueue[queueLength++] = otherTile2;
|
||||
otherTile2.MonstermosInfo.LastSlowQueueCycle = queueCycleSlow;
|
||||
otherTile2.MonstermosInfo.CurrentTransferDirection = direction.GetOpposite();
|
||||
otherTile2.MonstermosInfo.CurrentTransferDirection = k.ToOppositeDir();
|
||||
otherTile2.MonstermosInfo.CurrentTransferAmount = 0;
|
||||
|
||||
if (otherTile2.MonstermosInfo.MoleDelta > 0)
|
||||
@@ -338,7 +338,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
for (var i = 0; i < tileCount; i++)
|
||||
{
|
||||
var otherTile = _equalizeTiles[i]!;
|
||||
FinalizeEq(gridAtmosphere, otherTile, ent);
|
||||
FinalizeEq(ent, otherTile);
|
||||
}
|
||||
|
||||
for (var i = 0; i < tileCount; i++)
|
||||
@@ -473,7 +473,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if(tile2.Space)
|
||||
continue;
|
||||
|
||||
tile2.MonstermosInfo.CurrentTransferDirection = direction.GetOpposite();
|
||||
tile2.MonstermosInfo.CurrentTransferDirection = j.ToOppositeDir();
|
||||
tile2.MonstermosInfo.CurrentTransferAmount = 0.0f;
|
||||
tile2.PressureSpecificTarget = otherTile.PressureSpecificTarget;
|
||||
tile2.MonstermosInfo.LastSlowQueueCycle = queueCycleSlow;
|
||||
@@ -549,7 +549,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
otherTile.Air.Temperature = Atmospherics.TCMB;
|
||||
}
|
||||
|
||||
InvalidateVisuals(otherTile.GridIndex, otherTile.GridIndices, visuals);
|
||||
InvalidateVisuals(ent, otherTile);
|
||||
HandleDecompressionFloorRip(mapGrid, otherTile, otherTile.MonstermosInfo.CurrentTransferAmount);
|
||||
}
|
||||
|
||||
@@ -598,11 +598,13 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
UpdateAdjacentTiles(ent, tile);
|
||||
UpdateAdjacentTiles(ent, other);
|
||||
InvalidateVisuals(tile.GridIndex, tile.GridIndices, ent);
|
||||
InvalidateVisuals(other.GridIndex, other.GridIndices, ent);
|
||||
InvalidateVisuals(ent, tile);
|
||||
InvalidateVisuals(ent, other);
|
||||
}
|
||||
|
||||
private void FinalizeEq(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, GasTileOverlayComponent? visuals)
|
||||
private void FinalizeEq(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
|
||||
TileAtmosphere tile)
|
||||
{
|
||||
Span<float> transferDirections = stackalloc float[Atmospherics.Directions];
|
||||
var hasTransferDirs = false;
|
||||
@@ -629,17 +631,19 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
// Everything that calls this method already ensures that Air will not be null.
|
||||
if (tile.Air!.TotalMoles < amount)
|
||||
FinalizeEqNeighbors(gridAtmosphere, tile, transferDirections, visuals);
|
||||
FinalizeEqNeighbors(ent, tile, transferDirections);
|
||||
|
||||
otherTile.MonstermosInfo[direction.GetOpposite()] = 0;
|
||||
otherTile.MonstermosInfo[i.ToOppositeDir()] = 0;
|
||||
Merge(otherTile.Air, tile.Air.Remove(amount));
|
||||
InvalidateVisuals(tile.GridIndex, tile.GridIndices, visuals);
|
||||
InvalidateVisuals(otherTile.GridIndex, otherTile.GridIndices, visuals);
|
||||
ConsiderPressureDifference(gridAtmosphere, tile, direction, amount);
|
||||
InvalidateVisuals(ent, tile);
|
||||
InvalidateVisuals(ent, otherTile);
|
||||
ConsiderPressureDifference(ent, tile, direction, amount);
|
||||
}
|
||||
}
|
||||
|
||||
private void FinalizeEqNeighbors(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, ReadOnlySpan<float> transferDirs, GasTileOverlayComponent? visuals)
|
||||
private void FinalizeEqNeighbors(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
|
||||
TileAtmosphere tile, ReadOnlySpan<float> transferDirs)
|
||||
{
|
||||
for (var i = 0; i < Atmospherics.Directions; i++)
|
||||
{
|
||||
@@ -647,7 +651,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var amount = transferDirs[i];
|
||||
// Since AdjacentBits is set, AdjacentTiles[i] wouldn't be null, and neither would its air.
|
||||
if(amount < 0 && tile.AdjacentBits.IsFlagSet(direction))
|
||||
FinalizeEq(gridAtmosphere, tile.AdjacentTiles[i]!, visuals); // A bit of recursion if needed.
|
||||
FinalizeEq(ent, tile.AdjacentTiles[i]!); // A bit of recursion if needed.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,7 +668,9 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
Log.Error($"Encountered null-tile in {nameof(AdjustEqMovement)}. Trace: {Environment.StackTrace}");
|
||||
return;
|
||||
}
|
||||
var adj = tile.AdjacentTiles[direction.ToIndex()];
|
||||
|
||||
var idx = direction.ToIndex();
|
||||
var adj = tile.AdjacentTiles[idx];
|
||||
if (adj == null)
|
||||
{
|
||||
var nonNull = tile.AdjacentTiles.Where(x => x != null).Count();
|
||||
@@ -673,7 +679,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
}
|
||||
|
||||
tile.MonstermosInfo[direction] += amount;
|
||||
adj.MonstermosInfo[direction.GetOpposite()] -= amount;
|
||||
adj.MonstermosInfo[idx.ToOppositeDir()] -= amount;
|
||||
}
|
||||
|
||||
private void HandleDecompressionFloorRip(MapGridComponent mapGrid, TileAtmosphere tile, float sum)
|
||||
|
||||
Reference in New Issue
Block a user