diff options
Diffstat (limited to 'ecs')
-rw-r--r-- | ecs/src/lib.rs | 10 | ||||
-rw-r--r-- | ecs/src/query.rs | 20 |
2 files changed, 12 insertions, 18 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 3adc415..59129b0 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -20,7 +20,7 @@ use crate::phase::{Phase, START as START_PHASE}; use crate::query::flexible::Query as FlexibleQuery; use crate::query::term::Without; use crate::query::{ - ComponentIter, + Iter as QueryIter, TermWithFieldTuple as QueryTermWithFieldTuple, TermWithoutFieldTuple as QueryTermWithoutFieldTuple, Terms as QueryTerms, @@ -534,11 +534,6 @@ impl World fn emit_event_by_id(&self, event_id: Uid) { - //let query = self.flexible_query([ - // ComponentMetadata::of::<SystemComponent>(), - // ComponentMetadata { id: event_id, is_optional: false }, - //]); - let mut query_required_ids = [SystemComponent::id(), event_id]; let query = self.flexible_query( @@ -547,8 +542,7 @@ impl World .build(), ); - for (system,) in ComponentIter::<(&SystemComponent,), _>::new(self, query.iter()) - { + for (system,) in QueryIter::<(&SystemComponent,), _>::new(self, query.iter()) { unsafe { system.system.run(self); } diff --git a/ecs/src/query.rs b/ecs/src/query.rs index 668c573..9b8aeed 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -36,11 +36,11 @@ where #[must_use] pub fn iter<'query>( &'query self, - ) -> ComponentIter<'query, 'world, FieldTerms, FlexibleQueryIter<'query>> + ) -> Iter<'query, 'world, FieldTerms, FlexibleQueryIter<'query>> { tracing::trace!("Searching for {}", std::any::type_name::<FieldTerms>()); - ComponentIter { + Iter { world: self.world, iter: self.inner.iter(), comps_pd: PhantomData, @@ -48,7 +48,7 @@ where } /// Iterates over the entities matching this query, the iterator item being the entity - /// [`Uid`] and the entity components. + /// [`Uid`] and the matching entity components. #[must_use] pub fn iter_with_euids<'query>( &'query self, @@ -67,18 +67,18 @@ where /// `func`. /// /// This function exists so that a custom [`EntityHandle`] iterator can be given to - /// [`ComponentIter`] without giving the user access to a reference to the [`World`]. + /// [`Iter`] without giving the user access to a reference to the [`World`]. #[must_use] pub fn iter_with<'query, OutIter>( &'query self, func: impl FnOnce(FlexibleQueryIter<'query>) -> OutIter, - ) -> ComponentIter<'query, 'world, FieldTerms, OutIter> + ) -> Iter<'query, 'world, FieldTerms, OutIter> where OutIter: Iterator<Item = EntityHandle<'query>>, { tracing::trace!("Searching for {}", std::any::type_name::<FieldTerms>()); - ComponentIter { + Iter { world: self.world, iter: func(self.inner.iter()), comps_pd: PhantomData, @@ -113,7 +113,7 @@ where FieldTerms: TermWithFieldTuple + 'world, FieldlessTerms: TermWithoutFieldTuple, { - type IntoIter = ComponentIter<'query, 'world, FieldTerms, FlexibleQueryIter<'query>>; + type IntoIter = Iter<'query, 'world, FieldTerms, FlexibleQueryIter<'query>>; type Item = FieldTerms::Fields<'query>; fn into_iter(self) -> Self::IntoIter @@ -330,7 +330,7 @@ pub trait TermWithFieldTuple ) -> Self::Fields<'component>; } -pub struct ComponentIter<'query, 'world, FieldTerms, EntityHandleIter> +pub struct Iter<'query, 'world, FieldTerms, EntityHandleIter> where FieldTerms: TermWithFieldTuple + 'world, EntityHandleIter: Iterator<Item = EntityHandle<'query>>, @@ -341,7 +341,7 @@ where } impl<'query, 'world, FieldTerms, EntityHandleIter> - ComponentIter<'query, 'world, FieldTerms, EntityHandleIter> + Iter<'query, 'world, FieldTerms, EntityHandleIter> where FieldTerms: TermWithFieldTuple + 'world, EntityHandleIter: Iterator<Item = EntityHandle<'query>>, @@ -360,7 +360,7 @@ where } impl<'query, 'world, FieldTerms, EntityHandleIter> Iterator - for ComponentIter<'query, 'world, FieldTerms, EntityHandleIter> + for Iter<'query, 'world, FieldTerms, EntityHandleIter> where FieldTerms: TermWithFieldTuple + 'world, EntityHandleIter: Iterator<Item = EntityHandle<'query>>, |