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,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();
}
}
}