bevy/crates/bevy_ecs/src/schedule
JoJoJet 0c98f9a225 Add AND/OR combinators for run conditions (#7605)
# Objective

Fix #7584.

## Solution

Add an abstraction for creating custom system combinators with minimal boilerplate. Use this to implement AND/OR combinators. Use this to simplify the implementation of `PipeSystem`.

## Example

Feel free to bikeshed on the syntax.

I chose the names `and_then`/`or_else` to emphasize the fact that these short-circuit, while I chose method syntax to empasize that the arguments are *not* treated equally.

```rust
app.add_systems((
    my_system.run_if(resource_exists::<R>().and_then(resource_equals(R(0)))),
    our_system.run_if(resource_exists::<R>().or_else(resource_exists::<S>())),
));
```

---

## Todo

- [ ] Decide on a syntax
- [x] Write docs
- [x] Write tests

## Changelog

+ Added the extension methods `.and_then(...)` and `.or_else(...)` to run conditions, which allows combining run conditions with short-circuiting behavior.
+ Added the trait `Combine`, which can be used with the new `CombinatorSystem` to create system combinators with custom behavior.
2023-02-20 18:16:11 +00:00
..
executor Default to using ExecutorKind::SingleThreaded on wasm32 (#7717) 2023-02-17 00:22:56 +00:00
condition.rs Add AND/OR combinators for run conditions (#7605) 2023-02-20 18:16:11 +00:00
config.rs Add distributive_run_if to IntoSystemConfigs (#7724) 2023-02-18 21:33:09 +00:00
graph_utils.rs for disconnected, use Vec instead of HashSet to reduce insert overhead (#7744) 2023-02-19 16:35:39 +00:00
mod.rs Add distributive_run_if to IntoSystemConfigs (#7724) 2023-02-18 21:33:09 +00:00
schedule.rs Add report_sets option to ScheduleBuildSettings (#7756) 2023-02-20 15:31:10 +00:00
set.rs change is_system_type() -> bool to system_type() -> Option<TypeId> (#7715) 2023-02-16 22:25:48 +00:00
state.rs Rename state_equals condition to in_state (#7677) 2023-02-14 21:30:14 +00:00