#component #filter #query #bevy

bevy_mod_check_filter

A module for improved ergonomics with Enabled-style marker components

6 releases

0.3.0 Aug 15, 2022
0.2.1 Aug 15, 2022
0.1.2 Aug 14, 2022

#1541 in Game dev

Download history 4/week @ 2024-02-15 7/week @ 2024-02-22 3/week @ 2024-02-29 1/week @ 2024-03-07 58/week @ 2024-03-28

59 downloads per month

MIT/Apache

14KB
208 lines

bevy_mod_check_filter

A query filter to allow Enabled-style marker components without losing the ergonomics of ZST-style marker component filtering!

Example

Without bevy_mod_check_filter:

#[derive(Component)]
struct Poisoned;

#[derive(Component)]
struct Name { name: &'static str }

fn all_poisoned(entities: Query<&Name, With<Poisoned>>) {
    // ...
}

With bevy_mod_check_filter:

#[derive(Component)]
struct Poisoned(pub bool);

impl std::ops::Deref for Poisoned {
    type Target = bool;
 
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

#[derive(Component)]
struct Name { name: &'static str }

fn all_poisoned(entities: Query<&Name, Check<Poisoned, Is<true>>>) {
    // ...
}

// OR with one of the provided type aliases:
fn find_poisoned(entities: Query<&Name, IsTrue<Poisoned>>) {
    // ...
}

License

All code in this repository is dual-licensed under either:

Dependencies

~7–15MB
~166K SLoC