Skip to content

Commit

Permalink
Add again loading set and fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
eerii committed Apr 24, 2023
1 parent 26a979c commit 16922f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion bevy_asset_loader/examples/progress_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_state::<MyStates>()
.init_resource::<iyes_progress::ProgressCounter>()
.add_loading_state(LoadingState::new(MyStates::AssetLoading))
.add_collection_to_loading_state::<_, TextureAssets>(MyStates::AssetLoading)
.add_collection_to_loading_state::<_, AudioAssets>(MyStates::AssetLoading)
Expand Down
12 changes: 10 additions & 2 deletions bevy_asset_loader/src/loading_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ where
.add_systems(
OnEnter(self.loading_state.clone()),
reset_loading_state::<S>,
);
)
.configure_set(Update, LoadingStateSet(self.loading_state.clone()));
let mut loading_state_schedule = app.get_schedule_mut(loading_state_schedule).unwrap();
loading_state_schedule
.configure_set(
Expand Down Expand Up @@ -420,12 +421,15 @@ where
Update,
run_loading_state::<S>
.in_set(TrackedProgressSet)
.in_set(LoadingStateSet(self.loading_state.clone()))
.run_if(in_state(self.loading_state)),
);
#[cfg(not(feature = "progress_tracking"))]
app.add_systems(
Update,
run_loading_state::<S>.run_if(in_state(self.loading_state)),
run_loading_state::<S>
.in_set(LoadingStateSet(self.loading_state.clone()))
.run_if(in_state(self.loading_state)),
);
}

Expand All @@ -437,6 +441,10 @@ 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);

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

0 comments on commit 16922f8

Please sign in to comment.