simplify setting ambient light on hud toggle

This commit is contained in:
yuni 2024-04-24 03:58:11 +02:00
parent 90372afaef
commit 2522367026

View file

@ -194,7 +194,6 @@ fn setup(
mut commands: Commands,
settings: Res<var::Settings>,
asset_server: Res<AssetServer>,
mut ambient_light: ResMut<AmbientLight>,
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
) {
let visibility = if settings.hud_active {
@ -370,13 +369,6 @@ fn setup(
));
skeleton::load("selectagon", &mut entitycmd, &*asset_server);
// AR-related things
ambient_light.brightness = if settings.hud_active {
AMBIENT_LIGHT_AR
} else {
AMBIENT_LIGHT
};
ew_updateoverlays.send(UpdateOverlayVisibility);
}
@ -654,7 +646,6 @@ fn handle_input(
mut ew_togglemusic: EventWriter<audio::ToggleMusicEvent>,
mut ew_target: EventWriter<TargetEvent>,
mut ew_updateoverlays: EventWriter<UpdateOverlayVisibility>,
mut ambient_light: ResMut<AmbientLight>,
q_objects: Query<(Entity, &Transform), (With<IsClickable>, Without<IsTargeted>, Without<actor::PlayerDrivesThis>, Without<actor::Player>)>,
q_camera: Query<&Transform, With<Camera>>,
) {
@ -665,11 +656,6 @@ fn handle_input(
}
if keyboard_input.just_pressed(settings.key_togglehud) {
settings.hud_active ^= true;
if settings.hud_active {
ambient_light.brightness = AMBIENT_LIGHT_AR;
} else {
ambient_light.brightness = AMBIENT_LIGHT;
}
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
ew_togglemusic.send(audio::ToggleMusicEvent());
ew_updateoverlays.send(UpdateOverlayVisibility);
@ -815,6 +801,7 @@ fn update_poi_overlays (
fn update_overlay_visibility(
mut q_marker: Query<&mut Visibility, With<PointOfInterestMarker>>,
mut q_hudelement: Query<&mut Visibility, (With<ToggleableHudElement>, Without<PointOfInterestMarker>)>,
mut ambient_light: ResMut<AmbientLight>,
er_target: EventReader<UpdateOverlayVisibility>,
settings: Res<var::Settings>,
) {
@ -832,4 +819,10 @@ fn update_overlay_visibility(
for mut vis in &mut q_hudelement {
*vis = show_hud;
}
ambient_light.brightness = if settings.hud_active {
AMBIENT_LIGHT_AR
} else {
AMBIENT_LIGHT
};
}