From c2f1a1a383daa14b577231821ab98058faaca411 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 22 May 2016 01:32:23 +0300 Subject: [PATCH] Only the largest firesource within a hull plays a sound --- Subsurface/Source/Map/FireSource.cs | 36 +++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index 8dda33eed..2f8fbc1c2 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -144,19 +144,35 @@ namespace Barotrauma { float count = Rand.Range(0.0f, size.X/50.0f); - if (fireSoundBasic != null) + if (hull.FireSources.Any(fs => fs != this && fs.size.X > size.X)) { - basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex, - Math.Min(size.X / 100.0f, 1.0f), position + size / 2.0f, 1000.0f); + if (basicSoundIndex > 0) + { + Sounds.SoundManager.Stop(basicSoundIndex); + basicSoundIndex = -1; + } + if (largeSoundIndex > 0) + { + Sounds.SoundManager.Stop(largeSoundIndex); + largeSoundIndex = -1; + } + } + else + { + if (fireSoundBasic != null) + { + basicSoundIndex = fireSoundBasic.Loop(basicSoundIndex, + Math.Min(size.X / 100.0f, 1.0f), WorldPosition + size / 2.0f, 1000.0f); + } + if (fireSoundLarge != null) + { + largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex, + MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), WorldPosition + size / 2.0f, 1000.0f); + } } - if (fireSoundLarge != null) - { - largeSoundIndex = fireSoundLarge.Loop(largeSoundIndex, - MathHelper.Clamp((size.X - 200.0f) / 100.0f, 0.0f, 1.0f), position + size / 2.0f, 1000.0f); - } - - if (size.X>50.0f) + + if (size.X > 50.0f) { this.position.Y = MathHelper.Lerp(this.position.Y, hull.Rect.Y - hull.Rect.Height, deltaTime); }