Trait bones_framework::input::PlayerControls
source · pub trait PlayerControls<'a, Control> {
type InputCollector: InputCollector<'a, Self::ControlMapping, Self::ControlSource, Control>;
type ControlMapping: HasSchema;
type ControlSource;
// Required methods
fn update_controls(&mut self, collector: &mut Self::InputCollector);
fn get_control_source(
&self,
local_player_idx: usize,
) -> Option<Self::ControlSource>;
fn get_control(&self, player_idx: usize) -> &Control;
fn get_control_mut(&mut self, player_idx: usize) -> &mut Control;
}
Expand description
Trait that tracks player control state. Provides associated types for other input trait implementations.
Required Associated Types§
sourcetype InputCollector: InputCollector<'a, Self::ControlMapping, Self::ControlSource, Control>
type InputCollector: InputCollector<'a, Self::ControlMapping, Self::ControlSource, Control>
InputCollector used to update controls.
sourcetype ControlMapping: HasSchema
type ControlMapping: HasSchema
Control mapping from raw input, expected to be able to be retrieved as Resource
from world.
sourcetype ControlSource
type ControlSource
Type used to map source of input to control.
Required Methods§
sourcefn update_controls(&mut self, collector: &mut Self::InputCollector)
fn update_controls(&mut self, collector: &mut Self::InputCollector)
Update control state from input collector.
sourcefn get_control_source(
&self,
local_player_idx: usize,
) -> Option<Self::ControlSource>
fn get_control_source( &self, local_player_idx: usize, ) -> Option<Self::ControlSource>
Get ControlSource
for player (only present for local player).
sourcefn get_control(&self, player_idx: usize) -> &Control
fn get_control(&self, player_idx: usize) -> &Control
Get control for player.
sourcefn get_control_mut(&mut self, player_idx: usize) -> &mut Control
fn get_control_mut(&mut self, player_idx: usize) -> &mut Control
Get mutable control for player.
Object Safety§
This trait is not object safe.