diff options
Diffstat (limited to 'ecs/src/query')
-rw-r--r-- | ecs/src/query/flexible.rs | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs index 7d24dc9..652b96f 100644 --- a/ecs/src/query/flexible.rs +++ b/ecs/src/query/flexible.rs @@ -1,16 +1,16 @@ //! Low-level querying. use std::iter::{repeat_n, FlatMap, RepeatN, Zip}; -use crate::component::storage::archetype::{Archetype, ArchetypeEntity, EntityIter}; +use crate::component::storage::archetype::{Archetype, EntityIter}; use crate::component::storage::{ ArchetypeRefIter, ArchetypeSearchTerms, Storage as ComponentStorage, }; +use crate::entity::Handle as EntityHandle; use crate::lock::ReadGuard; use crate::query::Terms; -use crate::uid::Uid; -use crate::{EntityComponent, World}; +use crate::World; /// Low-level entity query structure. #[derive(Debug)] @@ -68,33 +68,7 @@ impl<'query> Iterator for Iter<'query> { let (archetype, entity) = self.iter.next()?; - Some(EntityHandle { archetype, entity }) - } -} - -pub struct EntityHandle<'query> -{ - archetype: &'query Archetype, - entity: &'query ArchetypeEntity, -} - -impl<'query> EntityHandle<'query> -{ - /// Returns the [`Uid`] of this entity. - #[inline] - #[must_use] - pub fn uid(&self) -> Uid - { - self.entity.uid - } - - #[inline] - #[must_use] - pub fn get_component(&self, component_uid: Uid) -> Option<&'query EntityComponent> - { - let index = self.archetype.get_index_for_component(component_uid)?; - - Some(self.entity.components.get(index).unwrap()) + Some(EntityHandle::new(archetype, entity)) } } |