#![allow(unused)]
#![allow(dead_code)]
use nya_ecs::{
ComponentKey, Filter, Query, Queryable as _, World, component, component_id, query::Exclude,
};
struct Tag;
component!(Tag);
struct Name(&'static str);
component!(Name);
struct Num(usize);
component!(Num);
fn main() {
let mut world = World::new();
for i in 0..5 {
let ent = world.spawn();
world.add(ent, Tag);
world.add(ent, Name("Object"));
if i % 2 == 0 {
world.add(ent, Num(i));
}
}
{
let ent = world.spawn();
world.add(ent, Num(1337));
}
let query = world.query::<(Tag, Num)>();
for e in &query {
println!("Entity #{e} has both `Tag` and `Num`");
}
for e in &world.query::<(Tag, Exclude<(Num,)>)>() {
println!("Entity #{e} has `Tag` without `Num`");
}
let filter = Filter::new()
.with_include(&[ComponentKey::of::<Tag>(), ComponentKey::of::<Name>()])
.with_exclude(&[component_id!(Num)]);
for _ in &world.query_filter(filter) {
}
}