pub struct EntityStore { /* private fields */ }Expand description
A wrapper around a vector of entities.
Implementations§
Source§impl EntityStore
impl EntityStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new EntityStore, allocating the exact number of slots as there are
registered Entitys.
This method assumes all types implementing Entity have been implemented correctly.
This is one of the pitfalls of this pattern: there is no guarantee that types
implementing Entity followed the rules. We can have at least some confidence,
though, in their correctness by supplying a correct implementation via a macro.
Sourcepub fn get<E: Entity>(&self) -> &E
pub fn get<E: Entity>(&self) -> &E
Fetches an immutable reference to the entity E from the registry. This
implementation lazily instantiates the item if it has not yet been instantiated.
Sourcepub fn get_mut<E: Entity>(&mut self) -> &mut E
pub fn get_mut<E: Entity>(&mut self) -> &mut E
Fetches a mutable reference to the item E from the registry. This
implementation lazily instantiates the item if it has not yet been instantiated.
Sourcepub fn get_entity_count<E: Entity>(&self) -> usize
pub fn get_entity_count<E: Entity>(&self) -> usize
Returns a total count of all created entities of type E.
Sourcepub fn get_entity_count_by_id(&self, id: usize) -> usize
pub fn get_entity_count_by_id(&self, id: usize) -> usize
Returns a total count of all created entities of type E.
Sourcepub fn get_entity_iterator<E: Entity>(&self) -> PopulationIterator<E> ⓘ
pub fn get_entity_iterator<E: Entity>(&self) -> PopulationIterator<E> ⓘ
Returns an iterator over all valid EntityId<E>s