Crates.io | bevy_mod_check_filter |
lib.rs | bevy_mod_check_filter |
version | 0.3.0 |
source | src |
created_at | 2022-08-10 19:54:55.662809 |
updated_at | 2022-08-15 08:51:43.578711 |
description | A module for improved ergonomics with Enabled-style marker components. |
homepage | |
repository | https://github.com/ItsDoot/bevy_mod_check_filter |
max_upload_size | |
id | 642853 |
size | 43,040 |
A query filter to allow Enabled
-style marker components without losing the
ergonomics of ZST
-style marker component filtering!
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>>) {
// ...
}
All code in this repository is dual-licensed under either: