From 546d708c403b01ccc0980a8b243df132bc92c990 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Tue, 19 Jul 2022 21:23:23 -0700 Subject: [PATCH] Add under-pressure lockout to air vents (#9824) * Add under-pressure lockout to vent pumps * Add examine text showing UPLO --- .../Unary/Components/GasVentPumpComponent.cs | 11 ++++++++++ .../Unary/EntitySystems/GasVentPumpSystem.cs | 22 +++++++++++++++++++ .../Locale/en-US/atmos/gas-vent-pump.ftl | 1 + 3 files changed, 34 insertions(+) create mode 100644 Resources/Locale/en-US/atmos/gas-vent-pump.ftl diff --git a/Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs b/Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs index 9289f6c804..c9e838f30b 100644 --- a/Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs +++ b/Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs @@ -33,6 +33,17 @@ namespace Content.Server.Atmos.Piping.Unary.Components [DataField("pressureChecks")] public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound; + [ViewVariables(VVAccess.ReadOnly)] + [DataField("underPressureLockout")] + public bool UnderPressureLockout { get; set; } = false; + + /// + /// In releasing mode, do not pump when environment pressure is below this limit. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("underPressureLockoutThreshold")] + public float UnderPressureLockoutThreshold = 1; + [ViewVariables(VVAccess.ReadWrite)] [DataField("externalPressureBound")] public float ExternalPressureBound diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs index 8b6b527b41..8b638c179a 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs @@ -16,6 +16,7 @@ using Content.Shared.Atmos.Monitor; using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Visuals; using Content.Shared.Audio; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.Timing; @@ -41,6 +42,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems SubscribeLocalEvent(OnPowerChanged); SubscribeLocalEvent(OnPacketRecv); SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnSignalReceived); } @@ -83,6 +85,13 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems if (environment.Pressure > vent.MaxPressure) return; + if (environment.Pressure < vent.UnderPressureLockoutThreshold) + { + vent.UnderPressureLockout = true; + return; + } + vent.UnderPressureLockout = false; + if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0) pressureDelta = MathF.Min(pressureDelta, vent.ExternalPressureBound - environment.Pressure); @@ -255,5 +264,18 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems appearance.SetData(VentPumpVisuals.State, VentPumpState.Welded); } } + + private void OnExamine(EntityUid uid, GasVentPumpComponent component, ExaminedEvent args) + { + if (!TryComp(uid, out var pumpComponent)) + return; + if (args.IsInDetailsRange) + { + if (pumpComponent.UnderPressureLockout) + { + args.PushMarkup(Loc.GetString("gas-vent-pump-uvlo")); + } + } + } } } diff --git a/Resources/Locale/en-US/atmos/gas-vent-pump.ftl b/Resources/Locale/en-US/atmos/gas-vent-pump.ftl new file mode 100644 index 0000000000..a65ac5d49a --- /dev/null +++ b/Resources/Locale/en-US/atmos/gas-vent-pump.ftl @@ -0,0 +1 @@ +gas-vent-pump-uvlo = It is in [color=red]under-pressure lock out[/color].