pub struct ReflectComponentFns {
pub insert: fn(_: &mut EntityWorldMut<'_>, _: &dyn Reflect, _: &TypeRegistry),
pub apply: fn(_: EntityMut<'_>, _: &dyn Reflect),
pub apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &dyn Reflect, _: &TypeRegistry),
pub remove: fn(_: &mut EntityWorldMut<'_>),
pub contains: fn(_: FilteredEntityRef<'_>) -> bool,
pub reflect: fn(_: FilteredEntityRef<'_>) -> Option<&dyn Reflect>,
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),
}
bevy_reflect
only.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
ReflectComponent
is an advanced feature that most users will not need. Usually aReflectComponent
is created for a type by derivingReflect
and adding the#[reflect(Component)]
attribute. After adding the component to theTypeRegistry
, itsReflectComponent
can 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, _: &TypeRegistry)
Function pointer implementing ReflectComponent::insert()
.
apply: fn(_: EntityMut<'_>, _: &dyn Reflect)
Function pointer implementing ReflectComponent::apply()
.
apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &dyn Reflect, _: &TypeRegistry)
Function pointer implementing ReflectComponent::apply_or_insert()
.
remove: fn(_: &mut EntityWorldMut<'_>)
Function pointer implementing ReflectComponent::remove()
.
contains: fn(_: FilteredEntityRef<'_>) -> bool
Function pointer implementing ReflectComponent::contains()
.
reflect: fn(_: FilteredEntityRef<'_>) -> Option<&dyn Reflect>
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: Component + Reflect + FromReflect>() -> Self
pub fn new<T: Component + Reflect + FromReflect>() -> Self
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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.