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