diff options
Diffstat (limited to 'ecs/src/query')
| -rw-r--r-- | ecs/src/query/flexible.rs | 10 | ||||
| -rw-r--r-- | ecs/src/query/term.rs | 7 |
2 files changed, 13 insertions, 4 deletions
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs index add30b0..936ab82 100644 --- a/ecs/src/query/flexible.rs +++ b/ecs/src/query/flexible.rs @@ -36,9 +36,16 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> .zip(archetype.entities()) }) as ComponentIterMapFn, ), + world: self.world, } } + #[must_use] + pub fn world(&self) -> &'world World + { + self.world + } + pub(crate) fn new(world: &'world World, terms: Terms<MAX_TERM_CNT>) -> Self { Self { world, terms } @@ -59,6 +66,7 @@ impl<'query, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'_, MAX_T pub struct Iter<'query> { iter: QueryEntityIter<'query>, + world: &'query World, } impl<'query> Iterator for Iter<'query> @@ -69,7 +77,7 @@ impl<'query> Iterator for Iter<'query> { let (archetype, entity) = self.iter.next()?; - Some(EntityHandle::new(archetype, entity)) + Some(EntityHandle::new(archetype, entity, self.world)) } } diff --git a/ecs/src/query/term.rs b/ecs/src/query/term.rs index 9c772da..0683918 100644 --- a/ecs/src/query/term.rs +++ b/ecs/src/query/term.rs @@ -69,7 +69,7 @@ impl<ComponentT: Component> TermWithField for Option<&ComponentT> { Some( ComponentHandle::<'world, ComponentT>::from_entity_component_ref( - entity_handle + &entity_handle .get_matching_components(ComponentT::id()) .next()?, ) @@ -95,14 +95,15 @@ impl<ComponentT: Component> TermWithField for Option<&mut ComponentT> fn get_field<'world>( entity_handle: &crate::entity::Handle<'world>, - _world: &'world crate::World, + world: &'world crate::World, ) -> Self::Field<'world> { Some( ComponentHandleMut::<'world, ComponentT>::from_entity_component_ref( - entity_handle + &entity_handle .get_matching_components(ComponentT::id()) .next()?, + world, ) .unwrap_or_else(|err| { panic!( |
