chore: Update to Bevy 0.11.

This commit is contained in:
Nolan Darilek 2023-07-16 13:24:12 -05:00
parent b76ca95495
commit e605495d9f
4 changed files with 57 additions and 43 deletions

View File

@ -11,11 +11,11 @@ repository = "https://labs.lightsout.games/projects/bevy_synthizer"
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
bevy = { version = "0.10", default-features = false, features = ["bevy_asset"] } bevy = { version = "0.11", default-features = false, features = ["bevy_asset"] }
synthizer = "0.5.6" synthizer = "0.5.6"
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.10", default-features = true } bevy = { version = "0.11", default-features = true }
[package.metadata.release] [package.metadata.release]
publish = false publish = false

View File

@ -63,16 +63,19 @@ fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut T
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins((
.add_plugin(SynthizerPlugin { DefaultPlugins,
default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf), SynthizerPlugin {
default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse), default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf),
..default() default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse),
}) ..default()
.add_system(bevy::window::close_on_esc) },
))
.init_resource::<AssetHandles>() .init_resource::<AssetHandles>()
.add_startup_system(setup) .add_systems(Startup, setup)
.add_system(load_and_create) .add_systems(
.add_system(rotate_listener) Update,
(bevy::window::close_on_esc, load_and_create, rotate_listener),
)
.run(); .run();
} }

View File

@ -42,14 +42,15 @@ fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut T
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins((
.add_plugin(SynthizerPlugin { DefaultPlugins,
default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf), SynthizerPlugin {
default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse), default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf),
..default() default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse),
}) ..default()
.add_system(bevy::window::close_on_esc) },
.add_startup_system(setup) ))
.add_system(rotate_listener) .add_systems(Startup, setup)
.add_systems(Update, (bevy::window::close_on_esc, rotate_listener))
.run(); .run();
} }

View File

@ -4,13 +4,13 @@ use std::collections::HashMap;
use bevy::{ use bevy::{
asset::{AssetLoader, LoadContext, LoadedAsset}, asset::{AssetLoader, LoadContext, LoadedAsset},
prelude::*, prelude::*,
reflect::TypeUuid, reflect::{TypePath, TypeUuid},
transform::TransformSystem, transform::TransformSystem,
utils::BoxedFuture, utils::BoxedFuture,
}; };
pub use synthizer as syz; pub use synthizer as syz;
#[derive(Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypeUuid)] #[derive(Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypePath, TypeUuid)]
#[uuid = "6b6b533a-bb1f-11ec-bda2-00155d8fdde9"] #[uuid = "6b6b533a-bb1f-11ec-bda2-00155d8fdde9"]
pub struct Buffer(syz::Buffer); pub struct Buffer(syz::Buffer);
@ -171,6 +171,7 @@ impl Default for Sound {
} }
} }
#[derive(Event, Debug)]
pub enum SynthizerEvent { pub enum SynthizerEvent {
Finished(Entity), Finished(Entity),
Looped(Entity), Looped(Entity),
@ -759,44 +760,53 @@ impl Plugin for SynthizerPlugin {
.insert_resource(defaults) .insert_resource(defaults)
.add_event::<SynthizerEvent>() .add_event::<SynthizerEvent>()
.add_systems( .add_systems(
PreUpdate,
( (
sync_config, sync_config,
swap_buffers, swap_buffers,
change_panner_strategy, change_panner_strategy,
add_sound_without_source, add_sound_without_source,
) )
.in_set(SynthizerSets::First) .in_set(SynthizerSets::First),
.in_base_set(CoreSet::PreUpdate),
) )
.configure_set(SynthizerSets::First.before(SynthizerSets::UpdateHandles)) .configure_set(
.add_systems( PreUpdate,
(add_source_handle, add_generator) SynthizerSets::First.before(SynthizerSets::UpdateHandles),
.in_base_set(CoreSet::PostUpdate)
.in_set(SynthizerSets::UpdateHandles),
)
.configure_set(SynthizerSets::UpdateHandles.before(SynthizerSets::UpdateProperties))
.add_system(
update_sound_properties
.in_base_set(CoreSet::PostUpdate)
.in_set(SynthizerSets::UpdateProperties),
) )
.add_systems( .add_systems(
PostUpdate,
(add_source_handle, add_generator).in_set(SynthizerSets::UpdateHandles),
)
.configure_set(
PostUpdate,
SynthizerSets::UpdateHandles.before(SynthizerSets::UpdateProperties),
)
.add_systems(
PostUpdate,
update_sound_properties.in_set(SynthizerSets::UpdateProperties),
)
.add_systems(
PostUpdate,
(update_listener, update_source_properties) (update_listener, update_source_properties)
.in_base_set(CoreSet::PostUpdate)
.in_set(SynthizerSets::UpdateProperties) .in_set(SynthizerSets::UpdateProperties)
.after(TransformSystem::TransformPropagate), .after(TransformSystem::TransformPropagate),
) )
.configure_set(SynthizerSets::UpdateProperties.before(SynthizerSets::UpdateState)) .configure_set(
PostUpdate,
SynthizerSets::UpdateProperties.before(SynthizerSets::UpdateState),
)
.add_systems( .add_systems(
PostUpdate,
(update_source_playback_state, update_sound_playback_state) (update_source_playback_state, update_sound_playback_state)
.in_base_set(CoreSet::PostUpdate)
.in_set(SynthizerSets::UpdateState), .in_set(SynthizerSets::UpdateState),
) )
.configure_set(SynthizerSets::UpdateState.before(SynthizerSets::Last)) .configure_set(
PostUpdate,
SynthizerSets::UpdateState.before(SynthizerSets::Last),
)
.add_systems( .add_systems(
(remove_sound, events) PostUpdate,
.in_set(SynthizerSets::Last) (remove_sound, events).in_set(SynthizerSets::Last),
.in_base_set(CoreSet::PostUpdate),
); );
} }
} }