Struct bevy::ecs::reflect::ReflectComponentFns
source · pub struct ReflectComponentFns {
pub insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static), _: &TypeRegistry),
pub apply: fn(_: EntityMut<'_>, _: &(dyn Reflect + 'static)),
pub apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static), _: &TypeRegistry),
pub remove: fn(_: &mut EntityWorldMut<'_>),
pub contains: fn(_: FilteredEntityRef<'_>) -> bool,
pub reflect: fn(_: FilteredEntityRef<'_>) -> Option<&(dyn Reflect + 'static)>,
pub reflect_mut: fn(_: FilteredEntityMut<'_>) -> Option<Mut<'_, dyn Reflect>>,
pub reflect_unchecked_mut: unsafe fn(_: UnsafeEntityCell<'_>) -> Option<Mut<'_, dyn Reflect>>,
pub copy: fn(_: &World, _: &mut World, _: Entity, _: Entity, _: &TypeRegistry),
}Expand description
The raw function pointers needed to make up a ReflectComponent.
This is used when creating custom implementations of ReflectComponent with
ReflectComponent::new().
Note: Creating custom implementations of
ReflectComponentis an advanced feature that most users will not need. Usually aReflectComponentis created for a type by derivingReflectand adding the#[reflect(Component)]attribute. After adding the component to theTypeRegistry, itsReflectComponentcan then be retrieved when needed.
Creating a custom ReflectComponent may be useful if you need to create new component types
at runtime, for example, for scripting implementations.
By creating a custom ReflectComponent and inserting it into a type’s
TypeRegistration,
you can modify the way that reflected components of that type will be inserted into the Bevy
world.
Fields§
§insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static), _: &TypeRegistry)Function pointer implementing ReflectComponent::insert().
apply: fn(_: EntityMut<'_>, _: &(dyn Reflect + 'static))Function pointer implementing ReflectComponent::apply().
apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static), _: &TypeRegistry)Function pointer implementing ReflectComponent::apply_or_insert().
remove: fn(_: &mut EntityWorldMut<'_>)Function pointer implementing ReflectComponent::remove().
contains: fn(_: FilteredEntityRef<'_>) -> boolFunction pointer implementing ReflectComponent::contains().
reflect: fn(_: FilteredEntityRef<'_>) -> Option<&(dyn Reflect + 'static)>Function pointer implementing ReflectComponent::reflect().
reflect_mut: fn(_: FilteredEntityMut<'_>) -> Option<Mut<'_, dyn Reflect>>Function pointer implementing ReflectComponent::reflect_mut().
reflect_unchecked_mut: unsafe fn(_: UnsafeEntityCell<'_>) -> Option<Mut<'_, dyn Reflect>>Function pointer implementing ReflectComponent::reflect_unchecked_mut().
§Safety
The function may only be called with an UnsafeEntityCell that can be used to mutably access the relevant component on the given entity.
copy: fn(_: &World, _: &mut World, _: Entity, _: Entity, _: &TypeRegistry)Function pointer implementing ReflectComponent::copy().
Implementations§
source§impl ReflectComponentFns
impl ReflectComponentFns
sourcepub fn new<T>() -> ReflectComponentFns
pub fn new<T>() -> ReflectComponentFns
Get the default set of ReflectComponentFns for a specific component type using its
FromType implementation.
This is useful if you want to start with the default implementation before overriding some of the functions to create a custom implementation.
Trait Implementations§
source§impl Clone for ReflectComponentFns
impl Clone for ReflectComponentFns
source§fn clone(&self) -> ReflectComponentFns
fn clone(&self) -> ReflectComponentFns
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ReflectComponentFns
impl RefUnwindSafe for ReflectComponentFns
impl Send for ReflectComponentFns
impl Sync for ReflectComponentFns
impl Unpin for ReflectComponentFns
impl UnwindSafe for ReflectComponentFns
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>. 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.