diff --git a/Content.Server/Atmos/Monitor/Components/AtmosAlarmableComponent.cs b/Content.Server/Atmos/Monitor/Components/AtmosAlarmableComponent.cs index a28a06e279..4d4b5e0d9c 100644 --- a/Content.Server/Atmos/Monitor/Components/AtmosAlarmableComponent.cs +++ b/Content.Server/Atmos/Monitor/Components/AtmosAlarmableComponent.cs @@ -31,7 +31,7 @@ public sealed class AtmosAlarmableComponent : Component [ViewVariables] public readonly Dictionary NetworkAlarmStates = new(); - [ViewVariables] public AtmosAlarmType LastAlarmState = AtmosAlarmType.Normal; + [ViewVariables] public AtmosAlarmType LastAlarmState = AtmosAlarmType.Invalid; [ViewVariables] public bool IgnoreAlarms { get; set; } = false; diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs index 47129d70db..ec3da21305 100644 --- a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs @@ -178,19 +178,17 @@ public sealed class AirAlarmSystem : EntitySystem private void OnPowerChanged(EntityUid uid, AirAlarmComponent component, PowerChangedEvent args) { - if (!args.Powered) + if (args.Powered) { - ForceCloseAllInterfaces(uid); - component.CurrentModeUpdater = null; - component.KnownDevices.Clear(); - component.ScrubberData.Clear(); - component.SensorData.Clear(); - component.VentData.Clear(); - } - else - { - SyncAllDevices(uid); + return; } + + ForceCloseAllInterfaces(uid); + component.CurrentModeUpdater = null; + component.KnownDevices.Clear(); + component.ScrubberData.Clear(); + component.SensorData.Clear(); + component.VentData.Clear(); } private void OnClose(EntityUid uid, AirAlarmComponent component, BoundUIClosedEvent args) diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs b/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs index 02e80ed859..b096b4215d 100644 --- a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs @@ -18,6 +18,7 @@ public sealed class AtmosAlarmableSystem : EntitySystem [Dependency] private readonly AppearanceSystem _appearance = default!; [Dependency] private readonly AudioSystem _audioSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNet = default!; + [Dependency] private readonly AtmosDeviceNetworkSystem _atmosDevNetSystem = default!; /// /// An alarm. Has three valid states: Normal, Warning, Danger. @@ -41,12 +42,12 @@ public sealed class AtmosAlarmableSystem : EntitySystem public override void Initialize() { - SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnPacketRecv); SubscribeLocalEvent(OnPowerChange); } - private void OnInit(EntityUid uid, AtmosAlarmableComponent component, ComponentInit args) + private void OnMapInit(EntityUid uid, AtmosAlarmableComponent component, MapInitEvent args) { TryUpdateAlert( uid, @@ -63,6 +64,10 @@ public sealed class AtmosAlarmableSystem : EntitySystem } else { + // sussy + _atmosDevNetSystem.Register(uid, null); + _atmosDevNetSystem.Sync(uid, null); + TryUpdateAlert( uid, TryGetHighestAlert(uid, out var alarm) ? alarm.Value : AtmosAlarmType.Normal, diff --git a/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs index 5a2ef52974..5d3c355712 100644 --- a/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs @@ -258,6 +258,11 @@ namespace Content.Server.DeviceNetwork.Systems private void SendToConnections(ReadOnlySpan connections, DeviceNetworkPacketEvent packet) { + if (Deleted(packet.Sender)) + { + return; + } + var xform = Transform(packet.Sender); BeforePacketSentEvent beforeEv = new(packet.Sender, xform, _transformSystem.GetWorldPosition(xform)); diff --git a/Content.Shared/Atmos/Monitor/AtmosAlarmType.cs b/Content.Shared/Atmos/Monitor/AtmosAlarmType.cs index c51106f8d2..40f211ae48 100644 --- a/Content.Shared/Atmos/Monitor/AtmosAlarmType.cs +++ b/Content.Shared/Atmos/Monitor/AtmosAlarmType.cs @@ -5,8 +5,9 @@ namespace Content.Shared.Atmos.Monitor; [Serializable, NetSerializable] public enum AtmosAlarmType : sbyte { - Normal = 0, - Warning = 1, - Danger = 2, // 1 << 1 is the exact same thing and we're not really doing **bitmasking** are we? - Emagged = 3, + Invalid = 0, + Normal = 1, + Warning = 2, + Danger = 3, + Emagged = 4, } diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml index 5789d05db2..37cc86d55c 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml @@ -81,6 +81,8 @@ - type: Construction graph: AirAlarm node: assembly + - type: Transform + anchored: true placement: mode: SnapgridCenter snap: diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml index 57c67a409c..186315aa02 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml @@ -91,6 +91,8 @@ - type: Construction graph: FireAlarm node: assembly + - type: Transform + anchored: true placement: mode: SnapgridCenter snap: