bevyengine / bevyengine/bevy

Replace `Trigger`'s default bundle filtering behavior from an OR to an AND

Open
#15,325 2 comments 3 reactions 0 assignees View on GitHub
A-ECS C-Bug D-Complex
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?

The fact that the `B` in `Trigger` currently means `OR` instead of `AND` is confusing enough that it even surprised a maintainer. Everywhere else in bevy, tuples (which bundles can be) mean `AND`, so we should change `Trigger`'s default behavior.

## What solution would you like?

The following code should work (but doesn't currently):
```rust
fn my_observer(trigger: Trigger) {

}

// This *should not* trigger the above observer:
world.trigger(Foo, world.component::());
// But *this* should:
world.trigger(Foo, (world.component::
(), world.component::());
```

## Additional context

[Moment of confusion on discord](https://discord.com/channels/691052431525675048/749335865876021248/1286511885759414296).

Contributor guide

Open the contributing guide

Research direction

Start by locating the Trigger observer implementation and any tests covering bundle filtering, then trace how world.trigger matches the bundle parameter. Update the default behavior so tuple bundles require all components, and verify that a trigger with only A does not match (A, B) while one with both does.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.