Struct bevy::ecs::reflect::ReflectMapEntities
pub struct ReflectMapEntities { /* private fields */ }
Expand description
For a specific type of component, this maps any fields with values of type Entity
to a new world.
Since a given Entity
ID is only valid for the world it came from, when performing deserialization
any stored IDs need to be re-allocated in the destination world.
See MapEntities
for more information.
Implementations§
§impl ReflectMapEntities
impl ReflectMapEntities
pub fn map_all_entities(
&self,
world: &mut World,
entity_map: &mut HashMap<Entity, Entity, EntityHash, Global>
)
pub fn map_all_entities( &self, world: &mut World, entity_map: &mut HashMap<Entity, Entity, EntityHash, Global> )
A general method for applying MapEntities
behavior to all elements in an EntityHashMap<Entity, Entity>
.
Be mindful in its usage: Works best in situations where the entities in the EntityHashMap<Entity, Entity>
are newly
created, before systems have a chance to add new components. If some of the entities referred to
by the EntityHashMap<Entity, Entity>
might already contain valid entity references, you should use map_entities
.
An example of this: A scene can be loaded with Parent
components, but then a Parent
component can be added
to these entities after they have been loaded. If you reload the scene using map_all_entities
, those Parent
components with already valid entity references could be updated to point at something else entirely.
pub fn map_entities(
&self,
world: &mut World,
entity_map: &mut HashMap<Entity, Entity, EntityHash, Global>,
entities: &[Entity]
)
pub fn map_entities( &self, world: &mut World, entity_map: &mut HashMap<Entity, Entity, EntityHash, Global>, entities: &[Entity] )
A general method for applying MapEntities
behavior to elements in an EntityHashMap<Entity, Entity>
. Unlike
map_all_entities
, this is applied to specific entities, not all values
in the EntityHashMap<Entity, Entity>
.
This is useful mostly for when you need to be careful not to update components that already contain valid entity
values. See map_all_entities
for more details.
Trait Implementations§
§impl Clone for ReflectMapEntities
impl Clone for ReflectMapEntities
§fn clone(&self) -> ReflectMapEntities
fn clone(&self) -> ReflectMapEntities
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<C> FromType<C> for ReflectMapEntitieswhere
C: Component + MapEntities,
impl<C> FromType<C> for ReflectMapEntitieswhere C: Component + MapEntities,
fn from_type() -> ReflectMapEntities
Auto Trait Implementations§
impl RefUnwindSafe for ReflectMapEntities
impl Send for ReflectMapEntities
impl Sync for ReflectMapEntities
impl Unpin for ReflectMapEntities
impl UnwindSafe for ReflectMapEntities
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.