From 8022e8998290b067b8aa0cb9cba8ba410826bdab Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 21 May 2026 17:55:20 +0200 Subject: chore: rename ecs* crates to engine-ecs* --- ecs/src/query/flexible.rs | 92 ----------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 ecs/src/query/flexible.rs (limited to 'ecs/src/query/flexible.rs') diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs deleted file mode 100644 index 936ab82..0000000 --- a/ecs/src/query/flexible.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! Low-level querying. -use std::iter::{repeat_n, FlatMap, RepeatN, Zip}; - -use crate::component::storage::archetype::{Archetype, EntityIter}; -use crate::component::storage::{ArchetypeRefIter, ArchetypeSearchTerms}; -use crate::entity::Handle as EntityHandle; -use crate::query::Terms; -use crate::World; - -/// Low-level entity query structure. -#[derive(Debug)] -pub struct Query<'world, const MAX_TERM_CNT: usize> -{ - world: &'world World, - terms: Terms, -} - -impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT> -{ - /// Iterates over the entities matching this query. - #[must_use] - pub fn iter(&self) -> Iter<'_> - { - Iter { - iter: self - .world - .data - .component_storage - .search_archetypes(ArchetypeSearchTerms { - required_components: &self.terms.required_components, - excluded_components: &self.terms.excluded_components, - }) - .flat_map( - (|archetype| { - repeat_n(archetype, archetype.entity_cnt()) - .zip(archetype.entities()) - }) as ComponentIterMapFn, - ), - world: self.world, - } - } - - #[must_use] - pub fn world(&self) -> &'world World - { - self.world - } - - pub(crate) fn new(world: &'world World, terms: Terms) -> Self - { - 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() - } -} - -pub struct Iter<'query> -{ - iter: QueryEntityIter<'query>, - world: &'query World, -} - -impl<'query> Iterator for Iter<'query> -{ - type Item = EntityHandle<'query>; - - fn next(&mut self) -> Option - { - let (archetype, entity) = self.iter.next()?; - - Some(EntityHandle::new(archetype, entity, self.world)) - } -} - -type ComponentIterMapFnOutput<'a> = Zip, EntityIter<'a>>; - -type ComponentIterMapFn = for<'a> fn(&'a Archetype) -> ComponentIterMapFnOutput<'a>; - -type QueryEntityIter<'query> = FlatMap< - ArchetypeRefIter<'query, 'query>, - ComponentIterMapFnOutput<'query>, - ComponentIterMapFn, ->; -- cgit v1.2.3-18-g5258