using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Assets.Source.Patterns.ObjectPool;

namespace Assets.Source.Content.Audio
{
    public class AudioObject : MonoBehaviour, IPoolObject
    {
        private AudioSource source;

        public void OnReturnToPool()
        {
            
        }

        public void OnSpawnFromPool()
        {
            
        }

        // Start is called before the first frame update
        void Awake()
        {
            source = GetComponent<AudioSource>();
        }
        
        public void SetAudioInstance(SoundInstance sound)
        {
            source.clip = sound.Clip;
            source.volume = sound.Volume;
            source.pitch = sound.Pitch;
            source.Play();

            this.After(source.clip.length, () => this.Release());
        }
    }
}
