From 4c8a4278a2736cfd95ad6dfce78e3f2ef5ba9ecf Mon Sep 17 00:00:00 2001 From: yuni Date: Fri, 29 Nov 2024 20:38:15 +0100 Subject: [PATCH] hud: display mass of target. Wow, the masses are all waaay off. --- src/hud.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 5bbeebb..8ba8ba7 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -986,7 +986,7 @@ fn update_hud( ), >, settings: Res, - q_target: Query<(&IsClickable, &Transform, Option<&Position>, Option<&LinearVelocity>), With>, + q_target: Query<(&IsClickable, &Transform, Option<&Mass>, Option<&Position>, Option<&LinearVelocity>), With>, ) { if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering { let q_camera_result = q_camera.get_single(); @@ -1013,12 +1013,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)); @@ -1041,7 +1042,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, trans, _, _)) = q_target.get_single() { + } else if let Ok((clickable, trans, mass, _, _)) = q_target.get_single() { let distance = if dist_scalar.is_nan() { "UNKNOWN".to_string() } else if dist_scalar != 0.0 { @@ -1056,8 +1057,11 @@ fn update_hud( "".to_string() }; let size = nature::readable_si(trans.scale.x as f64 * 2.0); + let mass = if let Some(mass) = mass { + nature::readable_si(mass.0 * 0.001) + } else { String::from("?") }; text.sections[0].value = - format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\n\n"); + format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\nMass: {mass}g\n\n"); } else { text.sections[0].value = "".to_string(); }