[][src]Trait legion::world::CloneImpl

pub trait CloneImpl {
    fn map_component_type(
        &self,
        component_type_id: ComponentTypeId
    ) -> (ComponentTypeId, ComponentMeta);
fn clone_components(
        &self,
        src_world: &World,
        src_component_storage: &ComponentStorage,
        src_component_storage_indexes: Range<ComponentIndex>,
        src_type: ComponentTypeId,
        src_entities: &[Entity],
        dst_entities: &[Entity],
        src_data: *const u8,
        dst_data: *mut u8,
        num_components: usize
    ); }

Describes how to handle a clone_from. Allows the user to transform components from one type to another and provide their own implementation for cloning/transforming

Required methods

fn map_component_type(
    &self,
    component_type_id: ComponentTypeId
) -> (ComponentTypeId, ComponentMeta)

When a component of the provided component_type is encountered, we will transfer data from it into the returned component type. For a basic clone implementation, this function should return the same type as was passed into it

fn clone_components(
    &self,
    src_world: &World,
    src_component_storage: &ComponentStorage,
    src_component_storage_indexes: Range<ComponentIndex>,
    src_type: ComponentTypeId,
    src_entities: &[Entity],
    dst_entities: &[Entity],
    src_data: *const u8,
    dst_data: *mut u8,
    num_components: usize
)

When called, the implementation should copy the data from src_data to dst_data. The src_world and src_entities are provided so that other components on the same Entity can be looked up. The dst_resources are provided so that any required side effects to resources (like registering a physics body into a physics engine) can be implemented.

Loading content...

Implementors

Loading content...