From 108efd0e559ab95ae45d5e86745d83c65c790537 Mon Sep 17 00:00:00 2001 From: yuni Date: Thu, 3 Oct 2024 05:59:50 +0200 Subject: [PATCH] unlimited energy in god mode --- src/actor.rs | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 086f9f7..5250074 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -287,48 +287,50 @@ pub fn update_power( let mut power_down = false; let d = time.delta_seconds(); for (mut battery, mut engine) in &mut q_battery { - if settings.flashlight_active { - battery.power -= POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power] * d; // 2.4MW - if battery.power <= 0.0 { - power_down = true; - settings.flashlight_active = false; - for mut flashlight_vis in &mut q_flashlight { - *flashlight_vis = Visibility::Hidden; + if !settings.god_mode { + if settings.flashlight_active { + battery.power -= POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power] * d; // 2.4MW + if battery.power <= 0.0 { + power_down = true; + settings.flashlight_active = false; + for mut flashlight_vis in &mut q_flashlight { + *flashlight_vis = Visibility::Hidden; + } } } - } - if settings.hud_active { - let mut hud_drain = POWER_DRAIN_AR; - hud_drain += POWER_DRAIN_LIGHTAMP[prefs.light_amp]; - battery.power -= hud_drain * d; - if battery.power <= 0.0 { - power_down = true; - ew_game.send(GameEvent::SetAR(Turn::Off)); - for mut flashlight_vis in &mut q_flashlight { - *flashlight_vis = Visibility::Hidden; + if settings.hud_active { + let mut hud_drain = POWER_DRAIN_AR; + hud_drain += POWER_DRAIN_LIGHTAMP[prefs.light_amp]; + battery.power -= hud_drain * d; + if battery.power <= 0.0 { + power_down = true; + ew_game.send(GameEvent::SetAR(Turn::Off)); + for mut flashlight_vis in &mut q_flashlight { + *flashlight_vis = Visibility::Hidden; + } } } - } - let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost]; - let boosting = !battery.overloaded_recovering - && prefs.thruster_boost != 2 - && (prefs.thruster_boost == 1 || engine.currently_matching_velocity); - if boosting { - if battery.power > drain * d * 100.0 { - engine.current_boost_factor = THRUSTER_BOOST_FACTOR[prefs.thruster_boost]; - if engine.currently_firing { - battery.power -= drain * d; + let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost]; + let boosting = !battery.overloaded_recovering + && prefs.thruster_boost != 2 + && (prefs.thruster_boost == 1 || engine.currently_matching_velocity); + if boosting { + if battery.power > drain * d * 100.0 { + engine.current_boost_factor = THRUSTER_BOOST_FACTOR[prefs.thruster_boost]; + if engine.currently_firing { + battery.power -= drain * d; + } + } else { + power_down = true; + battery.overloaded_recovering = true; + engine.current_boost_factor = 1.0; } } else { - power_down = true; - battery.overloaded_recovering = true; engine.current_boost_factor = 1.0; } - } else { - engine.current_boost_factor = 1.0; - } - if power_down { - ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::PowerDown)); + if power_down { + ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::PowerDown)); + } } let reactor = POWER_GAIN_REACTOR[settings.reactor_state]; battery.power = (battery.power + reactor * d).clamp(0.0, battery.capacity);