implement power, WIP suit systems (defunct)

This commit is contained in:
yuni 2024-03-17 22:28:10 +01:00
parent 41d97942de
commit cef6e5cce7
3 changed files with 74 additions and 7 deletions

View file

@ -26,7 +26,7 @@ fn setup(
settings: Res<settings::Settings>, settings: Res<settings::Settings>,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
) { ) {
let visibility = if settings.ar_active { let visibility = if settings.hud_active {
Visibility::Inherited Visibility::Inherited
} else { } else {
Visibility::Hidden Visibility::Hidden
@ -51,7 +51,25 @@ fn setup(
} }
), ),
TextSection::new( TextSection::new(
"\n OXYGEN ", "\n 电量 ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
"\n 氧 OXYGEN ",
TextStyle { TextStyle {
font: asset_server.load(FONT), font: asset_server.load(FONT),
font_size: settings.font_size_hud, font_size: settings.font_size_hud,
@ -109,10 +127,12 @@ fn update(
text.sections[1].value = format!("{value:.0}"); text.sections[1].value = format!("{value:.0}");
} }
} }
let power = playervars.power;
text.sections[3].value = format!("{power:}Wh");
let oxygen = playervars.oxygen * 100.0; let oxygen = playervars.oxygen * 100.0;
text.sections[3].value = format!("{oxygen:.1}%"); text.sections[5].value = format!("{oxygen:.1}%");
let adrenaline = playervars.adrenaline * 990.0 + 10.0; let adrenaline = playervars.adrenaline * 990.0 + 10.0;
text.sections[5].value = format!("{adrenaline:.0}pg/mL"); text.sections[7].value = format!("{adrenaline:.0}pg/mL");
} }
} }
} }

View file

@ -1,3 +1,4 @@
use crate::settings;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::window::PrimaryWindow; use bevy::window::PrimaryWindow;
@ -18,11 +19,39 @@ impl Default for Player {
} }
} }
pub enum SuitSystemHandler {
Heat,
None,
}
#[derive(Component)]
pub struct PlayerEntity;
#[derive(Component)]
pub struct SuitSystem {
pub name: String,
pub active: bool,
pub power: f32,
pub handler: SuitSystemHandler,
}
impl Default for SuitSystem {
fn default() -> Self {
Self {
name: "Untitled".to_string(),
active: true,
power: 0.0,
handler: SuitSystemHandler::None,
}
}
}
#[derive(Resource)] #[derive(Resource)]
pub struct PlayerVars { pub struct PlayerVars {
pub oxygen: f32, pub oxygen: f32,
pub adrenaline: f32, pub adrenaline: f32,
pub adrenaline_jolt: f32, pub adrenaline_jolt: f32,
pub power: f32,
} }
impl Default for PlayerVars { impl Default for PlayerVars {
@ -31,12 +60,30 @@ impl Default for PlayerVars {
oxygen: 0.1984, oxygen: 0.1984,
adrenaline: 0.1, adrenaline: 0.1,
adrenaline_jolt: 0.5, adrenaline_jolt: 0.5,
power: 6200.0,
} }
} }
} }
pub fn setup(mut commands: Commands) { pub fn setup(
mut commands: Commands,
settings: Res<settings::Settings>,
) {
commands.spawn(Player::default()); commands.spawn(Player::default());
commands.spawn((
PlayerEntity,
SuitSystem {
name: "HUD".to_string(),
active: settings.hud_active,
power: -0.05,
..default()
},
SuitSystem {
name: "Heater".to_string(),
handler: SuitSystemHandler::Heat,
..default()
}
));
} }
pub fn handle_input( pub fn handle_input(

View file

@ -9,7 +9,7 @@ pub struct Settings {
pub font_size_hud: f32, pub font_size_hud: f32,
pub font_size_conversations: f32, pub font_size_conversations: f32,
pub key_togglehud: KeyCode, pub key_togglehud: KeyCode,
pub ar_active: bool, pub hud_active: bool,
} }
impl Default for Settings { impl Default for Settings {
@ -22,7 +22,7 @@ impl Default for Settings {
font_size_hud: 32.0, font_size_hud: 32.0,
font_size_conversations: 32.0, font_size_conversations: 32.0,
key_togglehud: KeyCode::Tab, key_togglehud: KeyCode::Tab,
ar_active: true, hud_active: true,
} }
} }
} }