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

Create a System Builder Syntax instead of using System Descriptors #2736

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0c6a837
Add SystemConfig and some basic options
Aug 27, 2021
569513c
Cargo format
Aug 27, 2021
983a2be
System Builder Rework - In Progress
Aug 28, 2021
abd6d8b
Rename StartupConfig to conform with other traits
Aug 28, 2021
52e7fff
Remove trait_casting feature
Aug 28, 2021
011af54
SystemSet handle ExclusiveSystems
Aug 29, 2021
ecb855b
Testing SubType impl for StageConfig
Aug 29, 2021
20fd625
Sort imports and remove double refs in app.rs
Aug 29, 2021
d9f7558
Attempt at fixing `SystemConfig`, `StartupConfig`.
Ratysz Aug 31, 2021
e83c519
Merge pull request #1 from Ratysz/system-builder-syntax
Sep 1, 2021
b540f79
Separate configs and conform with StageConfig
Sep 1, 2021
3bad094
Make more system additions use the new methods
Sep 1, 2021
325689b
Found a solution to exclusive errors
Sep 1, 2021
9aeb408
Revert solution
Sep 1, 2021
d7e1e2a
Fix broken startup functionality
Sep 1, 2021
4514032
Actually use the correct impl
Sep 1, 2021
251fb40
.stage all the things
Sep 1, 2021
0995f85
Fix bevy_render error
Sep 1, 2021
2d062e6
Fix final stage.rs error
Sep 1, 2021
9a2284e
Fix all remaining crate errors
Sep 1, 2021
5487f83
Fix examples
Sep 1, 2021
1d34d96
Format
Sep 1, 2021
9822b19
Merge branch 'main' into system-builder-syntax
Sep 1, 2021
e80fded
Format again
Sep 1, 2021
7b4bb30
Fix some ci errors
Sep 1, 2021
aee8c9d
Fix InsertionPoint panic
Sep 2, 2021
eb207e5
Fix startup error
Sep 2, 2021
0c9ac6a
Fixed copy pasta failure (insertion point test)
Sep 2, 2021
6c28d69
Remove redundant fn impl
Sep 2, 2021
085a5ef
Update System docs
Sep 4, 2021
55b797c
Reduce internal config function visibility and doc
Sep 4, 2021
c8914c1
More docs
Sep 4, 2021
0a32358
Update crates/bevy_ecs/src/schedule/stage.rs
Sep 5, 2021
0f6494b
Update crates/bevy_ecs/src/system/config/system_config.rs
Sep 5, 2021
91cb4c2
Update crates/bevy_ecs/src/system/system.rs
Sep 5, 2021
b272cb4
Add specific config trait docs
Sep 7, 2021
cf372a7
Add link to SystemStage doc
Sep 7, 2021
25b1d31
Add system set conflict validation
Sep 13, 2021
d360e14
Use .any rather than for loops
Oct 2, 2021
a762965
Maybe cleaner add system set conflict checking
Oct 2, 2021
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
19 changes: 19 additions & 0 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,23 @@ impl App {
}

pub fn add_system_set(&mut self, set: SystemSet) -> &mut Self {
thechubbypanda marked this conversation as resolved.
Show resolved Hide resolved
fn ensure_no_conflicts(set: &SystemSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could keep a reference to the conflicting stage name and add that to the panic message.

Small suggestion, you could use this instead conflict = set.systems.iter().any(|system| system.config().stage != set.config().stage);, but that's entirely up to preference.

let mut conflict = false;
for system in set.systems.iter() {
if system.config().stage != set.config().stage {
conflict = true;
}
}
for system in set.exclusive_systems.iter() {
if system.config().stage != set.config().stage {
conflict = true;
}
}
if conflict {
panic!("There is a mismatch between a system set's stage and it's sub systems")
}
}

if set.config().startup {
let set = {
if set.config().stage.is_some() {
Expand All @@ -237,6 +254,7 @@ impl App {
set.stage(StartupStage::Startup)
}
};
ensure_no_conflicts(&set);
self.schedule
.stage(CoreStage::Startup, |schedule: &mut Schedule| {
schedule.add_system_set(set)
Expand All @@ -249,6 +267,7 @@ impl App {
set.stage(CoreStage::Update)
}
};
ensure_no_conflicts(&set);
self.schedule.add_system_set(set);
}
self
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/schedule/system_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{fmt::Debug, hash::Hash};
/// A builder for describing several systems at the same time.
#[derive(Default)]
pub struct SystemSet {
pub(crate) systems: Vec<BoxedSystem>,
pub(crate) exclusive_systems: Vec<BoxedExclusiveSystem>,
pub systems: Vec<BoxedSystem>,
pub exclusive_systems: Vec<BoxedExclusiveSystem>,
pub(crate) config: SystemConfig,
}

Expand Down