Struct entity_data::archetype::ArchetypeStorage
source · pub struct ArchetypeStorage { /* private fields */ }
Expand description
A collection of entities with unique combination of components. An archetype can hold a maximum of 2^32-1 entities.
Implementations§
source§impl ArchetypeStorage
impl ArchetypeStorage
sourcepub fn add_entity<S>(&mut self, state: S) -> u32where
S: ArchetypeState,
pub fn add_entity<S>(&mut self, state: S) -> u32where S: ArchetypeState,
Creates a new entity and returns its identifier.
sourcepub fn contains(&self, entity_id: ArchEntityId) -> bool
pub fn contains(&self, entity_id: ArchEntityId) -> bool
Returns true
if the archetype contains the specified entity.
pub fn component<C: Component>(&self) -> Option<ComponentStorageRef<'_, C>>
pub fn component_mut<C: Component>( &mut self ) -> Option<ComponentStorageMut<'_, C>>
sourcepub fn get<C: Component>(&self, entity_id: ArchEntityId) -> Option<&C>
pub fn get<C: Component>(&self, entity_id: ArchEntityId) -> Option<&C>
Returns a reference to the component C
of the specified entity id.
sourcepub fn get_mut<C: Component>(
&mut self,
entity_id: ArchEntityId
) -> Option<&mut C>
pub fn get_mut<C: Component>( &mut self, entity_id: ArchEntityId ) -> Option<&mut C>
Returns a mutable reference to the component C
of the specified entity id.
sourcepub fn get_state<S: StaticArchetype>(
&self,
entity_id: ArchEntityId
) -> Option<&S>
pub fn get_state<S: StaticArchetype>( &self, entity_id: ArchEntityId ) -> Option<&S>
Returns a reference to the state at entity_id
.
Panics if TypeId
of S
!= self.ty()
.
sourcepub fn get_state_mut<S: StaticArchetype>(
&mut self,
entity_id: ArchEntityId
) -> Option<&mut S>
pub fn get_state_mut<S: StaticArchetype>( &mut self, entity_id: ArchEntityId ) -> Option<&mut S>
Returns a mutable reference to the state at entity_id
.
Panics if TypeId
of S
!= self.ty()
.
sourcepub fn iter_component_infos(&self) -> impl Iterator<Item = &ComponentInfo>
pub fn iter_component_infos(&self) -> impl Iterator<Item = &ComponentInfo>
Returns iterator of archetype constituent components.
sourcepub fn count_entities(&self) -> usize
pub fn count_entities(&self) -> usize
Returns the number of entities in the archetype.
Trait Implementations§
source§impl Drop for ArchetypeStorage
impl Drop for ArchetypeStorage
impl Sync for ArchetypeStorage
Auto Trait Implementations§
impl !RefUnwindSafe for ArchetypeStorage
impl Send for ArchetypeStorage
impl Unpin for ArchetypeStorage
impl UnwindSafe for ArchetypeStorage
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