Removed DamageSoundType and replaced it with a string "tag" instead to allow mod creators to create custom damage sounds

Fixed damagemodifier sounds being completely ignored due to a variable misname
Added structure damage possibility for melee weapons so you can break down windows with a crowbar in spectacular fashion (it's clearly a very inferior method to plasma cutters though)
Clown hitsounds are in now which is awesome. Beat up some clowns!
This commit is contained in:
Alex Noir
2017-12-30 13:46:59 +03:00
parent 2cb0ee73be
commit 32a2b38112
11 changed files with 39 additions and 34 deletions
@@ -35,7 +35,7 @@ namespace Barotrauma
{
if (impact > ImpactTolerance)
{
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, Collider);
SoundPlayer.PlayDamageSound("LimbBlunt", strongestImpact, Collider);
}
}
@@ -10,26 +10,19 @@ using System.Xml.Linq;
namespace Barotrauma
{
public enum DamageSoundType
{
None,
StructureBlunt, StructureSlash,
LimbBlunt, LimbSlash, LimbArmor
}
public struct DamageSound
{
//the range of inflicted damage where the sound can be played
//(10.0f, 30.0f) would be played when the inflicted damage is between 10 and 30
public readonly Vector2 damageRange;
public readonly DamageSoundType damageType;
public readonly string damageType;
public readonly Sound sound;
public readonly string requiredTag;
public DamageSound(Sound sound, Vector2 damageRange, DamageSoundType damageType, string requiredTag = "")
public DamageSound(Sound sound, Vector2 damageRange, string damageType, string requiredTag = "")
{
this.sound = sound;
this.damageRange = damageRange;
@@ -161,8 +154,7 @@ namespace Barotrauma
Sound damageSound = Sound.Load(subElement.GetAttributeString("file", ""), false);
if (damageSound == null) continue;
DamageSoundType damageSoundType = DamageSoundType.None;
Enum.TryParse<DamageSoundType>(subElement.GetAttributeString("damagesoundtype", "None"), false, out damageSoundType);
string damageSoundType = subElement.GetAttributeString("damagesoundtype", "None");
damageSounds.Add(new DamageSound(
damageSound,
@@ -442,14 +434,14 @@ namespace Barotrauma
SplashSounds[splashIndex].Play(1.0f, 800.0f, worldPosition);
}
public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body)
public static void PlayDamageSound(string damageType, float damage, PhysicsBody body)
{
Vector2 bodyPosition = body.DrawPosition;
PlayDamageSound(damageType, damage, bodyPosition, 800.0f);
}
public static void PlayDamageSound(DamageSoundType damageType, float damage, Vector2 position, float range = 2000.0f, List<string> tags = null)
public static void PlayDamageSound(string damageType, float damage, Vector2 position, float range = 2000.0f, List<string> tags = null)
{
damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f);
var sounds = damageSounds.FindAll(s =>