Allow a Query to iterate over all elements that are not the current element of an existing iteration
- 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?
In the case I'm looking at, I have a set of ```TeamMember```s and there are times where a single ```TeamMember``` needs to consider all other ```TeamMember```s. When the data in question is mutable, this creates aliasing issues and is currently difficult to resolve - I've personally been using Events to do it, but that comes with the cost of a frame delay and a separation of logic.
## What solution would you like?
Something like this is sort of how I could imagine it working:
```
query: Query<(Entity, &mut Transform), With>
for element in query.iter_mut() {
let mut best_support = None;
let mut closest = f32::MAX;
// iter_except() returns an iterator over all elements *except* the one given to it
for mate in query.iter_except(element.0) {
// if mate is closest (this reads the mate Transform),
// save it as best_support and update closest
}
// move our translation closer to the best support
}
```
## What alternative(s) have you considered?
It's possible that this could be resolved with ParamSet, but I'm not certain if it would work given that both queries would be querying the same data. As noted, I've solved it currently using Events, but the frame delay and logic separation that comes with that doesn't feel very good.
Contributor guide
Assessment
This issue has not been assessed yet.