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>
This commit is contained in:
qwerltaz
2025-05-14 22:39:47 +02:00
committed by GitHub
parent 7eb44e15d1
commit b374d2468a
9 changed files with 33 additions and 4 deletions

View File

@@ -74,7 +74,13 @@
<!-- Mode buttons --> <!-- Mode buttons -->
<BoxContainer Orientation="Horizontal"> <BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'air-alarm-ui-window-mode-label'}" Margin="0 0 2 0" /> <Label Text="{Loc 'air-alarm-ui-window-mode-label'}" Margin="0 0 2 0" />
<OptionButton Name="CModeButton" HorizontalExpand="True" /> <Control HorizontalExpand="True">
<OptionButton Name="CModeButton" />
<ui:StripeBack Name="CModeSelectLocked">
<RichTextLabel Text="{Loc 'air-alarm-ui-window-mode-select-locked-label'}"
HorizontalAlignment="Center" />
</ui:StripeBack>
</Control>
<CheckBox Name="AutoModeCheckBox" Text="{Loc 'air-alarm-ui-window-auto-mode-label'}" /> <CheckBox Name="AutoModeCheckBox" Text="{Loc 'air-alarm-ui-window-auto-mode-label'}" />
</BoxContainer> </BoxContainer>
</BoxContainer> </BoxContainer>

View File

@@ -110,6 +110,8 @@ public sealed partial class AirAlarmWindow : FancyWindow
{ {
UpdateDeviceData(addr, dev); UpdateDeviceData(addr, dev);
} }
_modes.Visible = !state.PanicWireCut;
CModeSelectLocked.Visible = state.PanicWireCut;
} }
public void UpdateModeSelector(AirAlarmMode mode) public void UpdateModeSelector(AirAlarmMode mode)

View File

@@ -71,6 +71,7 @@ public sealed partial class ScrubberControl : BoxContainer
_data.PumpDirection = (ScrubberPumpDirection) args.Id; _data.PumpDirection = (ScrubberPumpDirection) args.Id;
ScrubberDataChanged?.Invoke(_address, _data); ScrubberDataChanged?.Invoke(_address, _data);
}; };
_pumpDirection.Disabled = data.AirAlarmPanicWireCut;
_copySettings.OnPressed += _ => _copySettings.OnPressed += _ =>
{ {
@@ -109,6 +110,7 @@ public sealed partial class ScrubberControl : BoxContainer
_data.PumpDirection = data.PumpDirection; _data.PumpDirection = data.PumpDirection;
_pumpDirection.Select((int) _data.PumpDirection); _pumpDirection.Select((int) _data.PumpDirection);
_pumpDirection.Disabled = data.AirAlarmPanicWireCut;
_data.VolumeRate = data.VolumeRate; _data.VolumeRate = data.VolumeRate;
_volumeRate.Value = _data.VolumeRate; _volumeRate.Value = _data.VolumeRate;

View File

@@ -47,4 +47,10 @@ public sealed partial class AirAlarmComponent : Component
/// </summary> /// </summary>
[DataField("normalPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))] [DataField("normalPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
public string NormalPort = "AirNormal"; public string NormalPort = "AirNormal";
/// <summary>
/// Whether the panic wire is cut, forcing the alarm into panic mode.
/// </summary>
[DataField, ViewVariables]
public bool PanicWireCut;
} }

View File

@@ -466,11 +466,17 @@ public sealed class AirAlarmSystem : EntitySystem
/// <param name="uiOnly">Whether this change is for the UI only, or if it changes the air alarm's operating mode. Defaults to true.</param> /// <param name="uiOnly">Whether this change is for the UI only, or if it changes the air alarm's operating mode. Defaults to true.</param>
public void SetMode(EntityUid uid, string origin, AirAlarmMode mode, bool uiOnly = true, AirAlarmComponent? controller = null) 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; return;
} }
if (controller.PanicWireCut)
{
mode = AirAlarmMode.Panic;
}
controller.CurrentMode = mode; controller.CurrentMode = mode;
// setting it to UI only means we don't have // 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) foreach (var (addr, data) in alarm.ScrubberData)
{ {
data.AirAlarmPanicWireCut = alarm.PanicWireCut;
dataToSend.Add((addr, data)); dataToSend.Add((addr, data));
} }
foreach (var (addr, data) in alarm.SensorData) foreach (var (addr, data) in alarm.SensorData)
@@ -669,7 +676,7 @@ public sealed class AirAlarmSystem : EntitySystem
_ui.SetUiState( _ui.SetUiState(
uid, uid,
SharedAirAlarmInterfaceKey.Key, 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; private const float Delay = 8f;

View File

@@ -30,6 +30,7 @@ public sealed partial class AirAlarmPanicWire : ComponentWireAction<AirAlarmComp
public override bool Cut(EntityUid user, Wire wire, AirAlarmComponent comp) public override bool Cut(EntityUid user, Wire wire, AirAlarmComponent comp)
{ {
comp.PanicWireCut = true;
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)) if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
{ {
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false); _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
@@ -40,6 +41,7 @@ public sealed partial class AirAlarmPanicWire : ComponentWireAction<AirAlarmComp
public override bool Mend(EntityUid user, Wire wire, AirAlarmComponent alarm) public override bool Mend(EntityUid user, Wire wire, AirAlarmComponent alarm)
{ {
alarm.PanicWireCut = false;
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet) if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)
&& alarm.CurrentMode == AirAlarmMode.Panic) && alarm.CurrentMode == AirAlarmMode.Panic)
{ {

View File

@@ -37,7 +37,7 @@ public interface IAtmosDeviceData
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class AirAlarmUIState : BoundUserInterfaceState 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; Address = address;
DeviceCount = deviceCount; DeviceCount = deviceCount;
@@ -47,6 +47,7 @@ public sealed class AirAlarmUIState : BoundUserInterfaceState
Mode = mode; Mode = mode;
AlarmType = alarmType; AlarmType = alarmType;
AutoMode = autoMode; AutoMode = autoMode;
PanicWireCut = panicWireCut;
} }
public string Address { get; } public string Address { get; }
@@ -64,6 +65,7 @@ public sealed class AirAlarmUIState : BoundUserInterfaceState
public AirAlarmMode Mode { get; } public AirAlarmMode Mode { get; }
public AtmosAlarmType AlarmType { get; } public AtmosAlarmType AlarmType { get; }
public bool AutoMode { get; } public bool AutoMode { get; }
public bool PanicWireCut { get; }
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -13,6 +13,7 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing; public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing;
public float VolumeRate { get; set; } = 200f; public float VolumeRate { get; set; } = 200f;
public bool WideNet { get; set; } = false; public bool WideNet { get; set; } = false;
public bool AirAlarmPanicWireCut { get; set; }
public static HashSet<Gas> DefaultFilterGases = new() public static HashSet<Gas> DefaultFilterGases = new()
{ {

View File

@@ -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-resync-devices-label = Resync
air-alarm-ui-window-mode-label = Mode 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-ui-window-auto-mode-label = Auto mode
-air-alarm-state-name = { $state -> -air-alarm-state-name = { $state ->