Created
June 12, 2021 11:48
-
-
Save RJ/3e2256f3ffa01185c0fa3c0541a34caa to your computer and use it in GitHub Desktop.
Example of adding systems to stages nested in deep schedules, with bevy 0.5. Trait to add feature to AppBuilder - add_system_to_stage only works if the stage is in the root schedule.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait AddSpawnSystem { | |
fn add_spawning_system(&mut self, system: impl Into<SystemDescriptor>) -> &mut AppBuilder; | |
} | |
impl AddSpawnSystem for AppBuilder { | |
fn add_spawning_system(&mut self, system: impl Into<SystemDescriptor>) -> &mut AppBuilder { | |
self.app.schedule.stage(stage::MAIN_SCHEDULE, |main_schedule: &mut Schedule| { | |
main_schedule.stage(stage::SIMULATION_SCHEDULE, |sim_schedule: &mut Schedule| { | |
sim_schedule.add_system_to_stage(Stages::SpawningStage, system) | |
}) | |
}); | |
self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment