summaryrefslogtreecommitdiff
path: root/engine-ecs/src/component/storage
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-07-24 22:32:21 +0200
committerHampusM <hampus@hampusmat.com>2026-07-26 19:44:20 +0200
commit9226356b7b54c4c5b036b6fee00bba376245c5f3 (patch)
treea693c9fba2b9d59370ce744784ee1bdf2977614d /engine-ecs/src/component/storage
parentd979565961b1e7770807663d89e3438b12c1fd54 (diff)
feat(engine-ecs): add traversal query termHEADmaster
Diffstat (limited to 'engine-ecs/src/component/storage')
-rw-r--r--engine-ecs/src/component/storage/archetype.rs32
1 files changed, 27 insertions, 5 deletions
diff --git a/engine-ecs/src/component/storage/archetype.rs b/engine-ecs/src/component/storage/archetype.rs
index c5cce10..236bf97 100644
--- a/engine-ecs/src/component/storage/archetype.rs
+++ b/engine-ecs/src/component/storage/archetype.rs
@@ -107,11 +107,6 @@ impl Archetype
EntityIter { iter: self.entities.iter() }
}
- pub fn entity_cnt(&self) -> usize
- {
- self.entities.len()
- }
-
pub fn component_cnt(&self) -> usize
{
self.component_index_lookup.len()
@@ -182,6 +177,33 @@ impl Archetype
self.contains_component_with_exact_id(component_id)
}
+ pub fn get_matching_component_ids(
+ &self,
+ component_id: Uid,
+ ) -> impl Iterator<Item = Uid> + use<'_>
+ {
+ if component_id.is_pair() && component_id.target() == Uid::wildcard() {
+ return Either::A(
+ self.component_ids
+ .iter()
+ .filter(move |other_comp_id| {
+ other_comp_id.is_pair()
+ && other_comp_id.has_same_relation_as(component_id)
+ })
+ .copied(),
+ );
+ }
+
+ Either::B(
+ (if self.contains_component_with_exact_id(component_id) {
+ Some(component_id)
+ } else {
+ None
+ })
+ .into_iter(),
+ )
+ }
+
pub fn contains_component_with_exact_id(&self, component_id: Uid) -> bool
{
debug_assert!(