From 40f55925b71c9f9cfc93d69ba2837c0bdb94e4e2 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Wed, 23 Jun 2021 16:47:08 +0000 Subject: [PATCH] Added helpful adders for systemsets (#2366) # Objective - This adds a way to add `SystemSet`s to Apps. --- crates/bevy_app/src/app_builder.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/bevy_app/src/app_builder.rs b/crates/bevy_app/src/app_builder.rs index 58a2dbdd87c223..90671ae48ab679 100644 --- a/crates/bevy_app/src/app_builder.rs +++ b/crates/bevy_app/src/app_builder.rs @@ -232,6 +232,10 @@ impl AppBuilder { self.add_startup_system_to_stage(StartupStage::Startup, system) } + pub fn add_startup_system_set(&mut self, system_set: SystemSet) -> &mut Self { + self.add_startup_system_set_to_stage(StartupStage::Startup, system_set) + } + pub fn add_startup_system_to_stage( &mut self, stage_label: impl StageLabel, @@ -245,6 +249,19 @@ impl AppBuilder { self } + pub fn add_startup_system_set_to_stage( + &mut self, + stage_label: impl StageLabel, + system_set: SystemSet, + ) -> &mut Self { + self.app + .schedule + .stage(CoreStage::Startup, |schedule: &mut Schedule| { + schedule.add_system_set_to_stage(stage_label, system_set) + }); + self + } + /// Adds a new [State] with the given `initial` value. /// This inserts a new `State` resource and adds a new "driver" to [CoreStage::Update]. /// Each stage that uses `State` for system run criteria needs a driver. If you need to use