Skip to main content

query

Macro query 

Source
macro_rules! query {
    ($($component:ty),+ $(,)?) => { ... };
    ($($component:ty),+, with: $with:ty $(,)?) => { ... };
    ($($component:ty),+, without: $without:ty $(,)?) => { ... };
    ($($component:ty),+, changed: $changed:ty $(,)?) => { ... };
    ($($component:ty),+, with: $with:ty, without: $without:ty $(,)?) => { ... };
    ($($component:ty),+, with: $with:ty, changed: $changed:ty $(,)?) => { ... };
    ($($component:ty),+, without: $without:ty, changed: $changed:ty $(,)?) => { ... };
    ($($component:ty),+, with: $with:ty, without: $without:ty, changed: $changed:ty $(,)?) => { ... };
}
Expand description

convenience wrapper for creating ecs query types.

this macro simplifies common query patterns by wrapping bevy_ecs query filters into a single expression. it is designed to be used in system function signatures.

§example

use lunar_math::query;
use bevy_ecs::prelude::Query;

// query for entities with Position and Velocity
fn my_system(query: query!(Position, Velocity)) {
    for (pos, vel) in query.iter() {
        // ...
    }
}

// query with filters
fn filtered(query: query!(Position, with: Player, without: Dead, changed: Velocity)) {
    // ...
}