summaryrefslogtreecommitdiff
path: root/ecs/examples/with_single.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-04-10 19:51:46 +0200
committerHampusM <hampus@hampusmat.com>2024-04-10 19:51:46 +0200
commitc70e06c6d879208eb2822f6207ea7b29d47c2087 (patch)
tree06b5b7ae8fbf69d6041fff1c576d7610ff6fba6a /ecs/examples/with_single.rs
parent9d8c73dd2671131929967214433dae5479e95b5b (diff)
chore(ecs): remove Event trait id method & take events by value
Diffstat (limited to 'ecs/examples/with_single.rs')
-rw-r--r--ecs/examples/with_single.rs26
1 files changed, 7 insertions, 19 deletions
diff --git a/ecs/examples/with_single.rs b/ecs/examples/with_single.rs
index 25b73d1..d222f76 100644
--- a/ecs/examples/with_single.rs
+++ b/ecs/examples/with_single.rs
@@ -1,5 +1,5 @@
use ecs::component::single::Single;
-use ecs::event::{Event, Id as EventId};
+use ecs::event::Event;
use ecs::{Component, Query, World};
#[derive(Component)]
@@ -33,31 +33,19 @@ fn print_total_ammo_count(ammo_counter: Single<AmmoCounter>)
#[derive(Debug)]
struct EventA;
-impl Event for EventA
-{
- fn id(&self) -> EventId
- {
- EventId::of::<Self>()
- }
-}
+impl Event for EventA {}
#[derive(Debug)]
struct EventB;
-impl Event for EventB
-{
- fn id(&self) -> EventId
- {
- EventId::of::<Self>()
- }
-}
+impl Event for EventB {}
fn main()
{
let mut world = World::new();
- world.register_system(&EventA, count_ammo);
- world.register_system(&EventB, print_total_ammo_count);
+ world.register_system(EventA, count_ammo);
+ world.register_system(EventB, print_total_ammo_count);
world.create_entity((Ammo { ammo_left: 4 },));
world.create_entity((Ammo { ammo_left: 7 },));
@@ -65,7 +53,7 @@ fn main()
world.add_single_component(AmmoCounter::default()).unwrap();
- world.emit(&EventA);
+ world.emit(EventA);
- world.emit(&EventB);
+ world.emit(EventB);
}