From 94e5e592baea2935af7c94ad44805a09d0e30740 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 9 Apr 2025 20:50:14 +0200 Subject: feat(ecs): replace Relationship component with pair UID support --- ecs/src/query/term.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'ecs/src/query/term.rs') diff --git a/ecs/src/query/term.rs b/ecs/src/query/term.rs index 78668c5..597dd1a 100644 --- a/ecs/src/query/term.rs +++ b/ecs/src/query/term.rs @@ -8,42 +8,43 @@ use crate::query::{ TermsBuilder, TermsBuilderInterface, }; +use crate::uid::With as WithUid; -pub struct With +pub struct With where - ComponentT: Component, + WithUidT: WithUid, { - _pd: PhantomData, + _pd: PhantomData, } -impl TermWithoutField for With +impl TermWithoutField for With where - ComponentT: Component, + WithUidT: WithUid, { fn apply_to_terms_builder( terms_builder: &mut TermsBuilder, ) { - terms_builder.with::(); + terms_builder.with::(); } } -pub struct Without +pub struct Without where - ComponentT: Component, + WithUidT: WithUid, { - _pd: PhantomData, + _pd: PhantomData, } -impl TermWithoutField for Without +impl TermWithoutField for Without where - ComponentT: Component, + WithUidT: WithUid, { fn apply_to_terms_builder( terms_builder: &mut TermsBuilder, ) { - terms_builder.without::(); + terms_builder.without::(); } } @@ -66,7 +67,11 @@ where { Some( ComponentRefT::Handle::<'world>::from_entity_component_ref( - Some(entity_handle.get_component(ComponentRefT::Component::id())?), + Some( + entity_handle + .get_matching_components(ComponentRefT::Component::id()) + .next()?, + ), world, ) .unwrap_or_else(|err| { -- cgit v1.2.3-18-g5258