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

@@ -4,6 +4,7 @@ using Content.Server.Medical.Components;
using Content.Server.Mind.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Preferences.Managers;
using Content.Shared.ActionBlocker;
using Content.Shared.CharacterAppearance.Components;
@@ -57,7 +58,7 @@ namespace Content.Server.Medical
private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
{
if (!IsPowered(scannerComponent))
if (!this.IsPowered(uid, EntityManager))
return;
UpdateUserInterface(uid, scannerComponent);
@@ -164,10 +165,8 @@ namespace Content.Server.Medical
private void UpdateUserInterface(EntityUid uid, MedicalScannerComponent scannerComponent)
{
if (!IsPowered(scannerComponent))
{
if (!this.IsPowered(uid, EntityManager))
return;
}
var newState = GetUserInterfaceState(uid, scannerComponent);
scannerComponent.UserInterface?.SetState(newState);
@@ -175,7 +174,7 @@ namespace Content.Server.Medical
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
{
if (IsPowered(scannerComponent))
if (this.IsPowered(scannerComponent.Owner, EntityManager))
{
var body = scannerComponent.BodyContainer.ContainedEntity;
if (body == null)
@@ -191,15 +190,6 @@ namespace Content.Server.Medical
return MedicalScannerStatus.Off;
}
public bool IsPowered(MedicalScannerComponent scannerComponent)
{
if (TryComp<ApcPowerReceiverComponent>(scannerComponent.Owner, out var receiver))
{
return receiver.Powered;
}
return false;
}
public bool IsOccupied(MedicalScannerComponent scannerComponent)
{
return scannerComponent.BodyContainer.ContainedEntity != null;