hud: display size of target (doesn't work with stars other than sol)
This commit is contained in:
parent
ab7296c1ae
commit
33aadd5d51
10
src/hud.rs
10
src/hud.rs
|
@ -986,7 +986,7 @@ fn update_hud(
|
||||||
),
|
),
|
||||||
>,
|
>,
|
||||||
settings: Res<Settings>,
|
settings: Res<Settings>,
|
||||||
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
q_target: Query<(&IsClickable, &Transform, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||||
) {
|
) {
|
||||||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||||
let q_camera_result = q_camera.get_single();
|
let q_camera_result = q_camera.get_single();
|
||||||
|
@ -1012,12 +1012,13 @@ fn update_hud(
|
||||||
},
|
},
|
||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
|
_,
|
||||||
)) = q_target.get_single()
|
)) = 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() {
|
||||||
target = Some(DVec3::new(0.0, 0.0, 0.0));
|
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();
|
text.sections[0].value = "ERROR: MULTIPLE TARGETS\n\n".to_string();
|
||||||
} else if target_error {
|
} else if target_error {
|
||||||
text.sections[0].value = "ERROR: FAILED TO AQUIRE TARGET\n\n".to_string();
|
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() {
|
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 {
|
||||||
|
@ -1054,8 +1055,9 @@ fn update_hud(
|
||||||
} else {
|
} else {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
|
let size = nature::readable_si(trans.scale.x as f64 * 2.0);
|
||||||
text.sections[0].value =
|
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 {
|
} else {
|
||||||
text.sections[0].value = "".to_string();
|
text.sections[0].value = "".to_string();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue