https://github.com/itsdoot/bevy_mod_check_filter
Better marker component ergonomics with the Bevy Engine
https://github.com/itsdoot/bevy_mod_check_filter
Last synced: 9 months ago
JSON representation
Better marker component ergonomics with the Bevy Engine
- Host: GitHub
- URL: https://github.com/itsdoot/bevy_mod_check_filter
- Owner: ItsDoot
- License: apache-2.0
- Created: 2022-08-10T19:49:12.000Z (almost 4 years ago)
- Default Branch: dev
- Last Pushed: 2022-08-15T08:50:47.000Z (almost 4 years ago)
- Last Synced: 2025-03-28T08:23:13.925Z (over 1 year ago)
- Language: Rust
- Homepage: https://crates.io/crates/bevy_mod_check_filter
- Size: 17.6 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
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`:
```rust
#[derive(Component)]
struct Poisoned;
#[derive(Component)]
struct Name { name: &'static str }
fn all_poisoned(entities: Query<&Name, With>) {
// ...
}
```
With `bevy_mod_check_filter`:
```rust
#[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>>) {
// ...
}
// OR with one of the provided type aliases:
fn find_poisoned(entities: Query<&Name, IsTrue>) {
// ...
}
```
## License
All code in this repository is dual-licensed under either:
- MIT License (LICENSE-MIT file or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE file or
http://www.apache.org/licenses/LICENSE-2.0)