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§

source

type InputCollector: InputCollector<'a, Self::ControlMapping, Self::ControlSource, Control>

InputCollector used to update controls.

source

type ControlMapping: HasSchema

Control mapping from raw input, expected to be able to be retrieved as Resource from world.

source

type ControlSource

Type used to map source of input to control.

Required Methods§

source

fn update_controls(&mut self, collector: &mut Self::InputCollector)

Update control state from input collector.

source

fn get_control_source( &self, local_player_idx: usize, ) -> Option<Self::ControlSource>

Get ControlSource for player (only present for local player).

source

fn get_control(&self, player_idx: usize) -> &Control

Get control for player.

source

fn get_control_mut(&mut self, player_idx: usize) -> &mut Control

Get mutable control for player.

Object Safety§

This trait is not object safe.

Implementors§