// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //

#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.

using UnityEngine;

namespace Animancer.Samples.Events
{
    /// <summary>
    /// A variation of the base <see cref="FootstepEvents"/> which responds to Animation Events called "Footstep" by
    /// playing a sound randomly selected from an array, using the Int Parameter of the event as the index to determine
    /// which foot to play the sound on. 0 is the Left Foot and 1 is the Right Foot.
    /// </summary>
    /// 
    /// <remarks>
    /// <strong>Sample:</strong>
    /// <see href="https://kybernetik.com.au/animancer/docs/samples/events/footsteps">
    /// Footstep Events</see>
    /// </remarks>
    /// 
    /// https://kybernetik.com.au/animancer/api/Animancer.Samples.Events/FootstepEventsAnimation
    /// 
    [AddComponentMenu(Strings.SamplesMenuPrefix + "Footstep Events - Footstep Events Animation")]
    [AnimancerHelpUrl(typeof(FootstepEventsAnimation))]
    public class FootstepEventsAnimation : MonoBehaviour
    {
        /************************************************************************************************************************/

        [SerializeField] private FootstepEvents _FootstepEvents;
        [SerializeField] private AudioSource[] _FootSources;

        /************************************************************************************************************************/

        // Called by Animation Events.
        private void Footstep(int foot)
        {
            _FootstepEvents.PlaySound(_FootSources[foot]);
        }

        /************************************************************************************************************************/
    }
}
