Revert "Make lights dim under low power" (#19708)

This commit is contained in:
metalgearsloth
2023-09-01 09:47:30 +10:00
committed by GitHub
parent 3ab346f471
commit 279674c0b3
4 changed files with 3 additions and 35 deletions

View File

@@ -4,7 +4,6 @@ using Content.Server.DeviceNetwork.Systems;
using Content.Server.Ghost; using Content.Server.Ghost;
using Content.Server.Light.Components; using Content.Server.Light.Components;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Temperature.Components; using Content.Server.Temperature.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Damage; using Content.Shared.Damage;
@@ -43,7 +42,6 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly PowerReceiverSystem _power = default!;
private static readonly TimeSpan ThunkDelay = TimeSpan.FromSeconds(2); private static readonly TimeSpan ThunkDelay = TimeSpan.FromSeconds(2);
public const string LightBulbContainer = "light_bulb"; public const string LightBulbContainer = "light_bulb";
@@ -243,14 +241,6 @@ namespace Content.Server.Light.EntitySystems
} }
#endregion #endregion
/// <summary>
/// Supply factor (0-1) as input x, returns linear light scale (0-1).
/// </summary>
private float LightCurve(float x)
{
return (float)(1/0.8*(x-0.2));
}
private void UpdateLight(EntityUid uid, private void UpdateLight(EntityUid uid,
PoweredLightComponent? light = null, PoweredLightComponent? light = null,
ApcPowerReceiverComponent? powerReceiver = null, ApcPowerReceiverComponent? powerReceiver = null,
@@ -275,10 +265,9 @@ namespace Content.Server.Light.EntitySystems
switch (lightBulb.State) switch (lightBulb.State)
{ {
case LightBulbState.Normal: case LightBulbState.Normal:
float factor = LightCurve(_power.SupplyFactor(uid, powerReceiver)); if (powerReceiver.Powered && light.On)
if (factor > 0 && light.On)
{ {
SetLight(uid, true, lightBulb.Color, light, lightBulb.LightRadius*factor, lightBulb.LightEnergy*factor, lightBulb.LightSoftness); SetLight(uid, true, lightBulb.Color, light, lightBulb.LightRadius, lightBulb.LightEnergy, lightBulb.LightSoftness);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.On, appearance); _appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.On, appearance);
var time = _gameTiming.CurTime; var time = _gameTiming.CurTime;
if (time > light.LastThunk + ThunkDelay) if (time > light.LastThunk + ThunkDelay)

View File

@@ -51,7 +51,6 @@ namespace Content.Server.Power.Components
} }
public bool? PoweredLastUpdate; public bool? PoweredLastUpdate;
public float LastPowerReceived;
[ViewVariables] [ViewVariables]
public PowerState.Load NetworkLoad { get; } = new PowerState.Load public PowerState.Load NetworkLoad { get; } = new PowerState.Load

View File

@@ -297,14 +297,13 @@ namespace Content.Server.Power.EntitySystems
while (enumerator.MoveNext(out var uid, out var apcReceiver)) while (enumerator.MoveNext(out var uid, out var apcReceiver))
{ {
var powered = apcReceiver.Powered; var powered = apcReceiver.Powered;
if (apcReceiver.LastPowerReceived == apcReceiver.NetworkLoad.ReceivingPower) if (powered == apcReceiver.PoweredLastUpdate)
continue; continue;
if (metaQuery.GetComponent(uid).EntityPaused) if (metaQuery.GetComponent(uid).EntityPaused)
continue; continue;
apcReceiver.PoweredLastUpdate = powered; apcReceiver.PoweredLastUpdate = powered;
apcReceiver.LastPowerReceived = apcReceiver.NetworkLoad.ReceivingPower;
var ev = new PowerChangedEvent(apcReceiver.Powered, apcReceiver.NetworkLoad.ReceivingPower); var ev = new PowerChangedEvent(apcReceiver.Powered, apcReceiver.NetworkLoad.ReceivingPower);
RaiseLocalEvent(apcReceiver.Owner, ref ev); RaiseLocalEvent(apcReceiver.Owner, ref ev);

View File

@@ -156,25 +156,6 @@ namespace Content.Server.Power.EntitySystems
return receiver.Powered; 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> /// <summary>
/// Turn this machine on or off. /// Turn this machine on or off.
/// Returns true if we turned it on, false if we turned it off. /// Returns true if we turned it on, false if we turned it off.