pub struct Archetype { /* private fields */ }
Expand description
A collection of entities having the same component types
Accessing Archetype
s is only required in niche cases. Typical use should go through the
World
.
Implementations§
source§impl Archetype
impl Archetype
sourcepub fn has_dynamic(&self, id: TypeId) -> bool
pub fn has_dynamic(&self, id: TypeId) -> bool
Whether this archetype contains components with the type identified by id
sourcepub fn get<'a, T>(&'a self) -> Option<<T as ComponentRef<'a>>::Column>where
T: ComponentRef<'a>,
pub fn get<'a, T>(&'a self) -> Option<<T as ComponentRef<'a>>::Column>where T: ComponentRef<'a>,
Borrow all components of a single type from these entities, if present
T
must be a shared or unique reference to a component type.
Useful for efficient serialization.
sourcepub fn component_types(&self) -> impl ExactSizeIterator
pub fn component_types(&self) -> impl ExactSizeIterator
Enumerate the types of the components of entities stored in this archetype.
Convenient for dispatching logic which needs to be performed on sets of type ids. For
example, suppose you’re building a scripting system, and you want to integrate the scripting
language with your ECS. This functionality allows you to iterate through all of the
archetypes of the world with World::archetypes()
and extract
all possible combinations of component types which are currently stored in the World
.
From there, you can then create a mapping of archetypes to wrapper objects for your
scripting language that provide functionality based off of the components of any given
Entity
, and bind them onto an Entity
when passed into your scripting language by
looking up the Entity
’s archetype using
EntityRef::component_types
.
sourcepub fn access<Q>(&self) -> Option<Access>where
Q: Query,
pub fn access<Q>(&self) -> Option<Access>where Q: Query,
How, if at all, Q
will access entities in this archetype
sourcepub fn ids(&self) -> &[u32]
pub fn ids(&self) -> &[u32]
Raw IDs of the entities in this archetype
Convertible into Entity
s with
World::find_entity_from_id()
. Useful for efficient
serialization.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Archetype
impl !Send for Archetype
impl !Sync for Archetype
impl Unpin for Archetype
impl UnwindSafe for Archetype
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.