diff options
Diffstat (limited to 'ecs/src/query/flexible.rs')
-rw-r--r-- | ecs/src/query/flexible.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs index 3e72b34..6d65ee0 100644 --- a/ecs/src/query/flexible.rs +++ b/ecs/src/query/flexible.rs @@ -2,13 +2,8 @@ use std::iter::{repeat_n, FlatMap, RepeatN, Zip}; use crate::component::storage::archetype::{Archetype, EntityIter}; -use crate::component::storage::{ - ArchetypeRefIter, - ArchetypeSearchTerms, - Storage as ComponentStorage, -}; +use crate::component::storage::{ArchetypeRefIter, ArchetypeSearchTerms}; use crate::entity::Handle as EntityHandle; -use crate::lock::ReadGuard; use crate::query::Terms; use crate::World; @@ -17,7 +12,6 @@ use crate::World; pub struct Query<'world, const MAX_TERM_CNT: usize> { world: &'world World, - component_storage: ReadGuard<'world, ComponentStorage>, terms: Terms<MAX_TERM_CNT>, } @@ -30,6 +24,8 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> Iter { world: self.world, iter: self + .world + .data .component_storage .search_archetypes(ArchetypeSearchTerms { required_components: &self.terms.required_components, @@ -46,15 +42,18 @@ impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> pub(crate) fn new(world: &'world World, terms: Terms<MAX_TERM_CNT>) -> Self { - Self { - world, - component_storage: world - .data - .component_storage - .read_nonblock() - .expect("Failed to acquire read-only component storage lock"), - terms, - } + Self { world, terms } + } +} + +impl<'query, const MAX_TERM_CNT: usize> IntoIterator for &'query Query<'_, MAX_TERM_CNT> +{ + type IntoIter = Iter<'query>; + type Item = EntityHandle<'query>; + + fn into_iter(self) -> Self::IntoIter + { + self.iter() } } |