Skip to content

Add support for traits in Query filters #50

Closed
@dbidwell94

Description

@dbidwell94

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 size for values of type (dyn OrderItem + 'static) cannot be known at compilation time the trait Sized is not implemented for (dyn OrderItem + 'static)
  • the trait bound (dyn OrderItem + 'static): bevy::prelude::Component is not satisfied
    the following other types implement trait bevy::prelude::Component

The definition for OrderItem is as such:

    #[bevy_trait_query::queryable]
    pub trait OrderItem {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions