use crate::{Actionlike, prelude::ActionState};
use bevy::prelude::Single;
pub fn action_toggle_active<A>(
default: bool,
action: A,
) -> impl for<'w, 's> FnMut(Option<Single<'w, 's, &'static ActionState<A>>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state| action_state.is_some_and(|state| state.pressed(&action)) || default
}
pub fn action_pressed<A>(
action: A,
) -> impl for<'w, 's> FnMut(Option<Single<'w, 's, &'static ActionState<A>>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state| action_state.is_some_and(|state| state.pressed(&action))
}
pub fn action_just_pressed<A>(
action: A,
) -> impl for<'w, 's> FnMut(Option<Single<'w, 's, &'static ActionState<A>>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state| action_state.is_some_and(|state| state.just_pressed(&action))
}
pub fn action_just_released<A>(
action: A,
) -> impl for<'w, 's> FnMut(Option<Single<'w, 's, &'static ActionState<A>>>) -> bool
where
A: Actionlike + Clone,
{
move |action_state| action_state.is_some_and(|state| state.just_released(&action))
}