using JohnsonUtils.Attributes;
using UnityEngine;

namespace JohnsonUtils.Audio
{
    [CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
    public class SimpleAudioEvent : AudioEvent
    {
        public AudioClip[] Clips;
        public RangedFloat Volume = new (0.9f,1f);

        [MinMaxRange(0, 2)] public RangedFloat Pitch = new (0.95f,1.05f);

        public override void Play(AudioSource source)
        {
            if (Clips.Length == 0) return;

            source.clip = Clips[Random.Range(0, Clips.Length)];
            source.volume = Random.Range(Volume.MinValue, Volume.MaxValue);
            source.pitch = Random.Range(Pitch.MinValue, Pitch.MaxValue);
            source.Play();
        }
    }
}