bevy_mod_check_filter

Crates.iobevy_mod_check_filter
lib.rsbevy_mod_check_filter
version0.3.0
sourcesrc
created_at2022-08-10 19:54:55.662809
updated_at2022-08-15 08:51:43.578711
descriptionA module for improved ergonomics with Enabled-style marker components.
homepage
repositoryhttps://github.com/ItsDoot/bevy_mod_check_filter
max_upload_size
id642853
size43,040
Christian Hughes (ItsDoot)

documentation

README

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:

Commit count: 14

cargo fmt