private float PowerFromBatteries(float joules_needed, List <Battery> batteries, IEnergyConsumer c) { int num_powered; do { float batteryJoulesAvailable = GetBatteryJoulesAvailable(batteries, out num_powered); float num = batteryJoulesAvailable * (float)num_powered; float num2 = (!(num < joules_needed)) ? joules_needed : num; joules_needed -= num2; ReportManager.Instance.ReportValue(ReportManager.ReportType.EnergyCreated, 0f - num2, c.Name, null); float joules = num2 / (float)num_powered; for (int i = batteries.Count - num_powered; i < batteries.Count; i++) { Battery battery = batteries[i]; battery.ConsumeEnergy(joules); } }while (joules_needed >= 0.01f && num_powered > 0); return(joules_needed); }
public override void ApplyDeltaJoules(float joules_delta, bool can_over_power = false) { battery.ConsumeEnergy(0f - joules_delta); base.ApplyDeltaJoules(joules_delta, can_over_power); }