using System.Collections.Generic;
using UnityEngine;

namespace ftt.Core.Sounds
{
    public enum GameAudioClip
    {
        MaskTurning,
        DoorOpening,
    }

    public class SoundsHandler : MonoBehaviour
    {
        [Header("Set in inspector")]
        [SerializeField] List<AudioClip> sfxClips;

        public AudioSource mainAudioSource;
        public AudioSource sfxSource;

        private void Start()
        {
            mainAudioSource.Play();
        }

        public void SetVolume(float value)
        {
            mainAudioSource.volume = value;
            sfxSource.volume = value;
        }

        ///<summary>Plays the passed clip one time</summary>
        public void PlayOneShot(GameAudioClip clip)
        {
            sfxSource.PlayOneShot(sfxClips[(int)clip]);
        }

        ///<summary>Mutes/unmutes the sound</summary>
        public void SetGameWideSoundtrackState(bool pause)
        {
            if (pause)
            {
                mainAudioSource.Pause();
            }
            else
            {
                mainAudioSource.UnPause();
            }
        }
    }
}