diff --git a/src/interaction/objects.rs b/src/interaction/objects.rs index 242b173..6198a71 100644 --- a/src/interaction/objects.rs +++ b/src/interaction/objects.rs @@ -101,14 +101,14 @@ pub fn handle_drop( pub fn handle_door_interaction( mut commands: Commands, - player_query: Query<(&PlayerAction, &Item), With>, + mut player_query: Query<(&PlayerAction, &mut Item), With>, card_query: Query<&KeyCardId>, // current interactable interaction_opportunity: ResMut, door_query: Query<(Entity, &OpenedByKey), With>, ) { // the card - let Ok((PlayerAction::OpenDoor, item)) = player_query.get_single() else { + let Ok((PlayerAction::OpenDoor, mut item)) = player_query.get_single_mut() else { return; }; let Some(current_card) = item.inner().and_then(|e| card_query.get(e).ok()) else { @@ -127,5 +127,6 @@ pub fn handle_door_interaction( commands.entity(door).despawn_recursive(); // unwrap is safe because of the item.inner().and_then commands.entity(item.inner().unwrap()).despawn_recursive(); + item.take(); } } diff --git a/src/level_instantiation/mod.rs b/src/level_instantiation/mod.rs index cd7d91a..3eef3ca 100644 --- a/src/level_instantiation/mod.rs +++ b/src/level_instantiation/mod.rs @@ -660,7 +660,7 @@ fn spawn_doors( ( (0, 1), Transform::from_xyz(2.0 * x as f32, 0.0, -2.0 * z as f32) - .with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())), + .with_rotation(Quat::from_rotation_y(-90.0_f32.to_radians())), ) } else { ( diff --git a/src/player.rs b/src/player.rs index 0840453..5ef5cc7 100644 --- a/src/player.rs +++ b/src/player.rs @@ -66,8 +66,7 @@ pub struct Flashlight { } #[derive(Debug, Component)] -pub struct SpotlightFlashlight { -} +pub struct SpotlightFlashlight {} #[derive(Component)] pub struct FlashlightButtonAnimation { @@ -95,7 +94,12 @@ pub fn plugin(app: &mut App) { apply_head_bob, on_resize_system, handle_flashlight, - (update_flashlight_button_animation, update_flashlight_charge, update_flashlight_sprite).chain(), + ( + update_flashlight_button_animation, + update_flashlight_charge, + update_flashlight_sprite, + ) + .chain(), ) .run_if(in_state(GameState::Playing)), ) @@ -163,7 +167,10 @@ pub fn init_player( let window = window.single(); let transform = flashlight_base_transform(window.width(), window.height()); parent.spawn(( - Flashlight { charge: 4.0, is_on: false }, + Flashlight { + charge: 4.0, + is_on: false, + }, Sprite::from_image(flashlights.flash_hold_4.clone()), transform.0.clone(), transform, @@ -173,7 +180,7 @@ pub fn init_player( // feitelijke pitslamp parent.spawn(( - SpotlightFlashlight{}, + SpotlightFlashlight {}, SpotLight { intensity: 0.0, color: Color::srgba(0.9, 0.628, 0.392, 1.0), @@ -435,10 +442,7 @@ pub fn handle_flashlight( } } -pub fn update_flashlight_charge( - time: Res