This commit is contained in:
Greg Shuflin 2023-03-18 14:15:17 -07:00
parent 5bc2934672
commit ad4f571deb
1 changed files with 9 additions and 8 deletions

View File

@ -5,7 +5,7 @@ pub struct GamarjobaPlugin;
impl Plugin for GamarjobaPlugin { impl Plugin for GamarjobaPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_startup_system(add_people) app.add_startup_system(add_people)
.add_system(gamarjoba) .insert_resource(GreetTimer(Timer::from_seconds(2.0, TimerMode::Repeating)))
.add_system(greetings); .add_system(greetings);
} }
@ -25,16 +25,17 @@ fn add_people(mut commands: Commands) {
commands.spawn((Person, Name("Mak'lazi Heyorem".into()))); commands.spawn((Person, Name("Mak'lazi Heyorem".into())));
} }
fn greetings(query: Query<&Name, With<Person>>) { #[derive(Resource)]
for name in &query { struct GreetTimer(Timer);
println!("Gamarjoba, {}", name.0)
fn greetings(query: Query<&Name, With<Person>>, time: Res<Time>, mut timer: ResMut<GreetTimer>) {
if timer.0.tick(time.delta()).just_finished() {
for name in &query {
println!("Gamarjoba, {}", name.0)
}
} }
} }
fn gamarjoba() {
println!("Gamarjoba, munde!");
}
fn main() { fn main() {
App::new() App::new()