using Darkmatter.Core;
using UnityEngine;
using VContainer;

namespace Darkmatter.Presentation
{
    public class AudioController : MonoBehaviour, IAudioController
    {
        [SerializeField] private AudioSource MusicSource;
        [SerializeField] private AudioSource SFXSource;

        public AudioClip backgroundMusicClip;
        public AudioClip jumpClip;
        public AudioClip deathClip;
        public AudioClip btnPressedClip;
        public AudioClip scoredClip;

        [Inject] private IGameSession IgameSession;

        private void Start()
        {
            MusicSource.clip = backgroundMusicClip;
            MusicSource.loop = true;
            MusicSource.Play();
        }


        public void PlaySfx(AudioClip clip)
        {
            if (!IgameSession.hasGameStarted) return;
            SFXSource.ignoreListenerPause = true;
            SFXSource.PlayOneShot(clip);
        }

        public void PlayJumpSound()
        {
            PlaySfx(jumpClip);
        }

        public void PlayDeathSound()
        {
            PlaySfx(deathClip);
        }

        public void PlayBtnPressedSound()
        {
            PlaySfx(btnPressedClip);
        }

        public void PlayScoredSound()
        {
            PlaySfx(scoredClip);
        }
    }



}
