From d95020b910bc69ab733f87d5d0238fe2d1164590 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sat, 16 Dec 2023 18:52:45 +0000
Subject: [PATCH] Overhauled audio management

---
 Assets/Scripts/Damageable.cs |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/Assets/Scripts/Damageable.cs b/Assets/Scripts/Damageable.cs
index 09fa72f..6fd7016 100644
--- a/Assets/Scripts/Damageable.cs
+++ b/Assets/Scripts/Damageable.cs
@@ -1,3 +1,4 @@
+using Assets.Scripts.Enums;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -23,9 +24,9 @@
     private float timeSinceHit = 0f;
     public float invincibilityTime = 0.25f;
 
-    public AudioClip hitSound;
-    public AudioClip healSound;
-    public AudioClip deathSound;
+    public SoundName hitSound;
+    public SoundName healSound;
+    public SoundName deathSound;
 
     public int MaxHealth
     {
@@ -48,10 +49,11 @@
             if (value <= 0)
             {
                 IsAlive = false;
-                if (deathSound != null)
-                {
-                    SoundManager.instance.PlaySoundAtPoint(gameObject, deathSound.name);
-                }
+                // Not needed here as it's played from the Animator
+                //if (deathSound != null)
+                //{
+                SoundManager.instance.PlaySoundAtPoint(gameObject, deathSound);
+                //}
             }
         }
     }
@@ -101,10 +103,7 @@
             isInvincible = true;
 
             CharacterEvents.characterDamaged.Invoke(gameObject, actualDamageAmount);
-            if (hitSound != null)
-            {
-                SoundManager.instance.PlaySoundAtPoint(gameObject, hitSound.name);
-            }
+            SoundManager.instance.PlaySoundAtPoint(gameObject, hitSound);
         }
     }
 
@@ -119,10 +118,7 @@
             CharacterEvents.characterHealed.Invoke(gameObject, actualHealAmount);
 
             result = true;
-            if (healSound != null)
-            {
-                SoundManager.instance.PlaySoundAtPoint(gameObject, healSound.name);
-            }
+            SoundManager.instance.PlaySoundAtPoint(gameObject, healSound);
 
         }
         return result;

--
Gitblit v1.9.3