Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I dont understand how the state is await for by its systems - documentation can be improved #28

Open
ethereumdegen opened this issue Feb 14, 2024 · 1 comment

Comments

@ethereumdegen
Copy link

ethereumdegen commented Feb 14, 2024

HI, i do not fully understand this example

 App::new()
        // Init bevy
        .add_plugins(DefaultPlugins)
        // Add our state type
        .add_state::<AppState>()
        // Add plugin for the splash screen
        .add_plugins(
            ProgressPlugin::new(AppState::Splash)
                .continue_to(AppState::MainMenu)
                .track_assets(),
        )
        // Add plugin for our game loading screen
        .add_plugins(ProgressPlugin::new(AppState::GameLoading).continue_to(AppState::InGame))
        // Load our UI assets during our splash screen
        .add_systems(OnEnter(AppState::Splash), load_ui_assets)
        // Our game loading screen
        // systems that implement tasks to be tracked for completion:
        .add_systems(
            Update,
            (
                net_init_session.track_progress(),
                world_generation.track_progress(),
                internal_thing.track_progress(),
                // we can also add regular untracked systems to our loading screen,
                // like to draw our progress bar:
                ui_progress_bar.after(TrackedProgressSet),
            )
                .run_if(in_state(AppState::GameLoading)),
        )
        .run();

So i am confused because it seems like in this example, if load_ui_assets takes a LONG time, the state would transition to AppState::MainMenu before that task is complete. If so, that is not helpful because main_main may require the ui assets. If not, how the heck is that being constrained? what part of load_ui_assets is indicating and telling the state manager to wait or go to the next state ?

@ethereumdegen
Copy link
Author

OH i think i see, is it the assetHandles being added to AssetsLoading?

Well what if that system doesnt get a chance to do a cycle before the progress plugin tries to go to the next state? wouldnt it just go right to the next state like a race condition?

furthermore, how could a system like that be defined such that it returns Progress instead like in an instance where i am loading something or doing some work that doesnt involve Asset Handles ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant