-
Hello ! I have a question as I try to learn Bevy ! A try to make a Then after added the plugin to my App, I decide to add a startup system which drop some mines at random places on the generated grid. But I'm façing a problem, the grid generation startup system and the mine dropping system are running in parallel, I have to tell the startup system from my app to wait until my Plugin startup system has finished. What a tried to do, is to define I have a #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
pub enum GridSet {
Generation,
GenerationFlush,
} Add it to my bundle and configure it : pub struct GridPlugin;
impl Plugin for GridPlugin {
fn build(&self, app: &mut bevy::prelude::App) {
app.insert_resource(GridParams::default())
.configure_sets((
GridSet::Generation,
GridSet::GenerationFlush.after(GridSet::Generation),
))
.add_startup_system(setup_grid.in_set(GridSet::Generation))
.add_system(apply_system_buffers.in_set(GridSet::GenerationFlush));
}
} I made another set for the app, and configure it to run after my GridSet::GenerationFlush. #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
enum SetupSet {
CellStateInitialization,
}
fn main() {
App::new()
.add_plugin(GridPlugin)
.configure_set(SetupSet::CellStateInitialization.after(GridSet::GenerationFlush))
.add_startup_system(setup_camera)
.add_startup_system(drop_mines.in_set(SetupSet::CellStateInitialization))
.run();
} But I think I'm doing something wrong, or there is something that I didn't understand clearly.. But after some search I couldn't find any answer which fix my issue, This previous post seems to be exactly what I'm looking for, but even when I added Maybe I try to structure thing the wrong way.. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The following should work: app.add_startup_systems((
setup_grid,
apply_system_buffers,
drop_mines,
).chain())); This way the three system are chained one after the other and are guaranteed to run in the specified order. In your code above |
Beta Was this translation helpful? Give feedback.
The following should work:
This way the three system are chained one after the other and are guaranteed to run in the specified order.
In your code above
apply_system_buffers
doesn't run during startup, but during the main schedule, sodrop_mines
runs before it during startup, and your grid won't be spawned yet.