Compare commits

...

4 commits

Author SHA1 Message Date
yuni 939f03b95d bump to v0.6.0 2024-04-08 04:45:14 +02:00
yuni cccef60090 better lightyear formatting 2024-04-08 04:42:04 +02:00
yuni ac9ee34e1f delta v actually displays the relative velocity now 2024-04-08 04:37:58 +02:00
yuni 48e54265f9 simplify 2024-04-08 04:28:19 +02:00
5 changed files with 29 additions and 32 deletions

2
Cargo.lock generated
View file

@ -2769,7 +2769,7 @@ dependencies = [
[[package]]
name = "outfly"
version = "0.5.3"
version = "0.6.0"
dependencies = [
"bevy",
"bevy_embedded_assets",

View file

@ -1,6 +1,6 @@
[package]
name = "outfly"
version = "0.5.3"
version = "0.6.0"
edition = "2021"
homepage = "https://codeberg.org/hut/outfly"
repository = "https://codeberg.org/hut/outfly"

View file

@ -151,7 +151,7 @@ python -m http.server -d wasm
# Changelog
- Git:
- v0.6.0:
- Implement zooming with right click (AR only)
- Implement targeting objects with left click (AR only)
- Implement matching velocity to targeted objects with space

View file

@ -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<(Option<&Position>, &IsClickable), With<IsTargeted>>,
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
) {
// TODO only when hud is actually on
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
@ -438,20 +438,16 @@ 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() {
@ -469,28 +465,29 @@ fn update_hud(
}
}
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 {
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(", ");
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");
}
else {
let speed = cam_v.length();
let speed_readable = nature::readable_distance(speed);
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
}
}
}

View file

@ -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.001 {
if abs_distance > LIGHTYEAR2METER * 0.01 {
let lightyears = distance / LIGHTYEAR2METER;
return format!("{lightyears:.3}ly");
return format!("{lightyears:.2} ly");
}
if abs_distance >= 1.0e10 {
let gigameters = distance * 1.0e-9;