bevy/crates
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
..
bevy_animation Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_app Remove obsolete after(apply_state_transition::<S>) (#7750) 2023-02-20 15:57:50 +00:00
bevy_asset Make StartupSet a base set (#7574) 2023-02-19 03:10:06 +00:00
bevy_audio Basic spatial audio (#6028) 2023-02-20 15:31:07 +00:00
bevy_core Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_core_pipeline fix ambiguities in render schedule (#7725) 2023-02-20 00:16:47 +00:00
bevy_derive update winit to 0.28 (#7480) 2023-02-03 16:41:39 +00:00
bevy_diagnostic Make StartupSet a base set (#7574) 2023-02-19 03:10:06 +00:00
bevy_dylib Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dynamic_plugin
bevy_ecs Add AND/OR combinators for run conditions (#7605) 2023-02-20 18:16:11 +00:00
bevy_ecs_compile_fail_tests
bevy_encase_derive add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) 2023-01-11 21:12:02 +00:00
bevy_gilrs Make StartupSet a base set (#7574) 2023-02-19 03:10:06 +00:00
bevy_gltf Add extras field to GltfNode (#6973) 2023-02-13 17:56:36 +00:00
bevy_hierarchy Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_input Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
bevy_internal Initial tonemapping options (#7594) 2023-02-19 20:38:13 +00:00
bevy_log
bevy_macro_utils Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_math
bevy_mikktspace
bevy_pbr fix ambiguities in render schedule (#7725) 2023-02-20 00:16:47 +00:00
bevy_ptr Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_reflect bevy_reflect: Improved documentation (#7148) 2023-02-18 20:42:01 +00:00
bevy_reflect_compile_fail_tests Enable deriving Reflect on structs with generic types (#7364) 2023-01-28 00:12:06 +00:00
bevy_render fix regex for shader define: must have at least one whitespace (#7754) 2023-02-20 02:19:41 +00:00
bevy_scene Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_sprite fix ambiguities in render schedule (#7725) 2023-02-20 00:16:47 +00:00
bevy_tasks improve safety comment in scope function (#7534) 2023-02-13 18:20:17 +00:00
bevy_text Add doc comments for the fields of Text2dBundle (#7749) 2023-02-20 04:15:16 +00:00
bevy_time Allow relative speed of -0.0 (#7740) 2023-02-18 22:43:08 +00:00
bevy_transform Make StartupSet a base set (#7574) 2023-02-19 03:10:06 +00:00
bevy_ui Initial tonemapping options (#7594) 2023-02-19 20:38:13 +00:00
bevy_utils Retain :: after >, ) or ] when shortening type names (#7755) 2023-02-20 15:31:08 +00:00
bevy_window Fix closing window does not exit app in desktop_app mode (#7628) 2023-02-13 19:15:24 +00:00
bevy_winit create window as soon as possible (#7668) 2023-02-14 15:08:04 +00:00