From 37d04a7538c9251a4d2a21faadb798d54b760bf4 Mon Sep 17 00:00:00 2001
From: Louis Capitanchik <contact@louiscap.co>
Date: Mon, 14 Nov 2022 04:01:41 +0000
Subject: [PATCH] Update to bevy 0.9, BKA 0.13

---
 Cargo.toml       | 8 ++++----
 README.md        | 7 +++++++
 src/channels.rs  | 6 ++++++
 src/lib.rs       | 6 ++++--
 src/music_box.rs | 4 ++--
 src/utilities.rs | 2 +-
 6 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index c87801b..29a251e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "micro_musicbox"
-version = "0.4.0"
+version = "0.5.0"
 edition = "2021"
 license = "Apache-2.0"
 authors = ["Louis Capitanchik <louis@microhacks.co.uk>"]
@@ -19,10 +19,10 @@ wav = ["bevy_kira_audio/wav"]
 ogg = ["bevy_kira_audio/ogg"]
 
 [dependencies]
-bevy = { version = "0.8", default-features = false }
-bevy_kira_audio = { version = "0.12", default-features = false }
+bevy = { version = "0.9.0", default-features = false }
+bevy_kira_audio = { version = "0.13.0", default-features = false }
 serde = { version = "1", optional = true }
 
 [dev_dependencies]
-bevy = "0.8"
+bevy = "0.9.0"
 log = "0.4"
\ No newline at end of file
diff --git a/README.md b/README.md
index 6e576fc..f03d22e 100644
--- a/README.md
+++ b/README.md
@@ -134,3 +134,10 @@ The examples in this repository use assets available under the following license
 - The-Great-Madeja.mp3 by [Rolemusic](http://rolemusic.sawsquarenoise.com/) is licensed under a [CC-BY-4.0 Attribution License](https://creativecommons.org/licenses/by/4.0/).
 - The-White-Kitty.mp3 by [Rolemusic](http://rolemusic.sawsquarenoise.com/) is licensed under a [CC-BY-4.0 Attribution License](https://creativecommons.org/licenses/by/4.0/).
 - KenneyBlocks.ttf by [Kenney](https://www.kenney.nl) is licensed under a [CC-0 Public Domain License](http://creativecommons.org/publicdomain/zero/1.0/) 
+
+## Compatibility
+
+| musicbox version | bevy version | bka version |
+|------------------|--------------|-------------|
+| 0.5              | 0.9          | 0.13        |
+| 0.4              | 0.8.0        | 0.12        |
\ No newline at end of file
diff --git a/src/channels.rs b/src/channels.rs
index eb49fc7..5812baa 100644
--- a/src/channels.rs
+++ b/src/channels.rs
@@ -1,3 +1,5 @@
+use bevy::prelude::Resource;
+
 /// The channel used for playing main background music tracks. When a track is started in this
 /// channel, the currently playing track (if it exist) will be stopped. Tweens can be applied to
 /// control this transition
@@ -5,6 +7,7 @@
 /// - *Volume Type:* Music
 /// - *Supports Concurrent Sounds:* No
 /// - *Supports Transitions*: Yes
+#[derive(Resource)]
 pub struct MusicAudioChannel;
 /// The channel used for playing an ambient background track. An ambient background track can
 /// be considered similar to a music track, but consisting of composite sound effects to create
@@ -13,12 +16,14 @@ pub struct MusicAudioChannel;
 /// - *Volume Type:* SFX
 /// - *Supports Concurrent Sounds:* No
 /// - *Supports Transitions*: Yes
+#[derive(Resource)]
 pub struct AmbianceAudioChannel;
 /// The channel used for generic one shot sound effects, such as spells, hits, attacks, grunts, etc.
 ///
 /// - *Volume Type:* SFX
 /// - *Supports Concurrent Sounds:* Yes
 /// - *Supports Transitions:* Yes
+#[derive(Resource)]
 pub struct SfxAudioChannel;
 /// The channel used for any UI related one-shot sound effects. The volume of ui sfx can be
 /// controlled separately from game related sound effects
@@ -26,4 +31,5 @@ pub struct SfxAudioChannel;
 /// - *Volume Type:* UI SFX
 /// - *Supports Concurrent Sounds:* Yes
 /// - *Supports Transitions:* Yes
+#[derive(Resource)]
 pub struct UiSfxAudioChannel;
diff --git a/src/lib.rs b/src/lib.rs
index 0a68d8c..9e59e4e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -106,7 +106,9 @@ impl<T: SuppliesAudio> CombinedAudioPlugins<T> {
 }
 
 impl<T: SuppliesAudio> PluginGroup for CombinedAudioPlugins<T> {
-	fn build(&mut self, group: &mut PluginGroupBuilder) {
-		group.add(AudioPlugin).add(MusicBoxPlugin::<T>::new());
+	fn build(self) -> PluginGroupBuilder {
+		let mut group = PluginGroupBuilder::start::<Self>();
+		group = group.add(AudioPlugin).add(MusicBoxPlugin::<T>::new());
+		group
 	}
 }
diff --git a/src/music_box.rs b/src/music_box.rs
index 2a410f4..36be07f 100644
--- a/src/music_box.rs
+++ b/src/music_box.rs
@@ -1,7 +1,7 @@
 use std::marker::PhantomData;
 
 use bevy::ecs::system::SystemParam;
-use bevy::prelude::{Assets, Commands, DetectChanges, Handle, Res, ResMut};
+use bevy::prelude::{Assets, Commands, DetectChanges, Handle, Res, ResMut, Resource};
 use bevy_kira_audio::{AudioChannel, AudioControl, AudioInstance, AudioSource, AudioTween};
 
 use crate::utilities::{AudioSettings, SuppliesAudio, TrackType};
@@ -36,7 +36,7 @@ pub struct MusicBox<'w, 's, T: SuppliesAudio> {
 
 /// Tracks the currently active audio instance singleton channels, to allow
 /// for transitions
-#[derive(Debug, Default)]
+#[derive(Debug, Default, Resource)]
 pub struct MusicBoxState {
 	pub active_music: Option<Handle<AudioInstance>>,
 	pub active_ambiance: Option<Handle<AudioInstance>>,
diff --git a/src/utilities.rs b/src/utilities.rs
index 24d3a4f..5c6cc40 100644
--- a/src/utilities.rs
+++ b/src/utilities.rs
@@ -32,7 +32,7 @@ pub trait SuppliesAudio: Resource {
 	fn get_audio_track<T: ToString>(&self, name: T) -> Option<Handle<AudioSource>>;
 }
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Resource)]
 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
 pub struct AudioSettings {
 	pub master_volume: f32,
-- 
GitLab