diff options
Diffstat (limited to 'engine-ecs/src/component/storage')
| -rw-r--r-- | engine-ecs/src/component/storage/archetype.rs | 32 |
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!( |
