Compare commits
No commits in common. "939f03b95d755672cea1e669470471552bc28e52" and "2ae05214f69a93d705db8bdc178c6d5ffc388714" have entirely different histories.
939f03b95d
...
2ae05214f6
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2769,7 +2769,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "outfly"
|
||||
version = "0.6.0"
|
||||
version = "0.5.3"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_embedded_assets",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "outfly"
|
||||
version = "0.6.0"
|
||||
version = "0.5.3"
|
||||
edition = "2021"
|
||||
homepage = "https://codeberg.org/hut/outfly"
|
||||
repository = "https://codeberg.org/hut/outfly"
|
||||
|
|
|
@ -151,7 +151,7 @@ python -m http.server -d wasm
|
|||
|
||||
# Changelog
|
||||
|
||||
- v0.6.0:
|
||||
- Git:
|
||||
- Implement zooming with right click (AR only)
|
||||
- Implement targeting objects with left click (AR only)
|
||||
- Implement matching velocity to targeted objects with space
|
||||
|
|
47
src/hud.rs
47
src/hud.rs
|
@ -401,7 +401,7 @@ fn update_hud(
|
|||
mut query_chat: Query<&mut Text, (With<ChatText>, Without<GaugesText>)>,
|
||||
query_all_actors: Query<&actor::Actor>,
|
||||
settings: Res<settings::Settings>,
|
||||
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
||||
q_target: Query<(Option<&Position>, &IsClickable), With<IsTargeted>>,
|
||||
) {
|
||||
// TODO only when hud is actually on
|
||||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||
|
@ -438,16 +438,20 @@ fn update_hud(
|
|||
text.sections[9].value = format!("{all_actors:.0}");
|
||||
let integrity = suit.integrity * 100.0;
|
||||
text.sections[11].value = format!("{integrity:.0}%");
|
||||
let speed = cam_v.length();
|
||||
let kmh = speed * 60.0 * 60.0 / 1000.0;
|
||||
let speed_readable = nature::readable_distance(speed);
|
||||
let gforce = gforce.gforce;
|
||||
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
||||
|
||||
// Target display
|
||||
let dist_scalar: f64;
|
||||
if let Ok((IsClickable { distance: Some(dist), .. }, _, _)) = q_target.get_single() {
|
||||
if let Ok((_, IsClickable { distance: Some(dist), .. })) = 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() {
|
||||
|
@ -465,29 +469,28 @@ fn update_hud(
|
|||
}
|
||||
}
|
||||
|
||||
let gforce = gforce.gforce;
|
||||
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 {
|
||||
nature::readable_distance(dist_scalar)
|
||||
} else {
|
||||
"ERROR".to_string()
|
||||
};
|
||||
let speed: f64 = if let Some(target_v) = target_v_maybe {
|
||||
(target_v.0 - cam_v.0).length()
|
||||
} else {
|
||||
cam_v.length()
|
||||
};
|
||||
let speed_readable = nature::readable_distance(speed);
|
||||
let target_name = clickable.name.clone().unwrap_or("Unnamed".to_string());
|
||||
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
|
||||
let target_name: String;
|
||||
let distance: String;
|
||||
if dist_scalar.is_nan() {
|
||||
distance = "UNKNOWN".to_string();
|
||||
}
|
||||
else if dist_scalar != 0.0 {
|
||||
distance = nature::readable_distance(dist_scalar);
|
||||
}
|
||||
else {
|
||||
let speed = cam_v.length();
|
||||
let speed_readable = nature::readable_distance(speed);
|
||||
distance = "ERROR".to_string();
|
||||
}
|
||||
if q_target.is_empty() {
|
||||
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
|
||||
}
|
||||
else {
|
||||
let targets: Vec<String> = q_target
|
||||
.iter()
|
||||
.map(|(_, clickable)| clickable.name.clone().unwrap_or("<unnamed>".to_string()))
|
||||
.collect();
|
||||
target_name = targets.join(", ");
|
||||
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,9 +85,9 @@ pub fn ring_density(radius: f32) -> f32 {
|
|||
|
||||
pub fn readable_distance(distance: f64) -> String {
|
||||
let abs_distance = distance.abs();
|
||||
if abs_distance > LIGHTYEAR2METER * 0.01 {
|
||||
if abs_distance > LIGHTYEAR2METER * 0.001 {
|
||||
let lightyears = distance / LIGHTYEAR2METER;
|
||||
return format!("{lightyears:.2} ly");
|
||||
return format!("{lightyears:.3}ly");
|
||||
}
|
||||
if abs_distance >= 1.0e10 {
|
||||
let gigameters = distance * 1.0e-9;
|
||||
|
|
Loading…
Reference in a new issue