pub struct ComponentCloneCtx<'a, 'b> { /* private fields */ }Expand description
Context for component clone handlers.
Provides fast access to useful resources like AppTypeRegistry
and allows component clone handler to get information about component being cloned.
Implementations§
Source§impl<'a, 'b> ComponentCloneCtx<'a, 'b>
impl<'a, 'b> ComponentCloneCtx<'a, 'b>
Sourcepub fn target_component_written(&self) -> bool
pub fn target_component_written(&self) -> bool
Returns true if write_target_component was called before.
Sourcepub fn component_id(&self) -> ComponentId
pub fn component_id(&self) -> ComponentId
Returns the ComponentId of the component being cloned.
Sourcepub fn component_info(&self) -> &ComponentInfo
pub fn component_info(&self) -> &ComponentInfo
Returns the ComponentInfo of the component being cloned.
Sourcepub fn linked_cloning(&self) -> bool
pub fn linked_cloning(&self) -> bool
Returns true if the EntityCloner is configured to recursively clone entities. When this is enabled,
entities stored in a cloned entity’s RelationshipTarget component with
RelationshipTarget::LINKED_SPAWN will also be cloned.
Sourcepub fn entity_mapper(&mut self) -> &mut dyn EntityMapper
pub fn entity_mapper(&mut self) -> &mut dyn EntityMapper
Returns this context’s EntityMapper.
Sourcepub fn write_target_component<C: Component>(&mut self, component: C)
pub fn write_target_component<C: Component>(&mut self, component: C)
Writes component data to target entity.
§Panics
This will panic if:
- Component has already been written once.
- Component being written is not registered in the world.
ComponentIdof component being written does not match expectedComponentId.
Sourcepub unsafe fn write_target_component_ptr(&mut self, ptr: Ptr<'_>)
pub unsafe fn write_target_component_ptr(&mut self, ptr: Ptr<'_>)
Writes component data to target entity by providing a pointer to source component data.
§Safety
Caller must ensure that the passed in ptr references data that corresponds to the type of the source / target ComponentId.
ptr must also contain data that the written component can “own” (for example, this should not directly copy non-Copy data).
§Panics
This will panic if component has already been written once.
Sourcepub fn queue_entity_clone(&mut self, entity: Entity)
pub fn queue_entity_clone(&mut self, entity: Entity)
Queues the entity to be cloned by the current EntityCloner