pub fn move_from(&mut self, world: World) {
        let span =
            span!(Level::INFO, "Merging worlds", source = world.id().0, destination = ?self.id());
        let _guard = span.enter();

        self.entity_allocator
            .merge(Arc::try_unwrap(world.entity_allocator).unwrap());

        for archetype in unsafe { &mut *world.storage.get() }.drain(..) {
            let target_archetype = {
                // use the description as an archetype filter
                let mut desc = archetype.description().clone();
                let archetype_data = ArchetypeFilterData {
                    component_types: self.storage().component_types(),
                    tag_types: self.storage().tag_types(),
                };
                let matches = desc
                    .matches(archetype_data)
                    .matching_indices()
                    .next()
                    .map(ArchetypeIndex);
                if let Some(arch_index) = matches {
                    // similar archetype already exists, merge
                    self.storage_mut()
                        .archetype_mut(arch_index)
                        .unwrap()
                        .move_from(archetype);
                    arch_index
                } else {
                    // archetype does not already exist, append
                    self.storage_mut().push(archetype);
                    ArchetypeIndex(self.storage_mut().archetypes().len() - 1)
                }
            };

            // update entity locations
            let archetype = &unsafe { &*self.storage.get() }.archetypes()[target_archetype];
            for (entity, location) in archetype.iter_entity_locations(target_archetype) {
                self.entity_locations.set(entity, location);
            }
        }
    }
/// Move entities from a world to this world, copying all appropriate archetypes,
/// tags entities and components into this world.
Move entities from a world to this world, copying all appropriate archetypes,
tags entities and components into this world.
Move entities from a world to this world copying all appropriate archetypes tags entities and components into this world .
pub fn move_from(&mut self, world: World) {
        let span =
            span!(Level::INFO, "Merging worlds", source = world.id().0, destination = ?self.id());
        let _guard = span.enter();
        self.entity_allocator
            .merge(Arc::try_unwrap(world.entity_allocator).unwrap());
        for archetype in unsafe { &mut *world.storage.get() }.drain(..) {
            let target_archetype = {
                // use the description as an archetype filter
                let mut desc = archetype.description().clone();
                let archetype_data = ArchetypeFilterData {
                    component_types: self.storage().component_types(),
                    tag_types: self.storage().tag_types(),
                };
                let matches = desc
                    .matches(archetype_data)
                    .matching_indices()
                    .next()
                    .map(ArchetypeIndex);
                if let Some(arch_index) = matches {
                    // similar archetype already exists, merge
                    self.storage_mut()
                        .archetype_mut(arch_index)
                        .unwrap()
                        .move_from(archetype);
                    arch_index
                } else {
                    // archetype does not already exist, append
                    self.storage_mut().push(archetype);
                    ArchetypeIndex(self.storage_mut().archetypes().len() - 1)
                }
            };
            // update entity locations
            let archetype = &unsafe { &*self.storage.get() }.archetypes()[target_archetype];
            for (entity, location) in archetype.iter_entity_locations(target_archetype) {
                self.entity_locations.set(entity, location);
            }
        }
    }
pub fn move_from ( & mut self , world : World ) { let span = span ! ( Level INFO " " source world id ( ) 0 destination self id ( ) ) ; let _guard = span . enter ( ) ; self . entity_allocator . merge ( Arc :: try_unwrap ( world . entity_allocator ) . unwrap ( ) ) ; for archetype in unsafe { & mut * world . storage . get ( ) } . drain ( .. ) { let target_archetype = { // use the description as an archetype filter let mut desc = archetype . description ( ) . clone ( ) ; let archetype_data = ArchetypeFilterData { component_types : self . storage ( ) . component_types ( ) , tag_types : self . storage ( ) . tag_types ( ) , } ; let matches = desc . matches ( archetype_data ) . matching_indices ( ) . next ( ) . map ( ArchetypeIndex ) ; if let Some ( arch_index ) = matches { // similar archetype already exists, merge self . storage_mut ( ) . archetype_mut ( arch_index ) . unwrap ( ) . move_from ( archetype ) ; arch_index } else { // archetype does not already exist, append self . storage_mut ( ) . push ( archetype ) ; ArchetypeIndex ( self . storage_mut ( ) . archetypes ( ) . len ( ) - 1 ) } } ; // update entity locations let archetype = & unsafe { & * self . storage . get ( ) } . archetypes ( ) [ target_archetype ] ; for ( entity , location ) in archetype . iter_entity_locations ( target_archetype ) { self . entity_locations . set ( entity , location ) ; } } }
Move entities from a world to this world, copying all appropriate archetypes,
tags entities and components into this world.
Move entities from a world to this world copying all appropriate archetypes tags entities and components into this world .
&mut self
world
World
&mut self
world
World