From ef86ce98ed8a21eeb00e60c0b3bd7d4f17544c92 Mon Sep 17 00:00:00 2001 From: Alec Deason Date: Sat, 31 Oct 2020 00:12:56 -0700 Subject: [PATCH] Make event example use a local resource (#754) Make EventListenerState a local resource --- examples/ecs/event.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/ecs/event.rs b/examples/ecs/event.rs index 536d7ca90a..1fe4e0e492 100644 --- a/examples/ecs/event.rs +++ b/examples/ecs/event.rs @@ -7,7 +7,6 @@ fn main() { .add_default_plugins() .add_event::() .init_resource::() - .init_resource::() .add_system(event_trigger_system.system()) .add_system(event_listener_system.system()) .run(); @@ -43,14 +42,12 @@ fn event_trigger_system( } } -#[derive(Default)] -struct EventListenerState { - my_event_reader: EventReader, -} - // prints events as they come in -fn event_listener_system(mut state: ResMut, my_events: Res>) { - for my_event in state.my_event_reader.iter(&my_events) { +fn event_listener_system( + mut my_event_reader: Local>, + my_events: Res>, +) { + for my_event in my_event_reader.iter(&my_events) { println!("{}", my_event.message); } }