Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
When scene changes, movement inputs are still recognized and holding …
Browse files Browse the repository at this point in the history
…them down moves the character (#153)
  • Loading branch information
porkbrain authored May 12, 2024
1 parent 4096ffa commit 37579fe
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
15 changes: 10 additions & 5 deletions common/action/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use bevy::prelude::*;
pub use leafwing_input_manager::{self, action_state::ActionState};
use leafwing_input_manager::{
action_state::ActionData,
input_map::InputMap,
plugin::InputManagerPlugin,
user_input::{InputKind, UserInput},
Expand All @@ -21,10 +20,16 @@ impl bevy::app::Plugin for Plugin {
fn build(&self, app: &mut App) {
app.init_resource::<ActionState<GlobalAction>>()
.insert_resource(GlobalAction::input_map())
.add_plugins(InputManagerPlugin::<GlobalAction>::default())
.register_type::<GlobalAction>()
.register_type::<ActionState<GlobalAction>>()
.register_type::<ActionData>();
.add_plugins(InputManagerPlugin::<GlobalAction>::default());

#[cfg(feature = "devtools")]
{
use leafwing_input_manager::action_state::ActionData;

app.register_type::<GlobalAction>()
.register_type::<ActionState<GlobalAction>>()
.register_type::<ActionData>();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions scenes/building1_basement1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ fn smooth_exit(
// reset local state for next time
*exit_animation = None;

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/building1_player_floor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ fn smooth_exit(
// reset local state for next time
*exit_animation = None;

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/clinic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ fn exit(
) {
info!("Leaving Clinic");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/downtown/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ fn exit(
) {
info!("Leaving downtown");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/mall/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ fn exit(
) {
info!("Leaving Mall");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/meditation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ fn all_cleaned_up(
// reset local state for next time
*since = None;

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/plant_shop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ fn exit(
) {
info!("Leaving {PlantShop:?}");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/sewers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ fn exit(
) {
info!("Leaving {Sewers:?}");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down
4 changes: 2 additions & 2 deletions scenes/twinpeaks_apartment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ fn exit(
) {
info!("Leaving {TwinpeaksApartment:?}");

// be a good guy and don't invade other game loops with our controls
controls.consume_all();
// be a good guy and don't invade other game loops with "Enter"
controls.consume(&GlobalAction::Interact);

use GlobalGameStateTransition::*;
match *transition {
Expand Down

0 comments on commit 37579fe

Please sign in to comment.