From: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Date: Tue, 23 Dec 2025 09:44:31 +0000 (-0800) Subject: Use cached Atmospherics AirtightData when applicable (#41390) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9f84b2473307965b02d8f5d2ab48d5b664b9f9b2;p=space-station-14.git Use cached Atmospherics AirtightData when applicable (#41390) --- diff --git a/Content.Server/Anomaly/AnomalySystem.Generator.cs b/Content.Server/Anomaly/AnomalySystem.Generator.cs index 46ad9278f8..09af0419bb 100644 --- a/Content.Server/Anomaly/AnomalySystem.Generator.cs +++ b/Content.Server/Anomaly/AnomalySystem.Generator.cs @@ -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; } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs index 96a5c69457..5cce6075b7 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs @@ -306,6 +306,8 @@ public partial class AtmosphereSystem /// The directions to check for air-blockage. /// Optional map grid component associated with the grid. /// True if the tile is air-blocked in the specified directions, false otherwise. + /// 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. [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); } + /// + /// Checks if a tile on a grid is air-blocked in the specified directions, using cached data. + /// + /// The grid to check. + /// The tile on the grid to check. + /// The directions to check for air-blockage. + /// True if the tile is air-blocked in the specified directions, false otherwise. + /// Returns data that is currently cached by Atmospherics. + /// You should always use this method over as it's more performant. + /// If you need to get up-to-date data because you've just invalidated airtight data, + /// use . + [PublicAPI] + public bool IsTileAirBlockedCached(Entity 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); + } + /// /// 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 diff --git a/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs b/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs index b3644e88b7..8183bb99e4 100644 --- a/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs @@ -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; } diff --git a/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs b/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs index cd93eae502..8f1f08269b 100644 --- a/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs +++ b/Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs @@ -116,7 +116,7 @@ public abstract partial class GameRuleSystem 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; }