Closed
Description
What problem does this solve or what need does it fill?
Reduce the verbosity of queries by using bundles, which are already used for this purpose during entity archetype construction.
What solution would you like?
The ability to add a struct that derives Bundle
to a query, and have it return with its fields accessible as components. E.g.:
#[derive(Bundle)]
struct Transform {
translation: Translation,
rotation: Rotation,
scale: Scale,
}
// can still use this common case
Query<&Transform>
// but also, able to query fields granularly with change detection
Query<&Transform, Changed<Rotation>>
//...
// Can use this to group other sets of components as query-able bundles
#[derive(Bundle)]
struct Dog {
legs: Legs
fluffy_tail: Tail
wet_nose: Nose
}
// These two queries are functionally equivalent, but the `Dog` query returns a list of `Dog` structs
Query<&Dog>
Query<(&Legs, &Tail, &Nose)>
What alternative(s) have you considered?
Most of this can already be achieved with some verbosity, as shown in the dog example above. However, it would also allow us to split apart common components like Transform
into their parts with field level change detection, without losing the ergonomics of the Transform
type.
Additional context
Similar to #786
Metadata
Metadata
Assignees
Labels
Entities, components, systems, and eventsA new feature, making something new possibleA change motivated by improving speed, memory usage or compile timesA targeted quality-of-life change that makes Bevy easier to useThis issue or PR is particularly complex, and needs an approved design doc before it can be merged