filter!() { /* proc-macro */ }Expand description
Implements Filter for the type, and implements Select optionally
if Target is defined.
Types implementing Filter only can be used in EntWrite only. Types
implementing both Filter and Select, on the other hand, also can be
used in Read and Write as well. Because Read and Write
mean requesting read or write access to a specific target component.
See Filter and Select for more details.
ยงExamples
use my_ecs::prelude::*;
#[derive(Component)] struct Ca;
#[derive(Component)] struct Cb;
#[derive(Component)] struct Cc;
#[derive(Component)] struct Cd;
#[derive(Component)] struct Ce;
// Declares `Fa` with an implemenation of `Filter`.
filter!(Fa, All = Ca);
// Declares `Fb` with an implemenation of `Filter`.
filter!(Fb, All = Ca, Any = Cb, None = Cc);
// Declares `Fc` with an implementation of `Filter` and `Select`.
filter!(Fc, Target = Ca);
// Declares `Fd` with an implementation of `Filter` and `Select`.
filter!(Fd, Target = Ca, All = Cb, Any = Cc, None = (Cd, Ce));
// All types implement `Filter` which means they can be used in
// `EntWrite`.
fn system_a(ew: EntWrite<(Fa, Fb, Fc, Fd)>) { /* ... */ }
// On the other hand, `Fc` and `Fd` can be used in `Read` and `Write`
// because they implement `Select` too.
fn system_b(r: Read<Fc>, w: Write<Fd>) { /* ... */ }