pub trait RemotePlayer: Send + Sync + 'static {
    type Info: DeserializeOwned;
    type Input: DeserializeOwned;
    fn accept(
        info: Self::Info,
        pid: PlayerId,
        world: &mut World
    ) -> Result<Self>
    where
        Self: Sized
;
fn apply_input(
        &mut self,
        entity: EntityId,
        world: &mut World,
        pack: Self::Input
    ); fn disconnected(self, world: &mut World)
    where
        Self: Sized
, { ... } }
Expand description

This trait defines how players are connected and commands are processed.

Associated Types

Player info type. It is taken from message sent when new player is added by connected client.

Player input type. It is taken from input message sent with associated player id. RemotePlayer::apply_input processes this data.

Required methods

Verifies player info.

On success spawns required entities. Attaches provided PlayerId to entities that must receive commands from client. Returns Self associated to spawned entities.

On error returns a reason.

Process input sent by associated player. This function is called for each entity that receives commands from the player.

Provided methods

Optional hook to perform an action when player is removed.

Implementors