Skip to content

Commit

Permalink
Extend AppBuilder api with add_system_set and similar methods (#1453)
Browse files Browse the repository at this point in the history
Extend AppBuilder api with `add_system_set` and similar methods
  • Loading branch information
TheRawMeatball authored Feb 19, 2021
1 parent 884dc46 commit fa73036
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/bevy_app/src/app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use crate::{
};
use bevy_ecs::{
clear_trackers_system, FromResources, IntoExclusiveSystem, IntoSystem, Resource, Resources,
RunOnce, Schedule, Stage, StageLabel, StateStage, SystemDescriptor, SystemStage, World,
RunOnce, Schedule, Stage, StageLabel, StateStage, SystemDescriptor, SystemSet, SystemStage,
World,
};
use bevy_utils::tracing::debug;

Expand Down Expand Up @@ -129,6 +130,10 @@ impl AppBuilder {
self.add_system_to_stage(CoreStage::Update, system)
}

pub fn add_system_set(&mut self, system_set: SystemSet) -> &mut Self {
self.add_system_set_to_stage(CoreStage::Update, system_set)
}

pub fn add_system_to_stage(
&mut self,
stage_label: impl StageLabel,
Expand All @@ -138,6 +143,17 @@ impl AppBuilder {
self
}

pub fn add_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
system_set: SystemSet,
) -> &mut Self {
self.app
.schedule
.add_system_set_to_stage(stage_label, system_set);
self
}

pub fn add_startup_system(&mut self, system: impl Into<SystemDescriptor>) -> &mut Self {
self.add_startup_system_to_stage(StartupStage::Startup, system)
}
Expand Down
10 changes: 10 additions & 0 deletions crates/bevy_ecs/src/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ impl Schedule {
self
}

pub fn add_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
system_set: SystemSet,
) -> &mut Self {
self.stage(stage_label, |stage: &mut SystemStage| {
stage.add_system_set(system_set)
})
}

pub fn stage<T: Stage, F: FnOnce(&mut T) -> &mut T>(
&mut self,
label: impl StageLabel,
Expand Down

0 comments on commit fa73036

Please sign in to comment.