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

@@ -1,4 +1,5 @@
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Wires;
namespace Content.Server.Wires;
@@ -17,7 +18,7 @@ public abstract class BaseWireAction : IWireAction
{
EntityManager = IoCManager.Resolve<IEntityManager>();
WiresSystem = EntitySystem.Get<WiresSystem>();
WiresSystem = EntityManager.EntitySysManager.GetEntitySystem<WiresSystem>();
}
public virtual bool AddWire(Wire wire, int count) => count == 1;
@@ -38,14 +39,8 @@ public abstract class BaseWireAction : IWireAction
/// Utility function to check if this given entity is powered.
/// </summary>
/// <returns>true if powered, false otherwise</returns>
public bool IsPowered(EntityUid uid)
protected bool IsPowered(EntityUid uid)
{
if (!EntityManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out var power)
|| power.PowerDisabled) // there's some kind of race condition here?
{
return false;
}
return power.Powered;
return WiresSystem.IsPowered(uid, EntityManager);
}
}