implements WithoutAny, a QueryFilter which is supposed to be the opposite of WithOne
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.
This should also solve https://github.com/JoJoJet/bevy-trait-query/issues/50. My use case is something similar as described there. I want to query for things that have / don't have components of a certain class. Small pseudo code example:
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);
});
}
(adding all the missing things to make this actually run is left as an exercise to the reader)
This PR:
WithoutAny
, aQueryFilter
which is supposed to be the opposite ofWithOne
WithOne
to make itQueryFilter
onlyNote 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.This should also solve https://github.com/JoJoJet/bevy-trait-query/issues/50. My use case is something similar as described there. I want to query for things that have / don't have components of a certain class. Small pseudo code example:
(adding all the missing things to make this actually run is left as an exercise to the reader)