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

Update development branch to Bevy 0.11-dev #132

Merged
merged 28 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cdf5c6c
Update checkout and cache actions
NiklasEi Feb 28, 2023
867f90f
Merge pull request #106 from NiklasEi/bevy_main
NiklasEi Mar 10, 2023
cec54fb
Compare paths instead of strings
NiklasEi Mar 16, 2023
050dad8
Merge pull request #112 from NiklasEi/fix_full_collection_example_on_…
NiklasEi Mar 16, 2023
d0c862b
Use .track_progress() in iyes_progress example
johanhelsing Mar 23, 2023
84eb35c
Merge pull request #115 from johanhelsing/progress-system
NiklasEi Mar 24, 2023
5de374f
Remove features for optional dependencies and bump bevy_common_assets
NiklasEi Mar 24, 2023
38a0e4a
Merge pull request #117 from NiklasEi/remove_features_for_optional_de…
NiklasEi Mar 25, 2023
e60e73f
Mention asset unloading in the readme (#114)
NiklasEi Mar 31, 2023
15048c6
Merge pull request #119 from NiklasEi/mention_asset_unloading
NiklasEi Apr 1, 2023
4a0e5a4
Bump to version 0.16.0
NiklasEi Apr 1, 2023
5cd9067
Bump to development version 0.17.0
NiklasEi Apr 1, 2023
e14fca5
Allow usage in multiple states
NiklasEi Apr 11, 2023
52dfef9
Merge pull request #127 from NiklasEi/allow_usage_in_multiple_states
NiklasEi Apr 12, 2023
dd12499
Mention adding the default plugins before configuring a loading state…
NiklasEi Apr 12, 2023
e472851
Allow reloading of dynamic asset files
NiklasEi Apr 12, 2023
bcab9b2
Merge pull request #130 from NiklasEi/add_asset_server_before_loading…
NiklasEi Apr 13, 2023
0acd104
Merge pull request #129 from NiklasEi/reload_dynamic_asset_collections
NiklasEi Apr 13, 2023
ba8aff6
Workaround for correct scheduling with non default exit criteria
NiklasEi Apr 14, 2023
c71df8b
Merge pull request #131 from NiklasEi/fix_crash_with_non_default_exit…
NiklasEi Apr 14, 2023
95d9795
Update to Bevy 0.11-dev
eerii Apr 15, 2023
3a2aa89
Fix tests and lint
eerii Apr 16, 2023
733c607
Update actions on GitHub Actions workflows
striezel Apr 20, 2023
ae9e3be
Merge pull request #133 from striezel-stash/ci-actions-update
NiklasEi Apr 22, 2023
d6fca09
Replace unmaintained actions-rs/toolchain action in CI workflows
striezel Apr 22, 2023
b9e4342
Merge pull request #134 from striezel-stash/actions-rs-toolchain-repl…
NiklasEi Apr 22, 2023
26a979c
Merge branch 'main' into bevy_main
eerii Apr 24, 2023
16922f8
Add again loading set and fix example
eerii Apr 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn main() {
.continue_to_state(GameState::Next)
)
.add_collection_to_loading_state::<_, MyAssets>(GameState::AssetLoading)
.add_system(use_my_assets.in_schedule(OnEnter(GameState::Next)))
.add_systems(OnEnter(GameState::Next), use_my_assets)
.run();
}

Expand Down
12 changes: 6 additions & 6 deletions bevy_asset_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ standard_dynamic_assets = ["dep:bevy_common_assets", "dep:serde"]
progress_tracking = ["dep:iyes_progress"]

