Extend AppBuilder api with add_system_set and similar methods (#1453)

Extend AppBuilder api with `add_system_set` and similar methods
This commit is contained in:
TheRawMeatball 2021-02-19 22:36:34 +03:00 committed by GitHub
parent 884dc46ffe
commit fa73036f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -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;
@ -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,
@ -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)
}

View File

@ -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,