From 37579fe99711120c093bfda933d4cebc95a26877 Mon Sep 17 00:00:00 2001 From: porkbrain Date: Sun, 12 May 2024 16:01:26 +0200 Subject: [PATCH] When scene changes, movement inputs are still recognized and holding them down moves the character (#153) --- common/action/src/lib.rs | 15 ++++++++++----- scenes/building1_basement1/src/lib.rs | 4 ++-- scenes/building1_player_floor/src/lib.rs | 4 ++-- scenes/clinic/src/lib.rs | 4 ++-- scenes/downtown/src/lib.rs | 4 ++-- scenes/mall/src/lib.rs | 4 ++-- scenes/meditation/src/lib.rs | 4 ++-- scenes/plant_shop/src/lib.rs | 4 ++-- scenes/sewers/src/lib.rs | 4 ++-- scenes/twinpeaks_apartment/src/lib.rs | 4 ++-- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/common/action/src/lib.rs b/common/action/src/lib.rs index 0b9fd0e5..df9e4aad 100644 --- a/common/action/src/lib.rs +++ b/common/action/src/lib.rs @@ -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}, @@ -21,10 +20,16 @@ impl bevy::app::Plugin for Plugin { fn build(&self, app: &mut App) { app.init_resource::>() .insert_resource(GlobalAction::input_map()) - .add_plugins(InputManagerPlugin::::default()) - .register_type::() - .register_type::>() - .register_type::(); + .add_plugins(InputManagerPlugin::::default()); + + #[cfg(feature = "devtools")] + { + use leafwing_input_manager::action_state::ActionData; + + app.register_type::() + .register_type::>() + .register_type::(); + } } } diff --git a/scenes/building1_basement1/src/lib.rs b/scenes/building1_basement1/src/lib.rs index bdf46b83..8a8df8ef 100644 --- a/scenes/building1_basement1/src/lib.rs +++ b/scenes/building1_basement1/src/lib.rs @@ -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 { diff --git a/scenes/building1_player_floor/src/lib.rs b/scenes/building1_player_floor/src/lib.rs index c3efd100..068b90ff 100644 --- a/scenes/building1_player_floor/src/lib.rs +++ b/scenes/building1_player_floor/src/lib.rs @@ -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 { diff --git a/scenes/clinic/src/lib.rs b/scenes/clinic/src/lib.rs index 17ae0bcc..b90c4207 100644 --- a/scenes/clinic/src/lib.rs +++ b/scenes/clinic/src/lib.rs @@ -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 { diff --git a/scenes/downtown/src/lib.rs b/scenes/downtown/src/lib.rs index 277a2f39..1c2ee575 100644 --- a/scenes/downtown/src/lib.rs +++ b/scenes/downtown/src/lib.rs @@ -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 { diff --git a/scenes/mall/src/lib.rs b/scenes/mall/src/lib.rs index c74e09da..8c6b3043 100644 --- a/scenes/mall/src/lib.rs +++ b/scenes/mall/src/lib.rs @@ -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 { diff --git a/scenes/meditation/src/lib.rs b/scenes/meditation/src/lib.rs index 8174f4c8..f36d700c 100644 --- a/scenes/meditation/src/lib.rs +++ b/scenes/meditation/src/lib.rs @@ -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 { diff --git a/scenes/plant_shop/src/lib.rs b/scenes/plant_shop/src/lib.rs index d89728ca..197d2161 100644 --- a/scenes/plant_shop/src/lib.rs +++ b/scenes/plant_shop/src/lib.rs @@ -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 { diff --git a/scenes/sewers/src/lib.rs b/scenes/sewers/src/lib.rs index cf4c66c9..3cdb8dfe 100644 --- a/scenes/sewers/src/lib.rs +++ b/scenes/sewers/src/lib.rs @@ -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 { diff --git a/scenes/twinpeaks_apartment/src/lib.rs b/scenes/twinpeaks_apartment/src/lib.rs index 2f66cca0..42b1b2d8 100644 --- a/scenes/twinpeaks_apartment/src/lib.rs +++ b/scenes/twinpeaks_apartment/src/lib.rs @@ -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 {