diff --git a/CHANGELOG.md b/CHANGELOG.md index fdec003..aa5efc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +- Update to Bevy 0.15 + ## v0.11.0 - 04.07.2024 - Update to Bevy 0.14 - Update `quick-xml` to `0.34` diff --git a/Cargo.toml b/Cargo.toml index 9cb9fc9..fc358d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_common_assets" -version = "0.11.0" +version = "0.12.0-rc.1" authors = ["Niklas Eicker "] edition = "2021" license = "MIT OR Apache-2.0" @@ -23,7 +23,7 @@ csv = ["dep:csv"] postcard = ["dep:postcard"] [dependencies] -bevy = { version = "0.14", default-features = false, features = ["bevy_asset"] } +bevy = { version = "0.15.0-rc.1", default-features = false, features = ["bevy_asset"] } serde_toml = { version = "0.8", package = "toml", optional = true } serde_ron = { version = "0.8", package = "ron", optional = true } serde_yaml = { version = "0.9", optional = true } @@ -31,13 +31,13 @@ serde_json = { version = "1", optional = true } rmp-serde = { version = "1", optional = true } csv = { version = "1", optional = true } thiserror = "1.0" -quick-xml = { version = "0.34", features = [ "serialize" ], optional = true } +quick-xml = { version = "0.36.2", features = [ "serialize" ], optional = true } serde = { version = "1" } anyhow = { version = "1" } postcard = {version = "1.0", features = ["use-std"], optional = true} [dev-dependencies] -bevy = { version = "0.14.0-rc.4" } +bevy = { version = "0.15.0-rc.1" } serde = { version = "1" } [package.metadata.docs.rs] diff --git a/examples/csv.rs b/examples/csv.rs index c4e5f39..fa31b84 100644 --- a/examples/csv.rs +++ b/examples/csv.rs @@ -9,7 +9,6 @@ fn main() { DefaultPlugins, CsvAssetPlugin::::new(&["level.csv"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -22,7 +21,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -33,17 +32,15 @@ fn spawn_level( positions: Res>, mut state: ResMut>, ) { - if asset_server.get_recursive_dependency_load_state(&level.0) - == Some(RecursiveDependencyLoadState::Loaded) - { + if matches!( + asset_server.get_recursive_dependency_load_state(&level.0), + Some(RecursiveDependencyLoadState::Loaded) + ) { for (_, position) in positions.iter() { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(Vec3::new( - position.x, position.y, position.z, - )), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(Vec3::new(position.x, position.y, position.z)), + )); } state.set(AppState::Level); diff --git a/examples/json.rs b/examples/json.rs index 5ee46c9..c753201 100644 --- a/examples/json.rs +++ b/examples/json.rs @@ -8,7 +8,6 @@ fn main() { DefaultPlugins, JsonAssetPlugin::::new(&["level.json"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -21,7 +20,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -33,11 +32,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); diff --git a/examples/msgpack.rs b/examples/msgpack.rs index c3606ca..b904eee 100644 --- a/examples/msgpack.rs +++ b/examples/msgpack.rs @@ -8,7 +8,6 @@ fn main() { DefaultPlugins, MsgPackAssetPlugin::::new(&["level.msgpack"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -21,7 +20,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -33,11 +32,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); diff --git a/examples/multiple_formats.rs b/examples/multiple_formats.rs index 827ea60..4ef6a54 100644 --- a/examples/multiple_formats.rs +++ b/examples/multiple_formats.rs @@ -1,4 +1,3 @@ -use bevy::asset::LoadState; use bevy::prelude::*; use bevy::reflect::TypePath; use bevy_common_assets::json::JsonAssetPlugin; @@ -13,7 +12,6 @@ fn main() { RonAssetPlugin::::new(&["level.ron"]), JsonAssetPlugin::::new(&["level.json"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, check_loading.run_if(in_state(AppState::Loading))) @@ -33,7 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -45,11 +43,10 @@ fn spawn_level( for handle in levels.0.iter() { let level = level_assets.remove(handle).unwrap(); for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } } } @@ -60,7 +57,11 @@ fn check_loading( mut state: ResMut>, ) { for handle in &handles.0 { - if asset_server.get_load_state(handle) != Some(LoadState::Loaded) { + if asset_server + .get_load_state(handle) + .map(|state| !state.is_loaded()) + .unwrap_or(true) + { return; } } diff --git a/examples/postcard.rs b/examples/postcard.rs index 5043fcd..b4d4e7e 100644 --- a/examples/postcard.rs +++ b/examples/postcard.rs @@ -8,7 +8,6 @@ fn main() { DefaultPlugins, PostcardAssetPlugin::::new(&["level.postcard"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -20,7 +19,7 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.insert_resource(level); let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -32,11 +31,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); } diff --git a/examples/ron.rs b/examples/ron.rs index 131597f..941447b 100644 --- a/examples/ron.rs +++ b/examples/ron.rs @@ -5,7 +5,6 @@ use bevy_common_assets::ron::RonAssetPlugin; fn main() { App::new() .add_plugins((DefaultPlugins, RonAssetPlugin::::new(&["level.ron"]))) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -18,7 +17,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -30,11 +29,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); diff --git a/examples/toml.rs b/examples/toml.rs index df4c455..3b6b835 100644 --- a/examples/toml.rs +++ b/examples/toml.rs @@ -8,7 +8,6 @@ fn main() { DefaultPlugins, TomlAssetPlugin::::new(&["level.toml"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -21,7 +20,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -33,11 +32,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); diff --git a/examples/xml.rs b/examples/xml.rs index 9413989..ae36523 100644 --- a/examples/xml.rs +++ b/examples/xml.rs @@ -6,7 +6,6 @@ use bevy_common_assets::xml::XmlAssetPlugin; fn main() { App::new() .add_plugins((DefaultPlugins, XmlAssetPlugin::::new(&["level.xml"]))) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -19,7 +18,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -31,13 +30,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(Vec3::new( - position.x, position.y, position.z, - )), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(Vec3::new(position.x, position.y, position.z)), + )); } state.set(AppState::Level); diff --git a/examples/yaml.rs b/examples/yaml.rs index e1831aa..2443175 100644 --- a/examples/yaml.rs +++ b/examples/yaml.rs @@ -8,7 +8,6 @@ fn main() { DefaultPlugins, YamlAssetPlugin::::new(&["level.yaml"]), )) - .insert_resource(Msaa::Off) .init_state::() .add_systems(Startup, setup) .add_systems(Update, spawn_level.run_if(in_state(AppState::Loading))) @@ -21,7 +20,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let tree = ImageHandle(asset_server.load("tree.png")); commands.insert_resource(tree); - commands.spawn(Camera2dBundle::default()); + commands.spawn((Camera2d, Msaa::Off)); } fn spawn_level( @@ -33,11 +32,10 @@ fn spawn_level( ) { if let Some(level) = levels.remove(level.0.id()) { for position in level.positions { - commands.spawn(SpriteBundle { - transform: Transform::from_translation(position.into()), - texture: tree.0.clone(), - ..default() - }); + commands.spawn(( + Sprite::from_image(tree.0.clone()), + Transform::from_translation(position.into()), + )); } state.set(AppState::Level); diff --git a/src/csv.rs b/src/csv.rs index b1e60f3..2c684bd 100644 --- a/src/csv.rs +++ b/src/csv.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, Handle, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, Handle, LoadContext}; use bevy::prelude::TypePath; use std::marker::PhantomData; use thiserror::Error; @@ -99,11 +99,11 @@ where type Settings = (); type Error = CsvLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/json.rs b/src/json.rs index 4c70b9a..a93b64c 100644 --- a/src/json.rs +++ b/src/json.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use serde_json::from_slice; use std::marker::PhantomData; use thiserror::Error; @@ -63,11 +63,11 @@ where type Settings = (); type Error = JsonLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/msgpack.rs b/src/msgpack.rs index 7a20d88..a186f5e 100644 --- a/src/msgpack.rs +++ b/src/msgpack.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use rmp_serde::from_slice; use std::marker::PhantomData; use thiserror::Error; @@ -63,11 +63,11 @@ where type Settings = (); type Error = MsgPackLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/postcard.rs b/src/postcard.rs index 61cfdf4..ef6e538 100644 --- a/src/postcard.rs +++ b/src/postcard.rs @@ -1,8 +1,7 @@ use bevy::{ app::{App, Plugin}, asset::{ - io::Reader, saver::AssetSaver, Asset, AssetApp, AssetLoader, AsyncReadExt, AsyncWriteExt, - LoadContext, + io::Reader, saver::AssetSaver, Asset, AssetApp, AssetLoader, AsyncWriteExt, LoadContext, }, prelude::*, }; @@ -69,11 +68,11 @@ where type Settings = (); type Error = PostcardAssetError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; @@ -105,11 +104,11 @@ impl Deserialize<'de> + Serialize> AssetSaver for PostcardAs type OutputLoader = PostcardAssetLoader; type Error = PostcardAssetError; - async fn save<'a>( - &'a self, - writer: &'a mut bevy::asset::io::Writer, - asset: bevy::asset::saver::SavedAsset<'a, Self::Asset>, - _settings: &'a Self::Settings, + async fn save( + &self, + writer: &mut bevy::asset::io::Writer, + asset: bevy::asset::saver::SavedAsset<'_, Self::Asset>, + _settings: &Self::Settings, ) -> Result<::Settings, Self::Error> { let bytes = to_stdvec(&asset.get())?; writer.write_all(&bytes).await?; diff --git a/src/ron.rs b/src/ron.rs index e9b64d6..9db32c6 100644 --- a/src/ron.rs +++ b/src/ron.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use serde_ron::de::from_bytes; use std::marker::PhantomData; use thiserror::Error; @@ -63,11 +63,11 @@ where type Settings = (); type Error = RonLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/toml.rs b/src/toml.rs index 52dab8c..514915e 100644 --- a/src/toml.rs +++ b/src/toml.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use std::marker::PhantomData; use std::str::from_utf8; use thiserror::Error; @@ -66,11 +66,11 @@ where type Settings = (); type Error = TomlLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/xml.rs b/src/xml.rs index f0b501e..685b4ee 100644 --- a/src/xml.rs +++ b/src/xml.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use quick_xml::de::from_str; use std::marker::PhantomData; use std::str::from_utf8; @@ -68,11 +68,11 @@ where type Settings = (); type Error = XmlLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/src/yaml.rs b/src/yaml.rs index 07eb5a4..3831877 100644 --- a/src/yaml.rs +++ b/src/yaml.rs @@ -1,6 +1,6 @@ use bevy::app::{App, Plugin}; use bevy::asset::io::Reader; -use bevy::asset::{Asset, AssetApp, AssetLoader, AsyncReadExt, LoadContext}; +use bevy::asset::{Asset, AssetApp, AssetLoader, LoadContext}; use serde_yaml::from_slice; use std::marker::PhantomData; use thiserror::Error; @@ -63,11 +63,11 @@ where type Settings = (); type Error = YamlLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?;