diff --git a/Content.Server/DeviceNetwork/Components/DeviceNetworkRequiresPowerComponent.cs b/Content.Server/DeviceNetwork/Components/DeviceNetworkRequiresPowerComponent.cs new file mode 100644 index 0000000000..72d946d313 --- /dev/null +++ b/Content.Server/DeviceNetwork/Components/DeviceNetworkRequiresPowerComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Server.DeviceNetwork.Components; + +/// +/// Component that indicates that this device networked entity requires power +/// in order to receive a packet. Having this component will cancel all packet events +/// if the entity is not powered. +/// +[RegisterComponent] +public sealed class DeviceNetworkRequiresPowerComponent : Component +{ +} diff --git a/Content.Server/DeviceNetwork/Systems/DeviceNetworkRequiresPowerSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceNetworkRequiresPowerSystem.cs new file mode 100644 index 0000000000..6e7bd255c5 --- /dev/null +++ b/Content.Server/DeviceNetwork/Systems/DeviceNetworkRequiresPowerSystem.cs @@ -0,0 +1,22 @@ +using Content.Server.DeviceNetwork.Components; +using Content.Server.Power.Components; +using Content.Server.Power.EntitySystems; + +namespace Content.Server.DeviceNetwork.Systems; + +public sealed class DeviceNetworkRequiresPowerSystem : EntitySystem +{ + public override void Initialize() + { + SubscribeLocalEvent(OnBeforePacketSent); + } + + private void OnBeforePacketSent(EntityUid uid, DeviceNetworkRequiresPowerComponent component, + BeforePacketSentEvent args) + { + if (!this.IsPowered(uid, EntityManager)) + { + args.Cancel(); + } + } +} diff --git a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml index 1b7f75cefe..9cb27f1afa 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml @@ -13,6 +13,7 @@ - type: DeviceNetwork deviceNetId: AtmosDevices receiveFrequencyId: AtmosMonitor + - type: DeviceNetworkRequiresPower - type: InteractionOutline - type: Damageable damageContainer: Inorganic diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index 27bf9bdeff..759990cdc6 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -640,6 +640,7 @@ receiveFrequencyId: SurveillanceCamera transmitFrequencyId: SurveillanceCamera - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: SurveillanceCameraMonitor - type: ActivatableUI key: enum.SurveillanceCameraMonitorUiKey.Key @@ -670,6 +671,7 @@ transmitFrequencyId: SurveillanceCamera - type: WirelessNetworkConnection range: 200 + - type: DeviceNetworkRequiresPower - type: SurveillanceCameraMonitor - type: ActivatableUI key: enum.SurveillanceCameraMonitorUiKey.Key diff --git a/Resources/Prototypes/Entities/Structures/Machines/surveillance_camera_routers.yml b/Resources/Prototypes/Entities/Structures/Machines/surveillance_camera_routers.yml index a02e455e1d..1eeaec9b7c 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/surveillance_camera_routers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/surveillance_camera_routers.yml @@ -10,6 +10,7 @@ receiveFrequencyId: SurveillanceCamera transmitFrequencyId: SurveillanceCamera - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: UserInterface interfaces: - key: enum.SurveillanceCameraSetupUiKey.Router @@ -114,6 +115,7 @@ transmitFrequencyId: SurveillanceCamera - type: WirelessNetworkConnection range: 200 + - type: DeviceNetworkRequiresPower - type: UserInterface interfaces: - key: enum.SurveillanceCameraSetupUiKey.Router diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml index 82e248394a..dc2e713b2c 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml @@ -36,6 +36,7 @@ prefix: device-address-prefix-vent sendBroadcastAttemptEvent: true - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: AtmosDevice - type: AtmosMonitor temperatureThreshold: stationTemperature @@ -126,6 +127,7 @@ receiveFrequencyId: AtmosMonitor transmitFrequencyId: AtmosMonitor prefix: device-address-prefix-scrubber + - type: DeviceNetworkRequiresPower - type: AtmosMonitor temperatureThreshold: stationTemperature pressureThreshold: stationPressure diff --git a/Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml b/Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml index 6ac3a23db9..19aaa24c2a 100644 --- a/Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml +++ b/Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml @@ -41,6 +41,7 @@ prefix: device-address-prefix-sensor sendBroadcastAttemptEvent: true - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: AtmosDevice - type: AtmosMonitor temperatureThreshold: stationTemperature diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml index 37cc86d55c..9704f1f513 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/air_alarm.yml @@ -16,6 +16,7 @@ sendBroadcastAttemptEvent: true - type: WiredNetworkConnection - type: DeviceList + - type: DeviceNetworkRequiresPower - type: AtmosAlarmable syncWith: - AirAlarm diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml index 186315aa02..6970d983e8 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/fire_alarm.yml @@ -16,6 +16,7 @@ sendBroadcastAttemptEvent: true - type: DeviceList - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: AtmosDevice - type: AtmosAlarmable syncWith: diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/monitors_televisions.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/monitors_televisions.yml index 54e1f8f6d1..d100ab7420 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/monitors_televisions.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/monitors_televisions.yml @@ -82,6 +82,7 @@ receiveFrequencyId: SurveillanceCamera transmitFrequencyId: SurveillanceCamera - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: SurveillanceCameraMonitor - type: ActivatableUI key: enum.SurveillanceCameraMonitorUiKey.Key @@ -157,6 +158,7 @@ transmitFrequencyId: SurveillanceCamera - type: WirelessNetworkConnection range: 200 + - type: DeviceNetworkRequiresPower - type: SurveillanceCameraMonitor - type: ActivatableUI key: enum.SurveillanceCameraMonitorUiKey.Key diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/surveillance_camera.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/surveillance_camera.yml index 373504bf4d..e57c7770de 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/surveillance_camera.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/surveillance_camera.yml @@ -17,6 +17,7 @@ - type: ExtensionCableReceiver - type: Eye - type: WiredNetworkConnection + - type: DeviceNetworkRequiresPower - type: Transform anchored: true - type: Wires