From 4fd57fed6fe2de038bb68366fe7c9a9b0a0780a8 Mon Sep 17 00:00:00 2001 From: Zicklag Date: Fri, 21 Jun 2024 11:33:27 -0500 Subject: [PATCH] feat: Impl `QueryItem` for `UntypedComponentStore`. (#416) Submitting on behalf of @tekhnaeraav: Minor tweak that allows you use untyped component stores in `entities.iter_with()`. Co-authored-by: Tekhnae Raav --- framework_crates/bones_ecs/src/entities.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/framework_crates/bones_ecs/src/entities.rs b/framework_crates/bones_ecs/src/entities.rs index 994b06a7b0..bf26a44d66 100644 --- a/framework_crates/bones_ecs/src/entities.rs +++ b/framework_crates/bones_ecs/src/entities.rs @@ -150,6 +150,17 @@ where OptionalQueryItemMut(component_ref, PhantomData) } +impl<'a> QueryItem for &'a Ref<'a, UntypedComponentStore> { + type Iter = UntypedComponentBitsetIterator<'a>; + fn apply_bitset(&self, bitset: &mut BitSetVec) { + bitset.bit_and(self.bitset()); + } + + fn iter_with_bitset(self, bitset: Rc) -> Self::Iter { + UntypedComponentStore::iter_with_bitset(self, bitset) + } +} + impl<'a, 'q, T: HasSchema> QueryItem for &'a Comp<'q, T> { type Iter = ComponentBitsetIterator<'a, T>; fn apply_bitset(&self, bitset: &mut BitSetVec) {