bevy
bevy copied to clipboard
Component Groups and data position boolean combinators.
Objective
Allow a generic group of components access to ergonomic filter queries.
Use case:
trait SomeBehavior {
type GroupA: ComponentGroup;
type GroupB: ComponentGroup;
}
fn behavior_system<B: SomeBehavior>(query: Query<
(Entity, <B::GroupA as ComponentGroup>::ReadQuery),
<B::GroupB as ComponentGroup>::With
>) {
...
}
Solution
Added trait ComponentGroup implemented on components and tuple Bundles. The trait has GATs that converts the tuple into queries, With queries, Has queries, Added queries, Changed queries, etc.
Or and its new counterpart And can now be used on the data side as boolean combinators to support this change.
Changelog
- Added aforementioned
ComponentGroup. - Added the capability of
AndandOrto function on the data side. - Since
ChangedandAddedrecently got removed from the data side due to their confusing nature, definedIs<T> = And<(T,)>as a way to use these queries on the data side. - Added primitives
AlwaysandNeveras default cases for some queries.
Migration Guide
I don't think there is a breaking change here.