From 8bedb5287ed779acf6ea7712743dcb635867f0d5 Mon Sep 17 00:00:00 2001 From: Niklas Eicker Date: Sat, 14 Oct 2023 22:05:48 +0200 Subject: [PATCH] Support explicitly ordering against the loading state --- CHANGELOG.md | 2 ++ README.md | 2 +- bevy_asset_loader/examples/progress_tracking.rs | 11 ++++------- bevy_asset_loader/src/lib.rs | 2 +- bevy_asset_loader/src/loading_state.rs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffd1069..1069c81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index a8e6a15..1ee45d5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bevy_asset_loader/examples/progress_tracking.rs b/bevy_asset_loader/examples/progress_tracking.rs index 3683a62..72a7e87 100644 --- a/bevy_asset_loader/examples/progress_tracking.rs +++ b/bevy_asset_loader/examples/progress_tracking.rs @@ -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(); } diff --git a/bevy_asset_loader/src/lib.rs b/bevy_asset_loader/src/lib.rs index b8686ac..7891780 100644 --- a/bevy_asset_loader/src/lib.rs +++ b/bevy_asset_loader/src/lib.rs @@ -92,7 +92,7 @@ pub mod prelude { DynamicAsset, DynamicAssetCollection, DynamicAssetCollections, DynamicAssetType, DynamicAssets, }, - loading_state::{LoadingState, LoadingStateAppExt}, + loading_state::{LoadingState, LoadingStateAppExt, LoadingStateSet}, }; } diff --git a/bevy_asset_loader/src/loading_state.rs b/bevy_asset_loader/src/loading_state.rs index 3b77bc9..ebde282 100644 --- a/bevy_asset_loader/src/loading_state.rs +++ b/bevy_asset_loader/src/loading_state.rs @@ -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); +pub struct LoadingStateSet(pub S); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] pub(crate) enum InternalLoadingStateSet {