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>(&mut self, component: C)where
    C: Component,
 
pub fn write_target_component<C>(&mut self, component: C)where
    C: Component,
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 expected- ComponentId.
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 write_target_component_reflect(&mut self, component: Box<dyn Reflect>)
 
pub fn write_target_component_reflect(&mut self, component: Box<dyn Reflect>)
Writes component data to target entity.
§Panics
This will panic if:
- World does not have AppTypeRegistry.
- Component does not implement ReflectFromPtr.
- Source component does not have TypeId.
- Passed component’s TypeIddoes not match source componentTypeId.
- Component has already been written once.
Sourcepub fn type_registry(&self) -> Option<&AppTypeRegistry>
 
pub fn type_registry(&self) -> Option<&AppTypeRegistry>
Returns AppTypeRegistry if it exists in the world.
NOTE: Prefer this method instead of manually reading the resource from the world.
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
Sourcepub fn queue_deferred(
    &mut self,
    deferred: impl FnOnce(&mut World, &mut dyn EntityMapper) + 'static,
)
 
pub fn queue_deferred( &mut self, deferred: impl FnOnce(&mut World, &mut dyn EntityMapper) + 'static, )
Auto Trait Implementations§
impl<'a, 'b> Freeze for ComponentCloneCtx<'a, 'b>
impl<'a, 'b> !RefUnwindSafe for ComponentCloneCtx<'a, 'b>
impl<'a, 'b> !Send for ComponentCloneCtx<'a, 'b>
impl<'a, 'b> !Sync for ComponentCloneCtx<'a, 'b>
impl<'a, 'b> Unpin for ComponentCloneCtx<'a, 'b>
impl<'a, 'b> !UnwindSafe for ComponentCloneCtx<'a, 'b>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
 
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
 
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T, W> HasTypeWitness<W> for Twhere
    W: MakeTypeWitness<Arg = T>,
    T: ?Sized,
 
impl<T, W> HasTypeWitness<W> for Twhere
    W: MakeTypeWitness<Arg = T>,
    T: ?Sized,
Source§impl<T> Identity for Twhere
    T: ?Sized,
 
impl<T> Identity for Twhere
    T: ?Sized,
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
 
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
 
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more