This commit is contained in:
Greg Shuflin 2023-03-18 14:15:17 -07:00
parent 5bc2934672
commit ad4f571deb

View File

@ -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<Person>>) {
for name in &query {
println!("Gamarjoba, {}", name.0)
#[derive(Resource)]
struct GreetTimer(Timer);
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() {
App::new()