menu: display suit system power usage

This commit is contained in:
yuni 2024-09-22 06:12:15 +02:00
parent ae3e9c9b48
commit 0b5058abf5
3 changed files with 20 additions and 10 deletions

View file

@ -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?

View file

@ -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;

View file

@ -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) {