speedometer shows speed relative to orbital velocity

This commit is contained in:
yuni 2024-06-11 01:12:41 +02:00
parent d04b400fad
commit 46a030f15e

View file

@ -707,7 +707,8 @@ fn update_dashboard(
fn update_speedometer(
timer: ResMut<FPSUpdateTimer>,
settings: Res<Settings>,
q_camera: Query<&LinearVelocity, With<actor::PlayerCamera>>,
jupiter_pos: Res<game::JupiterPos>,
q_camera: Query<(&LinearVelocity, &Position), With<actor::PlayerCamera>>,
q_player: Query<&actor::ExperiencesGForce, With<actor::Player>>,
q_target: Query<&LinearVelocity, With<IsTargeted>>,
mut q_speedometer: Query<&mut Style, (With<Speedometer>, Without<Speedometer2>)>,
@ -717,8 +718,9 @@ fn update_speedometer(
if !settings.hud_active || !timer.0.just_finished() {
return;
}
if let Ok(cam_v) = q_camera.get_single() {
let speed = cam_v.length();
if let Ok((cam_v, pos)) = q_camera.get_single() {
let orbital_v = nature::orbital_velocity(pos.0 - jupiter_pos.0, nature::JUPITER_MASS);
let speed = (cam_v.0 - orbital_v).length();
let speedometer_split = 5_000.0;
if let Ok(mut speedometer) = q_speedometer.get_single_mut() {