From b374d2468acfdef0bdaa556e749551d8f74613cb Mon Sep 17 00:00:00 2001 From: qwerltaz <69696513+qwerltaz@users.noreply.github.com> Date: Wed, 14 May 2025 22:39:47 +0200 Subject: [PATCH] air alarm panic wire snipping forces panic mode (#36439) * air alarm panic wire snipping forces panic mode * document * ForcedMode is datafield * switch to bool flag * lock button when panic wire cut * prevent manually individually changing scrubbers from siphon when panic wire is cut * failure alert when wire snipped * is Control * remove double horizontalExpand * Update Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs * Update Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml | 8 +++++++- .../Atmos/Monitor/UI/AirAlarmWindow.xaml.cs | 2 ++ .../Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs | 2 ++ .../Atmos/Monitor/Components/AirAlarmComponent.cs | 6 ++++++ .../Atmos/Monitor/Systems/AirAlarmSystem.cs | 11 +++++++++-- .../Atmos/Monitor/WireActions/AirAlarmPanicWire.cs | 2 ++ .../Monitor/Components/SharedAirAlarmComponent.cs | 4 +++- .../Unary/Components/SharedVentScrubberComponent.cs | 1 + Resources/Locale/en-US/atmos/air-alarm-ui.ftl | 1 + 9 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml index 1d87611949..697a027aa2 100644 --- a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml +++ b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml @@ -74,7 +74,13 @@ diff --git a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs index ed15579937..64680b5321 100644 --- a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs @@ -110,6 +110,8 @@ public sealed partial class AirAlarmWindow : FancyWindow { UpdateDeviceData(addr, dev); } + _modes.Visible = !state.PanicWireCut; + CModeSelectLocked.Visible = state.PanicWireCut; } public void UpdateModeSelector(AirAlarmMode mode) diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs index d03ac77ab3..9762f63992 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs @@ -71,6 +71,7 @@ public sealed partial class ScrubberControl : BoxContainer _data.PumpDirection = (ScrubberPumpDirection) args.Id; ScrubberDataChanged?.Invoke(_address, _data); }; + _pumpDirection.Disabled = data.AirAlarmPanicWireCut; _copySettings.OnPressed += _ => { @@ -109,6 +110,7 @@ public sealed partial class ScrubberControl : BoxContainer _data.PumpDirection = data.PumpDirection; _pumpDirection.Select((int) _data.PumpDirection); + _pumpDirection.Disabled = data.AirAlarmPanicWireCut; _data.VolumeRate = data.VolumeRate; _volumeRate.Value = _data.VolumeRate; diff --git a/Content.Server/Atmos/Monitor/Components/AirAlarmComponent.cs b/Content.Server/Atmos/Monitor/Components/AirAlarmComponent.cs index a4e83594f2..6bb5dcd0a7 100644 --- a/Content.Server/Atmos/Monitor/Components/AirAlarmComponent.cs +++ b/Content.Server/Atmos/Monitor/Components/AirAlarmComponent.cs @@ -47,4 +47,10 @@ public sealed partial class AirAlarmComponent : Component /// [DataField("normalPort", customTypeSerializer: typeof(PrototypeIdSerializer))] public string NormalPort = "AirNormal"; + + /// + /// Whether the panic wire is cut, forcing the alarm into panic mode. + /// + [DataField, ViewVariables] + public bool PanicWireCut; } diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs index 0ed33eaa46..8bd3608dfb 100644 --- a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs @@ -466,11 +466,17 @@ public sealed class AirAlarmSystem : EntitySystem /// Whether this change is for the UI only, or if it changes the air alarm's operating mode. Defaults to true. public void SetMode(EntityUid uid, string origin, AirAlarmMode mode, bool uiOnly = true, AirAlarmComponent? controller = null) { - if (!Resolve(uid, ref controller) || controller.CurrentMode == mode) + if (!Resolve(uid, ref controller)) { return; } + if (controller.PanicWireCut) + { + mode = AirAlarmMode.Panic; + } + + controller.CurrentMode = mode; // setting it to UI only means we don't have @@ -652,6 +658,7 @@ public sealed class AirAlarmSystem : EntitySystem } foreach (var (addr, data) in alarm.ScrubberData) { + data.AirAlarmPanicWireCut = alarm.PanicWireCut; dataToSend.Add((addr, data)); } foreach (var (addr, data) in alarm.SensorData) @@ -669,7 +676,7 @@ public sealed class AirAlarmSystem : EntitySystem _ui.SetUiState( uid, SharedAirAlarmInterfaceKey.Key, - new AirAlarmUIState(devNet.Address, deviceCount, pressure, temperature, dataToSend, alarm.CurrentMode, highestAlarm.Value, alarm.AutoMode)); + new AirAlarmUIState(devNet.Address, deviceCount, pressure, temperature, dataToSend, alarm.CurrentMode, highestAlarm.Value, alarm.AutoMode, alarm.PanicWireCut)); } private const float Delay = 8f; diff --git a/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs b/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs index c7c615455b..c0a82e575c 100644 --- a/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs +++ b/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs @@ -30,6 +30,7 @@ public sealed partial class AirAlarmPanicWire : ComponentWireAction(wire.Owner, out var devNet)) { _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false); @@ -40,6 +41,7 @@ public sealed partial class AirAlarmPanicWire : ComponentWireAction(wire.Owner, out var devNet) && alarm.CurrentMode == AirAlarmMode.Panic) { diff --git a/Content.Shared/Atmos/Monitor/Components/SharedAirAlarmComponent.cs b/Content.Shared/Atmos/Monitor/Components/SharedAirAlarmComponent.cs index ce3f00094a..3d67d18a0a 100644 --- a/Content.Shared/Atmos/Monitor/Components/SharedAirAlarmComponent.cs +++ b/Content.Shared/Atmos/Monitor/Components/SharedAirAlarmComponent.cs @@ -37,7 +37,7 @@ public interface IAtmosDeviceData [Serializable, NetSerializable] public sealed class AirAlarmUIState : BoundUserInterfaceState { - public AirAlarmUIState(string address, int deviceCount, float pressureAverage, float temperatureAverage, List<(string, IAtmosDeviceData)> deviceData, AirAlarmMode mode, AtmosAlarmType alarmType, bool autoMode) + public AirAlarmUIState(string address, int deviceCount, float pressureAverage, float temperatureAverage, List<(string, IAtmosDeviceData)> deviceData, AirAlarmMode mode, AtmosAlarmType alarmType, bool autoMode, bool panicWireCut) { Address = address; DeviceCount = deviceCount; @@ -47,6 +47,7 @@ public sealed class AirAlarmUIState : BoundUserInterfaceState Mode = mode; AlarmType = alarmType; AutoMode = autoMode; + PanicWireCut = panicWireCut; } public string Address { get; } @@ -64,6 +65,7 @@ public sealed class AirAlarmUIState : BoundUserInterfaceState public AirAlarmMode Mode { get; } public AtmosAlarmType AlarmType { get; } public bool AutoMode { get; } + public bool PanicWireCut { get; } } [Serializable, NetSerializable] diff --git a/Content.Shared/Atmos/Piping/Unary/Components/SharedVentScrubberComponent.cs b/Content.Shared/Atmos/Piping/Unary/Components/SharedVentScrubberComponent.cs index 4505c711c9..63d2e552a7 100644 --- a/Content.Shared/Atmos/Piping/Unary/Components/SharedVentScrubberComponent.cs +++ b/Content.Shared/Atmos/Piping/Unary/Components/SharedVentScrubberComponent.cs @@ -13,6 +13,7 @@ namespace Content.Shared.Atmos.Piping.Unary.Components public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing; public float VolumeRate { get; set; } = 200f; public bool WideNet { get; set; } = false; + public bool AirAlarmPanicWireCut { get; set; } public static HashSet DefaultFilterGases = new() { diff --git a/Resources/Locale/en-US/atmos/air-alarm-ui.ftl b/Resources/Locale/en-US/atmos/air-alarm-ui.ftl index 57e47cf4cf..25669997ed 100644 --- a/Resources/Locale/en-US/atmos/air-alarm-ui.ftl +++ b/Resources/Locale/en-US/atmos/air-alarm-ui.ftl @@ -13,6 +13,7 @@ air-alarm-ui-window-device-count-label = Total Devices air-alarm-ui-window-resync-devices-label = Resync air-alarm-ui-window-mode-label = Mode +air-alarm-ui-window-mode-select-locked-label = [bold][color=red] Mode selector failure! [/color][/bold] air-alarm-ui-window-auto-mode-label = Auto mode -air-alarm-state-name = { $state -> -- 2.51.2