#[non_exhaustive]pub struct AudioSource {
pub sound_name: String,
pub is_3d: bool,
pub volume: f32,
pub pitch: f32,
pub loop_sound: bool,
pub max_distance: f32,
pub _internal_sink_id: Option<u64>,
pub has_played: bool,
}Expand description
ECS component for a sound source that can be played in 2D or 3D.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sound_name: StringName of the loaded sound to play (see AudioManager::load_sound).
is_3d: boolWhether the sound should be played as a 3D spatial source.
volume: f32Playback volume multiplier (1.0 = original volume).
pitch: f32Playback pitch/speed multiplier (1.0 = original pitch).
loop_sound: boolWhether the sound should loop indefinitely.
max_distance: f32Distance at which the sound is fully attenuated (silent).
_internal_sink_id: Option<u64>Internal id of the active sink playing this source, if any.
has_played: boolLatches once this source has been auto-started, so a finished one-shot is not
restarted every frame. (When a one-shot ends the spatial system clears
_internal_sink_id; without this sentinel the auto-start guard would fire again
next frame → infinite repeat.) Transient runtime state — not persisted.
Implementations§
Source§impl AudioSource
impl AudioSource
Sourcepub fn new(name: &str) -> AudioSource
pub fn new(name: &str) -> AudioSource
Creates a new AudioSource for the sound with the given name.
Sourcepub fn with_loop(self, l: bool) -> AudioSource
pub fn with_loop(self, l: bool) -> AudioSource
Sets whether the sound loops, returning the modified source.
Sourcepub fn with_max_distance(self, dist: f32) -> AudioSource
pub fn with_max_distance(self, dist: f32) -> AudioSource
Sets the attenuation distance, returning the modified source.
Trait Implementations§
Source§impl Clone for AudioSource
impl Clone for AudioSource
Source§fn clone(&self) -> AudioSource
fn clone(&self) -> AudioSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for AudioSource
impl Component for AudioSource
fn storage_type() -> StorageType
Source§impl Debug for AudioSource
impl Debug for AudioSource
Source§impl Default for AudioSource
impl Default for AudioSource
Source§fn default() -> AudioSource
fn default() -> AudioSource
Source§impl<'de> Deserialize<'de> for AudioSource
impl<'de> Deserialize<'de> for AudioSource
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AudioSource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AudioSource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AudioSource
impl PartialEq for AudioSource
Source§impl Serialize for AudioSource
impl Serialize for AudioSource
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for AudioSource
Auto Trait Implementations§
impl Freeze for AudioSource
impl RefUnwindSafe for AudioSource
impl Send for AudioSource
impl Sync for AudioSource
impl Unpin for AudioSource
impl UnsafeUnpin for AudioSource
impl UnwindSafe for AudioSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BundleExt for Twhere
T: Bundle,
impl<T> BundleExt for Twhere
T: Bundle,
fn with<C>(self, component: C) -> DynamicBundle<Self, C>where
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().