Add configure_schedules to App and Schedules to apply ScheduleBuildSettings to all schedules (#9514)
# Objective - Fixes: #9508 - Fixes: #9526 ## Solution - Adds ```rust fn configure_schedules(&mut self, schedule_build_settings: ScheduleBuildSettings) ``` to `Schedules`, and `App` to simplify applying `ScheduleBuildSettings` to all schedules. --- ## Migration Guide - No breaking changes. - Adds `Schedule::get_build_settings()` getter for the schedule's `ScheduleBuildSettings`. - Can replaced manual configuration of all schedules: ```rust // Old for (_, schedule) in app.world.resource_mut::<Schedules>().iter_mut() { schedule.set_build_settings(build_settings); } // New app.configure_schedules(build_settings); ```
This commit is contained in:
parent
72fc63e594
commit
a8dc8350c6
@ -5,7 +5,7 @@ use bevy_ecs::{
|
|||||||
schedule::{
|
schedule::{
|
||||||
apply_state_transition, common_conditions::run_once as run_once_condition,
|
apply_state_transition, common_conditions::run_once as run_once_condition,
|
||||||
run_enter_schedule, BoxedScheduleLabel, IntoSystemConfigs, IntoSystemSetConfigs,
|
run_enter_schedule, BoxedScheduleLabel, IntoSystemConfigs, IntoSystemSetConfigs,
|
||||||
ScheduleLabel,
|
ScheduleBuildSettings, ScheduleLabel,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use bevy_utils::{tracing::debug, HashMap, HashSet};
|
use bevy_utils::{tracing::debug, HashMap, HashSet};
|
||||||
@ -850,6 +850,17 @@ impl App {
|
|||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Applies the provided [`ScheduleBuildSettings`] to all schedules.
|
||||||
|
pub fn configure_schedules(
|
||||||
|
&mut self,
|
||||||
|
schedule_build_settings: ScheduleBuildSettings,
|
||||||
|
) -> &mut Self {
|
||||||
|
self.world
|
||||||
|
.resource_mut::<Schedules>()
|
||||||
|
.configure_schedules(schedule_build_settings);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_once(mut app: App) {
|
fn run_once(mut app: App) {
|
||||||
|
|||||||
@ -103,6 +103,13 @@ impl Schedules {
|
|||||||
schedule.check_change_ticks(change_tick);
|
schedule.check_change_ticks(change_tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Applies the provided [`ScheduleBuildSettings`] to all schedules.
|
||||||
|
pub fn configure_schedules(&mut self, schedule_build_settings: ScheduleBuildSettings) {
|
||||||
|
for (_, schedule) in self.inner.iter_mut() {
|
||||||
|
schedule.set_build_settings(schedule_build_settings.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_executor(kind: ExecutorKind) -> Box<dyn SystemExecutor> {
|
fn make_executor(kind: ExecutorKind) -> Box<dyn SystemExecutor> {
|
||||||
@ -200,6 +207,11 @@ impl Schedule {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the schedule's current `ScheduleBuildSettings`.
|
||||||
|
pub fn get_build_settings(&self) -> ScheduleBuildSettings {
|
||||||
|
self.graph.settings.clone()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the schedule's current execution strategy.
|
/// Returns the schedule's current execution strategy.
|
||||||
pub fn get_executor_kind(&self) -> ExecutorKind {
|
pub fn get_executor_kind(&self) -> ExecutorKind {
|
||||||
self.executor.kind()
|
self.executor.kind()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user