diff options
author | HampusM <hampus@hampusmat.com> | 2025-01-05 22:03:34 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-01-05 22:03:34 +0100 |
commit | a44e663eb6d4aaf567dd35f2676014ba5aaa9e00 (patch) | |
tree | cd81d1f61b33e1905d6b3def851e5be18838556b /ecs/src/lib.rs | |
parent | cd385ddedc767c953f24109ec3ffe0a07d247ff5 (diff) |
feat(ecs): allow control over component mutability in query
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 11 |
1 files changed, 6 insertions, 5 deletions
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<Comps, OptionsT>(&self) -> Query<Comps, OptionsT> 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<DependsOn, Phase>), ()>(); + self.query::<(&SystemComponent, &Relationship<DependsOn, Phase>), ()>(); 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<ChildOf, Phase>), ()>(); + let phase_query = self.query::<(&Phase, &Relationship<ChildOf, Phase>), ()>(); 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<With<Relationship<ChildOf, Phase>>>>(); + self.query::<(&Phase,), Not<With<Relationship<ChildOf, Phase>>>>(); 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, |