[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_asset"] }
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset"] }
bevy_asset_loader_derive = { version = "=0.17.0-dev", path = "../bevy_asset_loader_derive" }
anyhow = "1"

bevy_common_assets = { version = "0.6.0", features = ["ron"], optional = true }
bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", branch = "bevy_main", features = ["ron"], optional = true }
serde = { version = "1", optional = true }
iyes_progress = { version = "0.8", optional = true }
iyes_progress = { git = "https://github.com/josekoalas/iyes_progress", branch = "bevy_main", optional = true }

[dev-dependencies]
bevy = { version = "0.10", features = ["vorbis"] }
bevy = { git = "https://github.com/bevyengine/bevy", features = ["vorbis"] }
anyhow = "1"
iyes_progress = { version = "0.8" }
bevy_common_assets = { version = "0.6.0", features = ["ron"] }
iyes_progress = { git = "https://github.com/josekoalas/iyes_progress", branch = "bevy_main" }
bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", branch = "bevy_main", features = ["ron"] }
serde = { version = "1" }
trybuild = { version = "1.0" }

Expand Down
7 changes: 5 additions & 2 deletions bevy_asset_loader/examples/atlas_from_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ fn main() {
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_system(draw_atlas.in_schedule(OnEnter(MyStates::Next)))
.add_system(animate_sprite_system.run_if(in_state(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), draw_atlas)
.add_systems(
Update,
animate_sprite_system.run_if(in_state(MyStates::Next)),
)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/custom_dynamic_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
"custom.my-assets.ron",
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(render_stuff.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), render_stuff)
.run();
}

Expand Down
8 changes: 6 additions & 2 deletions bevy_asset_loader/examples/dynamic_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ fn main() {
.add_collection_to_loading_state::<_, AudioAssets>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_systems(
(spawn_player_and_tree, play_background_audio).in_schedule(OnEnter(MyStates::Next)),
OnEnter(MyStates::Next),
(spawn_player_and_tree, play_background_audio),
)
.add_systems(
Update,
animate_sprite_system.run_if(in_state(MyStates::Next)),
)
.add_system(animate_sprite_system.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions bevy_asset_loader/examples/failure_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ fn main() {
.on_failure_continue_to_state(MyStates::ErrorScreen),
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(timeout.run_if(in_state(MyStates::AssetLoading)))
.add_system(fail.in_schedule(OnEnter(MyStates::Next)))
.add_system(ok.in_schedule(OnEnter(MyStates::ErrorScreen)))
.add_systems(Update, timeout.run_if(in_state(MyStates::AssetLoading)))
.add_systems(OnEnter(MyStates::Next), fail)
.add_systems(OnEnter(MyStates::ErrorScreen), ok)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/full_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
LoadingState::new(MyStates::AssetLoading).continue_to_state(MyStates::Next),
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(expectations.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), expectations)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/full_dynamic_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
"full_dynamic_collection.assets.ron",
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(expectations.run_if(in_state(MyStates::Next)))
.add_systems(Update, expectations.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/init_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
.add_collection_to_loading_state::<_, ImageAssets>(MyStates::AssetLoading)
.init_resource_after_loading_state::<_, CombinedImage>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_system(draw.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), draw)
.run();
}

Expand Down
23 changes: 16 additions & 7 deletions bevy_asset_loader/examples/manual_dynamic_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ fn main() {
.insert_resource(Msaa::Off)
.insert_resource(ShowBackground(false))
.add_systems(
(spawn_player_and_tree, play_background_audio).in_schedule(OnEnter(MyStates::Next)),
OnEnter(MyStates::Next),
(
spawn_player_and_tree,
play_background_audio,
render_optional_background,
),
)
.add_systems(OnEnter(MyStates::Menu), menu)
.add_systems(OnExit(MyStates::Menu), exit_menu)
.add_systems(
Update,
(
character_setup.run_if(in_state(MyStates::Menu)),
update_menu.run_if(in_state(MyStates::Menu)),
move_player.run_if(in_state(MyStates::Next)),
),
)
.add_system(menu.in_schedule(OnEnter(MyStates::Menu)))
.add_system(character_setup.run_if(in_state(MyStates::Menu)))
.add_system(update_menu.run_if(in_state(MyStates::Menu)))
.add_system(exit_menu.in_schedule(OnExit(MyStates::Menu)))
.add_system(render_optional_background.in_schedule(OnEnter(MyStates::Next)))
.add_system(move_player.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions bevy_asset_loader/examples/no_loading_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn main() {
// This requires the extension trait `AssetCollectionApp` to be in scope.
.init_collection::<ImageAssets>()
// This system listens for mouse clicks and then loads + inserts the AudioAssets collection
.add_system(load_and_play_audio)
.add_system(draw.on_startup())
.add_systems(Startup, draw)
.add_systems(Update, load_and_play_audio)
.run();
}

Expand Down
18 changes: 11 additions & 7 deletions bevy_asset_loader/examples/progress_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_state::<MyStates>()
.init_resource::<iyes_progress::ProgressCounter>()
eerii marked this conversation as resolved.
Show resolved Hide resolved
.add_loading_state(LoadingState::new(MyStates::AssetLoading))
.add_collection_to_loading_state::<_, TextureAssets>(MyStates::AssetLoading)
.add_collection_to_loading_state::<_, AudioAssets>(MyStates::AssetLoading)
.add_plugin(FrameTimeDiagnosticsPlugin::default())
// track progress during `MyStates::AssetLoading` and continue to `MyStates::Next` when progress is completed
.add_plugin(ProgressPlugin::new(MyStates::AssetLoading).continue_to(MyStates::Next))
// gracefully quit the app when `MyStates::Next` is reached
.add_system(expect.in_schedule(OnEnter(MyStates::Next)))
.add_system(
track_fake_long_task
.track_progress()
.before(print_progress)
.run_if(in_state(MyStates::AssetLoading)),
.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,
),
)
.add_system(print_progress)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/standard_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
color: Color::WHITE,
brightness: 0.2,
})
.add_system(spawn_player.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), spawn_player)
.run();
}

