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]]
|
[[package]]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.6.0"
|
version = "0.5.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy_embedded_assets",
|
"bevy_embedded_assets",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "outfly"
|
name = "outfly"
|
||||||
version = "0.6.0"
|
version = "0.5.3"
|
||||||
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
|
||||||
|
|
||||||
- v0.6.0:
|
- Git:
|
||||||
- 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
|
||||||
|
|
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>)>,
|
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<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
|
q_target: Query<(Option<&Position>, &IsClickable), 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,16 +438,20 @@ 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() {
|
||||||
|
@ -465,29 +469,28 @@ fn update_hud(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let gforce = gforce.gforce;
|
let target_name: String;
|
||||||
if let Ok((clickable, _, target_v_maybe)) = q_target.get_single() {
|
let distance: String;
|
||||||
let distance = if dist_scalar.is_nan() {
|
if dist_scalar.is_nan() {
|
||||||
"UNKNOWN".to_string()
|
distance = "UNKNOWN".to_string();
|
||||||
} else if dist_scalar != 0.0 {
|
}
|
||||||
nature::readable_distance(dist_scalar)
|
else if dist_scalar != 0.0 {
|
||||||
} else {
|
distance = nature::readable_distance(dist_scalar);
|
||||||
"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 {
|
else {
|
||||||
let speed = cam_v.length();
|
distance = "ERROR".to_string();
|
||||||
let speed_readable = nature::readable_distance(speed);
|
}
|
||||||
|
if q_target.is_empty() {
|
||||||
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
|
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 {
|
pub fn readable_distance(distance: f64) -> String {
|
||||||
let abs_distance = distance.abs();
|
let abs_distance = distance.abs();
|
||||||
if abs_distance > LIGHTYEAR2METER * 0.01 {
|
if abs_distance > LIGHTYEAR2METER * 0.001 {
|
||||||
let lightyears = distance / LIGHTYEAR2METER;
|
let lightyears = distance / LIGHTYEAR2METER;
|
||||||
return format!("{lightyears:.2} ly");
|
return format!("{lightyears:.3}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