Closed thombruce closed 1 year ago
Good documentation: https://bevyengine.org/news/bevy-0-10/
Two simple tricks help us out here:
.chain()
will execute the systems in the order they are listedapply_deferred
system enforces a buffer which means our entities are properly loaded by triggering the next systemNeither solved the problem alone, but together they do. Useful for loading things in a certain order, but as the documentation says... be careful not to overuse as this will cause bottlenecks. There are probably refactoring steps I can take in the actual systems. This has been hastily added to correct for a bug identified in a release.
fn build(&self, app: &mut App) {
app.add_plugins(OrbitPlugin);
// TODO: Having some real trouble with ordering systems
- app.add_systems(OnExit(AppState::StartMenu), spawn_star);
- app.add_systems(OnEnter(AppState::GameCreate), spawn_planets);
- app.add_systems(OnExit(AppState::GameCreate), spawn_demo_orbital);
+ app.add_systems(
+ OnEnter(AppState::GameCreate),
+ (
+ spawn_star,
+ apply_deferred,
+ spawn_planets,
+ apply_deferred,
+ spawn_demo_orbital,
+ )
+ .chain(),
+ );
app.add_systems(Update, animate_sprite.run_if(in_state(AppState::Active)));
}
Resolved as of d97a90877b0e7293e197df8ae9a48f82ab392d85. Release of v0.0.12 to follow shortly.
Due to systems ordering, if the player visits the credits before starting the game a star will be spawned. If they return to the main menu and start the game, the game will crash.
Good time to get systems to execute in a proper order and remove the dependency on schedule parameters.