diff options
Diffstat (limited to 'ecs/examples/simple.rs')
-rw-r--r-- | ecs/examples/simple.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ecs/examples/simple.rs b/ecs/examples/simple.rs new file mode 100644 index 0000000..b58d2ba --- /dev/null +++ b/ecs/examples/simple.rs @@ -0,0 +1,32 @@ +use ecs::{Query, World}; + +struct SomeData +{ + num: u64, +} + +fn say_hello(mut query: Query<(SomeData, String)>) +{ + for (data, text) in query.iter_mut() { + println!("Hello {}: {}", text, data.num); + } +} + +#[derive(Debug, PartialEq, Eq, Hash)] +enum Event +{ + Start, +} + +fn main() +{ + let mut world = World::<Event>::new(); + + world.register_system(Event::Start, say_hello); + + world.create_entity((SomeData { num: 987_654 }, "Yoo".to_string())); + + world.create_entity((SomeData { num: 345 }, "Haha".to_string())); + + world.emit(&Event::Start); +} |