Skip to content

Commit fa73036

Browse files
Extend AppBuilder api with add_system_set and similar methods (bevyengine#1453)
Extend AppBuilder api with `add_system_set` and similar methods
1 parent 884dc46 commit fa73036

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

crates/bevy_app/src/app_builder.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use crate::{
66
};
77
use bevy_ecs::{
88
clear_trackers_system, FromResources, IntoExclusiveSystem, IntoSystem, Resource, Resources,
9-
RunOnce, Schedule, Stage, StageLabel, StateStage, SystemDescriptor, SystemStage, World,
9+
RunOnce, Schedule, Stage, StageLabel, StateStage, SystemDescriptor, SystemSet, SystemStage,
10+
World,
1011
};
1112
use bevy_utils::tracing::debug;
1213

@@ -129,6 +130,10 @@ impl AppBuilder {
129130
self.add_system_to_stage(CoreStage::Update, system)
130131
}
131132

133+
pub fn add_system_set(&mut self, system_set: SystemSet) -> &mut Self {
134+
self.add_system_set_to_stage(CoreStage::Update, system_set)
135+
}
136+
132137
pub fn add_system_to_stage(
133138
&mut self,
134139
stage_label: impl StageLabel,
@@ -138,6 +143,17 @@ impl AppBuilder {
138143
self
139144
}
140145

146+
pub fn add_system_set_to_stage(
147+
&mut self,
148+
stage_label: impl StageLabel,
149+
system_set: SystemSet,
150+
) -> &mut Self {
151+
self.app
152+
.schedule
153+
.add_system_set_to_stage(stage_label, system_set);
154+
self
155+
}
156+
141157
pub fn add_startup_system(&mut self, system: impl Into<SystemDescriptor>) -> &mut Self {
142158
self.add_startup_system_to_stage(StartupStage::Startup, system)
143159
}

crates/bevy_ecs/src/schedule/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ impl Schedule {
153153
self
154154
}
155155

156+
pub fn add_system_set_to_stage(
157+
&mut self,
158+
stage_label: impl StageLabel,
159+
system_set: SystemSet,
160+
) -> &mut Self {
161+
self.stage(stage_label, |stage: &mut SystemStage| {
162+
stage.add_system_set(system_set)
163+
})
164+
}
165+
156166
pub fn stage<T: Stage, F: FnOnce(&mut T) -> &mut T>(
157167
&mut self,
158168
label: impl StageLabel,

0 commit comments

Comments
 (0)