Trait jumpy::prelude::PlayerControls

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§

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

InputCollector used to update controls.

type ControlMapping: HasSchema

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

type ControlSource

Type used to map source of input to control.

Required Methods§

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

Update control state from input collector.

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

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

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

Get control for player.

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§