unlimited energy in god mode

This commit is contained in:
yuni 2024-10-03 05:59:50 +02:00
parent 5da66a5b15
commit 108efd0e55

View file

@ -287,48 +287,50 @@ pub fn update_power(
let mut power_down = false; let mut power_down = false;
let d = time.delta_seconds(); let d = time.delta_seconds();
for (mut battery, mut engine) in &mut q_battery { for (mut battery, mut engine) in &mut q_battery {
if settings.flashlight_active { if !settings.god_mode {
battery.power -= POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power] * d; // 2.4MW if settings.flashlight_active {
if battery.power <= 0.0 { battery.power -= POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power] * d; // 2.4MW
power_down = true; if battery.power <= 0.0 {
settings.flashlight_active = false; power_down = true;
for mut flashlight_vis in &mut q_flashlight { settings.flashlight_active = false;
*flashlight_vis = Visibility::Hidden; for mut flashlight_vis in &mut q_flashlight {
*flashlight_vis = Visibility::Hidden;
}
} }
} }
} if settings.hud_active {
if settings.hud_active { let mut hud_drain = POWER_DRAIN_AR;
let mut hud_drain = POWER_DRAIN_AR; hud_drain += POWER_DRAIN_LIGHTAMP[prefs.light_amp];
hud_drain += POWER_DRAIN_LIGHTAMP[prefs.light_amp]; battery.power -= hud_drain * d;
battery.power -= hud_drain * d; if battery.power <= 0.0 {
if battery.power <= 0.0 { power_down = true;
power_down = true; ew_game.send(GameEvent::SetAR(Turn::Off));
ew_game.send(GameEvent::SetAR(Turn::Off)); for mut flashlight_vis in &mut q_flashlight {
for mut flashlight_vis in &mut q_flashlight { *flashlight_vis = Visibility::Hidden;
*flashlight_vis = Visibility::Hidden; }
} }
} }
} let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost];
let drain = POWER_DRAIN_THRUSTER[prefs.thruster_boost]; let boosting = !battery.overloaded_recovering
let boosting = !battery.overloaded_recovering && prefs.thruster_boost != 2
&& prefs.thruster_boost != 2 && (prefs.thruster_boost == 1 || engine.currently_matching_velocity);
&& (prefs.thruster_boost == 1 || engine.currently_matching_velocity); if boosting {
if boosting { if battery.power > drain * d * 100.0 {
if battery.power > drain * d * 100.0 { engine.current_boost_factor = THRUSTER_BOOST_FACTOR[prefs.thruster_boost];
engine.current_boost_factor = THRUSTER_BOOST_FACTOR[prefs.thruster_boost]; if engine.currently_firing {
if engine.currently_firing { battery.power -= drain * d;
battery.power -= drain * d; }
} else {
power_down = true;
battery.overloaded_recovering = true;
engine.current_boost_factor = 1.0;
} }
} else { } else {
power_down = true;
battery.overloaded_recovering = true;
engine.current_boost_factor = 1.0; engine.current_boost_factor = 1.0;
} }
} else { if power_down {
engine.current_boost_factor = 1.0; 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]; let reactor = POWER_GAIN_REACTOR[settings.reactor_state];
battery.power = (battery.power + reactor * d).clamp(0.0, battery.capacity); battery.power = (battery.power + reactor * d).clamp(0.0, battery.capacity);