A multiplayer VR framework w/voice chat
at main 897 B view raw
1use bevy::{ecs::component::Component, transform::components::Transform}; 2 3use crate::FelixAudioComponent; 4 5pub mod stream_source; 6pub mod static_source; 7 8#[derive(Component)] 9pub struct FelixAudioSource{ 10 inner: Box<dyn AudioSource + Send + Sync + 'static> 11} 12 13impl FelixAudioSource{ 14 pub fn init( &mut self, audio_system: &mut FelixAudioComponent ){ 15 self.inner.init(audio_system); 16 } 17 18 pub fn needs_init( &self ) -> bool{ 19 self.inner.needs_init() 20 } 21 22 pub fn update( &mut self, transform: &Transform ){ 23 self.inner.update(transform); 24 } 25} 26 27impl<T> From<T> for FelixAudioSource 28where 29 T: AudioSource + Send + Sync + 'static 30{ 31 fn from(value: T) -> Self { 32 Self { 33 inner: Box::new(value) 34 } 35 } 36} 37 38pub trait AudioSource{ 39 fn init( &mut self, audio_system: &mut FelixAudioComponent ); 40 fn needs_init( &self ) -> bool; 41 fn update( &mut self, transform: &Transform ); 42}