pub fn move_from<F: LayoutFilter>(&mut self, source: &mut World, filter: &F) {
        // find the archetypes in the source that we want to merge into the destination
        for src_arch in source.archetypes.iter_mut().filter(|arch| {
            filter
                .matches_layout(arch.layout().component_types())
                .is_pass()
        }) {
            // find conflicts, and remove the existing entity, to be replaced with that defined in
            // the source
            for src_entity in src_arch.entities() {
                self.remove(*src_entity);
            }

            // find or construct the destination archetype
            let layout = &**src_arch.layout();
            let dst_arch_index = if src_arch.entities().len() < 32 {
                self.index.search(layout).next()
            } else {
                None
            };
            let dst_arch_index =
                dst_arch_index.unwrap_or_else(|| self.insert_archetype(layout.clone()));
            let dst_arch = &mut self.archetypes[dst_arch_index.0 as usize];

            // build a writer for the destination archetype
            let mut writer =
                ArchetypeWriter::new(dst_arch_index, dst_arch, self.components.get_multi_mut());

            // push entity IDs into the archetype
            for entity in src_arch.entities() {
                writer.push(*entity);
            }

            // merge components into the archetype
            for component in src_arch.layout().component_types() {
                let src_storage = source.components.get_mut(*component).unwrap();
                let mut dst_storage = writer.claim_components_unknown(*component);
                dst_storage.move_archetype_from(src_arch.index(), src_storage);
            }

            for entity in src_arch.drain() {
                source.entities.remove(entity);
            }

            // record entity locations
            let (base, entities) = writer.inserted();
            self.entities.insert(entities, dst_arch_index, base);
        }
    }
/// Merges the given world into this world by moving all entities out of the source world.
Merges the given world into this world by moving all entities out of the source world.
Merges the given world into this world by moving all entities out of the source world .
pub fn move_from<F: LayoutFilter>(&mut self, source: &mut World, filter: &F) {
        // find the archetypes in the source that we want to merge into the destination
        for src_arch in source.archetypes.iter_mut().filter(|arch| {
            filter
                .matches_layout(arch.layout().component_types())
                .is_pass()
        }) {
            // find conflicts, and remove the existing entity, to be replaced with that defined in
            // the source
            for src_entity in src_arch.entities() {
                self.remove(*src_entity);
            }
            // find or construct the destination archetype
            let layout = &**src_arch.layout();
            let dst_arch_index = if src_arch.entities().len() < 32 {
                self.index.search(layout).next()
            } else {
                None
            };
            let dst_arch_index =
                dst_arch_index.unwrap_or_else(|| self.insert_archetype(layout.clone()));
            let dst_arch = &mut self.archetypes[dst_arch_index.0 as usize];
            // build a writer for the destination archetype
            let mut writer =
                ArchetypeWriter::new(dst_arch_index, dst_arch, self.components.get_multi_mut());
            // push entity IDs into the archetype
            for entity in src_arch.entities() {
                writer.push(*entity);
            }
            // merge components into the archetype
            for component in src_arch.layout().component_types() {
                let src_storage = source.components.get_mut(*component).unwrap();
                let mut dst_storage = writer.claim_components_unknown(*component);
                dst_storage.move_archetype_from(src_arch.index(), src_storage);
            }
            for entity in src_arch.drain() {
                source.entities.remove(entity);
            }
            // record entity locations
            let (base, entities) = writer.inserted();
            self.entities.insert(entities, dst_arch_index, base);
        }
    }
pub fn move_from < F : LayoutFilter > ( & mut self , source : & mut World , filter : & F ) { // find the archetypes in the source that we want to merge into the destination for src_arch in source . archetypes . iter_mut ( ) . filter ( | arch | { filter . matches_layout ( arch . layout ( ) . component_types ( ) ) . is_pass ( ) } ) { // find conflicts, and remove the existing entity, to be replaced with that defined in // the source for src_entity in src_arch . entities ( ) { self . remove ( * src_entity ) ; } // find or construct the destination archetype let layout = & * * src_arch . layout ( ) ; let dst_arch_index = if src_arch . entities ( ) . len ( ) < 32 { self . index . search ( layout ) . next ( ) } else { None } ; let dst_arch_index = dst_arch_index . unwrap_or_else ( | | self . insert_archetype ( layout . clone ( ) ) ) ; let dst_arch = & mut self . archetypes [ dst_arch_index . 0 as usize ] ; // build a writer for the destination archetype let mut writer = ArchetypeWriter :: new ( dst_arch_index , dst_arch , self . components . get_multi_mut ( ) ) ; // push entity IDs into the archetype for entity in src_arch . entities ( ) { writer . push ( * entity ) ; } // merge components into the archetype for component in src_arch . layout ( ) . component_types ( ) { let src_storage = source . components . get_mut ( * component ) . unwrap ( ) ; let mut dst_storage = writer . claim_components_unknown ( * component ) ; dst_storage . move_archetype_from ( src_arch . index ( ) , src_storage ) ; } for entity in src_arch . drain ( ) { source . entities . remove ( entity ) ; } // record entity locations let ( base , entities ) = writer . inserted ( ) ; self . entities . insert ( entities , dst_arch_index , base ) ; } }
Merges the given world into this world by moving all entities out of the source world.
Merges the given world into this world by moving all entities out of the source world .
&mut self
source
&mut World
filter
&F
&mut self
source
&mut World
filter
&F