Make lights dim under low power (#19317)
* Make lights dim under low power * Slightly more dramatic curve
This commit is contained in:
@@ -156,6 +156,25 @@ namespace Content.Server.Power.EntitySystems
|
||||
return receiver.Powered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the fraction of the load power that is actually supplied to this receiver, e.g. 1
|
||||
/// if full power and 0 if no power. Better at handling brownouts compared to IsPowered().
|
||||
/// Handles always-powered devices correctly.
|
||||
/// </summary>
|
||||
public float SupplyFactor(EntityUid uid, ApcPowerReceiverComponent? receiver = null)
|
||||
{
|
||||
if (!Resolve(uid, ref receiver, false))
|
||||
return 1f;
|
||||
|
||||
if (receiver.PowerDisabled)
|
||||
return 0f;
|
||||
|
||||
if (!receiver.NeedsPower)
|
||||
return 1f;
|
||||
|
||||
return receiver.NetworkLoad.ReceivingPower / receiver.Load;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turn this machine on or off.
|
||||
/// Returns true if we turned it on, false if we turned it off.
|
||||
|
||||
Reference in New Issue
Block a user