diff --git a/src/hud.rs b/src/hud.rs index 0ec0901..1263c66 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -97,7 +97,7 @@ enum Gauge { Health, Power, Oxygen, - Fuel, + Integrity, } #[derive(Resource)] @@ -345,13 +345,13 @@ fn setup( )); }); - // HP/O2/Fuel/Power Gauges + // HP/O2/Suit Integrity/Power Gauges let gauges_handle: Handle = asset_server.load("sprites/gauge_horizontal.png"); let gauges = [ ("sprites/dashboard_highbeams.png", Gauge::Health), ("sprites/dashboard_highbeams.png", Gauge::Power), ("sprites/dashboard_highbeams.png", Gauge::Oxygen), - ("sprites/dashboard_highbeams.png", Gauge::Fuel), + ("sprites/dashboard_highbeams.png", Gauge::Integrity), ]; for (i, (sprite, gauge)) in gauges.iter().enumerate() { let bar_length = if i == 0 { 196.0 } else { 128.0 }; @@ -666,15 +666,20 @@ fn update_speedometer( } fn update_gauges( + q_player: Query<(&actor::HitPoints, &actor::Suit), With>, mut q_gauges: Query<(&mut Style, &mut BackgroundColor, &Gauge, &GaugeLength)>, settings: Res, ) { + let player = q_player.get_single(); + if player.is_err() { return; } + let (hp, suit) = player.unwrap(); + for (mut style, mut bg, gauge, len) in &mut q_gauges { - let value = match gauge { - Gauge::Health => 0.9, - Gauge::Oxygen => 0.1, - Gauge::Fuel => 0.3, - Gauge::Power => 1.0, + let value: f32 = match gauge { + Gauge::Health => hp.current / hp.max, + Gauge::Oxygen => suit.oxygen / suit.oxygen_max, + Gauge::Integrity => suit.integrity, + Gauge::Power => suit.power / suit.power_max, }; if value < 0.5 { *bg = settings.hud_color_alert.into();