add breakers to power batteries (#16903)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-06-07 19:43:54 +00:00
committed by GitHub
parent 5b5a3bae76
commit 6acfe53e5f
6 changed files with 70 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using Content.Server.Emp;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.Events;
using Content.Server.Power.Pow3r;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
@@ -36,6 +37,7 @@ namespace Content.Server.Power.EntitySystems
SubscribeLocalEvent<ApcComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
SubscribeLocalEvent<ApcComponent, ApcToggleMainBreakerMessage>(OnToggleMainBreaker);
SubscribeLocalEvent<ApcComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<ApcComponent, BreakerPoppedEvent>(OnBreakerPopped);
SubscribeLocalEvent<ApcComponent, EmpPulseEvent>(OnEmpPulse);
}
@@ -111,6 +113,18 @@ namespace Content.Server.Power.EntitySystems
args.Handled = true;
}
private void OnBreakerPopped(EntityUid uid, ApcComponent comp, BreakerPoppedEvent args)
{
// already disabled, do nothing
if (!comp.MainBreakerEnabled)
return;
ApcToggleBreaker(uid, comp);
// popup so its clear what happened
_popup.PopupEntity(Loc.GetString("apc-component-breaker-popped"), uid);
}
public void UpdateApcState(EntityUid uid,
ApcComponent? apc=null,
PowerNetworkBatteryComponent? battery = null)