-
Notifications
You must be signed in to change notification settings - Fork 17
Add support for traits in Query filters #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would also love to be able to do this! |
RobWalt
added a commit
that referenced
this issue
Oct 28, 2024
solves #50 feat: Implement `WithoutAny` filter This PR: 1. implements `WithoutAny`, a `QueryFilter` which is supposed to be the opposite of `WithOne` 2. cleans up some parts of `WithOne` to make it `QueryFilter` only Note that 2. is a breaking change since we can't use it in the Data position anymore. However, I think this is fine since there is `One` which already fills this gap. So this is really a fix since it clears up the separation of concerns of the two structs. --- Small pseudo code example: ```rust struct Food; trait Fruit {} struct Banana; impl Fruit for Banana {} struct Apple; impl Fruit for Apple {} struct Sweets; struct Cake; fn eat_unhealthy( mut commands: Commands, q_non_fruits: Query<Entity, (With<Food>, WithoutAny<&dyn Fruit>)> ) { q_non_fruits.iter().for_each(|food| { // only sweets and cakes without fruits commands.eat(food); }); } ```
This feature is now supported as of Please see |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my particular use case, I would like the ability to be able to use traits in a
With<>
orWithout<>
filter in the query.Example:
The above return a compile error because
Sized
is not implemented for(dyn OrderItem + 'static)
(dyn OrderItem + 'static): bevy::prelude::Component
is not satisfiedthe following other types implement trait
bevy::prelude::Component
The definition for
OrderItem
is as such:The text was updated successfully, but these errors were encountered: