From d4bbe84ba1b2c9eda867952f30ac65fcc746da43 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 24 Jan 2021 17:25:36 +0100 Subject: [PATCH] allow looping a played 3d sound --- MLEM/Misc/SoundEffectInfo.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MLEM/Misc/SoundEffectInfo.cs b/MLEM/Misc/SoundEffectInfo.cs index 1dc99a7..ad923ef 100644 --- a/MLEM/Misc/SoundEffectInfo.cs +++ b/MLEM/Misc/SoundEffectInfo.cs @@ -55,11 +55,12 @@ namespace MLEM.Misc { /// /// Data about the listener /// The position to play the sound at + /// Whether to loop the sound effect instance /// The emitter's doppler scale, defaults to 1 /// The emitter's forward vector, defaults to /// The emitter's up vector, defaults to /// The emitter's velocity, defaults to - public void Play3D(AudioListener listener, Vector3 pos, float? dopplerScale = null, Vector3? forward = null, Vector3? up = null, Vector3? velocity = null) { + public SoundEffectInstance Play3D(AudioListener listener, Vector3 pos, bool loop = false, float? dopplerScale = null, Vector3? forward = null, Vector3? up = null, Vector3? velocity = null) { if (this.emitter == null) this.emitter = new AudioEmitter(); this.emitter.Position = pos; @@ -69,8 +70,10 @@ namespace MLEM.Misc { this.emitter.Velocity = velocity ?? Vector3.Zero; var inst = this.CreateInstance(); + inst.IsLooped = loop; inst.Apply3D(listener, this.emitter); inst.Play(); + return inst; } ///