-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Merged by Bors] - Add bevy_ecs::schedule_v3
module
#6587
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
Closed
Closed
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
a686708
Add `bevy_ecs::schedule_v3` module
maniwani 0e8c2ce
Update schedule.rs
maniwani 7451685
ambiguous_with system type sets
maniwani c1f35d2
docs
maniwani 33f7c98
move `petgraph` to utils
maniwani d1ed541
clean up warnings
maniwani 7f86219
document graph alg
maniwani 2ee5ef6
fix condition issue, flatten graph mod, get executor kind
maniwani 0152ce9
clippy being pedantic
maniwani a25017e
fix `is_apply_system_buffers` not working
maniwani 26d29a5
docs docs docs docs docs
maniwani 1a6a061
`explicit_iter_loop` is a dumb lint CMV
maniwani 77d35f1
simplify loop
maniwani 385d6bf
typo
maniwani 4ba6a1d
just leave `State<S>` in the world
maniwani 19fd6c0
nit
maniwani 47b3ff4
internal consistency
maniwani 54ba8b4
don't panic
maniwani 71d4631
cleanup
maniwani cc41572
default system set handling for system sets
maniwani 0c826fb
check docs
maniwani 20eb905
Make signalling dependents copyless
james7132 dc5abef
Apply suggestions from code review
maniwani c899e99
nits
maniwani 730182d
add some tests
hymm 4c2af44
move tests to mod.rs
hymm 6541956
fmt
maniwani 7e11b44
builder pattern for `Schedule` methods
maniwani 6ee040a
miri
maniwani a0bbdae
style + ticks
maniwani 23f2250
rename fields for clarity
maniwani 24c1945
respond to feedback pt1
maniwani 3af4d28
docs
maniwani 4869bed
update to match system param API changes
maniwani a2ef27b
beef with clippy
maniwani 10227fd
reorganize
maniwani 528f9dd
respond to feedback pt2
maniwani 789cf77
fix tests
maniwani 910b817
replace `ScheduleGraph` hash maps with vectors
maniwani 470cce1
make optional errors opt-in
maniwani 3d0224d
clippy
maniwani b465063
Apply suggestions from code review
maniwani d987a08
Apply suggestions from code review
maniwani 533e266
wording
maniwani c8f0a98
*mildly* cursed code
maniwani 3e10dc0
avoid counting bits in bitset
maniwani ca4e643
style
maniwani e357e30
Apply suggestions from review
maniwani 66263c7
rename `Statelike` to `States` and remove blanket impl
maniwani 1441bcd
all_tuples
maniwani 8d65fac
remove TODO
maniwani 7c0a1da
comment
maniwani 4dc4139
Apply suggestions from code review
maniwani d851616
simplify trait bound
maniwani fbc2438
james said `difference` isn't optimized
maniwani 7a15581
add `ambiguous_with` for tuples
maniwani 2020bd4
Apply suggestions from review
maniwani 6a70eef
safety
maniwani 1f86f21
clippy, my archenemy
maniwani cad97b2
style
maniwani 1ca012b
fix type signature
maniwani c10c467
take without option
maniwani c253885
Update crates/bevy_ecs/src/schedule_v3/executor/multi_threaded.rs
cart 9a62c72
pass the CI vibecheck
maniwani 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
pub use common_conditions::*; | ||
|
||
use crate::system::BoxedSystem; | ||
|
||
pub type BoxedCondition = BoxedSystem<(), bool>; | ||
|
||
/// A system that determines if one or more scheduled systems should run. | ||
/// | ||
/// Implemented for functions and closures that convert into [`System<In=(), Out=bool>`](crate::system::System) | ||
/// with [read-only](crate::system::ReadOnlySystemParam) parameters. | ||
pub trait Condition<Params>: sealed::Condition<Params> {} | ||
|
||
impl<Params, F> Condition<Params> for F where F: sealed::Condition<Params> {} | ||
|
||
mod sealed { | ||
use crate::system::{IntoSystem, IsFunctionSystem, ReadOnlySystemParam, SystemParamFunction}; | ||
|
||
pub trait Condition<Params>: IntoSystem<(), bool, Params> {} | ||
|
||
impl<Params, Marker, F> Condition<(IsFunctionSystem, Params, Marker)> for F | ||
where | ||
F: SystemParamFunction<(), bool, Params, Marker> + Send + Sync + 'static, | ||
Params: ReadOnlySystemParam + 'static, | ||
Marker: 'static, | ||
{ | ||
} | ||
} | ||
|
||
mod common_conditions { | ||
use crate::schedule_v3::{State, States}; | ||
use crate::system::{Res, Resource}; | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the resource exists. | ||
pub fn resource_exists<T>() -> impl FnMut(Option<Res<T>>) -> bool | ||
maniwani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
where | ||
T: Resource, | ||
{ | ||
move |res: Option<Res<T>>| res.is_some() | ||
} | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the resource is equal to `value`. | ||
/// | ||
/// # Panics | ||
/// | ||
/// The condition will panic if the resource does not exist. | ||
pub fn resource_equals<T>(value: T) -> impl FnMut(Res<T>) -> bool | ||
where | ||
T: Resource + PartialEq, | ||
{ | ||
move |res: Res<T>| *res == value | ||
} | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the resource exists and is equal to `value`. | ||
/// | ||
/// The condition will return `false` if the resource does not exist. | ||
pub fn resource_exists_and_equals<T>(value: T) -> impl FnMut(Option<Res<T>>) -> bool | ||
where | ||
T: Resource + PartialEq, | ||
{ | ||
move |res: Option<Res<T>>| match res { | ||
Some(res) => *res == value, | ||
None => false, | ||
} | ||
} | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the state machine exists. | ||
pub fn state_exists<S: States>() -> impl FnMut(Option<Res<State<S>>>) -> bool { | ||
move |current_state: Option<Res<State<S>>>| current_state.is_some() | ||
} | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the state machine is currently in `state`. | ||
/// | ||
/// # Panics | ||
/// | ||
/// The condition will panic if the resource does not exist. | ||
pub fn state_equals<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool { | ||
move |current_state: Res<State<S>>| current_state.0 == state | ||
} | ||
|
||
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` | ||
/// if the state machine exists and is currently in `state`. | ||
maniwani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// The condition will return `false` if the state does not exist. | ||
pub fn state_exists_and_equals<S: States>( | ||
state: S, | ||
) -> impl FnMut(Option<Res<State<S>>>) -> bool { | ||
move |current_state: Option<Res<State<S>>>| match current_state { | ||
Some(current_state) => current_state.0 == state, | ||
None => false, | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Are we able to doc link these traits?