From ceca39d78c1c42563cd41988e5f5a51dc51295af Mon Sep 17 00:00:00 2001 From: roman Date: Fri, 25 Aug 2023 18:12:40 +0300 Subject: [PATCH 1/6] Make un_if_inner public --- crates/bevy_ecs/src/schedule/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 708661035ed55..75bee0c2dc515 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -167,7 +167,7 @@ impl SystemConfigs { } } - pub(crate) fn run_if_inner(&mut self, condition: BoxedCondition) { + pub fn run_if_inner(&mut self, condition: BoxedCondition) { match self { SystemConfigs::SystemConfig(config) => { config.conditions.push(condition); From 95c58a1822f37793aeaff2fd48ee8df88a77ebd1 Mon Sep 17 00:00:00 2001 From: roman Date: Fri, 25 Aug 2023 18:49:37 +0300 Subject: [PATCH 2/6] Add docs --- crates/bevy_ecs/src/schedule/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 75bee0c2dc515..9ca6775a64391 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -167,6 +167,7 @@ impl SystemConfigs { } } + /// Adds a new condition pub fn run_if_inner(&mut self, condition: BoxedCondition) { match self { SystemConfigs::SystemConfig(config) => { From 7344b59b5fd4c58c09cfa79bb80f684393f59323 Mon Sep 17 00:00:00 2001 From: roman Date: Sat, 26 Aug 2023 17:15:29 +0300 Subject: [PATCH 3/6] run_if_inner => run_if_dyn --- crates/bevy_ecs/src/schedule/config.rs | 4 ++-- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 9ca6775a64391..111c168660e55 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -168,7 +168,7 @@ impl SystemConfigs { } /// Adds a new condition - pub fn run_if_inner(&mut self, condition: BoxedCondition) { + pub fn run_if_dyn(&mut self, condition: BoxedCondition) { match self { SystemConfigs::SystemConfig(config) => { config.conditions.push(condition); @@ -342,7 +342,7 @@ impl IntoSystemConfigs<()> for SystemConfigs { } fn run_if(mut self, condition: impl Condition) -> SystemConfigs { - self.run_if_inner(new_condition(condition)); + self.run_if_dyn(new_condition(condition)); self } diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 4f1b90ff9050d..4f2cc4c5715a7 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -539,7 +539,7 @@ impl ScheduleGraph { self.configure_set(set_config); } else { for condition in collective_conditions { - configs[0].run_if_inner(condition); + configs[0].run_if_dyn(condition); } } } From e1ec4bb386e591334b0c854fb285f97ef2e43a71 Mon Sep 17 00:00:00 2001 From: st0rmbtw <61053971+st0rmbtw@users.noreply.github.com> Date: Sat, 26 Aug 2023 17:58:11 +0300 Subject: [PATCH 4/6] Update crates/bevy_ecs/src/schedule/config.rs Co-authored-by: Alice Cecile --- crates/bevy_ecs/src/schedule/config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 111c168660e55..541f5ec0a06c3 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -167,7 +167,10 @@ impl SystemConfigs { } } - /// Adds a new condition + /// Adds a new boxed run condition to the systems. + /// + /// This is exposed to allow users to create custom scheduling abstractions: + /// it is generally only useful when working with boxed run conditions with an unknown dynamic type. pub fn run_if_dyn(&mut self, condition: BoxedCondition) { match self { SystemConfigs::SystemConfig(config) => { From a72691aa32c16e75cf24d440eeee811c4a0461b1 Mon Sep 17 00:00:00 2001 From: roman Date: Sat, 26 Aug 2023 18:05:53 +0300 Subject: [PATCH 5/6] Rename in_set_inner to in_set_dyn and make it pub --- crates/bevy_ecs/src/schedule/config.rs | 7 ++++--- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 111c168660e55..ace3836440ed2 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -83,14 +83,15 @@ impl SystemConfigs { }) } - pub(crate) fn in_set_inner(&mut self, set: BoxedSystemSet) { + /// Adds a new boxed system set to the systems. + pub fn in_set_dyn(&mut self, set: BoxedSystemSet) { match self { SystemConfigs::SystemConfig(config) => { config.graph_info.sets.push(set); } SystemConfigs::Configs { configs, .. } => { for config in configs { - config.in_set_inner(set.dyn_clone()); + config.in_set_dyn(set.dyn_clone()); } } } @@ -308,7 +309,7 @@ impl IntoSystemConfigs<()> for SystemConfigs { "adding arbitrary systems to a system type set is not allowed" ); - self.in_set_inner(set.dyn_clone()); + self.in_set_dyn(set.dyn_clone()); self } diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 4f2cc4c5715a7..18e230114e69d 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -532,7 +532,7 @@ impl ScheduleGraph { if more_than_one_entry { let set = AnonymousSet::new(); for config in &mut configs { - config.in_set_inner(set.dyn_clone()); + config.in_set_dyn(set.dyn_clone()); } let mut set_config = set.into_config(); set_config.conditions.extend(collective_conditions); From 0b621526197fcca03a6317d28bdb031fe03f6c20 Mon Sep 17 00:00:00 2001 From: st0rmbtw <61053971+st0rmbtw@users.noreply.github.com> Date: Sat, 26 Aug 2023 23:18:04 +0300 Subject: [PATCH 6/6] Update crates/bevy_ecs/src/schedule/config.rs Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com> --- crates/bevy_ecs/src/schedule/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index ec11ab0fd9dca..47b72232b1179 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -170,8 +170,8 @@ impl SystemConfigs { /// Adds a new boxed run condition to the systems. /// - /// This is exposed to allow users to create custom scheduling abstractions: - /// it is generally only useful when working with boxed run conditions with an unknown dynamic type. + /// This is useful if you have a run condition whose concrete type is unknown. + /// Prefer `run_if` for run conditions whose type is known at compile time. pub fn run_if_dyn(&mut self, condition: BoxedCondition) { match self { SystemConfigs::SystemConfig(config) => {