Bevy does not distinguish between "has a component" access and "read" access, leading to `OnRemove` + `Has` system param incompatibility
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
v0.16.0
## What you did
Code:
```rs
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_observer(foo)
.add_systems(Startup, setup)
.add_systems(Update, update)
.run();
}
#[derive(Component)]
struct A;
fn foo(t: Trigger, q: Query>) {
println!("foo: {:?}", q.get(t.target()));
}
fn setup(mut commands: Commands) {
commands.spawn(A);
}
fn update(mut commands: Commands, q: Query>, time: Res
## What went wrong
When the component `A` is removed from the entity, the observer `foo` is correctly triggered. However, the `Has` in query still reports `true`. This is a MRE, my actual implementation is way complicated, solely relay on `OnRemove` to tell if the component presents in my case is impossible, unless I totally rewrite that part of the logics (which is probably the only workaround, AFAIK).
Contributor guide
Research direction
Start with the minimal reproduction in the issue, focusing on the OnRemove observer and its Query> parameter when update removes A. Trace how the observer trigger and query access are handled; done means Has no longer reports true for the removed component during the observer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100