Skip to content
Snippets Groups Projects
Verified Commit 37d04a75 authored by Louis's avatar Louis :fire:
Browse files

Update to bevy 0.9, BKA 0.13

parent 879a3bcf
No related branches found
Tags v0.5.0
No related merge requests found
[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
......@@ -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
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;
......@@ -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
}
}
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>>,
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment