pub struct Archetype { /* private fields */ }Expand description
Metadata for a single archetype within a World.
For more information, see the module level documentation.
Implementations§
Source§impl Archetype
impl Archetype
Sourcepub fn id(&self) -> ArchetypeId
pub fn id(&self) -> ArchetypeId
Fetches the ID for the archetype.
Sourcepub fn entities(&self) -> &[ArchetypeEntity]
pub fn entities(&self) -> &[ArchetypeEntity]
Fetches the entities contained in this archetype.
Sourcepub fn entities_with_location(
&self,
) -> impl Iterator<Item = (Entity, EntityLocation)>
pub fn entities_with_location( &self, ) -> impl Iterator<Item = (Entity, EntityLocation)>
Fetches the entities contained in this archetype.
Sourcepub fn table_components(&self) -> impl Iterator<Item = ComponentId> + '_
pub fn table_components(&self) -> impl Iterator<Item = ComponentId> + '_
Gets an iterator of all of the components stored in Tables.
All of the IDs are unique.
Sourcepub fn sparse_set_components(&self) -> impl Iterator<Item = ComponentId> + '_
pub fn sparse_set_components(&self) -> impl Iterator<Item = ComponentId> + '_
Gets an iterator of all of the components stored in ComponentSparseSets.
All of the IDs are unique.
Sourcepub fn components(&self) -> &[ComponentId]
pub fn components(&self) -> &[ComponentId]
Returns a slice of all of the components in the archetype.
All of the IDs are unique.
Sourcepub fn iter_components(&self) -> impl Iterator<Item = ComponentId> + Clone
pub fn iter_components(&self) -> impl Iterator<Item = ComponentId> + Clone
Gets an iterator of all of the components in the archetype.
All of the IDs are unique.
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Returns the total number of components in the archetype
Sourcepub fn edges(&self) -> &Edges
pub fn edges(&self) -> &Edges
Fetches an immutable reference to the archetype’s Edges, a cache of
archetypal relationships.
Sourcepub fn entity_table_row(&self, row: ArchetypeRow) -> TableRow
pub fn entity_table_row(&self, row: ArchetypeRow) -> TableRow
Fetches the row in the Table where the components for the entity at index
is stored.
An entity’s archetype row can be fetched from EntityLocation::archetype_row, which
can be retrieved from Entities::get.
§Panics
This function will panic if index >= self.len().
Sourcepub fn contains(&self, component_id: ComponentId) -> bool
pub fn contains(&self, component_id: ComponentId) -> bool
Checks if the archetype contains a specific component. This runs in O(1) time.
Sourcepub fn get_storage_type(&self, component_id: ComponentId) -> Option<StorageType>
pub fn get_storage_type(&self, component_id: ComponentId) -> Option<StorageType>
Gets the type of storage where a component in the archetype can be found.
Returns None if the component is not part of the archetype.
This runs in O(1) time.
Sourcepub fn has_add_hook(&self) -> bool
pub fn has_add_hook(&self) -> bool
Returns true if any of the components in this archetype have on_add hooks
Sourcepub fn has_insert_hook(&self) -> bool
pub fn has_insert_hook(&self) -> bool
Returns true if any of the components in this archetype have on_insert hooks
Sourcepub fn has_replace_hook(&self) -> bool
pub fn has_replace_hook(&self) -> bool
Returns true if any of the components in this archetype have on_replace hooks
Sourcepub fn has_remove_hook(&self) -> bool
pub fn has_remove_hook(&self) -> bool
Returns true if any of the components in this archetype have on_remove hooks
Sourcepub fn has_despawn_hook(&self) -> bool
pub fn has_despawn_hook(&self) -> bool
Returns true if any of the components in this archetype have on_despawn hooks
Sourcepub fn has_add_observer(&self) -> bool
pub fn has_add_observer(&self) -> bool
Returns true if any of the components in this archetype have at least one Add observer
Sourcepub fn has_insert_observer(&self) -> bool
pub fn has_insert_observer(&self) -> bool
Returns true if any of the components in this archetype have at least one Insert observer
Sourcepub fn has_replace_observer(&self) -> bool
pub fn has_replace_observer(&self) -> bool
Returns true if any of the components in this archetype have at least one Replace observer
Sourcepub fn has_remove_observer(&self) -> bool
pub fn has_remove_observer(&self) -> bool
Returns true if any of the components in this archetype have at least one Remove observer
Sourcepub fn has_despawn_observer(&self) -> bool
pub fn has_despawn_observer(&self) -> bool
Returns true if any of the components in this archetype have at least one Despawn observer
Trait Implementations§
Source§impl QueryData for &Archetype
SAFETY: Self is the same as Self::ReadOnly
impl QueryData for &Archetype
SAFETY: Self is the same as Self::ReadOnly
Source§const IS_READ_ONLY: bool = true
const IS_READ_ONLY: bool = true
Source§type ReadOnly = &Archetype
type ReadOnly = &Archetype
QueryData, which satisfies the ReadOnlyQueryData trait.Source§type Item<'w, 's> = &'w Archetype
type Item<'w, 's> = &'w Archetype
WorldQuery
This will be the data retrieved by the query,
and is visible to the end user when calling e.g. Query<Self>::get.Source§fn shrink<'wlong: 'wshort, 'wshort, 's>(
item: Self::Item<'wlong, 's>,
) -> Self::Item<'wshort, 's>
fn shrink<'wlong: 'wshort, 'wshort, 's>( item: Self::Item<'wlong, 's>, ) -> Self::Item<'wshort, 's>
Source§unsafe fn fetch<'w, 's>(
_state: &'s Self::State,
fetch: &mut Self::Fetch<'w>,
entity: Entity,
_table_row: TableRow,
) -> Self::Item<'w, 's>
unsafe fn fetch<'w, 's>( _state: &'s Self::State, fetch: &mut Self::Fetch<'w>, entity: Entity, _table_row: TableRow, ) -> Self::Item<'w, 's>
Self::Item for either the given entity in the current Table,
or for the given entity in the current Archetype. This must always be called after
WorldQuery::set_table with a table_row in the range of the current Table or after
WorldQuery::set_archetype with an entity in the current archetype.
Accesses components registered in WorldQuery::update_component_access. Read moreSource§fn provide_extra_access(
_state: &mut Self::State,
_access: &mut Access,
_available_access: &Access,
)
fn provide_extra_access( _state: &mut Self::State, _access: &mut Access, _available_access: &Access, )
update_component_access.
Implementations may add additional access that is a subset of available_access
and does not conflict with anything in access,
and must update access to include that access. Read moreSource§impl ReleaseStateQueryData for &Archetype
impl ReleaseStateQueryData for &Archetype
Source§fn release_state<'w>(item: Self::Item<'w, '_>) -> Self::Item<'w, 'static>
fn release_state<'w>(item: Self::Item<'w, '_>) -> Self::Item<'w, 'static>
'static state lifetime.Source§impl WorldQuery for &Archetype
SAFETY:
update_component_access does nothing.
This is sound because fetch does not access components.
impl WorldQuery for &Archetype
SAFETY:
update_component_access does nothing.
This is sound because fetch does not access components.
Source§const IS_DENSE: bool = true
const IS_DENSE: bool = true
Source§type Fetch<'w> = (&'w Entities, &'w Archetypes)
type Fetch<'w> = (&'w Entities, &'w Archetypes)
WorldQuery to compute Self::Item for each entity.Source§type State = ()
type State = ()
Self::Fetch. This will be cached inside QueryState,
so it is best to move as much data / computation here as possible to reduce the cost of
constructing Self::Fetch.Source§fn shrink_fetch<'wlong: 'wshort, 'wshort>(
fetch: Self::Fetch<'wlong>,
) -> Self::Fetch<'wshort>
fn shrink_fetch<'wlong: 'wshort, 'wshort>( fetch: Self::Fetch<'wlong>, ) -> Self::Fetch<'wshort>
Source§unsafe fn init_fetch<'w, 's>(
world: UnsafeWorldCell<'w>,
_state: &'s Self::State,
_last_run: Tick,
_this_run: Tick,
) -> Self::Fetch<'w>
unsafe fn init_fetch<'w, 's>( world: UnsafeWorldCell<'w>, _state: &'s Self::State, _last_run: Tick, _this_run: Tick, ) -> Self::Fetch<'w>
Self::Fetch,
by combining data from the World with the cached Self::State.
Readonly accesses resources registered in WorldQuery::update_component_access. Read moreSource§unsafe fn set_archetype<'w, 's>(
_fetch: &mut Self::Fetch<'w>,
_state: &'s Self::State,
_archetype: &'w Archetype,
_table: &Table,
)
unsafe fn set_archetype<'w, 's>( _fetch: &mut Self::Fetch<'w>, _state: &'s Self::State, _archetype: &'w Archetype, _table: &Table, )
Archetype. This will always be called on
archetypes that match this WorldQuery. Read moreSource§unsafe fn set_table<'w, 's>(
_fetch: &mut Self::Fetch<'w>,
_state: &'s Self::State,
_table: &'w Table,
)
unsafe fn set_table<'w, 's>( _fetch: &mut Self::Fetch<'w>, _state: &'s Self::State, _table: &'w Table, )
Table. This will always be called on tables
that match this WorldQuery. Read moreSource§fn update_component_access(_state: &Self::State, _access: &mut FilteredAccess)
fn update_component_access(_state: &Self::State, _access: &mut FilteredAccess)
Source§fn init_state(_world: &mut World)
fn init_state(_world: &mut World)
State for this WorldQuery type.Source§fn matches_component_set(
_state: &Self::State,
_set_contains_id: &impl Fn(ComponentId) -> bool,
) -> bool
fn matches_component_set( _state: &Self::State, _set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool
impl ReadOnlyQueryData for &Archetype
SAFETY: access is read only