When combining system conditions `not()` and `and()`, `not()` has no effect
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version and features
0.18.1
## What you did
I combined system conditions with `and()` so `on_countdown_completed` would run when `Countdown` reached zero. I added `not(resource_added::)` because I didn't want it to run immediately after the resource was added, but that didn’t work.
```rust
use bevy::prelude::*;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Resource)]
struct Countdown(usize);
fn on_countdown_completed(countdown: Res) {
dbg!(countdown.is_added(), countdown.is_changed(), countdown.0);
println!("countdown completed")
}
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.init_resource::()
.add_systems(
Update,
on_countdown_completed.run_if(
// This system should not run if Countdown was just added.
not(resource_added::)
// This system should run if Countdown was decremented to zero.
.and(resource_changed::)
.and(resource_equals(Countdown(0))),
),
)
.run();
}
```
## What went wrong
`on_countdown_completed` runs when `countdown.is_added()` is `true`.
```
[src/main.rs:7:5] countdown.is_added() = true
[src/main.rs:7:5] countdown.is_changed() = true
[src/main.rs:7:5] countdown.0 = 0
countdown completed
```
Replacing `not(resource_added::)` with `resource_added::` produced the same output.
What's going on?
Contributor guide
Assessment
This issue has not been assessed yet.