JoJoJet / bevy-trait-query

adds trait queries to the bevy game engine
Apache License 2.0
65 stars 11 forks source link

Add support for traits in Query filters #50

Open dbidwell94 opened 6 months ago

dbidwell94 commented 6 months ago

In my particular use case, I would like the ability to be able to use traits in a With<> or Without<> filter in the query.

Example:

pub fn cleanup_status(
    mut commands: Commands,
    q: Query<
        Entity,
        (
            With<PawnStatus<pawn_status::Attacking>>,
            Without<dyn work_order::OrderItem>,
        ),
    >,
) {
}

The above return a compile error because

The definition for OrderItem is as such:

    #[bevy_trait_query::queryable]
    pub trait OrderItem {}
brandon-reinhart commented 4 months ago

I would also love to be able to do this!

RobWalt commented 1 month ago

The desired behavior should be achievable with the results from #55 and #58 . Instead of using the native With and Without filters, you should be able to use WithOne and WithoutOne to get the same result. If I'm missing a case, let me know!