Skip to content

Commit

Permalink
Support explicitly ordering against the loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasEi committed Oct 14, 2023
1 parent ccbe379 commit 8bedb52
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

- Make `loading_state::LoadingStateSet` public for explicit system ordering

## v0.17.0
- update to Bevy 0.11
- Use "/" in paths used as keys for mapped collections on all platforms (resolves [#135](https://github.com/NiklasEi/bevy_asset_loader/issues/135))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ See [`progress_tracking`](bevy_asset_loader/examples/progress_tracking.rs) for a

### A note on system ordering

The loading state runs in a base set between `CoreSet::StateTransitions` and `CoreSet::Update`. This means that systems running in `CoreSet::Update` can already see the reported progress of all tracked asset collections for the current frame.
The loading state is organized in a private schedule that runs in a single system during the `Update` schedule. If you want to explicitly order against the system running the loading state, you can do so with the system set `LoadingStateSet`.

## Failure state

Expand Down
11 changes: 4 additions & 7 deletions bevy_asset_loader/examples/progress_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ fn main() {
.add_systems(OnEnter(MyStates::Next), expect)
.add_systems(
Update,
(
track_fake_long_task
.track_progress()
.before(print_progress)
.run_if(in_state(MyStates::AssetLoading)),
print_progress,
),
(track_fake_long_task.track_progress(), print_progress)
.chain()
.run_if(in_state(MyStates::AssetLoading))
.after(LoadingStateSet(MyStates::AssetLoading)),
)
.run();
}
Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub mod prelude {
DynamicAsset, DynamicAssetCollection, DynamicAssetCollections, DynamicAssetType,
DynamicAssets,
},
loading_state::{LoadingState, LoadingStateAppExt},
loading_state::{LoadingState, LoadingStateAppExt, LoadingStateSet},
};
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/src/loading_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ where

/// Systems in this set check the loading state of assets and will change the [`InternalLoadingState`] accordingly.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)]
pub(crate) struct LoadingStateSet<S: States>(S);
pub struct LoadingStateSet<S: States>(pub S);

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)]
pub(crate) enum InternalLoadingStateSet {
Expand Down

0 comments on commit 8bedb52

Please sign in to comment.