fix flashlight when in vehicles
This commit is contained in:
parent
534a313e21
commit
ed0641d68e
13
src/actor.rs
13
src/actor.rs
|
@ -428,11 +428,10 @@ pub fn handle_input(
|
||||||
|
|
||||||
pub fn handle_vehicle_enter_exit(
|
pub fn handle_vehicle_enter_exit(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut settings: ResMut<Settings>,
|
|
||||||
mut er_vehicle: EventReader<VehicleEnterExitEvent>,
|
mut er_vehicle: EventReader<VehicleEnterExitEvent>,
|
||||||
mut ew_achievement: EventWriter<game::AchievementEvent>,
|
mut ew_achievement: EventWriter<game::AchievementEvent>,
|
||||||
mut q_playerflashlight: Query<
|
mut q_playerflashlight: Query<
|
||||||
&mut Visibility,
|
&mut Transform,
|
||||||
(
|
(
|
||||||
With<PlayersFlashLight>,
|
With<PlayersFlashLight>,
|
||||||
Without<ActorVehicleBeingEntered>,
|
Without<ActorVehicleBeingEntered>,
|
||||||
|
@ -477,9 +476,9 @@ pub fn handle_vehicle_enter_exit(
|
||||||
commands.entity(vehicle).remove::<hud::IsTargeted>();
|
commands.entity(vehicle).remove::<hud::IsTargeted>();
|
||||||
commands.entity(vehicle).insert(PlayerCamera);
|
commands.entity(vehicle).insert(PlayerCamera);
|
||||||
commands.entity(vehicle).insert(PlayerDrivesThis);
|
commands.entity(vehicle).insert(PlayerDrivesThis);
|
||||||
if let Ok(mut flashlight_vis) = q_playerflashlight.get_single_mut() {
|
if let Ok(mut flashlight_trans) = q_playerflashlight.get_single_mut() {
|
||||||
*flashlight_vis = Visibility::Hidden;
|
flashlight_trans.rotation = Quat::from_rotation_y(0f32);
|
||||||
settings.flashlight_active = false;
|
flashlight_trans.translation = Vec3::new(0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
if let Some(vehicle_name) = &event.name {
|
if let Some(vehicle_name) = &event.name {
|
||||||
ew_achievement.send(game::AchievementEvent::RideVehicle(
|
ew_achievement.send(game::AchievementEvent::RideVehicle(
|
||||||
|
@ -491,6 +490,10 @@ pub fn handle_vehicle_enter_exit(
|
||||||
if let Some(collider) = &vehicle_component.stored_drivers_collider {
|
if let Some(collider) = &vehicle_component.stored_drivers_collider {
|
||||||
commands.entity(driver).insert(collider.clone());
|
commands.entity(driver).insert(collider.clone());
|
||||||
}
|
}
|
||||||
|
if let Ok(mut flashlight_trans) = q_playerflashlight.get_single_mut() {
|
||||||
|
flashlight_trans.rotation = Quat::from_rotation_y(180f32.to_radians());
|
||||||
|
flashlight_trans.translation = Vec3::new(0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
commands.entity(driver).insert(RigidBody::Dynamic);
|
commands.entity(driver).insert(RigidBody::Dynamic);
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
||||||
commands.entity(vehicle).remove::<PlayerCamera>();
|
commands.entity(vehicle).remove::<PlayerCamera>();
|
||||||
|
|
|
@ -34,7 +34,11 @@ impl Plugin for CameraPlugin {
|
||||||
app.add_systems(Startup, setup_camera);
|
app.add_systems(Startup, setup_camera);
|
||||||
app.add_systems(Update, handle_input.run_if(in_control));
|
app.add_systems(Update, handle_input.run_if(in_control));
|
||||||
app.add_systems(Update, update_map_only_object_visibility.run_if(alive));
|
app.add_systems(Update, update_map_only_object_visibility.run_if(alive));
|
||||||
app.add_systems(Update, manage_player_actor.after(handle_input));
|
app.add_systems(
|
||||||
|
PostUpdate,
|
||||||
|
manage_player_actor
|
||||||
|
.in_set(sync::SyncSet::PositionToTransform),
|
||||||
|
);
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
PostUpdate,
|
PostUpdate,
|
||||||
sync_camera_to_player
|
sync_camera_to_player
|
||||||
|
|
Loading…
Reference in a new issue