pub trait UpdatableInput: 'static {
type SourceData: Resource;
// Required method
fn compute(
central_input_store: ResMut<'_, CentralInputStore>,
source_data: Res<'_, Self::SourceData>,
);
}
Expand description
A trait that enables user input to be updated based on the state of the world.
This trait is intended to be used for the values stored inside of CentralInputStore
.
For the actual user inputs that you might bind actions to, use UserInput
instead.
The values of each UserInput
type will be computed by calling the methods on CentralInputStore
,
and so the UpdatableInput
trait is only needed when defining new kinds of input that we can
derive user-facing inputs from.
In simple cases, a type will be both UserInput
and UpdatableInput
,
however when configuration is needed (such as for processed axes or virtual d-pads),
two distinct types must be used.
To add a new kind of input, call CentralInputStore::register_input_kind
during App
setup.
Required Associated Types§
sourcetype SourceData: Resource
type SourceData: Resource
The resource data that must be fetched from the world in order to update the user input.
§Panics
This type cannot be CentralInputStore
, as that would cause mutable aliasing and panic at runtime.
Required Methods§
sourcefn compute(
central_input_store: ResMut<'_, CentralInputStore>,
source_data: Res<'_, Self::SourceData>,
)
fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )
A system that updates the central store of user input based on the state of the world.
When defining these systems, use the update
methods on CentralInputStore
to store the new values.
§Warning
This system should not be added manually: instead, call CentralInputStore::register_input_kind
.