From a44e663eb6d4aaf567dd35f2676014ba5aaa9e00 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 5 Jan 2025 22:03:34 +0100 Subject: feat(ecs): allow control over component mutability in query --- ecs/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ecs/src/lib.rs') diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index ae5fd19..d217525 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -15,6 +15,7 @@ use crate::component::{ Component, IsOptional as ComponentIsOptional, Metadata as ComponentMetadata, + RefSequence as ComponentRefSequence, Sequence as ComponentSequence, }; use crate::entity::CREATE_STATIC_ENTITIES; @@ -175,7 +176,7 @@ impl World pub fn query(&self) -> Query where - Comps: ComponentSequence, + Comps: ComponentRefSequence, OptionsT: QueryOptions, { Query::new(self) @@ -236,7 +237,7 @@ impl World fn query_and_run_systems(&self, phase_euid: Uid) { let system_comps_query = - self.query::<(SystemComponent, Relationship), ()>(); + self.query::<(&SystemComponent, &Relationship), ()>(); let system_iter = system_comps_query.iter().filter(|(_, phase_rel)| { phase_rel @@ -254,7 +255,7 @@ impl World fn perform_child_phases(&self, parent_phase_euid: Uid) { - let phase_query = self.query::<(Phase, Relationship), ()>(); + let phase_query = self.query::<(&Phase, &Relationship), ()>(); for (index, (_, phase_rel)) in phase_query.iter().enumerate() { if !phase_rel @@ -277,7 +278,7 @@ impl World fn perform_phases(&self) { let phase_query = - self.query::<(Phase,), Not>>>(); + self.query::<(&Phase,), Not>>>(); for (index, (_,)) in phase_query.iter().enumerate() { let child_phase_euid = phase_query @@ -440,7 +441,7 @@ impl World fn emit_event_by_id(&self, event_id: Uid) { for (system,) in self - .query::<(SystemComponent,), ()>() + .query::<(&SystemComponent,), ()>() .iter_with_extra_comps([ComponentMetadata { id: event_id, is_optional: ComponentIsOptional::No, -- cgit v1.2.3-18-g5258