use ecs::{Component, Query, World}; #[derive(Component)] struct SomeData { num: u64, } #[derive(Component)] struct Greeting { greeting: String, } fn say_hello(query: Query<(SomeData, Greeting)>) { for (data, greeting) in &query { println!("{}: {}", greeting.greeting, data.num); } } #[derive(Debug, PartialEq, Eq, Hash)] enum Event { Start, } fn main() { let mut world = World::::new(); world.register_system(Event::Start, say_hello); world.create_entity(( SomeData { num: 987_654 }, Greeting { greeting: "Good afternoon".to_string(), }, )); world.create_entity(( SomeData { num: 345 }, Greeting { greeting: "Good evening".to_string() }, )); world.emit(&Event::Start); }