From 0b5058abf58f2215d644d1ecffecdbb249f8d2da Mon Sep 17 00:00:00 2001 From: yuni Date: Sun, 22 Sep 2024 06:12:15 +0200 Subject: [PATCH] menu: display suit system power usage --- doc/gamedesign.md | 2 +- src/actor.rs | 12 +++++++----- src/menu.rs | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/doc/gamedesign.md b/doc/gamedesign.md index 96b3b7d..a63185c 100644 --- a/doc/gamedesign.md +++ b/doc/gamedesign.md @@ -115,7 +115,7 @@ A variety of relatively simple game systems should interact with each other to c - [X] Augmented Reality - [X] Flashlight intensity - [ ] AI assistance systems - - [ ] Thruster boost + - [X] Thruster boost - [ ] G-force dampeners - [ ] Life support, material recyclers (air, water, etc) - [ ] High energy particle shield? diff --git a/src/actor.rs b/src/actor.rs index 4c8e415..434e387 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -21,10 +21,12 @@ use bevy_xpbd_3d::prelude::*; pub const ENGINE_SPEED_FACTOR: f32 = 30.0; const MAX_TRANSMISSION_DISTANCE: f32 = 100.0; const MAX_INTERACT_DISTANCE: f32 = 50.0; -const POWER_DRAIN_THRUSTER: [f32; 3] = [3e6, 3e6, 0.0]; -const THRUSTER_BOOST_FACTOR: [f64; 3] = [3.0, 3.0, 0.0]; -const POWER_DRAIN_FLASHLIGHT: [f32; 3] = [200e3, 1500e3, 2500e3]; +pub const POWER_DRAIN_THRUSTER: [f32; 3] = [3e6, 3e6, 0.0]; +pub const THRUSTER_BOOST_FACTOR: [f64; 3] = [3.0, 3.0, 0.0]; +pub const POWER_DRAIN_FLASHLIGHT: [f32; 3] = [200e3, 1500e3, 2500e3]; pub const FLASHLIGHT_INTENSITY: [f32; 3] = [10e6, 400e6, 2e9]; // in lumens +pub const POWER_DRAIN_LIGHTAMP: [f32; 4] = [0.0, 200e3, 400e3, 800e3]; +pub const POWER_DRAIN_AR: f32 = 300e3; pub struct ActorPlugin; impl Plugin for ActorPlugin { @@ -295,8 +297,8 @@ pub fn update_power( } } if settings.hud_active { - let mut hud_drain = 300e3; // 300kW - hud_drain += prefs.light_amp as f32 * 200e3; // 200kW per level + 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; diff --git a/src/menu.rs b/src/menu.rs index b1b5316..2974e91 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -486,15 +486,21 @@ pub fn update_menu( } MenuAction::ToggleAR => { let onoff = bool2string(settings.hud_active); - text.sections[i].value = format!("Augmented Reality: {onoff} [TAB]\n"); + let p = if settings.hud_active { actor::POWER_DRAIN_AR / 1e3 } else { 0.0 }; + let kw = if p > 0.0 { format!(" ({p}kW)") } else { String::from("") }; + text.sections[i].value = format!("Augmented Reality: {onoff}{kw} [TAB]\n"); } MenuAction::ModLightAmp => { let n = prefs.light_amp; - text.sections[i].value = format!("Light Amplification: {n}/3\n"); + let p = actor::POWER_DRAIN_LIGHTAMP[prefs.light_amp] / 1e3; + let kw = if p > 0.0 { format!(" ({p}kW)") } else { String::from("") }; + text.sections[i].value = format!("Light Amplification: {n}/3{kw}\n"); } MenuAction::ModFlashlightPower => { let n = prefs.flashlight_power + 1; - text.sections[i].value = format!("Flashlight Power: {n}/3\n"); + let p = actor::POWER_DRAIN_FLASHLIGHT[prefs.flashlight_power] / 1e3; + let kw = if p > 0.0 { format!(" ({p}kW)") } else { String::from("") }; + text.sections[i].value = format!("Flashlight Power: {n}/3{kw}\n"); } MenuAction::ModThrusterBoost => { let state = match prefs.thruster_boost { @@ -503,7 +509,9 @@ pub fn update_menu( 2 => "Off", _ => "ERROR", }; - text.sections[i].value = format!("Thruster Boost: {state}\n"); + let p = actor::POWER_DRAIN_THRUSTER[prefs.thruster_boost] / 1e3; + let kw = if p > 0.0 { format!(" ({p}kW)") } else { String::from("") }; + text.sections[i].value = format!("Thruster Boost: {state}{kw}\n"); } MenuAction::ChangeARAvatar => { if let Some(ava) = hud::PLAYER_AR_AVATARS.get(settings.ar_avatar) {