Skip to main content

GlobalEntitySpawner

Trait GlobalEntitySpawner 

Source
pub trait GlobalEntitySpawner<E: Copy + Eq + Hash + Send + Sync>: EntityAndGlobalEntityConverter<E> {
    // Required methods
    fn spawn(
        &mut self,
        world_entity: E,
        remote_entity_opt: Option<RemoteEntity>,
    ) -> GlobalEntity;
    fn reserve_global_entity(
        &mut self,
        remote_entity: RemoteEntity,
    ) -> GlobalEntity;
    fn despawn_by_global(&mut self, global_entity: &GlobalEntity);
    fn despawn_by_world(&mut self, world_entity: &E);
    fn to_converter(&self) -> &dyn EntityAndGlobalEntityConverter<E>;
}
Expand description

Extends EntityAndGlobalEntityConverter with the ability to create, reserve, and destroy entity mappings.

Required Methods§

Source

fn spawn( &mut self, world_entity: E, remote_entity_opt: Option<RemoteEntity>, ) -> GlobalEntity

Registers world_entity in the map, reusing a reserved GlobalEntity for remote_entity_opt if one exists.

Source

fn reserve_global_entity(&mut self, remote_entity: RemoteEntity) -> GlobalEntity

Pre-allocates a GlobalEntity slot for remote_entity before the local world entity is spawned.

Source

fn despawn_by_global(&mut self, global_entity: &GlobalEntity)

Removes the mapping keyed by global_entity, panicking if it does not exist.

Source

fn despawn_by_world(&mut self, world_entity: &E)

Removes the mapping keyed by world_entity, panicking if it does not exist.

Source

fn to_converter(&self) -> &dyn EntityAndGlobalEntityConverter<E>

Returns self as an EntityAndGlobalEntityConverter reference for read-only lookups.

Implementors§