private void UpdateSoundEntry(SoundSemaphore soundEntry)
 {
     if (soundEntry.PlaysRemaining < soundEntry.MaxSimultaneousPlays)
     {
         soundEntry.ElapsedTime += Time.unscaledDeltaTime;
         if (soundEntry.ElapsedTime >= soundEntry.CooldownSeconds)
         {
             // Note: there can be a slight drift in cooldown since we're not carrying over the remainder.
             soundEntry.ElapsedTime    = 0f;
             soundEntry.PlaysRemaining = Math.Min(soundEntry.PlaysRemaining + 1, soundEntry.MaxSimultaneousPlays);
         }
     }
     else
     {
         // This will flag the update loop to remove it from the active list
         soundEntry.IsActive = false;
     }
 }
        private void PlaySound(SoundSemaphore soundEntry)
        {
            // Check if we have any plays available
            if (soundEntry.PlaysRemaining > 0)
            {
                soundEntry.PlaysRemaining--;

                if (soundEntry.SingleSound != null)
                {
                    AudioSource.PlayClipAtPoint(soundEntry.SingleSound, this.AudioOriginPoint.position);
                }
                else
                {
                    soundEntry.Sounds.Play();
                }

                if (!soundEntry.IsActive)
                {
                    soundEntry.IsActive = true;
                    mActiveSounds.Add(soundEntry);
                }
            }
        }