pub struct ArchetypeDescriptor { /* private fields */ }
Expand description
Represents a combination of components.
Each component type MUST be unique (i.e. no duplicate component types).
Length must be larger than 0 and lower or equal to MAX_COMPONENTS_PER_ENTITY
.
Use the ArchetypeDescriptor::is_valid
function to check for validity.
Any use of an invalid archetype descriptor is considered UB.
Implementations
sourceimpl ArchetypeDescriptor
impl ArchetypeDescriptor
sourcepub const INVALID: ArchetypeDescriptor = _
pub const INVALID: ArchetypeDescriptor = _
The invalid archetype descriptor. Has 0 components and an ArchetypeId of 0.
sourcepub const fn is_valid(&self) -> bool
pub const fn is_valid(&self) -> bool
Returns true if it is a valid archetype.
A valid archetype has a length larger than 0 and smaller than MAX_COMPONENTS_PER_ENTITY
.
It also contains no duplicate components.
sourcepub const fn new(
archetype_id: ArchetypeId,
len: u8,
components: [ComponentDescriptor; 14]
) -> Self
pub const fn new(
archetype_id: ArchetypeId,
len: u8,
components: [ComponentDescriptor; 14]
) -> Self
Creates a new archetype descriptor with the given id, length and components.
sourcepub const fn compute_archetype_id(
descriptors: &[ComponentDescriptor]
) -> ArchetypeId
pub const fn compute_archetype_id(
descriptors: &[ComponentDescriptor]
) -> ArchetypeId
Computes an archetype ID, returns ArchetypeId::INVALID
if given an invalid combination of components.
sourcepub const fn contains_subset(&self, descriptor: &ArchetypeDescriptor) -> bool
pub const fn contains_subset(&self, descriptor: &ArchetypeDescriptor) -> bool
Returns whether the descriptor provided is contained in self. (i.e. subset inclusion) Do not provide an invalid descriptor to this!
sourcepub const fn excludes_subset(&self, descriptor: &ArchetypeDescriptor) -> bool
pub const fn excludes_subset(&self, descriptor: &ArchetypeDescriptor) -> bool
Returns whether the descriptor provided is excluded from self. (i.e. subset exclusion) Do not provide an invalid descriptor to this!
sourcepub fn add_component_from<C: Component>(&self) -> Option<ArchetypeDescriptor>
pub fn add_component_from<C: Component>(&self) -> Option<ArchetypeDescriptor>
Returns a new archetype with the given component type added to it. Returns none if the current archetype already contains the component type or it is full.
sourcepub fn add_component(
&self,
component_descriptor: &ComponentDescriptor
) -> Option<ArchetypeDescriptor>
pub fn add_component(
&self,
component_descriptor: &ComponentDescriptor
) -> Option<ArchetypeDescriptor>
Returns a new archetype with the given component type added to it. Returns none if the current archetype already contains the component type or it is full.
pub fn remove_component(
&self,
component: ComponentTypeId
) -> Option<ArchetypeDescriptor>
sourcepub fn has_component<C: Component>(&self) -> bool
pub fn has_component<C: Component>(&self) -> bool
Returns whether the archetype descriptor has a given component type.
sourcepub const fn archetype_id(&self) -> ArchetypeId
pub const fn archetype_id(&self) -> ArchetypeId
Get a the archetype descriptor’s archetype id.
sourcepub const unsafe fn components_unchecked(&self) -> &[ComponentDescriptor; 14]
pub const unsafe fn components_unchecked(&self) -> &[ComponentDescriptor; 14]
Get a reference to the archetype descriptor’s components. This version is const but unsafe, as length is NOT accounted for. Therefore any descriptor past the len is considered invalid or garbage data.
Safety
Data outside of the valid component descriptor range must not be modified.
sourcepub fn components(&self) -> &[ComponentDescriptor]
pub fn components(&self) -> &[ComponentDescriptor]
Get a reference to the archetype descriptor’s components.
Trait Implementations
sourceimpl Clone for ArchetypeDescriptor
impl Clone for ArchetypeDescriptor
sourcefn clone(&self) -> ArchetypeDescriptor
fn clone(&self) -> ArchetypeDescriptor
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more