Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make run_if_inner public and rename to run_if_dyn #9576

Merged
merged 7 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/bevy_ecs/src/schedule/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Comment on lines +86 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this change will be unnecessary if #7762 is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I revert that change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, that PR isn't guaranteed to get merged. Just thought I'd mention that this function might get removed later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, okay

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());
}
}
}
Expand Down Expand Up @@ -167,7 +168,11 @@ impl SystemConfigs {
}
}

pub(crate) fn run_if_inner(&mut self, condition: BoxedCondition) {
/// 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.
st0rmbtw marked this conversation as resolved.
Show resolved Hide resolved
pub fn run_if_dyn(&mut self, condition: BoxedCondition) {
match self {
SystemConfigs::SystemConfig(config) => {
config.conditions.push(condition);
Expand Down Expand Up @@ -307,7 +312,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
}
Expand Down Expand Up @@ -341,7 +346,7 @@ impl IntoSystemConfigs<()> for SystemConfigs {
}

fn run_if<M>(mut self, condition: impl Condition<M>) -> SystemConfigs {
self.run_if_inner(new_condition(condition));
self.run_if_dyn(new_condition(condition));
self
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,14 @@ 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);
self.configure_set(set_config);
} else {
for condition in collective_conditions {
configs[0].run_if_inner(condition);
configs[0].run_if_dyn(condition);
}
}
}
Expand Down