less frequent updating of speedometer, dashboard, gauges

This commit is contained in:
yuni 2024-05-08 01:20:22 +02:00
parent 406bd79877
commit 4b9ed44dd4

View file

@ -607,21 +607,29 @@ fn setup(
}
fn update_dashboard(
timer: ResMut<FPSUpdateTimer>,
mut q_flashlight: Query<&mut Visibility, With<DashboardFlashlight>>,
settings: Res<var::Settings>,
) {
if !timer.0.just_finished() {
return;
}
for mut vis in &mut q_flashlight {
*vis = bool2vis(settings.flashlight_active);
}
}
fn update_speedometer(
timer: ResMut<FPSUpdateTimer>,
q_camera: Query<&LinearVelocity, With<actor::PlayerCamera>>,
q_target: Query<&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>>,
) {
if !timer.0.just_finished() {
return;
}
if let Ok(cam_v) = q_camera.get_single() {
let speed = cam_v.length();
@ -659,10 +667,14 @@ fn update_speedometer(
}
fn update_gauges(
timer: ResMut<FPSUpdateTimer>,
q_player: Query<(&actor::HitPoints, &actor::Suit), With<actor::Player>>,
mut q_gauges: Query<(&mut Style, &mut BackgroundColor, &Gauge, &GaugeLength)>,
settings: Res<var::Settings>,
) {
if !timer.0.just_finished() {
return;
}
let player = q_player.get_single();
if player.is_err() { return; }
let (hp, suit) = player.unwrap();