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
This commit is contained in:
Alex Noir
2017-12-17 18:05:05 +03:00
parent 0eacbce313
commit 714b52dce8
3 changed files with 12 additions and 11 deletions
@@ -453,10 +453,11 @@ namespace Barotrauma
{ {
damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f); damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f);
var sounds = damageSounds.FindAll(s => var sounds = damageSounds.FindAll(s =>
damage >= s.damageRange.X && s.damageRange == null ||
damage <= s.damageRange.Y && (damage >= s.damageRange.X &&
damage <= s.damageRange.Y) &&
s.damageType == damageType && 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; if (!sounds.Any()) return;
@@ -16,8 +16,8 @@
<damagesound file="Content/Sounds/Damage/GlassImpact3.ogg" damagerange="10.0,20.0" damagesoundtype="StructureBlunt" requiredtag="glass"/> <damagesound file="Content/Sounds/Damage/GlassImpact3.ogg" damagerange="10.0,20.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="20.0,50.0" damagesoundtype="StructureBlunt" requiredtag="glass"/> <damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="20.0,50.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="25.0,80.0" damagesoundtype="StructureBlunt" requiredtag="glass"/> <damagesound file="Content/Sounds/Damage/GlassBreak2.ogg" damagerange="25.0,80.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
<damagesound file="Content/Sounds/Damage/GlassBreak1.ogg" damagerange="50.0,100.0" damagesoundtype="StructureBlunt" requiredtag="glass"/> <damagesound file="Content/Sounds/Damage/GlassBreak3.ogg" damagerange="50.0,100.0" damagesoundtype="StructureBlunt" requiredtag="glass"/>
<damagesound file="Content/Sounds/Damage/StructureCrunch1.ogg" damagerange="0.0,40.0" damagesoundtype="StructureSlash"/> <damagesound file="Content/Sounds/Damage/StructureCrunch1.ogg" damagerange="0.0,40.0" damagesoundtype="StructureSlash"/>
<damagesound file="Content/Sounds/Damage/StructureCrunch2.ogg" damagerange="5.0,70.0" damagesoundtype="StructureSlash"/> <damagesound file="Content/Sounds/Damage/StructureCrunch2.ogg" damagerange="5.0,70.0" damagesoundtype="StructureSlash"/>
@@ -506,15 +506,15 @@ namespace Barotrauma
float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f; float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f;
if (impact < 10.0f) return true;
#if CLIENT #if CLIENT
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact, SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact,
new Vector2( new Vector2(
sections[section].rect.X + sections[section].rect.Width / 2, sections[section].rect.X + sections[section].rect.Width / 2,
sections[section].rect.Y - sections[section].rect.Height / 2)); sections[section].rect.Y - sections[section].rect.Height / 2), tags: Tags);
#endif #endif
if (impact < 10.0f) return true;
AddDamage(section, impact); AddDamage(section, impact);
} }
} }
@@ -661,10 +661,10 @@ namespace Barotrauma
#if CLIENT #if CLIENT
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f); 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; DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash;
SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition); SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition, tags: Tags);
} }
#endif #endif