delta v actually displays the relative velocity now
This commit is contained in:
parent
48e54265f9
commit
ac9ee34e1f
20
src/hud.rs
20
src/hud.rs
|
@ -401,7 +401,7 @@ fn update_hud(
|
||||||
mut query_chat: Query<&mut Text, (With<ChatText>, Without<GaugesText>)>,
|
mut query_chat: Query<&mut Text, (With<ChatText>, Without<GaugesText>)>,
|
||||||
query_all_actors: Query<&actor::Actor>,
|
query_all_actors: Query<&actor::Actor>,
|
||||||
settings: Res<settings::Settings>,
|
settings: Res<settings::Settings>,
|
||||||
q_target: Query<(Option<&Position>, &IsClickable), With<IsTargeted>>,
|
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||||
) {
|
) {
|
||||||
// TODO only when hud is actually on
|
// TODO only when hud is actually on
|
||||||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||||
|
@ -438,19 +438,16 @@ fn update_hud(
|
||||||
text.sections[9].value = format!("{all_actors:.0}");
|
text.sections[9].value = format!("{all_actors:.0}");
|
||||||
let integrity = suit.integrity * 100.0;
|
let integrity = suit.integrity * 100.0;
|
||||||
text.sections[11].value = format!("{integrity:.0}%");
|
text.sections[11].value = format!("{integrity:.0}%");
|
||||||
let speed = cam_v.length();
|
|
||||||
let speed_readable = nature::readable_distance(speed);
|
|
||||||
let gforce = gforce.gforce;
|
|
||||||
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
||||||
|
|
||||||
// Target display
|
// Target display
|
||||||
let dist_scalar: f64;
|
let dist_scalar: f64;
|
||||||
if let Ok((_, IsClickable { distance: Some(dist), .. })) = q_target.get_single() {
|
if let Ok((IsClickable { distance: Some(dist), .. }, _, _)) = q_target.get_single() {
|
||||||
dist_scalar = *dist;
|
dist_scalar = *dist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let target: Option<DVec3>;
|
let target: Option<DVec3>;
|
||||||
if let Ok((Some(targetpos), _)) = q_target.get_single() {
|
if let Ok((_, Some(targetpos), _)) = q_target.get_single() {
|
||||||
target = Some(targetpos.0);
|
target = Some(targetpos.0);
|
||||||
}
|
}
|
||||||
else if q_target.is_empty() {
|
else if q_target.is_empty() {
|
||||||
|
@ -468,7 +465,8 @@ fn update_hud(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok((_, clickable)) = q_target.get_single() {
|
let gforce = gforce.gforce;
|
||||||
|
if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
||||||
let distance = if dist_scalar.is_nan() {
|
let distance = if dist_scalar.is_nan() {
|
||||||
"UNKNOWN".to_string()
|
"UNKNOWN".to_string()
|
||||||
} else if dist_scalar != 0.0 {
|
} else if dist_scalar != 0.0 {
|
||||||
|
@ -476,10 +474,18 @@ fn update_hud(
|
||||||
} else {
|
} else {
|
||||||
"ERROR".to_string()
|
"ERROR".to_string()
|
||||||
};
|
};
|
||||||
|
let speed: f64 = if let Some(target_v) = target_v_maybe {
|
||||||
|
(target_v.0 - cam_v.0).length()
|
||||||
|
} else {
|
||||||
|
cam_v.length()
|
||||||
|
};
|
||||||
|
let speed_readable = nature::readable_distance(speed);
|
||||||
let target_name = clickable.name.clone().unwrap_or("Unnamed".to_string());
|
let target_name = clickable.name.clone().unwrap_or("Unnamed".to_string());
|
||||||
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
|
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
let speed = cam_v.length();
|
||||||
|
let speed_readable = nature::readable_distance(speed);
|
||||||
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
|
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue