bevyengine / bevyengine/bevy

Affinitize System Sets to Schedules

Open
#9,139 10 comments 1 reaction 0 assignees View on GitHub
A-ECS A-States C-Usability S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Sometimes people do things like:

```rust
#[derive(SystemSet, Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct X;

app
.configure_sets(Update, X.run_if(in_state(GameState::Playing)))
.add_systems(Update, foo.in_set(X))
.add_systems(PostUpdate, foo.in_set(X))
```

Then they get confused when `foo` runs unconditionally in `PostUpdate` (because sets are "per schedule" configuration).

## What solution would you like?

One way to ensure this never happens is to require a specified ScheduleLabel type when implementing SystemSet.

```rust
#[derive(SystemSet, Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[system_set(Update)]
struct X;

app
.configure_sets(Update, X.run_if(in_state(GameState::Playing)))
.add_systems(Update, foo.in_set(X))
// This fails to compile
.add_systems(PostUpdate, foo.in_set(X))
```

I haven't fully thought this one through yet / I'm not sure we _actually_ want this solution. Just putting the idea out there.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.