pub struct EntityId {
pub index: u32,
pub generation: u32,
}
Expand description
A unique identifier for an entity in the world.
It combines an index with a generation count to solve the “ABA problem”.
When an entity is despawned, its index can be recycled for a new entity,
but the generation is incremented. This ensures that old EntityId
handles
pointing to a recycled index become invalid and cannot accidentally affect
the new entity.
Fields§
§index: u32
The index of the entity’s metadata in the central Vec<EntityMetadata>
.
generation: u32
A generation counter that is incremented each time the index is recycled.
Trait Implementations§
Source§impl WorldQuery for EntityId
impl WorldQuery for EntityId
Source§type Item<'a> = EntityId
type Item<'a> = EntityId
The type of item that the query iterator will yield (e.g.,
(&'a Position, &'a mut Velocity)
).Source§fn type_ids() -> Vec<TypeId>
fn type_ids() -> Vec<TypeId>
Returns the sorted list of
TypeId
s for the components to be INCLUDED in the query.
This signature is used to find ComponentPage
s that contain all these components.Source§unsafe fn fetch<'a>(
page_ptr: *const ComponentPage,
row_index: usize,
) -> Self::Item<'a>
unsafe fn fetch<'a>( page_ptr: *const ComponentPage, row_index: usize, ) -> Self::Item<'a>
Fetches the query’s item from a specific row in a
ComponentPage
. Read moreSource§fn without_type_ids() -> Vec<TypeId>
fn without_type_ids() -> Vec<TypeId>
Returns the sorted list of
TypeId
s for components to be EXCLUDED from the query.
Used to filter out pages that contain these components.impl Copy for EntityId
impl Eq for EntityId
impl StructuralPartialEq for EntityId
Auto Trait Implementations§
impl Freeze for EntityId
impl RefUnwindSafe for EntityId
impl Send for EntityId
impl Sync for EntityId
impl Unpin for EntityId
impl UnwindSafe for EntityId
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
Mutably borrows from an owned value. Read more