Add Archetype::component_count (#12119)

Add Archetype::component_count utility method

# Objective

I wanted a method to count components on an archetype without iterating
over them.

## Solution

Added `Archetype::component_count`

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
AxiomaticSemantics 2024-02-25 23:54:25 -05:00 committed by GitHub
parent c4caebb528
commit e0e9794c9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -404,6 +404,12 @@ impl Archetype {
self.components.indices() self.components.indices()
} }
/// Returns the total number of components in the archetype
#[inline]
pub fn component_count(&self) -> usize {
self.components.len()
}
/// Fetches a immutable reference to the archetype's [`Edges`], a cache of /// Fetches a immutable reference to the archetype's [`Edges`], a cache of
/// archetypal relationships. /// archetypal relationships.
#[inline] #[inline]