This commit is contained in:
Rane
2022-02-17 21:43:24 -05:00
committed by GitHub
parent 94c56980cb
commit 8049a709e6
29 changed files with 323 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ using Content.Server.Power.Pow3r;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.APC;
using Content.Shared.Emag.Systems;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -34,6 +35,7 @@ namespace Content.Server.Power.EntitySystems
SubscribeLocalEvent<ApcComponent, MapInitEvent>(OnApcInit);
SubscribeLocalEvent<ApcComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
SubscribeLocalEvent<ApcComponent, ApcToggleMainBreakerMessage>(OnToggleMainBreaker);
SubscribeLocalEvent<ApcComponent, GotEmaggedEvent>(OnEmagged);
}
// Change the APC's state only when the battery state changes, or when it's first created.
@@ -68,6 +70,15 @@ namespace Content.Server.Power.EntitySystems
}
}
private void OnEmagged(EntityUid uid, ApcComponent comp, GotEmaggedEvent args)
{
if(!comp.Emagged)
{
comp.Emagged = true;
args.Handled = true;
}
}
public void UpdateApcState(EntityUid uid,
ApcComponent? apc=null,
BatteryComponent? battery=null)
@@ -115,6 +126,9 @@ namespace Content.Server.Power.EntitySystems
ApcComponent? apc=null,
BatteryComponent? battery=null)
{
if (apc != null && apc.Emagged)
return ApcChargeState.Emag;
if (!Resolve(uid, ref apc, ref battery))
return ApcChargeState.Lack;