Skip to content

Commit

Permalink
Merge pull request #155 from NiklasEi/document-system-ordering
Browse files Browse the repository at this point in the history
Support explicitly ordering against the loading state
  • Loading branch information
NiklasEi authored Oct 14, 2023
2 parents ccbe379 + 5b2a7ab commit a60227c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 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
12 changes: 6 additions & 6 deletions bevy_asset_loader/tests/ui/no_default.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ error[E0277]: the trait bound `NoDefault: std::default::Default` is not satisfie
| ^^^^^^^^^^ the trait `std::default::Default` is not implemented for `NoDefault`
|
= help: the following other types implement trait `FromWorld`:
BlitPipeline
CASNode
CASPipeline
MainPass2dNode
Children
FallbackImage
FallbackImageCubemap
FallbackImageZero
FxaaPipeline
Parent
SceneLoader
MsaaWritebackNode
Material2dPipeline<M>
BlitPipeline
and $N others
= note: required for `NoDefault` to implement `FromWorld`
help: consider annotating `NoDefault` with `#[derive(Default)]`
Expand Down

0 comments on commit a60227c

Please sign in to comment.