move g-force gauge to speedometer
This commit is contained in:
parent
4b9ed44dd4
commit
1140e1eaca
37
src/hud.rs
37
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<FPSUpdateTimer>,
|
||||
q_camera: Query<&LinearVelocity, With<actor::PlayerCamera>>,
|
||||
q_player: Query<&actor::ExperiencesGForce, With<actor::Player>>,
|
||||
q_target: Query<&LinearVelocity, With<IsTargeted>>,
|
||||
mut q_speedometer: Query<&mut Style, (With<Speedometer>, Without<Speedometer2>)>,
|
||||
mut q_speedometer2: Query<&mut Style, (With<Speedometer2>, Without<Speedometer>)>,
|
||||
|
@ -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<DiagnosticsStore>,
|
||||
time: Res<Time>,
|
||||
mut log: ResMut<Log>,
|
||||
player: Query<(&actor::HitPoints, &actor::Suit, &actor::ExperiencesGForce), With<actor::Player>>,
|
||||
q_camera: Query<(&Position, &LinearVelocity), With<actor::PlayerCamera>>,
|
||||
mut timer: ResMut<FPSUpdateTimer>,
|
||||
q_choices: Query<&chat::Choice>,
|
||||
|
@ -715,10 +730,8 @@ fn update_hud(
|
|||
// TODO only when hud is actually on
|
||||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||
let q_camera_result = q_camera.get_single();
|
||||
let player = player.get_single();
|
||||
let mut freshest_line: f64 = 0.0;
|
||||
if player.is_ok() && q_camera_result.is_ok() {
|
||||
let (_, _, gforce) = player.unwrap();
|
||||
if q_camera_result.is_ok() {
|
||||
let (pos, _) = q_camera_result.unwrap();
|
||||
for mut text in &mut q_node_hud {
|
||||
text.sections[0].value = format!("2524-03-12 03:02");
|
||||
|
@ -761,18 +774,6 @@ fn update_hud(
|
|||
}
|
||||
}
|
||||
|
||||
// let dev_speed = if settings.dev_mode {
|
||||
// let x = pos.x;
|
||||
// let y = pos.y;
|
||||
// let z = pos.z;
|
||||
// format!("\n{x:.0}\n{y:.0}\n{z:.0}")
|
||||
// } else {
|
||||
// "".to_string()
|
||||
// };
|
||||
let dev_speed = "";
|
||||
let gforce = gforce.gforce;
|
||||
text.sections[3].value = format!("\n{gforce:.1}g{dev_speed}");
|
||||
|
||||
if target_multiple {
|
||||
text.sections[4].value = "\n\nERROR: MULTIPLE TARGETS".to_string();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue