pub fn clone_from_single<C: CloneImpl>(
        &mut self,
        src_world: &World,
        src_entity: Entity,
        clone_impl: &C,
        replace_mapping: Option<Entity>,
    ) -> Entity {
        let span = span!(Level::INFO, "CloneMergingSingle worlds", source = src_world.id().0, destination = ?self.id());
        let _guard = span.enter();

        let src_storage = unsafe { &(*src_world.storage.get()) };
        let dst_storage = unsafe { &mut (*self.storage.get()) };

        if !src_world.entity_allocator.is_alive(src_entity) {
            panic!("src_entity not alive");
        }

        // Erase all entities that are referred to by value. The code following will update the location
        // of all these entities to point to new, valid locations
        if let Some(replace_mapping) = replace_mapping {
            if self.entity_allocator.is_alive(replace_mapping) {
                let location = self
                    .entity_locations
                    .get(replace_mapping)
                    .expect("Failed to get location of live entity");
                self.delete_location(location);
            } else {
                panic!("clone_from_single assumes entity_mapping exists in the destination world");
            }
        }

        let src_location = src_world.entity_locations.get(src_entity).unwrap();
        let src_archetype = &src_storage.archetypes()[src_location.archetype()];

        // Iterate all archetypes in the src world
        let archetype_data = ArchetypeFilterData {
            component_types: self.storage().component_types(),
            tag_types: self.storage().tag_types(),
        };

        let dst_archetype_index = World::find_or_create_archetype_for_clone_move(
            clone_impl,
            src_archetype.description(),
            archetype_data,
            dst_storage,
        );

        // Do the clone_from for this archetype
        dst_storage
            .archetype_mut(dst_archetype_index)
            .unwrap()
            .clone_from_single(
                &src_world,
                src_archetype,
                &src_location,
                dst_archetype_index,
                &self.entity_allocator,
                &mut self.entity_locations,
                clone_impl,
                replace_mapping,
            )
    }
/// This will *copy* the `src_entity` from `src_world` into this world. The logic to do the copy
/// is delegated to the `clone_impl` provided by the user. In addition to simple copying, it's
/// also possible to transform from one type to another. This is useful for cases where you want
/// to read from serializable data (like a physics shape definition) and construct something
/// that isn't serializable (like a handle to a physics body)
///
/// By default, the entity in the new world will be assigned a new Entity. The return value
/// indicates the Entity in the new world, which allows for mapping data the old and new world.
///
/// If you want to replace an existing entity (for example to hot-reload data from a file,)
/// populate `replace_mapping`. This entity must exist in the destination world. The entity in
/// the destination world will be deleted, and the entity copied over will be assigned
/// the same entity. If these constraints are not met, this function will panic.
This will *copy* the `src_entity` from `src_world` into this world. The logic to do the copy
is delegated to the `clone_impl` provided by the user. In addition to simple copying, it's
also possible to transform from one type to another. This is useful for cases where you want
to read from serializable data (like a physics shape definition) and construct something
that isn't serializable (like a handle to a physics body)

By default, the entity in the new world will be assigned a new Entity. The return value
indicates the Entity in the new world, which allows for mapping data the old and new world.

If you want to replace an existing entity (for example to hot-reload data from a file,)
populate `replace_mapping`. This entity must exist in the destination world. The entity in
the destination world will be deleted, and the entity copied over will be assigned
the same entity. If these constraints are not met, this function will panic.
This will * copy * the ` src_entity ` from ` src_world ` into this world . The logic to do the copy is delegated to the ` clone_impl ` provided by the user . In addition to simple copying it ' s also possible to transform from one type to another . This is useful for cases where you want to read from serializable data ( like a physics shape definition ) and construct something that isn ' t serializable ( like a handle to a physics body ) By default the entity in the new world will be assigned a new Entity . The return value indicates the Entity in the new world which allows for mapping data the old and new world . If you want to replace an existing entity ( for example to hot - reload data from a file ) populate ` replace_mapping ` . This entity must exist in the destination world . The entity in the destination world will be deleted and the entity copied over will be assigned the same entity . If these constraints are not met this function will panic .
pub fn clone_from_single<C: CloneImpl>(
        &mut self,
        src_world: &World,
        src_entity: Entity,
        clone_impl: &C,
        replace_mapping: Option<Entity>,
    ) -> Entity {
        let span = span!(Level::INFO, "CloneMergingSingle worlds", source = src_world.id().0, destination = ?self.id());
        let _guard = span.enter();
        let src_storage = unsafe { &(*src_world.storage.get()) };
        let dst_storage = unsafe { &mut (*self.storage.get()) };
        if !src_world.entity_allocator.is_alive(src_entity) {
            panic!("src_entity not alive");
        }
        // Erase all entities that are referred to by value. The code following will update the location
        // of all these entities to point to new, valid locations
        if let Some(replace_mapping) = replace_mapping {
            if self.entity_allocator.is_alive(replace_mapping) {
                let location = self
                    .entity_locations
                    .get(replace_mapping)
                    .expect("Failed to get location of live entity");
                self.delete_location(location);
            } else {
                panic!("clone_from_single assumes entity_mapping exists in the destination world");
            }
        }
        let src_location = src_world.entity_locations.get(src_entity).unwrap();
        let src_archetype = &src_storage.archetypes()[src_location.archetype()];
        // Iterate all archetypes in the src world
        let archetype_data = ArchetypeFilterData {
            component_types: self.storage().component_types(),
            tag_types: self.storage().tag_types(),
        };
        let dst_archetype_index = World::find_or_create_archetype_for_clone_move(
            clone_impl,
            src_archetype.description(),
            archetype_data,
            dst_storage,
        );
        // Do the clone_from for this archetype
        dst_storage
            .archetype_mut(dst_archetype_index)
            .unwrap()
            .clone_from_single(
                &src_world,
                src_archetype,
                &src_location,
                dst_archetype_index,
                &self.entity_allocator,
                &mut self.entity_locations,
                clone_impl,
                replace_mapping,
            )
    }
pub fn clone_from_single < C : CloneImpl > ( & mut self , src_world : & World , src_entity : Entity , clone_impl : & C , replace_mapping : Option < Entity > , ) -> Entity { let span = span ! ( Level INFO " " source src_world id ( ) 0 destination self id ( ) ) ; let _guard = span . enter ( ) ; let src_storage = unsafe { & ( * src_world . storage . get ( ) ) } ; let dst_storage = unsafe { & mut ( * self . storage . get ( ) ) } ; if ! src_world . entity_allocator . is_alive ( src_entity ) { panic ! ( " " ) ; } // Erase all entities that are referred to by value. The code following will update the location // of all these entities to point to new, valid locations if let Some ( replace_mapping ) = replace_mapping { if self . entity_allocator . is_alive ( replace_mapping ) { let location = self . entity_locations . get ( replace_mapping ) . expect ( " " ) ; self . delete_location ( location ) ; } else { panic ! ( " " ) ; } } let src_location = src_world . entity_locations . get ( src_entity ) . unwrap ( ) ; let src_archetype = & src_storage . archetypes ( ) [ src_location . archetype ( ) ] ; // Iterate all archetypes in the src world let archetype_data = ArchetypeFilterData { component_types : self . storage ( ) . component_types ( ) , tag_types : self . storage ( ) . tag_types ( ) , } ; let dst_archetype_index = World :: find_or_create_archetype_for_clone_move ( clone_impl , src_archetype . description ( ) , archetype_data , dst_storage , ) ; // Do the clone_from for this archetype dst_storage . archetype_mut ( dst_archetype_index ) . unwrap ( ) . clone_from_single ( & src_world , src_archetype , & src_location , dst_archetype_index , & self . entity_allocator , & mut self . entity_locations , clone_impl , replace_mapping , ) }
This will *copy* the `src_entity` from `src_world` into this world.
This will * copy * the ` src_entity ` from ` src_world ` into this world .
&mut self
src_world
&World
src_entity
Entity
clone_impl
&C
replace_mapping
Option<Entity>
&mut self
src_world
&World
src_entity
Entity
clone_impl
&C
replace_mapping
Option<Entity>