diff --git a/Content.Server/Atmos/IGridAtmosphereComponent.cs b/Content.Server/Atmos/IGridAtmosphereComponent.cs index 56678a75a1..8060276652 100644 --- a/Content.Server/Atmos/IGridAtmosphereComponent.cs +++ b/Content.Server/Atmos/IGridAtmosphereComponent.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Content.Server.GameObjects.Components.Atmos.Piping; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; +using Content.Shared.Atmos; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -152,7 +153,7 @@ namespace Content.Server.Atmos /// /// Returns a dictionary of adjacent TileAtmospheres. /// - Dictionary GetAdjacentTiles(MapIndices indices, bool includeAirBlocked = false); + Dictionary GetAdjacentTiles(MapIndices indices, bool includeAirBlocked = false); void Update(float frameTime); diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 3703eff58d..e4085a66af 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -35,7 +35,7 @@ namespace Content.Server.GameObjects.Components.Atmos if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) { - EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID)?.Invalidate(snapGrid.Position); + EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID)?.Revalidate(snapGrid.Position); } } } diff --git a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs index fd56e9d34d..a1186c9bd2 100644 --- a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs @@ -210,60 +210,66 @@ namespace Content.Server.GameObjects.Components.Atmos private void Revalidate() { - if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return; - foreach (var indices in _invalidatedCoords.ToArray()) { - var tile = GetTile(indices); - AddActiveTile(tile); - - if (tile == null) - { - tile = new TileAtmosphere(this, mapGrid.Grid.Index, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}); - _tiles[indices] = tile; - } - - if (IsSpace(indices)) - { - tile.Air = new GasMixture(GetVolumeForCells(1)); - tile.Air.MarkImmutable(); - _tiles[indices] = tile; - - } else if (IsAirBlocked(indices)) - { - tile.Air = null; - } - else - { - var obs = GetObstructingComponent(indices); - - if (obs != null) - { - if (tile.Air == null && obs.FixVacuum) - { - FixVacuum(tile.GridIndices); - } - } - - tile.Air ??= new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}; - } - - tile.UpdateAdjacent(); - tile.UpdateVisuals(); - - for (var i = 0; i < Atmospherics.Directions; i++) - { - var direction = (AtmosDirection) (1 << i); - var otherIndices = indices.Offset(direction.ToDirection()); - var otherTile = GetTile(otherIndices); - AddActiveTile(otherTile); - otherTile?.UpdateAdjacent(direction.GetOpposite()); - } + Revalidate(indices); } _invalidatedCoords.Clear(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Revalidate(MapIndices indices) + { + if (!Owner.TryGetComponent(out IMapGridComponent? mapGrid)) return; + + var tile = GetTile(indices); + + if (tile == null) + { + tile = new TileAtmosphere(this, mapGrid.Grid.Index, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}); + _tiles[indices] = tile; + } + + if (IsSpace(indices)) + { + tile.Air = new GasMixture(GetVolumeForCells(1)); + tile.Air.MarkImmutable(); + _tiles[indices] = tile; + + } else if (IsAirBlocked(indices)) + { + tile.Air = null; + } + else + { + var obs = GetObstructingComponent(indices); + + if (obs != null) + { + if (tile.Air == null && obs.FixVacuum) + { + FixVacuum(tile.GridIndices); + } + } + + tile.Air ??= new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C}; + } + + AddActiveTile(tile); + tile.UpdateAdjacent(); + tile.UpdateVisuals(); + + for (var i = 0; i < Atmospherics.Directions; i++) + { + var direction = (AtmosDirection) (1 << i); + var otherIndices = indices.Offset(direction.ToDirection()); + var otherTile = GetTile(otherIndices); + AddActiveTile(otherTile); + otherTile?.UpdateAdjacent(direction.GetOpposite()); + } + } + /// public void FixVacuum(MapIndices indices) {