fix cheats/gauges relative to Jupiter (which has no LinearVelocity)
This commit is contained in:
parent
3a7badf45b
commit
1bf83b424f
16
src/game.rs
16
src/game.rs
|
@ -472,7 +472,19 @@ fn handle_cheats(
|
|||
|
||||
if key_input.just_pressed(settings.key_cheat_stop) {
|
||||
gforce.ignore_gforce_seconds = 1.0;
|
||||
v.0 = nature::orbital_velocity(pos.0 - jupiter_pos.0, nature::JUPITER_MASS);
|
||||
if let Ok((_, _, target_v)) = q_target.get_single() {
|
||||
if let Some(target_v) = target_v {
|
||||
// We targeted something. Match its velocity.
|
||||
v.0 = target_v.0;
|
||||
} else {
|
||||
// We targeted something, but it has no velocity.
|
||||
v.0 = DVec3::ZERO;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We aren't targeting anything. Match orbital velocity.
|
||||
v.0 = nature::orbital_velocity(pos.0 - jupiter_pos.0, nature::JUPITER_MASS);
|
||||
}
|
||||
}
|
||||
if key_input.pressed(settings.key_cheat_speed)
|
||||
|| key_input.pressed(settings.key_cheat_speed_backward)
|
||||
|
@ -498,6 +510,8 @@ fn handle_cheats(
|
|||
pos.0 = **target_pos + offset;
|
||||
if let Some(target_v) = target_v {
|
||||
*v = target_v.clone();
|
||||
} else {
|
||||
v.0 = DVec3::ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -841,7 +841,7 @@ fn update_speedometer(
|
|||
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>>,
|
||||
q_target: Query<Option<&LinearVelocity>, With<IsTargeted>>,
|
||||
mut q_speedometer: Query<&mut Style, (With<Speedometer>, Without<Speedometer2>)>,
|
||||
mut q_speedometer2: Query<&mut Style, (With<Speedometer2>, Without<Speedometer>)>,
|
||||
mut q_node_speed: Query<&mut Text, With<NodeSpeedometerText>>,
|
||||
|
@ -904,7 +904,11 @@ fn update_speedometer(
|
|||
|
||||
// Velocity relative to target
|
||||
speed_text.sections[2].value = if let Ok(target_v) = q_target.get_single() {
|
||||
let delta_v = (target_v.0 - cam_v.0).length();
|
||||
let delta_v = if let Some(target_v) = target_v {
|
||||
(target_v.0 - cam_v.0).length()
|
||||
} else {
|
||||
cam_v.0.length()
|
||||
};
|
||||
if delta_v > 0.0001 {
|
||||
format!("Δv {}\n", nature::readable_speed(delta_v))
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue