Fix NoAirWhenFullyAirBlocked (#12709)

This commit is contained in:
Leon Friedrich
2022-11-24 14:45:08 +13:00
committed by GitHub
parent 32ba8e4f9d
commit 186b8e00da
3 changed files with 13 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Reactions; using Content.Server.Atmos.Reactions;
using Content.Server.NodeContainer.NodeGroups; using Content.Server.NodeContainer.NodeGroups;
@@ -297,7 +298,14 @@ public partial class AtmosphereSystem
(EntityUid GridId, Vector2i Tile, ReactionResult Result = default, bool Handled = false); (EntityUid GridId, Vector2i Tile, ReactionResult Result = default, bool Handled = false);
[ByRefEvent] private record struct IsTileAirBlockedMethodEvent [ByRefEvent] private record struct IsTileAirBlockedMethodEvent
(EntityUid Grid, Vector2i Tile, AtmosDirection Direction = AtmosDirection.All, MapGridComponent? MapGridComponent = null, bool Result = false, bool Handled = false); (EntityUid Grid, Vector2i Tile, AtmosDirection Direction = AtmosDirection.All, MapGridComponent? MapGridComponent = null, bool Result = false, bool Handled = false)
{
/// <summary>
/// True if one of the enabled blockers has <see cref="AirtightComponent.NoAirWhenFullyAirBlocked"/>. Note
/// that this does not actually check if all directions are blocked.
/// </summary>
public bool NoAir = false;
}
[ByRefEvent] private record struct IsTileSpaceMethodEvent [ByRefEvent] private record struct IsTileSpaceMethodEvent
(EntityUid? Grid, EntityUid? Map, Vector2i Tile, MapGridComponent? MapGridComponent = null, bool Result = true, bool Handled = false); (EntityUid? Grid, EntityUid? Map, Vector2i Tile, MapGridComponent? MapGridComponent = null, bool Result = true, bool Handled = false);

View File

@@ -241,6 +241,7 @@ public sealed partial class AtmosphereSystem
// We set the directions that are air-blocked so far, // We set the directions that are air-blocked so far,
// as you could have a full obstruction with only 4 directional air blockers. // as you could have a full obstruction with only 4 directional air blockers.
directions |= obstructingComponent.AirBlockedDirection; directions |= obstructingComponent.AirBlockedDirection;
args.NoAir |= obstructingComponent.NoAirWhenFullyAirBlocked;
if (directions.IsFlagSet(args.Direction)) if (directions.IsFlagSet(args.Direction))
{ {

View File

@@ -83,22 +83,10 @@ namespace Content.Server.Atmos.EntitySystems
tile.Air = GetTileMixture(null, mapUid, indices); tile.Air = GetTileMixture(null, mapUid, indices);
tile.MolesArchived = tile.Air != null ? new float[Atmospherics.AdjustedNumberOfGases] : null; tile.MolesArchived = tile.Air != null ? new float[Atmospherics.AdjustedNumberOfGases] : null;
tile.Space = IsTileSpace(null, mapUid, indices, mapGridComp); tile.Space = IsTileSpace(null, mapUid, indices, mapGridComp);
} else if (isAirBlocked)
{
var nullAir = false;
var enumerator = GetObstructingComponentsEnumerator(mapGridComp, indices);
while (enumerator.MoveNext(out var airtight))
{
if (!airtight.NoAirWhenFullyAirBlocked)
continue;
nullAir = true;
break;
} }
else if (isAirBlocked)
if (nullAir) {
if (airBlockedEv.NoAir)
{ {
tile.Air = null; tile.Air = null;
tile.MolesArchived = null; tile.MolesArchived = null;