From 6969b79c1c4b968f3910e7b15c0f64c3e56300d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Fri, 4 Sep 2020 17:40:44 +0200 Subject: [PATCH] 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) --- Content.Server/Atmos/ExcitedGroup.cs | 3 ++- Content.Server/Atmos/TileAtmosphere.cs | 31 +++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Content.Server/Atmos/ExcitedGroup.cs b/Content.Server/Atmos/ExcitedGroup.cs index 7935be28b5..6a32a422eb 100644 --- a/Content.Server/Atmos/ExcitedGroup.cs +++ b/Content.Server/Atmos/ExcitedGroup.cs @@ -105,6 +105,7 @@ namespace Content.Server.Atmos { if (tile?.Air == null) continue; tile.Air.CopyFromMutable(combined); + tile.AtmosCooldown = 0; tile.UpdateVisuals(); } @@ -131,7 +132,7 @@ namespace Content.Server.Atmos _disposed = true; _gridAtmosphereComponent.RemoveExcitedGroup(this); - Dismantle(); + Dismantle(false); _gridAtmosphereComponent = null; } diff --git a/Content.Server/Atmos/TileAtmosphere.cs b/Content.Server/Atmos/TileAtmosphere.cs index a8afc84cb5..5718263124 100644 --- a/Content.Server/Atmos/TileAtmosphere.cs +++ b/Content.Server/Atmos/TileAtmosphere.cs @@ -9,6 +9,7 @@ using Content.Server.Interfaces; using Content.Shared.Atmos; using Content.Shared.Audio; using Content.Shared.Maps; +using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -40,6 +41,9 @@ namespace Content.Server.Atmos [ViewVariables] private static GasTileOverlaySystem _gasTileOverlaySystem; + [ViewVariables] + public int AtmosCooldown { get; set; } = 0; + [ViewVariables] private float _temperature = Atmospherics.T20C; @@ -73,9 +77,11 @@ namespace Content.Server.Atmos [ViewVariables] private readonly TileAtmosphere[] _adjacentTiles = new TileAtmosphere[Atmospherics.Directions]; - [ViewVariables] private AtmosDirection _adjacentBits = AtmosDirection.Invalid; + [ViewVariables, UsedImplicitly] + private int AdjacentBitsInt => (int)_adjacentBits; + [ViewVariables] private TileAtmosInfo _tileAtmosInfo; @@ -84,6 +90,9 @@ namespace Content.Server.Atmos private AtmosDirection _pressureDirection; + [ViewVariables, UsedImplicitly] + private int PressureDirectionInt => (int)_pressureDirection; + [ViewVariables] public GridId GridIndex { get; } @@ -635,6 +644,15 @@ namespace Content.Server.Atmos _currentCycle = fireCount; 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++) { 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(enemyTile?.Air == null) continue; - adjacentTileLength++; if (fireCount <= enemyTile._currentCycle) continue; enemyTile.Archive(fireCount); @@ -703,7 +720,13 @@ namespace Content.Server.Atmos React(); 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); } @@ -1124,9 +1147,11 @@ namespace Content.Server.Atmos if (lastShare > Atmospherics.MinimumAirToSuspend) { ExcitedGroup.ResetCooldowns(); + AtmosCooldown = 0; } else if (lastShare > Atmospherics.MinimumMolesDeltaToMove) { ExcitedGroup.DismantleCooldown = 0; + AtmosCooldown = 0; } }