From c70e06c6d879208eb2822f6207ea7b29d47c2087 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 10 Apr 2024 19:51:46 +0200 Subject: chore(ecs): remove Event trait id method & take events by value --- ecs/examples/with_single.rs | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'ecs/examples/with_single.rs') 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) #[derive(Debug)] struct EventA; -impl Event for EventA -{ - fn id(&self) -> EventId - { - EventId::of::() - } -} +impl Event for EventA {} #[derive(Debug)] struct EventB; -impl Event for EventB -{ - fn id(&self) -> EventId - { - EventId::of::() - } -} +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); } -- cgit v1.2.3-18-g5258