coreheart/crates/input/src/conditions.rs

28 lines
826 B
Rust
Raw Normal View History

2025-08-24 09:42:18 -04:00
use bevy::prelude::*;
use crate::{Inputs, actions::InputAction};
pub fn action_pressed<T: Send + Sync + 'static>(
action: InputAction,
) -> impl FnMut(Res<Inputs<T>>) -> bool + Clone {
move |inputs: Res<Inputs<T>>| inputs.pressed(action)
}
pub fn action_just_pressed<T: Send + Sync + 'static>(
action: InputAction,
) -> impl FnMut(Res<Inputs<T>>) -> bool + Clone {
move |inputs: Res<Inputs<T>>| inputs.just_pressed(action)
}
pub fn action_released<T: Send + Sync + 'static>(
action: InputAction,
) -> impl FnMut(Res<Inputs<T>>) -> bool + Clone {
move |inputs: Res<Inputs<T>>| inputs.released(action)
}
pub fn action_just_released<T: Send + Sync + 'static>(
action: InputAction,
) -> impl FnMut(Res<Inputs<T>>) -> bool + Clone {
move |inputs: Res<Inputs<T>>| inputs.just_released(action)
}