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§const IS_ARCHETYPAL: bool = true
const IS_ARCHETYPAL: 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, 's>(
item: <&Archetype as QueryData>::Item<'wlong, 's>,
) -> <&Archetype as QueryData>::Item<'wshort, 's>where
'wlong: 'wshort,
fn shrink<'wlong, 'wshort, 's>(
item: <&Archetype as QueryData>::Item<'wlong, 's>,
) -> <&Archetype as QueryData>::Item<'wshort, 's>where
'wlong: 'wshort,
Source§unsafe fn fetch<'w, 's>(
_state: &'s <&Archetype as WorldQuery>::State,
fetch: &mut <&Archetype as WorldQuery>::Fetch<'w>,
entity: Entity,
_table_row: TableRow,
) -> Option<<&Archetype as QueryData>::Item<'w, 's>>
unsafe fn fetch<'w, 's>( _state: &'s <&Archetype as WorldQuery>::State, fetch: &mut <&Archetype as WorldQuery>::Fetch<'w>, entity: Entity, _table_row: TableRow, ) -> Option<<&Archetype as QueryData>::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 iter_access(
_state: &<&Archetype as WorldQuery>::State,
) -> impl Iterator<Item = EcsAccessType<'_>>
fn iter_access( _state: &<&Archetype as WorldQuery>::State, ) -> impl Iterator<Item = EcsAccessType<'_>>
QueryData::fetch. Access conflicts are usually
checked in WorldQuery::update_component_access, but in certain cases this method can be useful to implement
a way of checking for access conflicts in a non-allocating way.Source§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§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>(
fetch: <&Archetype as WorldQuery>::Fetch<'wlong>,
) -> <&Archetype as WorldQuery>::Fetch<'wshort>where
'wlong: 'wshort,
fn shrink_fetch<'wlong, 'wshort>(
fetch: <&Archetype as WorldQuery>::Fetch<'wlong>,
) -> <&Archetype as WorldQuery>::Fetch<'wshort>where
'wlong: 'wshort,
Source§unsafe fn init_fetch<'w, 's>(
world: UnsafeWorldCell<'w>,
_state: &'s <&Archetype as WorldQuery>::State,
_last_run: Tick,
_this_run: Tick,
) -> <&Archetype as WorldQuery>::Fetch<'w>
unsafe fn init_fetch<'w, 's>( world: UnsafeWorldCell<'w>, _state: &'s <&Archetype as WorldQuery>::State, _last_run: Tick, _this_run: Tick, ) -> <&Archetype as WorldQuery>::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 <&Archetype as WorldQuery>::Fetch<'w>,
_state: &'s <&Archetype as WorldQuery>::State,
_archetype: &'w Archetype,
_table: &Table,
)
unsafe fn set_archetype<'w, 's>( _fetch: &mut <&Archetype as WorldQuery>::Fetch<'w>, _state: &'s <&Archetype as WorldQuery>::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 <&Archetype as WorldQuery>::Fetch<'w>,
_state: &'s <&Archetype as WorldQuery>::State,
_table: &'w Table,
)
unsafe fn set_table<'w, 's>( _fetch: &mut <&Archetype as WorldQuery>::Fetch<'w>, _state: &'s <&Archetype as WorldQuery>::State, _table: &'w Table, )
Table. This will always be called on tables
that match this WorldQuery. Read moreSource§fn update_component_access(
_state: &<&Archetype as WorldQuery>::State,
_access: &mut FilteredAccess,
)
fn update_component_access( _state: &<&Archetype as WorldQuery>::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: &<&Archetype as WorldQuery>::State,
_set_contains_id: &impl Fn(ComponentId) -> bool,
) -> bool
fn matches_component_set( _state: &<&Archetype as WorldQuery>::State, _set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool
impl ArchetypeQueryData for &Archetype
impl ReadOnlyQueryData for &Archetype
SAFETY: access is read only
Auto Trait Implementations§
impl Freeze for Archetype
impl !RefUnwindSafe for Archetype
impl !Send for Archetype
impl !Sync for Archetype
impl Unpin for Archetype
impl UnsafeUnpin for Archetype
impl !UnwindSafe for Archetype
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
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> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.