Adds a component to require an entity to be powered to receive DeviceNetwork packets. (#11390)

This commit is contained in:
Flipp Syder
2022-09-19 16:59:32 -07:00
committed by GitHub
parent 2ed3779405
commit 1c4e1ba5de
11 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
namespace Content.Server.DeviceNetwork.Components;
/// <summary>
/// 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.
/// </summary>
[RegisterComponent]
public sealed class DeviceNetworkRequiresPowerComponent : Component
{
}

View File

@@ -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<DeviceNetworkRequiresPowerComponent, BeforePacketSentEvent>(OnBeforePacketSent);
}
private void OnBeforePacketSent(EntityUid uid, DeviceNetworkRequiresPowerComponent component,
BeforePacketSentEvent args)
{
if (!this.IsPowered(uid, EntityManager))
{
args.Cancel();
}
}
}

View File

@@ -13,6 +13,7 @@
- type: DeviceNetwork
deviceNetId: AtmosDevices
receiveFrequencyId: AtmosMonitor
- type: DeviceNetworkRequiresPower
- type: InteractionOutline
- type: Damageable
damageContainer: Inorganic

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -41,6 +41,7 @@
prefix: device-address-prefix-sensor
sendBroadcastAttemptEvent: true
- type: WiredNetworkConnection
- type: DeviceNetworkRequiresPower
- type: AtmosDevice
- type: AtmosMonitor
temperatureThreshold: stationTemperature

View File

@@ -16,6 +16,7 @@
sendBroadcastAttemptEvent: true
- type: WiredNetworkConnection
- type: DeviceList
- type: DeviceNetworkRequiresPower
- type: AtmosAlarmable
syncWith:
- AirAlarm

View File

@@ -16,6 +16,7 @@
sendBroadcastAttemptEvent: true
- type: DeviceList
- type: WiredNetworkConnection
- type: DeviceNetworkRequiresPower
- type: AtmosDevice
- type: AtmosAlarmable
syncWith:

View File

@@ -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

View File

@@ -17,6 +17,7 @@
- type: ExtensionCableReceiver
- type: Eye
- type: WiredNetworkConnection
- type: DeviceNetworkRequiresPower
- type: Transform
anchored: true
- type: Wires