Allow Option<Entity> with the new Query many() interface
- 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?
I'd like to get multiple entities at once from a Query where some of those entities may be optional. Unless I've missed something, I don't currently see a way to do this.
## What solution would you like?
```
struct SomeEntities {
a: Entity,
b: Option,
}
fn system(mut query: Query<&mut Transform>, entities: Res) {
let [a_transform, b_transform] = query.many_mut([entities.a, entities.b]);
if let Some(b_transform) = b_transform {
// ...
}
}
```
## What alternative(s) have you considered?
So far I'm not sure of an alternative aside from the old ways of working without the new many() interface.
Contributor guide
Research direction
Start by locating the new Query many() and many_mut() interface and tracing how entity arguments and optional results are represented. Compare the requested Option example with the existing behavior, then identify the relevant test coverage; done means the example supports an optional entity while preserving required query results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100