2022-05-23 16:51:44 +00:00
|
|
|
use std::{fmt::Debug, hash::Hash};
|
|
|
|
|
|
|
|
use bevy::prelude::*;
|
|
|
|
|
|
|
|
use crate::core::CoreConfig;
|
|
|
|
|
|
|
|
pub mod footstep;
|
|
|
|
pub mod icon;
|
|
|
|
|
|
|
|
pub use footstep::{Footstep, FootstepBundle};
|
|
|
|
pub use icon::{SoundIcon, SoundIconBundle};
|
|
|
|
|
2022-05-23 18:35:25 +00:00
|
|
|
/*fn scale_sounds(config: Res<CoreConfig>, mut sounds: Query<&mut Sound>) {
|
2022-05-23 16:51:44 +00:00
|
|
|
let pixels_per_unit = config.pixels_per_unit as f32;
|
|
|
|
for mut sound in sounds.iter_mut() {
|
|
|
|
sound.reference_distance *= pixels_per_unit;
|
|
|
|
if sound.max_distance != f32::MAX {
|
|
|
|
sound.max_distance *= pixels_per_unit;
|
|
|
|
}
|
|
|
|
}
|
2022-05-23 18:35:25 +00:00
|
|
|
}*/
|
2022-05-23 16:51:44 +00:00
|
|
|
|
|
|
|
pub struct SoundPlugin<'a, S>(std::marker::PhantomData<&'a S>);
|
|
|
|
|
|
|
|
impl<'a, S> Default for SoundPlugin<'a, S> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self(std::marker::PhantomData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, S> Plugin for SoundPlugin<'a, S>
|
|
|
|
where
|
|
|
|
S: 'static + Clone + Debug + Eq + Hash + Send + Sync,
|
|
|
|
'a: 'static,
|
|
|
|
{
|
|
|
|
fn build(&self, app: &mut App) {
|
2022-05-24 16:37:12 +00:00
|
|
|
let _core_config = *app.world.get_resource::<CoreConfig>().unwrap();
|
2022-05-23 18:35:25 +00:00
|
|
|
/*if let Some(context) = app.world.get_resource::<Context>() {
|
2022-05-23 16:51:44 +00:00
|
|
|
context
|
|
|
|
.set_meters_per_unit(1. / core_config.pixels_per_unit as f32)
|
|
|
|
.unwrap();
|
2022-05-23 18:35:25 +00:00
|
|
|
}*/
|
2022-05-23 16:51:44 +00:00
|
|
|
app.add_plugin(footstep::FootstepPlugin)
|
2022-05-23 18:35:25 +00:00
|
|
|
.add_plugin(icon::SoundIconPlugin::<S>::default());
|
|
|
|
// .add_system(scale_sounds);
|
2022-05-23 16:51:44 +00:00
|
|
|
}
|
|
|
|
}
|