From 6e92e37cdfa274d29a85730ccf0d9ffc578eae7b Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 7 May 2024 19:13:49 +0200 Subject: [PATCH] turn off flashlight when entering vehicle --- src/actor.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/actor.rs b/src/actor.rs index abef7c7..3fd444d 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -343,6 +343,7 @@ pub fn handle_input( pub fn handle_vehicle_enter_exit( mut commands: Commands, mut er_vehicle: EventReader, + mut q_playerflashlight: Query<&mut Visibility, (With, Without, Without)>, mut q_drivers: Query<(Entity, &mut Visibility, Option<&Collider>), (Without, With)>, mut q_vehicles: Query<(Entity, &mut Vehicle, &mut Visibility), (With, Without)>, mut ew_sfx: EventWriter, @@ -368,6 +369,9 @@ pub fn handle_vehicle_enter_exit( commands.entity(driver).insert(JustNowEnteredVehicle); commands.entity(vehicle).insert(PlayerCamera); commands.entity(vehicle).insert(PlayerDrivesThis); + if let Ok(mut flashlight_vis) = q_playerflashlight.get_single_mut() { + *flashlight_vis = Visibility::Hidden; + } } else { // Exiting Vehicle