From 866b0e299b87af5d6a48579fa9e667783d75d468 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Fri, 23 Dec 2022 18:45:29 -0500 Subject: [PATCH 1/4] add a basic example for system ordering --- crates/bevy_ecs/src/system/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 0dcc806c6d44a..3967ec01c6b71 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -45,6 +45,31 @@ //! methods such as `.before()` and `.after()` are appended to systems to determine //! execution order in respect to other systems. //! +//! ## Example +//! +//! ``` +//! # use bevy_ecs::prelude::*; +//! # struct App; +//! # impl App { +//! # fn new() -> SystemStage { SystemStage::single_threaded() } +//! # } +//! # let mut app = SystemStage::single_threaded(); +//! # let mut app = +//! App::new() +//! # ; app +//! .add_system(print_first) +//! .add_system(print_second.after(print_first)) +//! # ; app +//! .run(); // Prints "Hello, World!" each frame. +//! +//! fn print_first() { +//! print!("Hello, "); +//! } +//! fn print_second() { +//! println!("World!"); +//! } +//! ``` +//! //! # System parameter list //! Following is the complete list of accepted types as system parameters: //! From af8b9727b55c2f16392b72f2c8716f3c1b00ae32 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Fri, 23 Dec 2022 18:52:50 -0500 Subject: [PATCH 2/4] add an example of `before` --- crates/bevy_ecs/src/system/mod.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 3967ec01c6b71..51b2c88d1f28a 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -54,18 +54,21 @@ //! # fn new() -> SystemStage { SystemStage::single_threaded() } //! # } //! # let mut app = SystemStage::single_threaded(); -//! # let mut app = -//! App::new() -//! # ; app -//! .add_system(print_first) -//! .add_system(print_second.after(print_first)) -//! # ; app -//! .run(); // Prints "Hello, World!" each frame. +//! // Prints "Hello, World!" each frame. +//! app +//! .add_system(print_first.before(print_mid)) +//! .add_system(print_mid) +//! .add_system(print_last.after(print_mid)); +//! # let mut world = World::new(); +//! # app.run(&mut world); //! //! fn print_first() { -//! print!("Hello, "); +//! print!("Hello"); //! } -//! fn print_second() { +//! fn print_mid() { +//! print!(", "); +//! } +//! fn print_last() { //! println!("World!"); //! } //! ``` From d8299dc75f60a8a52a2750b52932233cfc993723 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:06:31 -0500 Subject: [PATCH 3/4] update docs to use `SystemTypeIdLabel` by default --- crates/bevy_ecs/src/system/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 51b2c88d1f28a..0c7ba092ec642 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -41,9 +41,11 @@ //! //! - **System Stages:** They determine hard execution synchronization boundaries inside of //! which systems run in parallel by default. -//! - **Labeling:** First, systems are labeled upon creation by calling `.label()`. Then, -//! methods such as `.before()` and `.after()` are appended to systems to determine -//! execution order in respect to other systems. +//! - **Labels:** Systems may be ordered within a stage using the methods `.before()` and `.after()`, +//! which order systems based on their [`SystemLabel`]s. Each system is implicitly labeled with +//! its `fn` type, and custom labels may be added by calling `.label()`. +//! +//! [`SystemLabel`]: crate::schedule::SystemLabel //! //! ## Example //! From 237dd9708d0acc855cd007c779165664852ebc55 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 24 Dec 2022 08:03:44 -0500 Subject: [PATCH 4/4] remove some leftover code --- crates/bevy_ecs/src/system/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 0c7ba092ec642..be66144b4a6a8 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -51,10 +51,6 @@ //! //! ``` //! # use bevy_ecs::prelude::*; -//! # struct App; -//! # impl App { -//! # fn new() -> SystemStage { SystemStage::single_threaded() } -//! # } //! # let mut app = SystemStage::single_threaded(); //! // Prints "Hello, World!" each frame. //! app