leafwing_input_manager/
common_conditions.rsuse crate::{prelude::ActionState, Actionlike};
use bevy::prelude::Res;
pub fn action_toggle_active<A>(default: bool, action: A) -> impl FnMut(Res<ActionState<A>>) -> bool
where
A: Actionlike + Clone,
{
let mut active = default;
move |action_state: Res<ActionState<A>>| {
active ^= action_state.just_pressed(&action);
active
}
}
pub fn action_pressed<A>(action: A) -> impl FnMut(Res<ActionState<A>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state: Res<ActionState<A>>| action_state.pressed(&action)
}
pub fn action_just_pressed<A>(action: A) -> impl FnMut(Res<ActionState<A>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state: Res<ActionState<A>>| action_state.just_pressed(&action)
}
pub fn action_just_released<A>(action: A) -> impl FnMut(Res<ActionState<A>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state: Res<ActionState<A>>| action_state.just_released(&action)
}