From 714b52dce80b01bf6493c8cca6067aecab3b213f Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Sun, 17 Dec 2017 18:05:05 +0300 Subject: [PATCH] Fixed several sound-related issues that have been bothering me for ages, e.g. * Sounds not playing when the structure is fully destroyed * Glass windows using wrong sound effects * Only one glassBreak sound was used despite there being 3 --- .../BarotraumaClient/Source/Sounds/SoundPlayer.cs | 7 ++++--- .../BarotraumaShared/Content/Sounds/sounds.xml | 4 ++-- Barotrauma/BarotraumaShared/Source/Map/Structure.cs | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs index 8442023e4..9f7055eae 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs @@ -453,10 +453,11 @@ namespace Barotrauma { damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f); var sounds = damageSounds.FindAll(s => - damage >= s.damageRange.X && - damage <= s.damageRange.Y && + s.damageRange == null || + (damage >= s.damageRange.X && + damage <= s.damageRange.Y) && s.damageType == damageType && - (string.IsNullOrEmpty(s.requiredTag) || (tags != null && tags.Contains(s.requiredTag)))); + (tags == null ? string.IsNullOrEmpty(s.requiredTag) : tags.Contains(s.requiredTag))); if (!sounds.Any()) return; diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml index 8aae1829b..d4156d5d9 100644 --- a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml +++ b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml @@ -16,8 +16,8 @@ - - + + diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index a9f7f8330..46a7fd781 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -506,15 +506,15 @@ namespace Barotrauma float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f; - if (impact < 10.0f) return true; - #if CLIENT SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact, new Vector2( - sections[section].rect.X + sections[section].rect.Width / 2, - sections[section].rect.Y - sections[section].rect.Height / 2)); + sections[section].rect.X + sections[section].rect.Width / 2, + sections[section].rect.Y - sections[section].rect.Height / 2), tags: Tags); #endif + if (impact < 10.0f) return true; + AddDamage(section, impact); } } @@ -661,10 +661,10 @@ namespace Barotrauma #if CLIENT GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f); - if (playSound && !SectionBodyDisabled(i)) + if (playSound)// && !SectionBodyDisabled(i)) { DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash; - SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition); + SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition, tags: Tags); } #endif