Skip to content

Commit

Permalink
freeze player in dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Wabtey committed Sep 21, 2023
1 parent 5909d93 commit 2f9b1c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/characters/npcs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
character::{npcs::*, player::PLAYER_SPAWN, *},
interactions::INTERACT_BUTTON_SCALE,
},
hud_opened,
interactions::{InteractIcon, Interactible, InteractionResources, InteractionSensor},
locations::{
landmarks::{reserved_random_free_landmark, Landmark},
Expand All @@ -34,6 +35,8 @@ use self::{
movement::{FollowRangeSensor, TargetSeeker, TargetType},
};

use super::player::Player;

#[derive(Default)]
pub struct NPCPlugin;

Expand Down Expand Up @@ -87,6 +90,7 @@ impl Plugin for NPCPlugin {
idle::flexing_timer
.in_set(NPCSystems::Idle)
.after(NPCSystems::Movement),
freeze_player_in_dialog.run_if(hud_opened),
)
.run_if(in_state(GameState::Playing)),
)
Expand Down Expand Up @@ -145,6 +149,17 @@ pub fn character_interaction_event(
}
}

/// FIXME: Freeze ALL character in Dialog
fn freeze_player_in_dialog(
// talker_query: Query<&mut Velocity, With<InDialog>>,
mut player_query: Query<(&mut Velocity, &mut CharacterState), With<Player>>,
) {
let (mut rb_vel, mut character_state) = player_query.single_mut();
rb_vel.linvel.x = 0.;
rb_vel.linvel.y = 0.;
*character_state = CharacterState::Idle;
}

/// Cats and all friendly npc
fn spawn_characters(
mut commands: Commands,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ pub fn in_menu(game_state: Res<State<GameState>>) -> bool {
pub fn hud_closed(hud_state: Res<State<HUDState>>) -> bool {
hud_state.get() == &HUDState::Closed
}

pub fn hud_opened(hud_state: Res<State<HUDState>>) -> bool {
hud_state.get() != &HUDState::Closed
}

0 comments on commit 2f9b1c4

Please sign in to comment.