]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Use cached Atmospherics AirtightData when applicable (#41390)
authorArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Tue, 23 Dec 2025 09:44:31 +0000 (01:44 -0800)
committerGitHub <noreply@github.com>
Tue, 23 Dec 2025 09:44:31 +0000 (01:44 -0800)
Content.Server/Anomaly/AnomalySystem.Generator.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs
Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs
Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs

index 46ad9278f8a16cf2e7fa9f61ed84be99f131c163..09af0419bbd982db6e0db59ebd6bdafcb85a288c 100644 (file)
@@ -100,7 +100,7 @@ public sealed partial class AnomalySystem
 
             // no air-blocked areas.
             if (_atmosphere.IsTileSpace(grid, xform.MapUid, tile) ||
-                _atmosphere.IsTileAirBlocked(grid, tile, mapGridComp: gridComp))
+                _atmosphere.IsTileAirBlockedCached(grid, tile))
             {
                 continue;
             }
index 96a5c694573faf5415e17e602cdba5394d6eb85a..5cce6075b705e93f10aa15f7f659e12758a024cf 100644 (file)
@@ -306,6 +306,8 @@ public partial class AtmosphereSystem
     /// <param name="directions">The directions to check for air-blockage.</param>
     /// <param name="mapGridComp">Optional map grid component associated with the grid.</param>
     /// <returns>True if the tile is air-blocked in the specified directions, false otherwise.</returns>
+    /// <remarks>This rebuilds airtight data on-the-fly. You should only use this if you've just
+    /// invalidated airtight data, and you cannot wait one atmostick to revalidate it.</remarks>
     [PublicAPI]
     public bool IsTileAirBlocked(EntityUid gridUid,
         Vector2i tile,
@@ -315,11 +317,35 @@ public partial class AtmosphereSystem
         if (!Resolve(gridUid, ref mapGridComp, false))
             return false;
 
-        // TODO ATMOS: This reconstructs the data instead of getting the cached version. Might want to include a method to get the cached version later.
         var data = GetAirtightData(gridUid, mapGridComp, tile);
         return data.BlockedDirections.IsFlagSet(directions);
     }
 
+    /// <summary>
+    /// Checks if a tile on a grid is air-blocked in the specified directions, using cached data.
+    /// </summary>
+    /// <param name="grid">The grid to check.</param>
+    /// <param name="tile">The tile on the grid to check.</param>
+    /// <param name="directions">The directions to check for air-blockage.</param>
+    /// <returns>True if the tile is air-blocked in the specified directions, false otherwise.</returns>
+    /// <remarks>Returns data that is currently cached by Atmospherics.
+    /// You should always use this method over <see cref="IsTileAirBlocked"/> as it's more performant.
+    /// If you need to get up-to-date data because you've just invalidated airtight data,
+    /// use <see cref="IsTileAirBlocked"/>.</remarks>
+    [PublicAPI]
+    public bool IsTileAirBlockedCached(Entity<GridAtmosphereComponent?> grid,
+        Vector2i tile,
+        AtmosDirection directions = AtmosDirection.All)
+    {
+        if (!_atmosQuery.Resolve(grid, ref grid.Comp, false))
+            return false;
+
+        if (!grid.Comp.Tiles.TryGetValue(tile, out var atmosTile))
+            return false;
+
+        return atmosTile.AirtightData.BlockedDirections.IsFlagSet(directions);
+    }
+
     /// <summary>
     /// Checks if a tile on a grid or map is space as defined by a tile's definition of space.
     /// Some tiles can hold back space and others cannot - for example, plating can hold
index b3644e88b73a0d5364b9bf0591c81fffa49f6db1..8183bb99e49175637d480631199dc81342ba5de9 100644 (file)
@@ -43,7 +43,7 @@ public sealed class HeatExchangerSystem : EntitySystem
         // make sure that the tile the device is on isn't blocked by a wall or something similar.
         if (args.Grid is {} grid
             && _transform.TryGetGridTilePosition(uid, out var tile)
-            && _atmosphereSystem.IsTileAirBlocked(grid, tile))
+            && _atmosphereSystem.IsTileAirBlockedCached(grid, tile))
         {
             return;
         }
index cd93eae502bf126f3bdd9b83a3491075afd96052..8f1f08269b0023fdb0750c6cd3420ab1e8be52d9 100644 (file)
@@ -116,7 +116,7 @@ public abstract partial class GameRuleSystem<T> where T: IComponent
 
             tile = new Vector2i(randomX, randomY);
             if (_atmosphere.IsTileSpace(targetGrid, Transform(targetGrid).MapUid, tile)
-                || _atmosphere.IsTileAirBlocked(targetGrid, tile, mapGridComp: gridComp))
+                || _atmosphere.IsTileAirBlockedCached(targetGrid, tile))
             {
                 continue;
             }