pub(crate) struct Entities {
meta: Vec<Meta>,
free: Vec<u32>,
reserved: usize,
}Expand description
Allocates entity handles and maps them to their row in an archetype.
Fields§
§meta: Vec<Meta>§free: Vec<u32>Indices whose entity is despawned and whose current generation is
already recorded in meta.
reserved: usizeHow many indices are reserved but not spawned. Every reserved index is
flagged in its Meta, so releasing one is a flag flip rather than a
search.
Implementations§
Source§impl Entities
impl Entities
Sourcepub(crate) fn contains(&self, entity: Entity) -> bool
pub(crate) fn contains(&self, entity: Entity) -> bool
Whether the handle refers to a live entity.
Sourcepub(crate) fn location(
&self,
entity: Entity,
) -> Result<Location, EntityAccessError>
pub(crate) fn location( &self, entity: Entity, ) -> Result<Location, EntityAccessError>
Where the entity lives.
A handle whose index was never allocated, whose generation was bumped by
a despawn, or whose index is reserved but not spawned yet answers
EntityAccessError::NotAlive.
Sourcepub(crate) fn set_location(&mut self, entity: Entity, location: Location)
pub(crate) fn set_location(&mut self, entity: Entity, location: Location)
Record where an entity lives, replacing any earlier location.
Panics when the handle is not live: a location is only ever recorded for an entity that was just allocated or reserved.
Sourcepub(crate) fn reserve(&mut self, name: &'static str) -> Entity
pub(crate) fn reserve(&mut self, name: &'static str) -> Entity
Hand out a fresh handle and mark the index as reserved.
Sourcepub(crate) fn alloc(&mut self, name: &'static str) -> Entity
pub(crate) fn alloc(&mut self, name: &'static str) -> Entity
Hand out a handle for a new entity, reusing a free index when possible.
Sourcepub(crate) fn is_reserved(&self, entity: Entity) -> bool
pub(crate) fn is_reserved(&self, entity: Entity) -> bool
Whether the handle came from reserve and has not
been spawned or freed yet.
Sourcepub(crate) fn take_reserved(&mut self, entity: Entity) -> bool
pub(crate) fn take_reserved(&mut self, entity: Entity) -> bool
Mark a reserved handle as spawned.
Returns whether the handle was reserved; a handle that is not is left untouched.