From 67bd2b00e17319c8b5a04df4b47f8198a3a5f24b Mon Sep 17 00:00:00 2001 From: vil'mo <101888203+vil-mo@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:10:58 +0700 Subject: [PATCH] Expose `SystemMeta`'s access field as part of public API (#16625) # Objective Outside of the `bevy_ecs` crate it's hard to implement `SystemParam` trait on params that require access to the `World`, because `init_state` expects user to extend access in `SystemMeta` and access-related fields of `SystemMeta` are private. ## Solution Expose those fields as a functions --- crates/bevy_ecs/src/system/function_system.rs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 7c5806abbc..52b3aedf7c 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -136,6 +136,55 @@ impl SystemMeta { { self.param_warn_policy.try_warn::
(&self.name);
}
+
+ /// Archetype component access that is used to determine which systems can run in parallel with each other
+ /// in the multithreaded executor.
+ ///
+ /// We use an [`ArchetypeComponentId`] as it is more precise than just checking [`ComponentId`]:
+ /// for example if you have one system with `Query<&mut A, With`, and one system with `Query<&mut A, Without`,
+ /// they conflict if you just look at the [`ComponentId`];
+ /// but no archetype that matches the first query will match the second and vice versa,
+ /// which means there's no risk of conflict.
+ #[inline]
+ pub fn archetype_component_access(&self) -> &Access