-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add API for simple system ordering #5165
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,13 @@ | ||||||
use bevy_ecs_macros::impl_into_linked_system_set; | ||||||
|
||||||
use crate::schedule::{ | ||||||
AmbiguitySetLabel, BoxedAmbiguitySetLabel, BoxedSystemLabel, IntoRunCriteria, | ||||||
IntoSystemDescriptor, RunCriteriaDescriptorOrLabel, State, StateData, SystemDescriptor, | ||||||
SystemLabel, | ||||||
}; | ||||||
use crate::system::AsSystemLabel; | ||||||
use crate::system::{AsSystemLabel, SystemParam, SystemParamFunction}; | ||||||
|
||||||
use super::ParallelSystemDescriptorCoercion; | ||||||
|
||||||
/// A builder for describing several systems at the same time. | ||||||
#[derive(Default)] | ||||||
|
@@ -138,3 +142,80 @@ impl SystemSet { | |||||
(run_criteria, systems) | ||||||
} | ||||||
} | ||||||
|
||||||
/// A trait that provides the [`.link()`] method to tuples of systems. | ||||||
/// | ||||||
/// [`.link()`]: IntoLinkedSystemSet::link | ||||||
pub trait IntoLinkedSystemSet<S, P> { | ||||||
/// A helper method to create system sets with automatic | ||||||
/// ordering of execution. | ||||||
/// | ||||||
/// This is only implemented for tuples of 2 to 15 systems. | ||||||
/// | ||||||
/// ``` | ||||||
/// # use bevy_ecs::prelude::*; | ||||||
/// # | ||||||
/// # fn first_system() {} | ||||||
/// # fn second_system() {} | ||||||
/// # fn third_system() {} | ||||||
/// # fn fourth_system() {} | ||||||
/// | ||||||
/// // This expression... | ||||||
/// | ||||||
/// ( | ||||||
/// first_system, | ||||||
/// second_system, | ||||||
/// third_system, | ||||||
/// fourth_system, | ||||||
/// ).link(); | ||||||
/// | ||||||
/// // ...is equal to: | ||||||
/// | ||||||
/// SystemSet::new() | ||||||
/// .with_system(first_system) | ||||||
/// .with_system(second_system.after(first_system)) | ||||||
/// .with_system(third_system.after(second_system)) | ||||||
/// .with_system(fourth_system.after(third_system)); | ||||||
/// ``` | ||||||
fn link(self) -> SystemSet; | ||||||
} | ||||||
|
||||||
impl_into_linked_system_set!(); | ||||||
|
||||||
/// A trait that provides the [`.then()`] method to systems. | ||||||
/// | ||||||
/// [`.then()`]: IntoSequentialSystemSet::then | ||||||
pub trait IntoSequentialSystemSet<S0, S1, P0, P1> { | ||||||
/// A helper method to create system sets with automatic | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// ordering of execution. | ||||||
/// | ||||||
/// ``` | ||||||
/// # use bevy_ecs::prelude::*; | ||||||
/// # | ||||||
/// # fn first_system() {} | ||||||
/// # fn second_system() {} | ||||||
/// | ||||||
/// // This expression... | ||||||
/// | ||||||
/// first_system.then(second_system); | ||||||
/// | ||||||
/// // ...is equal to: | ||||||
/// | ||||||
/// SystemSet::new() | ||||||
/// .with_system(first_system) | ||||||
/// .with_system(second_system.after(first_system)); | ||||||
/// ``` | ||||||
fn then(self, next_system: S1) -> SystemSet; | ||||||
} | ||||||
|
||||||
impl<S0, S1, P0, P1> IntoSequentialSystemSet<S0, S1, P0, P1> for S0 | ||||||
where | ||||||
P0: SystemParam + 'static, | ||||||
P1: SystemParam + 'static, | ||||||
S0: SystemParamFunction<(), (), P0, ()> + 'static, | ||||||
S1: SystemParamFunction<(), (), P1, ()> + 'static, | ||||||
{ | ||||||
fn then(self, next_system: S1) -> SystemSet { | ||||||
(self, next_system).link() | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.