Enhanced APC UI + New NT logo to footer (#14258)

This commit is contained in:
James Simonson
2023-03-07 09:55:35 +08:00
committed by GitHub
parent 04e2f3aa15
commit 3bcd319ae4
12 changed files with 124 additions and 44 deletions

View File

@@ -37,6 +37,7 @@ namespace Content.Server.Power.EntitySystems
UpdatesAfter.Add(typeof(PowerNetSystem));
SubscribeLocalEvent<ApcComponent, BoundUIOpenedEvent>(OnBoundUiOpen);
SubscribeLocalEvent<ApcComponent, MapInitEvent>(OnApcInit);
SubscribeLocalEvent<ApcComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
SubscribeLocalEvent<ApcComponent, ApcToggleMainBreakerMessage>(OnToggleMainBreaker);
@@ -59,6 +60,22 @@ namespace Content.Server.Power.EntitySystems
{
UpdateApcState(uid, component);
}
//Update the HasAccess var for UI to read
private void OnBoundUiOpen(EntityUid uid, ApcComponent component, BoundUIOpenedEvent args)
{
TryComp<AccessReaderComponent>(uid, out var access);
if (args.Session.AttachedEntity == null)
return;
if (access == null || _accessReader.IsAllowed(args.Session.AttachedEntity.Value, access))
{
component.HasAccess = true;
}
else
{
component.HasAccess = false;
}
}
private void OnToggleMainBreaker(EntityUid uid, ApcComponent component, ApcToggleMainBreakerMessage args)
{
TryComp<AccessReaderComponent>(uid, out var access);
@@ -141,7 +158,7 @@ namespace Content.Server.Power.EntitySystems
if (_userInterfaceSystem.GetUiOrNull(uid, ApcUiKey.Key, ui) is { } bui)
{
bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, (int)MathF.Ceiling(power), apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, apc.HasAccess, (int)MathF.Ceiling(power), apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
}
}