hud: display mass of target. Wow, the masses are all waaay off.
This commit is contained in:
parent
90d7e01b95
commit
4c8a4278a2
12
src/hud.rs
12
src/hud.rs
|
@ -986,7 +986,7 @@ fn update_hud(
|
|||
),
|
||||
>,
|
||||
settings: Res<Settings>,
|
||||
q_target: Query<(&IsClickable, &Transform, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||
q_target: Query<(&IsClickable, &Transform, Option<&Mass>, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||
) {
|
||||
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<DVec3>;
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue