From ad4f571debde043af75666e6c6421976fc454de8 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sat, 18 Mar 2023 14:15:17 -0700 Subject: [PATCH] Resource --- src/main.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7a5e3ec..4e57af4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ pub struct GamarjobaPlugin; impl Plugin for GamarjobaPlugin { fn build(&self, app: &mut App) { app.add_startup_system(add_people) - .add_system(gamarjoba) + .insert_resource(GreetTimer(Timer::from_seconds(2.0, TimerMode::Repeating))) .add_system(greetings); } @@ -25,16 +25,17 @@ fn add_people(mut commands: Commands) { commands.spawn((Person, Name("Mak'lazi Heyorem".into()))); } -fn greetings(query: Query<&Name, With>) { - for name in &query { - println!("Gamarjoba, {}", name.0) +#[derive(Resource)] +struct GreetTimer(Timer); + +fn greetings(query: Query<&Name, With>, time: Res