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

source

pub fn add_entity<S>(&mut self, state: S) -> u32where S: ArchetypeState,

Creates a new entity and returns its identifier.

source

pub fn contains(&self, entity_id: ArchEntityId) -> bool

Returns true if the archetype contains the specified entity.

source

pub fn component<C: Component>(&self) -> Option<ComponentStorageRef<'_, C>>

source

pub fn component_mut<C: Component>( &mut self ) -> Option<ComponentStorageMut<'_, C>>

source

pub fn get<C: Component>(&self, entity_id: ArchEntityId) -> Option<&C>

Returns a reference to the component C of the specified entity id.

source

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.

source

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().

source

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().

source

pub fn iter_component_infos(&self) -> impl Iterator<Item = &ComponentInfo>

Returns iterator of archetype constituent components.

source

pub fn count_entities(&self) -> usize

Returns the number of entities in the archetype.

source

pub fn ty(&self) -> &TypeId

Returns the TypeId of a single state in this archetype.

Trait Implementations§

source§

impl Drop for ArchetypeStorage

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Sync for ArchetypeStorage

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Component for Twhere T: Send + Sync + 'static,