bevyengine / bevyengine/bevy

Allow Option<Entity> with the new Query many() interface

Open
#4,510 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Usability
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.