From 19f4c5280ef2f57e787426f2f255d4b0893e08e7 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Mon, 29 Jul 2024 23:05:19 -0700 Subject: [PATCH] custom plugin --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6ecf13c..f47d66d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,7 @@ use bevy::prelude::*; fn main() { - App::new() - .add_plugins(DefaultPlugins) - .add_systems(Startup, add_people) - .add_systems(Update, (hello_world, greet_people).chain()) - .run(); + App::new().add_plugins((DefaultPlugins, HelloPlugin)).run(); } fn hello_world() { @@ -29,3 +25,12 @@ fn greet_people(query: Query<&Name, With>) { println!("hello {}!", name.0); } } + +pub struct HelloPlugin; + +impl Plugin for HelloPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, add_people) + .add_systems(Update, (hello_world, greet_people).chain()); + } +}