From c7fb4eef3fa98a9316b108cf34f453d6bbbc691b Mon Sep 17 00:00:00 2001 From: yuni Date: Fri, 29 Nov 2024 18:16:16 +0100 Subject: [PATCH] fix thruster boost in god mode --- src/actor.rs | 78 +++++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 22b859a..db25b7f 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -339,49 +339,57 @@ pub fn update_power( let d = time.delta_seconds(); let inside_vehicle = !q_bike.is_empty(); for (mut battery, mut engine) in &mut q_battery { - if !inside_vehicle && !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; - } - } - } - let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost]; + if !inside_vehicle { 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 { + if settings.god_mode { + if boosting { 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 { - engine.current_boost_factor = 1.0; - } - if power_down { - ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::PowerDown)); + 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; + } + } + } + let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost]; + 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 { + engine.current_boost_factor = 1.0; + } + if power_down { + ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::PowerDown)); + } } } let reactor = POWER_GAIN_REACTOR[settings.reactor_state];