diff options
Diffstat (limited to 'ecs/src/query.rs')
-rw-r--r-- | ecs/src/query.rs | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/ecs/src/query.rs b/ecs/src/query.rs index 2c52206..bc98ac0 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -9,11 +9,7 @@ use crate::component::storage::{ ArchetypeRefIter, Storage as ComponentStorage, }; -use crate::component::{ - Id as ComponentId, - IsOptional as ComponentIsOptional, - Sequence as ComponentSequence, -}; +use crate::component::{Metadata as ComponentMetadata, Sequence as ComponentSequence}; use crate::lock::{Lock, ReadGuard}; use crate::query::options::Options; use crate::system::{ @@ -52,7 +48,7 @@ where ComponentIter { entities: self .component_storage - .find_entities(&Comps::ids()) + .find_entities(Comps::metadata()) .map((|archetype| archetype.components.as_slice()) as ComponentIterMapFn) .flatten() .filter(|components| OptionsT::entity_filter(*components)), @@ -124,7 +120,7 @@ where fn get_comparable() -> Box<dyn Any> { - Box::new(QueryComponentIds { component_ids: Comps::ids() }) + Box::new(QueryComponentIds { component_ids: Comps::metadata() }) } fn prepare(world_data: &WorldData) @@ -140,18 +136,7 @@ where std::any::type_name::<Comps>() ); - component_storage_lock.add_archetype_lookup_entry( - &Comps::ids() - .into_iter() - .filter_map(|(component_id, is_optional)| { - if is_optional == ComponentIsOptional::Yes { - return None; - } - - Some(component_id) - }) - .collect::<Vec<_>>(), - ); + component_storage_lock.add_archetype_lookup_entry(Comps::metadata()); } } @@ -183,7 +168,7 @@ where #[derive(Debug)] struct QueryComponentIds { - component_ids: Vec<(ComponentId, ComponentIsOptional)>, + component_ids: Vec<ComponentMetadata>, } impl QueryComponentIds @@ -192,13 +177,13 @@ impl QueryComponentIds where OtherComps: ComponentSequence, { - let other_ids = OtherComps::ids() + let other_ids = OtherComps::metadata() .into_iter() - .map(|(id, _)| id) + .map(|component_metadata| component_metadata.id) .collect::<HashSet<_>>(); self.component_ids .iter() - .all(|(id, _)| other_ids.contains(id)) + .all(|component_metadata| other_ids.contains(&component_metadata.id)) } } |