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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user