bevyengine / bevyengine/bevy

Add one default `SystemId` registration for one-shot systems

Open
#10,382 11 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Usability X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

One-shot system provides one concise way to run some logic. But it doesn't always come with a concise way in _most_ cases IMO.
Better to have a method for system to get its default `SystemId` automatically registered in world.

## What solution would you like?

Something like:
```rust
commands.run_system(some_system.id());
// or
commands.run_system(id(some_system));
```
~Every `.id()` refers to same `SystemId` registered in first call.~

UPDATE:

Maybe a `id(some_system)` or `id!(some_system)` will be easier to deal with.

`id()` will return a reference to a struct holds `SystemId` or system it self, which implements `IntoSystemId` or whatever.
`run_system` does registration when it gets no `SystemId`, then puts the registration result i.e. `SystemId` back.
`id()` manages a HashMap recording `system` -> `SystemId`, always returns `SystemId` for system after initialization.

Or simply, use system itself as parameter, let `run_system` manage the HashMap.

I don't know exactly how the trait magic works, or it's feasible to extends system to bear additional data?

## Additional context

Some use cases assumed:

- Run a setup system after gameover
- Call various entity spawner systems during setup

Contributor guide

Open the contributing guide

Research direction

Start by reading the SystemId, one-shot system, and Commands::run_system APIs named in the issue. Determine whether repeated calls can reuse a default registration and how id(some_system) or passing the system itself should behave. Done means the chosen API is specified and its repeated-call and setup use cases are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.