Trait evoke::server::RemotePlayer
source · [−]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
type Info: DeserializeOwned
type Info: DeserializeOwned
Player info type. It is taken from message sent when new player is added by connected client.
type Input: DeserializeOwned
type Input: DeserializeOwned
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.
fn apply_input(
&mut self,
entity: EntityId,
world: &mut World,
pack: Self::Input
)
fn apply_input(
&mut self,
entity: EntityId,
world: &mut World,
pack: Self::Input
)
Process input sent by associated player. This function is called for each entity that receives commands from the player.
Provided methods
fn disconnected(self, world: &mut World) where
Self: Sized,
fn disconnected(self, world: &mut World) where
Self: Sized,
Optional hook to perform an action when player is removed.