From a4b33834e79c1cee834732e2de34a552d3328f59 Mon Sep 17 00:00:00 2001
From: Louis Capitanchik <contact@louiscap.co>
Date: Tue, 9 Jul 2024 14:35:17 +0100
Subject: [PATCH] Support Bevy version 0.14

---
 Cargo.toml        | 10 ++++-----
 README.md         | 29 +++++++++++++-------------
 examples/basic.rs | 12 +++++------
 src/loader.rs     | 52 ++++++++++++++++++++++-------------------------
 src/systems.rs    |  2 +-
 5 files changed, 51 insertions(+), 54 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 0f2a73d..0bccedb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,11 +1,11 @@
 [package]
 name = "micro_banimate"
-version = "0.8.0"
+version = "0.9.0"
 edition = "2021"
 license = "Apache-2.0"
 description = "Easily manage complex Bevy 2D sprite animations"
 authors = [
-	"Louis Capitanchik <louis@microhacks.co.uk>"
+    "Louis Capitanchik <louis@microhacks.co.uk>"
 ]
 repository = "https://lab.lcr.gr/microhacks/micro-banimate"
 
@@ -25,8 +25,8 @@ anyhow = "^1.0"
 serde = { version = "^1.0", optional = true }
 serde_json = { version = "^1.0", optional = true }
 toml = { version = "0.8", optional = true }
-bevy = { version = "^0.13.0", default-features = false, features = ["bevy_asset", "bevy_sprite"] }
+bevy = { version = "^0.14", default-features = false, features = ["bevy_asset", "bevy_sprite"] }
 
-[dev_dependencies]
-bevy = "0.13"
+[dev-dependencies]
+bevy = "0.14"
 log = "0.4"
diff --git a/README.md b/README.md
index decd95a..8de1c85 100644
--- a/README.md
+++ b/README.md
@@ -60,22 +60,22 @@ like this:
 ```json
 {
   "idle": {
-	"frames": [
-	  1,
-	  2,
-	  3
-	],
-	"frame_time": 250
+    "frames": [
+      1,
+      2,
+      3
+    ],
+    "frame_time": 250
   },
   "shoot_right": {
-	"frames": [
-	  34,
-	  34,
-	  34,
-	  35,
-	  36
-	],
-	"frame_time": 100
+    "frames": [
+      34,
+      34,
+      34,
+      35,
+      36
+    ],
+    "frame_time": 100
   }
 }
 ```
@@ -99,6 +99,7 @@ frame_time = 100
 
 | banimate version    | bevy version | tilemap version                          |
 |---------------------|--------------|------------------------------------------|
+| 0.9.0               | 0.14         | n/a                                      |
 | 0.8.0               | 0.13         | n/a                                      |
 | 0.7.0               | 0.12         | n/a                                      |
 | 0.6.0-rc.1          | 0.11         | 55c15bfa43c7a9e2adef6b70007e92d699377454 |
diff --git a/examples/basic.rs b/examples/basic.rs
index 0b299fe..6debe1f 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -28,7 +28,7 @@ fn load_assets(
 ) {
 	let sprites = assets.load("character.png");
 	let atlas = atlas.add(TextureAtlasLayout::from_grid(
-		Vec2::new(48., 48.),
+		UVec2::new(48, 48),
 		10,
 		6,
 		None,
@@ -48,12 +48,12 @@ fn spawn_assets(mut commands: Commands, assets: Res<ExampleAssets>) {
 	const HEIGHT: f32 = 320.0;
 
 	commands.spawn((
-		SpriteSheetBundle {
+		TextureAtlas {
+			layout: assets.atlas.clone_weak(),
+			index: 0,
+		},
+		SpriteBundle {
 			texture: assets.sprites.clone_weak(),
-			atlas: TextureAtlas {
-				layout: assets.atlas.clone_weak(),
-				index: 0,
-			},
 			..Default::default()
 		},
 		DirectionalAnimationBundle::with_direction(
diff --git a/src/loader.rs b/src/loader.rs
index 90c65d8..1484e64 100644
--- a/src/loader.rs
+++ b/src/loader.rs
@@ -27,7 +27,7 @@ impl Error for LoaderError {}
 #[cfg(feature = "json_loader")]
 mod json_loader {
 	use bevy::asset::io::Reader;
-	use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext};
+	use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext};
 
 	use crate::definitions::AnimationSet;
 	use crate::loader::LoaderError;
@@ -38,21 +38,19 @@ mod json_loader {
 		type Settings = ();
 		type Error = LoaderError;
 
-		fn load<'a>(
+		async fn load<'a>(
 			&'a self,
-			reader: &'a mut Reader,
+			reader: &'a mut Reader<'_>,
 			_settings: &'a Self::Settings,
-			_load_context: &'a mut LoadContext,
-		) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
-			Box::pin(async move {
-				let mut bytes = Vec::new();
-				reader
-					.read_to_end(&mut bytes)
-					.await
-					.expect("Failed to read all bytes");
-
-				serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json)
-			})
+			_load_context: &'a mut LoadContext<'_>,
+		) -> Result<Self::Asset, Self::Error> {
+			let mut bytes = Vec::new();
+			reader
+				.read_to_end(&mut bytes)
+				.await
+				.expect("Failed to read all bytes");
+
+			serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json)
 		}
 
 		fn extensions(&self) -> &[&str] {
@@ -65,7 +63,7 @@ mod json_loader {
 #[cfg(feature = "toml_loader")]
 mod toml_loader {
 	use bevy::asset::io::Reader;
-	use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext};
+	use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext};
 
 	use crate::definitions::AnimationSet;
 	use crate::loader::LoaderError;
@@ -76,21 +74,19 @@ mod toml_loader {
 		type Settings = ();
 		type Error = LoaderError;
 
-		fn load<'a>(
+		async fn load<'a>(
 			&'a self,
-			reader: &'a mut Reader,
+			reader: &'a mut Reader<'_>,
 			_settings: &'a Self::Settings,
-			_load_context: &'a mut LoadContext,
-		) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
-			Box::pin(async move {
-				let mut bytes = String::new();
-				reader
-					.read_to_string(&mut bytes)
-					.await
-					.expect("Failed to read all bytes");
-
-				toml::from_str(bytes.as_str()).map_err(LoaderError::Toml)
-			})
+			_load_context: &'a mut LoadContext<'_>,
+		) -> Result<Self::Asset, Self::Error> {
+			let mut bytes = String::new();
+			reader
+				.read_to_string(&mut bytes)
+				.await
+				.expect("Failed to read all bytes");
+
+			toml::from_str(bytes.as_str()).map_err(LoaderError::Toml)
 		}
 
 		fn extensions(&self) -> &[&str] {
diff --git a/src/systems.rs b/src/systems.rs
index 4febe7f..f9fbe1b 100644
--- a/src/systems.rs
+++ b/src/systems.rs
@@ -10,7 +10,7 @@ pub enum AnimationSystems {
 	SyncAnimations,
 }
 
-#[derive(Copy, Clone, Debug, Component, PartialEq, Eq, Ord, PartialOrd, Event)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Event)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct AnimationCompleted {
 	pub entity: Entity,
-- 
GitLab