Skip to content

Commit

Permalink
Extend API
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRawMeatball committed Feb 15, 2021
1 parent 49adf8e commit 1202bff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
17 changes: 16 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,7 @@ use crate::{
};
use bevy_ecs::{
clear_trackers_system, FromResources, IntoExclusiveSystem, IntoSystem, Resources, RunOnce,
Schedule, Stage, SystemDescriptor, SystemStage, World,
Schedule, Stage, SystemDescriptor, SystemSet, SystemStage, World,
};
use bevy_utils::tracing::debug;

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

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

pub fn add_system_to_stage(
&mut self,
stage_name: &'static str,
Expand All @@ -138,6 +142,17 @@ impl AppBuilder {
self
}

pub fn add_system_set_to_stage(
&mut self,
stage_name: &'static str,
system_set: SystemSet,
) -> &mut Self {
self.app
.schedule
.add_system_set_to_stage(stage_name, system_set);
self
}

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

pub fn add_system_set_to_stage(
&mut self,
stage_name: &'static str,
system_set: SystemSet,
) -> &mut Self {
let stage = self
.get_stage_mut::<SystemStage>(stage_name)
.unwrap_or_else(|| {
panic!(
"Stage '{}' does not exist or is not a SystemStage",
stage_name
)
});
stage.add_system_set(system_set);
self
}

pub fn stage<T: Stage, F: FnOnce(&mut T) -> &mut T>(
&mut self,
name: &str,
Expand Down

0 comments on commit 1202bff

Please sign in to comment.