Add static "IsPowered" method (#8434)

* Add static "IsPowered" method

* Use IsPowered in more places

Co-authored-by: wrexbe <wrexbe@protonmail.com>
This commit is contained in:
metalgearsloth
2022-05-27 10:36:12 +10:00
committed by GitHub
parent 33c03fa0a0
commit 2d873a2cf2
20 changed files with 104 additions and 141 deletions

View File

@@ -21,13 +21,11 @@ namespace Content.Server.Power.EntitySystems
private void OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
{
if (args.Cancelled) return;
if (EntityManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
{
if (TryComp<WiresComponent>(uid, out var wires) && wires.IsPanelOpen)
return;
args.User.PopupMessageCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)));
args.Cancel();
}
if (this.IsPowered(uid, EntityManager)) return;
if (TryComp<WiresComponent>(uid, out var wires) && wires.IsPanelOpen)
return;
args.User.PopupMessageCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)));
args.Cancel();
}
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, PowerChangedEvent args)