Expand Down
5 changes: 3 additions & 2 deletions bevy_asset_loader/examples/two_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ fn main() {
.add_collection_to_loading_state::<_, AudioAssets>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_systems(
(spawn_player_and_tree, play_background_audio).in_schedule(OnEnter(MyStates::Next)),
OnEnter(MyStates::Next),
(spawn_player_and_tree, play_background_audio),
)
.add_system(move_player.run_if(in_state(MyStates::Next)))
.add_systems(Update, move_player.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
101 changes: 44 additions & 57 deletions bevy_asset_loader/src/loading_state.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
mod dynamic_asset_systems;
mod systems;

use bevy::app::{App, CoreSet, IntoSystemAppConfig, Plugin};
use bevy::app::{App, Plugin};
use bevy::asset::{Asset, HandleUntyped};
use bevy::ecs::schedule::{
common_conditions::in_state, IntoSystemConfig, IntoSystemSetConfig, NextState, OnEnter, States,
SystemSet,
use bevy::ecs::{
schedule::{
common_conditions::in_state, BoxedScheduleLabel, IntoSystemConfigs, IntoSystemSetConfig,
NextState, OnEnter, ScheduleLabel, State, States, SystemSet,
},
system::Resource,
world::FromWorld,
};
use bevy::ecs::schedule::{BoxedScheduleLabel, ScheduleLabel, State};
use bevy::ecs::system::Resource;
use bevy::ecs::world::FromWorld;
use bevy::prelude::{StateTransition, Update};
use bevy::utils::{default, HashMap, HashSet};
use std::any::TypeId;
use std::array::IntoIter;
Expand Down Expand Up @@ -58,7 +60,7 @@ use crate::loading_state::systems::{apply_internal_state_transition, run_loading
/// )
/// .add_collection_to_loading_state::<_, AudioAssets>(GameState::Loading)
/// .add_collection_to_loading_state::<_, ImageAssets>(GameState::Loading)
/// .add_system(play_audio.in_schedule(OnEnter(GameState::Menu)))
/// .add_systems(OnEnter(GameState::Menu), play_audio)
/// # .set_runner(|mut app| app.update())
/// .run();
/// }
Expand Down Expand Up @@ -372,25 +374,19 @@ where
));

if configure_loading_state {
app.add_systems((
resume_to_loading_asset_collections::<S>
.in_schedule(loading_state_schedule.clone())
.in_set(InternalLoadingStateSet::ResumeDynamicAssetCollections),
initialize_loading_state::<S>
.in_schedule(loading_state_schedule.clone())
.in_set(InternalLoadingStateSet::Initialize),
resume_to_finalize::<S>
.in_schedule(loading_state_schedule.clone())
.in_set(InternalLoadingStateSet::CheckAssets),
finish_loading_state::<S>
.in_schedule(loading_state_schedule.clone())
.in_set(InternalLoadingStateSet::Finalize),
))
.add_system(reset_loading_state::<S>.in_schedule(OnEnter(self.loading_state.clone())))
.configure_set(
LoadingStateSet(self.loading_state.clone())
.after(CoreSet::StateTransitions)
.before(CoreSet::Update),
app.add_systems(
loading_state_schedule.clone(),
(
resume_to_loading_asset_collections::<S>
.in_set(InternalLoadingStateSet::ResumeDynamicAssetCollections),
initialize_loading_state::<S>.in_set(InternalLoadingStateSet::Initialize),
resume_to_finalize::<S>.in_set(InternalLoadingStateSet::CheckAssets),
finish_loading_state::<S>.in_set(InternalLoadingStateSet::Finalize),
),
)
.add_systems(
OnEnter(self.loading_state.clone()),
reset_loading_state::<S>,
);
let mut loading_state_schedule = app.get_schedule_mut(loading_state_schedule).unwrap();
loading_state_schedule
Expand Down Expand Up @@ -420,17 +416,16 @@ where
);

#[cfg(feature = "progress_tracking")]
app.add_system(
app.add_systems(
Update,
run_loading_state::<S>
.in_set(TrackedProgressSet)
.in_base_set(LoadingStateSet(self.loading_state.clone()))
.run_if(in_state(self.loading_state)),
);
#[cfg(not(feature = "progress_tracking"))]
app.add_system(
run_loading_state::<S>
.in_base_set(LoadingStateSet(self.loading_state.clone()))
.run_if(in_state(self.loading_state)),
app.add_systems(
Update,
run_loading_state::<S>.run_if(in_state(self.loading_state)),
);
}

Expand All @@ -442,12 +437,6 @@ where
}
}

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

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)]
pub(crate) enum InternalLoadingStateSet {
Initialize,
Expand Down Expand Up @@ -685,16 +674,13 @@ impl LoadingStateAppExt for App {
&mut self,
loading_state: S,
) -> &mut Self {
self.add_system(
start_loading_collection::<S, A>.in_schedule(OnEnterInternalLoadingState(
loading_state.clone(),
InternalLoadingState::LoadingAssets,
)),
self.add_systems(
OnEnterInternalLoadingState(loading_state.clone(), InternalLoadingState::LoadingAssets),
start_loading_collection::<S, A>,
)
.add_system(
check_loading_collection::<S, A>
.in_schedule(LoadingStateSchedule(loading_state))
.in_set(InternalLoadingStateSet::CheckAssets),
.add_systems(
LoadingStateSchedule(loading_state),
check_loading_collection::<S, A>.in_set(InternalLoadingStateSet::CheckAssets),
)
}

Expand All @@ -709,15 +695,16 @@ impl LoadingStateAppExt for App {
.unwrap();

if dynamic_asset_collections.register_file::<C>(loading_state.clone(), file) {
self.add_system(load_dynamic_asset_collections::<S, C>.in_schedule(
self.add_systems(
OnEnterInternalLoadingState(
loading_state.clone(),
InternalLoadingState::LoadingDynamicAssetCollections,
),
))
.add_system(
load_dynamic_asset_collections::<S, C>,
)
.add_systems(
LoadingStateSchedule(loading_state),
check_dynamic_asset_collections::<S, C>
.in_schedule(LoadingStateSchedule(loading_state))
.in_set(InternalLoadingStateSet::CheckDynamicAssetCollections),
);
}
Expand All @@ -729,10 +716,10 @@ impl LoadingStateAppExt for App {
&mut self,
loading_state: S,
) -> &mut Self {
self.add_system(init_resource::<A>.in_schedule(OnEnterInternalLoadingState(
loading_state,
InternalLoadingState::Finalize,
)))
self.add_systems(
OnEnterInternalLoadingState(loading_state, InternalLoadingState::Finalize),
init_resource::<A>,
)
}
}

Expand All @@ -756,6 +743,6 @@ where
S: States,
{
fn build(&self, app: &mut App) {
app.add_system(apply_internal_state_transition::<S>.in_base_set(CoreSet::StateTransitions));
app.add_systems(StateTransition, apply_internal_state_transition::<S>);
}
}
Loading