pub struct InputManagerPlugin<A: Actionlike, UserState: Resource + PartialEq + Clone = ()> { /* private fields */ }
Expand description
A [Plugin
] that collects [Input
] from disparate sources, producing an ActionState
to consume in game logic
This plugin needs to be passed in an Actionlike
enum type that you’ve created for your game,
which acts as a “virtual button” that can be comfortably consumed
Each InputManagerBundle
contains:
- an
InputMap
component, which stores an entity-specific mapping between the assorted input streams and an internal repesentation of “actions” - an
ActionState
component, which stores the current input state for that entity in an source-agnostic fashion
Systems
tick_action_state
, which resets thepressed
andjust_pressed
fields of theActionState
each frame- labeled
InputManagerSystem::Reset
- labeled
update_action_state
which collects [Input
] resources to update theActionState
- labeled
InputManagerSystem::Update
- labeled
update_action_state_from_interaction
, for triggering actions from buttons- powers the
ActionStateDriver
component baseod on an [Interaction
] component - labeled
InputManagerSystem::Update
- powers the
Implementations
Creates a version of this plugin that will only run in the specified state_variant
Example
use bevy::prelude::*;
use leafwing_input_manager::*;
#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, EnumIter)]
enum PlayerAction {
// Movement
Up,
Down,
Left,
Right,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
enum GameState {
Playing,
Paused,
Menu,
}
App::new().add_plugin(InputManagerPlugin::<PlayerAction, GameState>::run_in_state(GameState::Playing));
Trait Implementations
impl<A: Actionlike, UserState: Resource + PartialEq + Clone> Plugin for InputManagerPlugin<A, UserState>
impl<A: Actionlike, UserState: Resource + PartialEq + Clone> Plugin for InputManagerPlugin<A, UserState>
Auto Trait Implementations
impl<A, UserState> RefUnwindSafe for InputManagerPlugin<A, UserState> where
A: RefUnwindSafe,
UserState: RefUnwindSafe,
impl<A, UserState> Send for InputManagerPlugin<A, UserState>
impl<A, UserState> Sync for InputManagerPlugin<A, UserState>
impl<A, UserState> Unpin for InputManagerPlugin<A, UserState> where
A: Unpin,
UserState: Unpin,
impl<A, UserState> UnwindSafe for InputManagerPlugin<A, UserState> where
A: UnwindSafe,
UserState: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
pub fn from_world(_world: &mut World) -> T
pub fn from_world(_world: &mut World) -> T
Creates Self
using data from the given [World]
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more