Improves atmos even more.

* Adds AtmosCooldown to tiles, so they stop being active after a certain number of cycles without a cooldown reset.
* Fixes adjacentTileLength in ProcessCell. It wasn't being set beforehand, (probably) causing some incorrect air shares.
* Removing a tile from active tiles no longer unexcites every other tile in their excited group. (Basically, Dismantle in ExcitedGroup's Dispose() method no longer unexcites tiles)
This commit is contained in:
Víctor Aguilera Puerto
2020-09-04 17:40:44 +02:00
parent f42ecf73b5
commit 6969b79c1c
2 changed files with 30 additions and 4 deletions

View File

@@ -105,6 +105,7 @@ namespace Content.Server.Atmos
{ {
if (tile?.Air == null) continue; if (tile?.Air == null) continue;
tile.Air.CopyFromMutable(combined); tile.Air.CopyFromMutable(combined);
tile.AtmosCooldown = 0;
tile.UpdateVisuals(); tile.UpdateVisuals();
} }
@@ -131,7 +132,7 @@ namespace Content.Server.Atmos
_disposed = true; _disposed = true;
_gridAtmosphereComponent.RemoveExcitedGroup(this); _gridAtmosphereComponent.RemoveExcitedGroup(this);
Dismantle(); Dismantle(false);
_gridAtmosphereComponent = null; _gridAtmosphereComponent = null;
} }

View File

@@ -9,6 +9,7 @@ using Content.Server.Interfaces;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Maps; using Content.Shared.Maps;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -40,6 +41,9 @@ namespace Content.Server.Atmos
[ViewVariables] [ViewVariables]
private static GasTileOverlaySystem _gasTileOverlaySystem; private static GasTileOverlaySystem _gasTileOverlaySystem;
[ViewVariables]
public int AtmosCooldown { get; set; } = 0;
[ViewVariables] [ViewVariables]
private float _temperature = Atmospherics.T20C; private float _temperature = Atmospherics.T20C;
@@ -73,9 +77,11 @@ namespace Content.Server.Atmos
[ViewVariables] [ViewVariables]
private readonly TileAtmosphere[] _adjacentTiles = new TileAtmosphere[Atmospherics.Directions]; private readonly TileAtmosphere[] _adjacentTiles = new TileAtmosphere[Atmospherics.Directions];
[ViewVariables]
private AtmosDirection _adjacentBits = AtmosDirection.Invalid; private AtmosDirection _adjacentBits = AtmosDirection.Invalid;
[ViewVariables, UsedImplicitly]
private int AdjacentBitsInt => (int)_adjacentBits;
[ViewVariables] [ViewVariables]
private TileAtmosInfo _tileAtmosInfo; private TileAtmosInfo _tileAtmosInfo;
@@ -84,6 +90,9 @@ namespace Content.Server.Atmos
private AtmosDirection _pressureDirection; private AtmosDirection _pressureDirection;
[ViewVariables, UsedImplicitly]
private int PressureDirectionInt => (int)_pressureDirection;
[ViewVariables] [ViewVariables]
public GridId GridIndex { get; } public GridId GridIndex { get; }
@@ -635,6 +644,15 @@ namespace Content.Server.Atmos
_currentCycle = fireCount; _currentCycle = fireCount;
var adjacentTileLength = 0; var adjacentTileLength = 0;
AtmosCooldown++;
for (var i = 0; i < Atmospherics.Directions; i++)
{
var direction = (AtmosDirection) (1 << i);
if(_adjacentBits.HasFlag(direction))
adjacentTileLength++;
}
for(var i = 0; i < Atmospherics.Directions; i++) for(var i = 0; i < Atmospherics.Directions; i++)
{ {
var direction = (AtmosDirection) (1 << i); var direction = (AtmosDirection) (1 << i);
@@ -643,7 +661,6 @@ namespace Content.Server.Atmos
// If the tile is null or has no air, we don't do anything for it. // If the tile is null or has no air, we don't do anything for it.
if(enemyTile?.Air == null) continue; if(enemyTile?.Air == null) continue;
adjacentTileLength++;
if (fireCount <= enemyTile._currentCycle) continue; if (fireCount <= enemyTile._currentCycle) continue;
enemyTile.Archive(fireCount); enemyTile.Archive(fireCount);
@@ -703,7 +720,13 @@ namespace Content.Server.Atmos
React(); React();
UpdateVisuals(); UpdateVisuals();
if((!(Air.Temperature > Atmospherics.MinimumTemperatureStartSuperConduction && ConsiderSuperconductivity(true))) && ExcitedGroup == null) var remove = true;
if(Air.Temperature > Atmospherics.MinimumTemperatureStartSuperConduction)
if (ConsiderSuperconductivity(true))
remove = false;
if((ExcitedGroup == null && remove) || (AtmosCooldown > (Atmospherics.ExcitedGroupsDismantleCycles * 2)))
_gridAtmosphereComponent.RemoveActiveTile(this); _gridAtmosphereComponent.RemoveActiveTile(this);
} }
@@ -1124,9 +1147,11 @@ namespace Content.Server.Atmos
if (lastShare > Atmospherics.MinimumAirToSuspend) if (lastShare > Atmospherics.MinimumAirToSuspend)
{ {
ExcitedGroup.ResetCooldowns(); ExcitedGroup.ResetCooldowns();
AtmosCooldown = 0;
} else if (lastShare > Atmospherics.MinimumMolesDeltaToMove) } else if (lastShare > Atmospherics.MinimumMolesDeltaToMove)
{ {
ExcitedGroup.DismantleCooldown = 0; ExcitedGroup.DismantleCooldown = 0;
AtmosCooldown = 0;
} }
} }