summaryrefslogtreecommitdiff
path: root/ecs/examples/with_local.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/examples/with_local.rs')
-rw-r--r--ecs/examples/with_local.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/ecs/examples/with_local.rs b/ecs/examples/with_local.rs
index b37a5c3..0342930 100644
--- a/ecs/examples/with_local.rs
+++ b/ecs/examples/with_local.rs
@@ -1,4 +1,5 @@
use ecs::component::Local;
+use ecs::event::{Event, Id as EventId};
use ecs::system::{Into, System};
use ecs::{Component, Query, World};
@@ -41,25 +42,30 @@ fn say_whats_up(query: Query<(SomeData, Name)>, mut state: Local<SayHelloState>)
}
}
-#[derive(Debug, PartialEq, Eq, Hash)]
-enum Event
+#[derive(Debug)]
+struct Update;
+
+impl Event for Update
{
- Update,
+ fn id(&self) -> EventId
+ {
+ EventId::of::<Self>()
+ }
}
fn main()
{
- let mut world = World::<Event>::new();
+ let mut world = World::new();
world.register_system(
- Event::Update,
+ &Update,
say_hello
.into_system()
.initialize((SayHelloState { cnt: 0 },)),
);
world.register_system(
- Event::Update,
+ &Update,
say_whats_up
.into_system()
.initialize((SayHelloState { cnt: 0 },)),
@@ -69,9 +75,9 @@ fn main()
world.create_entity((SomeData { num: 345 },));
- world.emit(&Event::Update);
+ world.emit(&Update);
println!("Haha");
- world.emit(&Event::Update);
+ world.emit(&Update);
}