From fe62665b1d62d36ee0839e6bf24e3841ea667da9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 21 Mar 2025 20:05:53 +0100 Subject: refactor(ecs): replace query options with fieldless terms --- ecs/src/query/options.rs | 59 ------------------------------------------------ 1 file changed, 59 deletions(-) delete mode 100644 ecs/src/query/options.rs (limited to 'ecs/src/query/options.rs') diff --git a/ecs/src/query/options.rs b/ecs/src/query/options.rs deleted file mode 100644 index 6318359..0000000 --- a/ecs/src/query/options.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::marker::PhantomData; - -use hashbrown::HashSet; - -use crate::component::Component; -use crate::EntityComponent; - -/// Query options. -pub trait Options -{ - fn entity_filter(components: &[EntityComponent]) -> bool; -} - -impl Options for () -{ - fn entity_filter(_components: &[EntityComponent]) -> bool - { - true - } -} - -pub struct With -where - ComponentT: Component, -{ - _pd: PhantomData, -} - -impl Options for With -where - ComponentT: Component, -{ - fn entity_filter(components: &[EntityComponent]) -> bool - { - let ids_set = components - .iter() - .map(|component| component.id) - .collect::>(); - - ids_set.contains(&ComponentT::id()) - } -} - -pub struct Not -where - OptionsT: Options, -{ - _pd: PhantomData, -} - -impl Options for Not -where - OptionsT: Options, -{ - fn entity_filter(components: &[EntityComponent]) -> bool - { - !OptionsT::entity_filter(components) - } -} -- cgit v1.2.3-18-g5258