From c71df1b676f34bc5119aa718d7e1f827144cf950 Mon Sep 17 00:00:00 2001 From: Niklas Eicker Date: Thu, 24 Oct 2024 20:25:20 +0200 Subject: [PATCH 01/15] WIP update to Bevy 0.15 rc.1 --- CHANGELOG.md | 1 + README.md | 5 +- bevy_asset_loader/Cargo.toml | 12 +- .../examples/configure_loading_state.rs | 8 +- .../examples/custom_dynamic_assets.rs | 59 +++++----- bevy_asset_loader/examples/dynamic_asset.rs | 8 +- bevy_asset_loader/examples/failure_state.rs | 2 +- bevy_asset_loader/examples/full_collection.rs | 71 ++++------- .../examples/full_dynamic_collection.rs | 110 +++++------------- bevy_asset_loader/examples/image_asset.rs | 35 +++--- .../examples/manual_dynamic_asset.rs | 8 +- .../examples/progress_tracking.rs | 2 +- bevy_asset_loader/examples/two_collections.rs | 8 +- .../src/loading_state/systems.rs | 10 +- .../tests/can_run_without_next_state.rs | 2 +- .../tests/continues_to_failure_state.rs | 2 +- bevy_asset_loader/tests/init_resource.rs | 2 +- .../tests/mapped_path_use_slash.rs | 2 +- .../tests/multiple_asset_collections.rs | 2 +- .../tests/multiple_loading_states.rs | 2 +- bevy_asset_loader/tests/multiple_states.rs | 2 +- .../tests/reload_dynamic_asset_files.rs | 2 +- .../tests/same_collection_multiple_times.rs | 2 +- bevy_asset_loader_derive/Cargo.toml | 2 +- bevy_asset_loader_derive/src/lib.rs | 2 +- 25 files changed, 147 insertions(+), 214 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7922eb..0ecc41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- support for Bevy 0.15 - custom `on_unimplemented` diagnostics for the `AssetCollection` trait - image derive attribute `array_texture_layers` - wait for dependencies of assets to load diff --git a/README.md b/README.md index 1fb7a46..060f245 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,7 @@ struct AudioAssets { /// This system runs in MyStates::Next. Thus, AudioAssets is available as a resource /// and the contained handle is done loading. fn start_background_audio(mut commands: Commands, audio_assets: Res) { - commands.spawn(AudioBundle { - source: audio_assets.background.clone(), - settings: PlaybackSettings::LOOP, - }); + commands.spawn((AudioPlayer(audio_assets.background.clone()), PlaybackSettings::LOOP)); } #[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] diff --git a/bevy_asset_loader/Cargo.toml b/bevy_asset_loader/Cargo.toml index b3227ed..18d9fdf 100644 --- a/bevy_asset_loader/Cargo.toml +++ b/bevy_asset_loader/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_asset_loader" -version = "0.21.0" +version = "0.22.0-rc.1" authors = ["Niklas Eicker "] edition = "2021" license = "MIT OR Apache-2.0" @@ -22,20 +22,20 @@ standard_dynamic_assets = ["dep:bevy_common_assets", "dep:serde"] progress_tracking = ["dep:iyes_progress"] [dependencies] -bevy = { version = "0.14.0", default-features = false, features = ["bevy_asset", "bevy_state"] } -bevy_asset_loader_derive = { version = "=0.21.0", path = "../bevy_asset_loader_derive" } +bevy = { version = "0.15.0-rc.1", default-features = false, features = ["bevy_asset", "bevy_state"] } +bevy_asset_loader_derive = { version = "=0.22.0-rc.1", path = "../bevy_asset_loader_derive" } anyhow = "1" path-slash = "0.2" -bevy_common_assets = { version = "0.11.0", features = ["ron"], optional = true } +bevy_common_assets = { version = "0.12.0-rc.1", features = ["ron"], optional = true } serde = { version = "1", optional = true } iyes_progress = { version = "0.12.0", optional = true } [dev-dependencies] -bevy = { version = "0.14.0", features = ["vorbis"] } +bevy = { version = "0.15.0-rc.1", features = ["vorbis"] } anyhow = "1" iyes_progress = { version = "0.12.0" } -bevy_common_assets = { version = "0.11.0", features = ["ron"] } +bevy_common_assets = { version = "0.12.0-rc.1", features = ["ron"] } serde = { version = "1" } ron = "0.8.1" trybuild = { version = "1.0" } diff --git a/bevy_asset_loader/examples/configure_loading_state.rs b/bevy_asset_loader/examples/configure_loading_state.rs index 2a8a695..837b61f 100644 --- a/bevy_asset_loader/examples/configure_loading_state.rs +++ b/bevy_asset_loader/examples/configure_loading_state.rs @@ -77,10 +77,10 @@ fn spawn_player(mut commands: Commands, image_assets: Res) { } fn play_background_audio(mut commands: Commands, audio_assets: Res) { - commands.spawn(AudioBundle { - source: audio_assets.background.clone(), - settings: PlaybackSettings::LOOP, - }); + commands.spawn(( + AudioPlayer(audio_assets.background.clone()), + PlaybackSettings::LOOP, + )); } #[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] diff --git a/bevy_asset_loader/examples/custom_dynamic_assets.rs b/bevy_asset_loader/examples/custom_dynamic_assets.rs index ee92a69..18263d8 100644 --- a/bevy_asset_loader/examples/custom_dynamic_assets.rs +++ b/bevy_asset_loader/examples/custom_dynamic_assets.rs @@ -26,46 +26,45 @@ fn main() { } fn render_stuff(mut commands: Commands, assets: Res) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..Camera3dBundle::default() - }); - commands.spawn(PbrBundle { - mesh: assets.cube.clone(), - material: assets.tree_standard_material.clone(), - transform: Transform::from_xyz(-1., 0., 1.), - ..default() - }); - commands.spawn(PbrBundle { - mesh: assets.cube.clone(), - material: assets.player_standard_material.clone(), - transform: Transform::from_xyz(1., 0., 1.), - ..default() - }); - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), + )); + commands.spawn(( + Mesh3d(assets.cube.clone()), + MeshMaterial3d(assets.tree_standard_material.clone()), + Transform::from_xyz(-1., 0., 1.), + )); + commands.spawn(( + Mesh3d(assets.cube.clone()), + MeshMaterial3d(assets.player_standard_material.clone()), + Transform::from_xyz(1., 0., 1.), + )); + commands.spawn(( + PointLight { intensity: 1500.0, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); - commands.spawn(Camera2dBundle { - camera: Camera { + commands.spawn(( + Camera2d, + Camera { order: 1, clear_color: ClearColorConfig::None, ..default() }, - ..default() - }); + )); // Combined image as sprite - commands.spawn(SpriteBundle { - texture: assets.combined_image.clone(), - transform: Transform::from_xyz(0.0, 200.0, 0.0), - ..default() - }); + commands.spawn(( + Sprite { + image: assets.combined_image.clone(), + ..default() + }, + Transform::from_xyz(0.0, 200.0, 0.0), + )); } #[derive(AssetCollection, Resource)] diff --git a/bevy_asset_loader/examples/dynamic_asset.rs b/bevy_asset_loader/examples/dynamic_asset.rs index e5a0096..b22fcca 100644 --- a/bevy_asset_loader/examples/dynamic_asset.rs +++ b/bevy_asset_loader/examples/dynamic_asset.rs @@ -77,10 +77,10 @@ fn spawn_player_and_tree(mut commands: Commands, image_assets: Res) } fn play_background_audio(mut commands: Commands, audio_assets: Res) { - commands.spawn(AudioBundle { - source: audio_assets.background.clone(), - settings: PlaybackSettings::LOOP, - }); + commands.spawn(( + AudioPlayer(audio_assets.background.clone()), + PlaybackSettings::LOOP, + )); } #[derive(Clone, Eq, PartialEq, Debug, Hash, Default, States)] diff --git a/bevy_asset_loader/examples/failure_state.rs b/bevy_asset_loader/examples/failure_state.rs index 31e14b4..0da3520 100644 --- a/bevy_asset_loader/examples/failure_state.rs +++ b/bevy_asset_loader/examples/failure_state.rs @@ -39,7 +39,7 @@ fn ok(mut quit: EventWriter) { } fn timeout(time: Res