Removes AtmosCooldown from TileAtmosphere, fixes various atmos issues (#2297)
* Remove AtmosCooldown * Fix former space tiles always having an immutable gas mixture * _tile -> _tiles
This commit is contained in:
committed by
GitHub
parent
717a375abb
commit
19d32eb4ce
@@ -12,7 +12,7 @@ namespace Content.Server.Atmos
|
|||||||
private bool _disposed = false;
|
private bool _disposed = false;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private readonly HashSet<TileAtmosphere> _tile = new HashSet<TileAtmosphere>();
|
private readonly HashSet<TileAtmosphere> _tiles = new HashSet<TileAtmosphere>();
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private GridAtmosphereComponent _gridAtmosphereComponent;
|
private GridAtmosphereComponent _gridAtmosphereComponent;
|
||||||
@@ -25,35 +25,41 @@ namespace Content.Server.Atmos
|
|||||||
|
|
||||||
public void AddTile(TileAtmosphere tile)
|
public void AddTile(TileAtmosphere tile)
|
||||||
{
|
{
|
||||||
_tile.Add(tile);
|
_tiles.Add(tile);
|
||||||
tile.ExcitedGroup = this;
|
tile.ExcitedGroup = this;
|
||||||
ResetCooldowns();
|
ResetCooldowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool RemoveTile(TileAtmosphere tile)
|
||||||
|
{
|
||||||
|
tile.ExcitedGroup = null;
|
||||||
|
return _tiles.Remove(tile);
|
||||||
|
}
|
||||||
|
|
||||||
public void MergeGroups(ExcitedGroup other)
|
public void MergeGroups(ExcitedGroup other)
|
||||||
{
|
{
|
||||||
var ourSize = _tile.Count;
|
var ourSize = _tiles.Count;
|
||||||
var otherSize = other._tile.Count;
|
var otherSize = other._tiles.Count;
|
||||||
|
|
||||||
if (ourSize > otherSize)
|
if (ourSize > otherSize)
|
||||||
{
|
{
|
||||||
foreach (var tile in other._tile)
|
foreach (var tile in other._tiles)
|
||||||
{
|
{
|
||||||
tile.ExcitedGroup = this;
|
tile.ExcitedGroup = this;
|
||||||
_tile.Add(tile);
|
_tiles.Add(tile);
|
||||||
}
|
}
|
||||||
other._tile.Clear();
|
other._tiles.Clear();
|
||||||
other.Dispose();
|
other.Dispose();
|
||||||
ResetCooldowns();
|
ResetCooldowns();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var tile in _tile)
|
foreach (var tile in _tiles)
|
||||||
{
|
{
|
||||||
tile.ExcitedGroup = other;
|
tile.ExcitedGroup = other;
|
||||||
other._tile.Add(tile);
|
other._tiles.Add(tile);
|
||||||
}
|
}
|
||||||
_tile.Clear();
|
_tiles.Clear();
|
||||||
Dispose();
|
Dispose();
|
||||||
other.ResetCooldowns();
|
other.ResetCooldowns();
|
||||||
}
|
}
|
||||||
@@ -80,7 +86,7 @@ namespace Content.Server.Atmos
|
|||||||
{
|
{
|
||||||
var combined = new GasMixture(Atmospherics.CellVolume);
|
var combined = new GasMixture(Atmospherics.CellVolume);
|
||||||
|
|
||||||
var tileSize = _tile.Count;
|
var tileSize = _tiles.Count;
|
||||||
|
|
||||||
if (_disposed) return;
|
if (_disposed) return;
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ namespace Content.Server.Atmos
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var tile in _tile)
|
foreach (var tile in _tiles)
|
||||||
{
|
{
|
||||||
if (tile?.Air == null) continue;
|
if (tile?.Air == null) continue;
|
||||||
combined.Merge(tile.Air);
|
combined.Merge(tile.Air);
|
||||||
@@ -101,11 +107,10 @@ namespace Content.Server.Atmos
|
|||||||
|
|
||||||
combined.Multiply(1 / (float)tileSize);
|
combined.Multiply(1 / (float)tileSize);
|
||||||
|
|
||||||
foreach (var tile in _tile)
|
foreach (var tile in _tiles)
|
||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +119,7 @@ namespace Content.Server.Atmos
|
|||||||
|
|
||||||
public void Dismantle(bool unexcite = true)
|
public void Dismantle(bool unexcite = true)
|
||||||
{
|
{
|
||||||
foreach (var tile in _tile)
|
foreach (var tile in _tiles)
|
||||||
{
|
{
|
||||||
if (tile == null) continue;
|
if (tile == null) continue;
|
||||||
tile.ExcitedGroup = null;
|
tile.ExcitedGroup = null;
|
||||||
@@ -123,7 +128,7 @@ namespace Content.Server.Atmos
|
|||||||
_gridAtmosphereComponent.RemoveActiveTile(tile);
|
_gridAtmosphereComponent.RemoveActiveTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
_tile.Clear();
|
_tiles.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace Content.Server.Atmos
|
|||||||
/// Use with caution.
|
/// Use with caution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tile"></param>
|
/// <param name="tile"></param>
|
||||||
void RemoveActiveTile(TileAtmosphere tile);
|
void RemoveActiveTile(TileAtmosphere tile, bool disposeGroup = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks a tile as having a hotspot so it can be processed.
|
/// Marks a tile as having a hotspot so it can be processed.
|
||||||
|
|||||||
@@ -44,9 +44,6 @@ namespace Content.Server.Atmos
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private static GasTileOverlaySystem _gasTileOverlaySystem;
|
private static GasTileOverlaySystem _gasTileOverlaySystem;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
public int AtmosCooldown { get; set; } = 0;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public float Temperature {get; private set; } = Atmospherics.T20C;
|
public float Temperature {get; private set; } = Atmospherics.T20C;
|
||||||
|
|
||||||
@@ -647,7 +644,7 @@ namespace Content.Server.Atmos
|
|||||||
// Can't process a tile without air
|
// Can't process a tile without air
|
||||||
if (Air == null)
|
if (Air == null)
|
||||||
{
|
{
|
||||||
_gridAtmosphereComponent.RemoveActiveTile(this);
|
Excited = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,7 +654,6 @@ namespace Content.Server.Atmos
|
|||||||
_currentCycle = fireCount;
|
_currentCycle = fireCount;
|
||||||
var adjacentTileLength = 0;
|
var adjacentTileLength = 0;
|
||||||
|
|
||||||
AtmosCooldown++;
|
|
||||||
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);
|
||||||
@@ -738,7 +734,7 @@ namespace Content.Server.Atmos
|
|||||||
if (ConsiderSuperconductivity(true))
|
if (ConsiderSuperconductivity(true))
|
||||||
remove = false;
|
remove = false;
|
||||||
|
|
||||||
if((ExcitedGroup == null && remove) || (AtmosCooldown > (Atmospherics.ExcitedGroupsDismantleCycles * 2)))
|
if(ExcitedGroup == null && remove)
|
||||||
_gridAtmosphereComponent.RemoveActiveTile(this);
|
_gridAtmosphereComponent.RemoveActiveTile(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1187,11 +1183,9 @@ 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
FixVacuum(tile.GridIndices);
|
FixVacuum(tile.GridIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tile used to be space, but isn't anymore.
|
||||||
|
if (tile.Air?.Immutable ?? false)
|
||||||
|
{
|
||||||
|
tile.Air = null;
|
||||||
|
}
|
||||||
|
|
||||||
tile.Air ??= new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C};
|
tile.Air ??= new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,12 +306,15 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public virtual void RemoveActiveTile(TileAtmosphere? tile)
|
public virtual void RemoveActiveTile(TileAtmosphere? tile, bool disposeGroup = true)
|
||||||
{
|
{
|
||||||
if (tile == null) return;
|
if (tile == null) return;
|
||||||
_activeTiles.Remove(tile);
|
_activeTiles.Remove(tile);
|
||||||
tile.Excited = false;
|
tile.Excited = false;
|
||||||
tile.ExcitedGroup?.Dispose();
|
if(disposeGroup)
|
||||||
|
tile.ExcitedGroup?.Dispose();
|
||||||
|
else
|
||||||
|
tile.ExcitedGroup?.RemoveTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
|
|
||||||
public override void AddActiveTile(TileAtmosphere? tile) { }
|
public override void AddActiveTile(TileAtmosphere? tile) { }
|
||||||
|
|
||||||
public override void RemoveActiveTile(TileAtmosphere? tile) { }
|
public override void RemoveActiveTile(TileAtmosphere? tile, bool disposeGroup = true) { }
|
||||||
|
|
||||||
public override void AddHotspotTile(TileAtmosphere? tile) { }
|
public override void AddHotspotTile(TileAtmosphere? tile) { }
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||||
[Dependency] private IEntityManager _entityManager = default!;
|
|
||||||
|
|
||||||
private GasReactionPrototype[] _gasReactions = Array.Empty<GasReactionPrototype>();
|
private GasReactionPrototype[] _gasReactions = Array.Empty<GasReactionPrototype>();
|
||||||
|
|
||||||
@@ -38,11 +37,6 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<GasReactionPrototype> GasReactions => _gasReactions!;
|
public IEnumerable<GasReactionPrototype> GasReactions => _gasReactions!;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// EventBus reference for gas reactions.
|
|
||||||
/// </summary>
|
|
||||||
public IEventBus EventBus => _entityManager.EventBus;
|
|
||||||
|
|
||||||
public GridTileLookupSystem GridTileLookupSystem => _gridTileLookup ??= Get<GridTileLookupSystem>();
|
public GridTileLookupSystem GridTileLookupSystem => _gridTileLookup ??= Get<GridTileLookupSystem>();
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|||||||
@@ -109,8 +109,8 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimum temperature for starting superconduction.
|
/// Minimum temperature for starting superconduction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float MinimumTemperatureStartSuperConduction = (T20C + 200f);
|
public const float MinimumTemperatureStartSuperConduction = (T20C + 400f);
|
||||||
public const float MinimumTemperatureForSuperconduction = (T20C + 10f);
|
public const float MinimumTemperatureForSuperconduction = (T20C + 80f);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimum heat capacity.
|
/// Minimum heat capacity.
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gases to Ids. Keep these updated with the prototypes!
|
/// Gases to Ids. Keep these updated with the prototypes!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Gas
|
public enum Gas : sbyte
|
||||||
{
|
{
|
||||||
Oxygen = 0,
|
Oxygen = 0,
|
||||||
Nitrogen = 1,
|
Nitrogen = 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user