Stop BatterySystem from iterating over every battery just to recharge micro-reactors (#5393)

This commit is contained in:
20kdc
2021-11-18 19:02:17 +00:00
committed by GitHub
parent f8b6cfca6c
commit 856e570c7b
5 changed files with 30 additions and 15 deletions

View File

@@ -34,10 +34,6 @@ namespace Content.Server.Power.Components
/// </summary>
[ViewVariables] public bool IsFullyCharged => MathHelper.CloseToPercent(CurrentCharge, MaxCharge);
[ViewVariables(VVAccess.ReadWrite)] [DataField("autoRecharge")] public bool AutoRecharge { get; set; }
[ViewVariables(VVAccess.ReadWrite)] [DataField("autoRechargeRate")] public float AutoRechargeRate { get; set; }
/// <summary>
/// If sufficient charge is avaiable on the battery, use it. Otherwise, don't.
/// </summary>
@@ -89,12 +85,5 @@ namespace Content.Server.Power.Components
_currentCharge = MathHelper.Clamp(newChargeAmount, 0, MaxCharge);
OnChargeChanged();
}
public void OnUpdate(float frameTime)
{
if (!AutoRecharge) return;
if (IsFullyCharged) return;
CurrentCharge += AutoRechargeRate * frameTime;
}
}
}