Struct bevy_ecs::reflect::ReflectMapEntities
source · 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 SceneEntityMapper and MapEntities for more information.
Implementations§
source§impl ReflectMapEntities
impl ReflectMapEntities
sourcepub fn map_all_entities(
&self,
world: &mut World,
entity_map: &mut EntityHashMap<Entity>
)
pub fn map_all_entities( &self, world: &mut World, entity_map: &mut EntityHashMap<Entity> )
A general method for applying MapEntities behavior to all elements in an EntityHashMap<Entity>.
Be mindful in its usage: Works best in situations where the entities in the EntityHashMap<Entity> are newly
created, before systems have a chance to add new components. If some of the entities referred to
by the EntityHashMap<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.
sourcepub fn map_entities(
&self,
world: &mut World,
entity_map: &mut EntityHashMap<Entity>,
entities: &[Entity]
)
pub fn map_entities( &self, world: &mut World, entity_map: &mut EntityHashMap<Entity>, entities: &[Entity] )
A general method for applying MapEntities behavior to elements in an EntityHashMap<Entity>. Unlike
map_all_entities, this is applied to specific entities, not all values
in the EntityHashMap<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§
source§impl Clone for ReflectMapEntities
impl Clone for ReflectMapEntities
source§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 moresource§impl<C: Component + MapEntities> FromType<C> for ReflectMapEntities
impl<C: Component + MapEntities> FromType<C> for ReflectMapEntities
Auto Trait Implementations§
impl Freeze for ReflectMapEntities
impl RefUnwindSafe for ReflectMapEntities
impl Send for ReflectMapEntities
impl Sync for ReflectMapEntities
impl Unpin for ReflectMapEntities
impl UnwindSafe for ReflectMapEntities
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> 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.