From 1140e1eacaa42e015c44433d89da95e3d62a0223 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 8 May 2024 01:35:28 +0200 Subject: [PATCH] move g-force gauge to speedometer --- src/hud.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index e4eb3fc..f3c84a6 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -528,6 +528,7 @@ fn setup( )); }); let mut bundle_speedometer_text = TextBundle::from_sections([ + TextSection::new("", style_speedometer.clone()), // speed relative to target TextSection::new("", style_speedometer.clone()), // speed relative to target TextSection::new("", style_speedometer.clone()), // speed relative to orbit ]).with_style(Style { @@ -622,6 +623,7 @@ fn update_dashboard( fn update_speedometer( timer: ResMut, q_camera: Query<&LinearVelocity, With>, + q_player: Query<&actor::ExperiencesGForce, With>, q_target: Query<&LinearVelocity, With>, mut q_speedometer: Query<&mut Style, (With, Without)>, mut q_speedometer2: Query<&mut Style, (With, Without)>, @@ -647,7 +649,19 @@ fn update_speedometer( speedometer2.width = Val::Vw(wid); } if let Ok(mut speed_text) = q_node_speed.get_single_mut() { - speed_text.sections[0].value = if let Ok(target_v) = q_target.get_single() { + // G forces + speed_text.sections[0].value = if let Ok(gforce) = q_player.get_single() { + if gforce.gforce > 0.0001 { + format!("{:.1}g\n", gforce.gforce) + } else { + "".to_string() + } + } else { + "".to_string() + }; + + // Velocity relative to target + speed_text.sections[1].value = if let Ok(target_v) = q_target.get_single() { let delta_v = (target_v.0 - cam_v.0).length(); if delta_v > 0.0001 { format!("Δv {}\n", nature::readable_speed(delta_v)) @@ -657,7 +671,9 @@ fn update_speedometer( } else { "".to_string() }; - speed_text.sections[1].value = if speed > 0.0001 { + + // "Absolute velocity", or velocity relative to orbit + speed_text.sections[2].value = if speed > 0.0001 { nature::readable_speed(speed) } else { "".to_string() @@ -700,7 +716,6 @@ fn update_hud( diagnostics: Res, time: Res