diff options
Diffstat (limited to 'ecs/src/query.rs')
-rw-r--r-- | ecs/src/query.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ecs/src/query.rs b/ecs/src/query.rs index 683dde7..61e2797 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -3,7 +3,10 @@ use std::collections::HashSet; use std::marker::PhantomData; use std::sync::{Arc, Weak}; -use crate::component::Sequence as ComponentSequence; +use crate::component::{ + IsOptional as ComponentIsOptional, + Sequence as ComponentSequence, +}; use crate::lock::{Lock, ReadGuard}; use crate::system::{ NoInitParamFlag as NoInitSystemParamFlag, @@ -184,7 +187,7 @@ pub struct ComponentIter<'world, Comps> { component_storage: &'world ComponentStorage, current_entity_index: usize, - component_type_ids: Vec<TypeId>, + component_type_ids: Vec<(TypeId, ComponentIsOptional)>, comps_pd: PhantomData<Comps>, } @@ -216,7 +219,7 @@ where #[derive(Debug)] struct QueryComponentIds { - component_type_ids: Vec<TypeId>, + component_type_ids: Vec<(TypeId, ComponentIsOptional)>, } impl QueryComponentIds @@ -227,10 +230,13 @@ impl QueryComponentIds { let other_component_type_ids = OtherComps::type_ids() .into_iter() + .map(|(type_id, _)| type_id) .collect::<HashSet<TypeId>>(); self.component_type_ids .iter() - .all(|component_type_id| other_component_type_ids.contains(component_type_id)) + .all(|(component_type_id, _)| { + other_component_type_ids.contains(component_type_id) + }) } } |