From 98d0f4251090c69375e3d281ea58ca7e716500f4 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 26 Jan 2018 17:25:22 +0200 Subject: [PATCH] Fixed structure impact damage sounds. Character colliders caused the impact sounds to be triggered almost constantly, but the sounds were not played at the world position of the structure, causing them to only be heard inside ruins (whose positions are the same as worldpositions). --- .../BarotraumaShared/Source/Map/Structure.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index 1332b6e76..3a61cb9ce 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -513,21 +513,15 @@ namespace Barotrauma Vector2 pos = ConvertUnits.ToDisplayUnits(f2.Body.Position); int section = FindSectionIndex(pos); - if (section > 0) + if (section > -1) { Vector2 normal = contact.Manifold.LocalNormal; - float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f; - -#if CLIENT - SoundPlayer.PlayDamageSound("StructureBlunt", impact, - new Vector2( - sections[section].rect.X + sections[section].rect.Width / 2, - sections[section].rect.Y - sections[section].rect.Height / 2), tags: Tags); -#endif - + float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal) * f2.Body.Mass * 0.1f; if (impact < 10.0f) return true; - +#if CLIENT + SoundPlayer.PlayDamageSound("StructureBlunt", impact, SectionPosition(section, true), tags: Tags); +#endif AddDamage(section, impact); } }