From d86623eed712b695c4206b5ac898ae28f66f521a Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Mon, 8 Mar 2021 14:57:05 +0100 Subject: [PATCH] Improves AirtightComponent. - Atmos now nulls air in fully airblocked tiles ONLY if one of the airtight entities in it has NoAirWhenFullyAirBlocked to true. - Fixes edge firelocks atmos airtight direction - Fixes atmos debug overlay not accounting for angle 0 being south. --- Content.Client/Atmos/AtmosDebugOverlay.cs | 6 ++++-- .../Components/Atmos/AirtightComponent.cs | 6 +++++- .../Components/Atmos/GridAtmosphereComponent.cs | 14 +++++++++++++- Content.Shared/Atmos/AtmosDirection.cs | 6 +++--- Resources/Changelog/Parts/edge_firelocks.yml | 4 ++++ .../Entities/Constructible/Doors/firelock.yml | 7 +++++-- .../Textures/Shaders/gradient_circle_mask.swsl | 2 +- 7 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 Resources/Changelog/Parts/edge_firelocks.yml diff --git a/Content.Client/Atmos/AtmosDebugOverlay.cs b/Content.Client/Atmos/AtmosDebugOverlay.cs index a1794162db..dacf02231e 100644 --- a/Content.Client/Atmos/AtmosDebugOverlay.cs +++ b/Content.Client/Atmos/AtmosDebugOverlay.cs @@ -105,7 +105,8 @@ namespace Content.Client.Atmos { if (data.BlockDirection.HasFlag(dir)) { - var atmosAngle = dir.ToAngle(); + // Account for South being 0. + var atmosAngle = dir.ToAngle() - Angle.FromDegrees(90); var atmosAngleOfs = atmosAngle.ToVec() * 0.45f; var atmosAngleOfsR90 = new Vector2(atmosAngleOfs.Y, -atmosAngleOfs.X); var tileCentre = new Vector2(tile.X + 0.5f, tile.Y + 0.5f); @@ -121,7 +122,8 @@ namespace Content.Client.Atmos // -- Pressure Direction -- if (data.PressureDirection != AtmosDirection.Invalid) { - var atmosAngle = data.PressureDirection.ToAngle(); + // Account for South being 0. + var atmosAngle = data.PressureDirection.ToAngle() - Angle.FromDegrees(90); var atmosAngleOfs = atmosAngle.ToVec() * 0.4f; var tileCentre = new Vector2(tile.X + 0.5f, tile.Y + 0.5f); var basisA = mapGrid.LocalToWorld(tileCentre); diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 649212903b..d826fd0bd8 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -39,6 +39,10 @@ namespace Content.Server.GameObjects.Components.Atmos [DataField("fixAirBlockedDirectionInitialize")] private bool _fixAirBlockedDirectionInitialize = true; + [ViewVariables] + [field: DataField("noAirWhenFullyAirBlocked")] + public bool NoAirWhenFullyAirBlocked { get; } = true; + [ViewVariables(VVAccess.ReadWrite)] public bool AirBlocked { @@ -78,7 +82,7 @@ namespace Content.Server.GameObjects.Components.Atmos Owner.EnsureComponentWarn(out SnapGridComponent _); if (_fixAirBlockedDirectionInitialize) - RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.LocalRotation)); + RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.WorldRotation)); UpdatePosition(); } diff --git a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs index 0d9f4b57c3..3ab6d1ce4a 100644 --- a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs @@ -288,7 +288,19 @@ namespace Content.Server.GameObjects.Components.Atmos } else if (isAirBlocked) { - tile.Air = null; + var nullAir = false; + + foreach (var airtight in GetObstructingComponents(indices)) + { + if (airtight.NoAirWhenFullyAirBlocked) + { + nullAir = true; + break; + } + } + + if(nullAir) + tile.Air = null; } else { diff --git a/Content.Shared/Atmos/AtmosDirection.cs b/Content.Shared/Atmos/AtmosDirection.cs index d649247366..d6989f0db6 100644 --- a/Content.Shared/Atmos/AtmosDirection.cs +++ b/Content.Shared/Atmos/AtmosDirection.cs @@ -90,12 +90,12 @@ namespace Content.Shared.Atmos { AtmosDirection.East => Angle.FromDegrees(90), AtmosDirection.North => Angle.FromDegrees(180), - AtmosDirection.West => Angle.FromDegrees(-90), + AtmosDirection.West => Angle.FromDegrees(270), AtmosDirection.South => Angle.FromDegrees(0), AtmosDirection.NorthEast => Angle.FromDegrees(135), - AtmosDirection.NorthWest => Angle.FromDegrees(-135), - AtmosDirection.SouthWest => Angle.FromDegrees(-45), + AtmosDirection.NorthWest => Angle.FromDegrees(205), + AtmosDirection.SouthWest => Angle.FromDegrees(315), AtmosDirection.SouthEast => Angle.FromDegrees(45), _ => throw new ArgumentOutOfRangeException(nameof(direction), $"It was {direction}."), diff --git a/Resources/Changelog/Parts/edge_firelocks.yml b/Resources/Changelog/Parts/edge_firelocks.yml new file mode 100644 index 0000000000..a6343ed401 --- /dev/null +++ b/Resources/Changelog/Parts/edge_firelocks.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix + message: Having four edge firelocks in a single tile no longer destroys any air within it. diff --git a/Resources/Prototypes/Entities/Constructible/Doors/firelock.yml b/Resources/Prototypes/Entities/Constructible/Doors/firelock.yml index 873bc4175a..120b64fbe0 100644 --- a/Resources/Prototypes/Entities/Constructible/Doors/firelock.yml +++ b/Resources/Prototypes/Entities/Constructible/Doors/firelock.yml @@ -53,6 +53,7 @@ openTimeTwo: 0.6 startOpen: true bumpOpen: false + inhibitCrush: false - type: Firelock - type: Appearance visuals: @@ -88,6 +89,7 @@ components: - type: Door occludes: false + inhibitCrush: false - type: Occluder enabled: false - type: Sprite @@ -100,13 +102,14 @@ components: - type: Door occludes: false - inhibitCrush: true + inhibitCrush: false - type: Sprite sprite: Constructible/Structures/Doors/edge_door_hazard.rsi - type: Airtight fixVacuum: true + noAirWhenFullyAirBlocked: false airBlockedDirection: - - East + - South - type: Physics fixtures: - shape: diff --git a/Resources/Textures/Shaders/gradient_circle_mask.swsl b/Resources/Textures/Shaders/gradient_circle_mask.swsl index 8a6addd5b4..f32fa4ce5f 100644 --- a/Resources/Textures/Shaders/gradient_circle_mask.swsl +++ b/Resources/Textures/Shaders/gradient_circle_mask.swsl @@ -18,7 +18,7 @@ void fragment() { highp vec4 grad = vec4(0.8 - length( uv - center )/res_xy.y * gradientfalloffwidth); highp vec4 layer1 = vec4(vec3(255.0),0.0); - + highp vec4 layer2 = circle(uv, center, radius, grad.rgb); COLOR = mix(layer1, layer2, layer2.a);