Event for PowerNetBattery CurrentSupply changing (#4570)

I re-used AmbientOnPowered but maybe that was lazy; I was doubtful anything would ever have ApcPowerReceiver and PowerNetBatteryComponent.
This commit is contained in:
metalgearsloth
2021-09-30 10:09:16 +10:00
committed by GitHub
parent accb83b344
commit 8365e8d52c
3 changed files with 50 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -10,6 +11,15 @@ namespace Content.Server.Audio
{
base.Initialize();
SubscribeLocalEvent<AmbientOnPoweredComponent, PowerChangedEvent>(HandlePowerChange);
SubscribeLocalEvent<AmbientOnPoweredComponent, PowerNetBatterySupplyEvent>(HandlePowerSupply);
}
private void HandlePowerSupply(EntityUid uid, AmbientOnPoweredComponent component, PowerNetBatterySupplyEvent args)
{
if (!ComponentManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambientSound)) return;
if (ambientSound.Enabled == args.Supply) return;
ambientSound.Enabled = args.Supply;
ambientSound.Dirty();
}
private void HandlePowerChange(EntityUid uid, AmbientOnPoweredComponent component, PowerChangedEvent args)