pub struct Entities { /* private fields */ }Expand description
Entities tracks all known EntityIndexs and their metadata.
This is like a base table of information all entities have.
Implementations§
Source§impl Entities
impl Entities
Sourcepub fn get_spawned(
&self,
entity: Entity,
) -> Result<EntityLocation, EntityNotSpawnedError>
pub fn get_spawned( &self, entity: Entity, ) -> Result<EntityLocation, EntityNotSpawnedError>
Returns the EntityLocation of an Entity if it is valid and spawned.
This will return an error if the EntityGeneration of this entity has passed or if the EntityIndex is not spawned.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn get(
&self,
entity: Entity,
) -> Result<Option<EntityLocation>, InvalidEntityError>
pub fn get( &self, entity: Entity, ) -> Result<Option<EntityLocation>, InvalidEntityError>
Returns the EntityLocation of an Entity if it is valid.
The location will be None if the entity is not spawned.
If you expect the entity to be spawned, use get_spawned.
This will fail if the Entity is not valid (ex: the generation is mismatched).
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn resolve_from_index(&self, index: EntityIndex) -> Entity
pub fn resolve_from_index(&self, index: EntityIndex) -> Entity
Get the Entity for the given EntityIndex.
Note that this entity may not be spawned yet.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn is_index_spawned(&self, index: EntityIndex) -> bool
pub fn is_index_spawned(&self, index: EntityIndex) -> bool
Returns whether the entity at this index is spawned or not.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn contains(&self, entity: Entity) -> bool
pub fn contains(&self, entity: Entity) -> bool
Returns true if the entity is valid. This will return true for entities that are valid but have not been spawned.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn contains_spawned(&self, entity: Entity) -> bool
pub fn contains_spawned(&self, entity: Entity) -> bool
Returns true if the entity is valid and is spawned.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn check_can_spawn_at(&self, entity: Entity) -> Result<(), SpawnError>
pub fn check_can_spawn_at(&self, entity: Entity) -> Result<(), SpawnError>
Provides information regarding if entity may be safely spawned.
This can error if the entity is invalid or is already spawned.
See the module docs for a full explanation of these ids, entity life cycles, and the meaning of this result.
Sourcepub fn entity_get_spawned_or_despawned_by(
&self,
entity: Entity,
) -> MaybeLocation<Option<&'static Location<'static>>>
pub fn entity_get_spawned_or_despawned_by( &self, entity: Entity, ) -> MaybeLocation<Option<&'static Location<'static>>>
Try to get the source code location from which this entity has last been spawned or despawned.
Returns None if the entity does not exist or has never been construced/despawned.
Sourcepub fn entity_get_spawn_or_despawn_tick(&self, entity: Entity) -> Option<Tick>
pub fn entity_get_spawn_or_despawn_tick(&self, entity: Entity) -> Option<Tick>
Try to get the Tick at which this entity has last been spawned or despawned.
Returns None if the entity does not exist or has never been construced/despawned.
Sourcepub fn len(&self) -> u32
pub fn len(&self) -> u32
The count of currently allocated entity indices.
For information on active entities, see Self::count_spawned.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if any entity has been declared.
For information on active entities, see Self::any_spawned.
Sourcepub fn count_spawned(&self) -> u32
pub fn count_spawned(&self) -> u32
Counts the number of entity indices currently spawned. See the module docs for a more precise explanation of what spawning means. Be aware that this is O(n) and is intended only to be used as a diagnostic for tests.
Sourcepub fn any_spawned(&self) -> bool
pub fn any_spawned(&self) -> bool
Returns true if there are any entity indices currently spawned. See the module docs for a more precise explanation of what spawning means.
Trait Implementations§
Source§impl<'a> SystemParam for &'a Entities
impl<'a> SystemParam for &'a Entities
Source§type Item<'w, 's> = &'w Entities
type Item<'w, 's> = &'w Entities
Self, instantiated with new lifetimes. Read moreSource§fn init_state(_world: &mut World) -> Self::State
fn init_state(_world: &mut World) -> Self::State
State.Source§fn init_access(
_state: &Self::State,
_system_meta: &mut SystemMeta,
_component_access_set: &mut FilteredAccessSet,
_world: &mut World,
)
fn init_access( _state: &Self::State, _system_meta: &mut SystemMeta, _component_access_set: &mut FilteredAccessSet, _world: &mut World, )
World access used by this SystemParamSource§unsafe fn get_param<'w, 's>(
_state: &'s mut Self::State,
_system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
_change_tick: Tick,
) -> Self::Item<'w, 's>
unsafe fn get_param<'w, 's>( _state: &'s mut Self::State, _system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, _change_tick: Tick, ) -> Self::Item<'w, 's>
SystemParamFunction. Read moreSource§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
SystemParam’s state.
This is used to apply Commands during ApplyDeferred.Source§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>,
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )
ApplyDeferred.Source§unsafe fn validate_param(
state: &mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'_>,
) -> Result<(), SystemParamValidationError>
unsafe fn validate_param( state: &mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'_>, ) -> Result<(), SystemParamValidationError>
impl<'a> ReadOnlySystemParam for &'a Entities
Auto Trait Implementations§
impl Freeze for Entities
impl RefUnwindSafe for Entities
impl Send for Entities
impl Sync for Entities
impl Unpin for Entities
impl UnwindSafe for Entities
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§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.