bevy/crates
Carter Anderson dcc03724a5 Base Sets (#7466)
# Objective

NOTE: This depends on #7267 and should not be merged until #7267 is merged. If you are reviewing this before that is merged, I highly recommend viewing the Base Sets commit instead of trying to find my changes amongst those from #7267.

"Default sets" as described by the [Stageless RFC](https://github.com/bevyengine/rfcs/pull/45) have some [unfortunate consequences](https://github.com/bevyengine/bevy/discussions/7365).

## Solution

This adds "base sets" as a variant of `SystemSet`:

A set is a "base set" if `SystemSet::is_base` returns `true`. Typically this will be opted-in to using the `SystemSet` derive:

```rust
#[derive(SystemSet, Clone, Hash, Debug, PartialEq, Eq)]
#[system_set(base)]
enum MyBaseSet {
  A,
  B,
}
``` 

**Base sets are exclusive**: a system can belong to at most one "base set". Adding a system to more than one will result in an error. When possible we fail immediately during system-config-time with a nice file + line number. For the more nested graph-ey cases, this will fail at the final schedule build. 

**Base sets cannot belong to other sets**: this is where the word "base" comes from

Systems and Sets can only be added to base sets using `in_base_set`. Calling `in_set` with a base set will fail. As will calling `in_base_set` with a normal set.

```rust
app.add_system(foo.in_base_set(MyBaseSet::A))
       // X must be a normal set ... base sets cannot be added to base sets
       .configure_set(X.in_base_set(MyBaseSet::A))
```

Base sets can still be configured like normal sets:

```rust
app.add_system(MyBaseSet::B.after(MyBaseSet::Ap))
``` 

The primary use case for base sets is enabling a "default base set":

```rust
schedule.set_default_base_set(CoreSet::Update)
  // this will belong to CoreSet::Update by default
  .add_system(foo)
  // this will override the default base set with PostUpdate
  .add_system(bar.in_base_set(CoreSet::PostUpdate))
```

This allows us to build apis that work by default in the standard Bevy style. This is a rough analog to the "default stage" model, but it use the new "stageless sets" model instead, with all of the ordering flexibility (including exclusive systems) that it provides.

---

## Changelog

- Added "base sets" and ported CoreSet to use them.

## Migration Guide

TODO
2023-02-06 03:10:08 +00:00
..
bevy_animation Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_app Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_asset Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_audio Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_core Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_core_pipeline Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
bevy_derive update winit to 0.28 (#7480) 2023-02-03 16:41:39 +00:00
bevy_diagnostic Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_dylib Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dynamic_plugin Adapt path type of dynamically_load_plugin (#6734) 2022-12-05 23:39:43 +00:00
bevy_ecs Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_ecs_compile_fail_tests Fix clippy lints and failed test with Rust 1.66 (#6945) 2022-12-15 18:05:15 +00:00
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 Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_gltf enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00
bevy_hierarchy Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_input Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_internal update winit to 0.28 (#7480) 2023-02-03 16:41:39 +00:00
bevy_log Fix suppression of all console logs when trace_tracy is enabled (#6955) 2022-12-20 23:45:43 +00:00
bevy_macro_utils Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_math Improve code/comments for Ray::intersect_plane and its tests (#6823) 2022-12-05 22:49:06 +00:00
bevy_mikktspace Release 0.9.0 (#6568) 2022-11-12 20:01:29 +00:00
bevy_pbr Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_ptr Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_reflect Follow up on Todo in bevy_reflect_derive (#7461) 2023-02-02 04:37:32 +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 Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_scene Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_sprite Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
bevy_tasks Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
bevy_text Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_time Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_transform Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_ui Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_utils Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
bevy_window Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_winit Base Sets (#7466) 2023-02-06 03:10:08 +00:00