From 33aadd5d51ae4bf2133cfbad998f29d6937ffecf Mon Sep 17 00:00:00 2001 From: yuni Date: Fri, 29 Nov 2024 20:27:14 +0100 Subject: [PATCH] hud: display size of target (doesn't work with stars other than sol) --- src/hud.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 6f11b66..5bbeebb 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -986,7 +986,7 @@ fn update_hud( ), >, settings: Res, - q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With>, + q_target: Query<(&IsClickable, &Transform, Option<&Position>, Option<&LinearVelocity>), With>, ) { if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering { let q_camera_result = q_camera.get_single(); @@ -1012,12 +1012,13 @@ fn update_hud( }, _, _, + _, )) = q_target.get_single() { dist_scalar = *dist; } else { let target: Option; - if let Ok((_, Some(targetpos), _)) = q_target.get_single() { + if let Ok((_, _, Some(targetpos), _)) = q_target.get_single() { target = Some(targetpos.0); } else if q_target.is_empty() { target = Some(DVec3::new(0.0, 0.0, 0.0)); @@ -1040,7 +1041,7 @@ fn update_hud( text.sections[0].value = "ERROR: MULTIPLE TARGETS\n\n".to_string(); } else if target_error { text.sections[0].value = "ERROR: FAILED TO AQUIRE TARGET\n\n".to_string(); - } else if let Ok((clickable, _, _)) = q_target.get_single() { + } else if let Ok((clickable, trans, _, _)) = q_target.get_single() { let distance = if dist_scalar.is_nan() { "UNKNOWN".to_string() } else if dist_scalar != 0.0 { @@ -1054,8 +1055,9 @@ fn update_hud( } else { "".to_string() }; + let size = nature::readable_si(trans.scale.x as f64 * 2.0); text.sections[0].value = - format!("Target: {target_name}\n{pronoun}Distance: {distance}\n\n"); + format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\n\n"); } else { text.sections[0].value = "".to_string(); }