better error handling with target acquisition
This commit is contained in:
parent
fd16d6931e
commit
3079b17a1b
15
src/hud.rs
15
src/hud.rs
|
@ -422,6 +422,8 @@ fn update_hud(
|
|||
|
||||
// Target display
|
||||
let dist_scalar: f64;
|
||||
let mut target_multiple = false;
|
||||
let mut target_error = false;
|
||||
if let Ok((IsClickable { distance: Some(dist), .. }, _, _)) = q_target.get_single() {
|
||||
dist_scalar = *dist;
|
||||
}
|
||||
|
@ -433,7 +435,12 @@ fn update_hud(
|
|||
else if q_target.is_empty() {
|
||||
target = Some(DVec3::new(0.0, 0.0, 0.0));
|
||||
}
|
||||
else if q_target.iter().len() > 1 {
|
||||
target_multiple = true;
|
||||
target = None;
|
||||
}
|
||||
else {
|
||||
target_error = true;
|
||||
target = None;
|
||||
}
|
||||
if let Some(target_pos) = target {
|
||||
|
@ -458,7 +465,13 @@ fn update_hud(
|
|||
let speed_readable = nature::readable_distance(speed);
|
||||
text.sections[14].value = format!("\n{speed_readable}/s\n{gforce:.1}g{dev_speed}");
|
||||
|
||||
if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
||||
if target_multiple {
|
||||
text.sections[15].value = "\n\nERROR: MULTIPLE TARGETS".to_string();
|
||||
}
|
||||
else if target_error {
|
||||
text.sections[15].value = "\n\nERROR: FAILED TO AQUIRE TARGET".to_string();
|
||||
}
|
||||
else if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
||||
let distance = if dist_scalar.is_nan() {
|
||||
"UNKNOWN".to_string()
|
||||
} else if dist_scalar != 0.0 {
|
||||
|
|
Loading…
Reference in a new issue