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

#if ! UNITY_EDITOR
#pragma warning disable CS0618 // Type or member is obsolete (for HybridAnimancerComponent in Animancer Lite).
#endif

using Animancer.Samples.StateMachines;
using UnityEngine;

namespace Animancer.Samples.AnimatorControllers
{
    /// <summary>A <see cref="CharacterState"/> which plays an animation.</summary>
    /// 
    /// <remarks>
    /// This class is very similar to <see cref="IdleState"/>,
    /// except that it plays the animation inside an Animator Controller instead of as a Transition.
    /// <para></para>
    /// <strong>Sample:</strong>
    /// <see href="https://kybernetik.com.au/animancer/docs/samples/animator-controllers/character">
    /// Hybrid Character</see>
    /// </remarks>
    /// 
    /// https://kybernetik.com.au/animancer/api/Animancer.Samples.AnimatorControllers/HybridIdleState
    /// 
    [AddComponentMenu(Strings.SamplesMenuPrefix + "Hybrid - Idle State")]
    [AnimancerHelpUrl(typeof(HybridIdleState))]
    public class HybridIdleState : CharacterState
    {
        /************************************************************************************************************************/

        /// <summary>
        /// Normally the <see cref="Character"/> class would have a reference to the specific type of
        /// <see cref="AnimancerComponent"/> we want, but for the sake of reusing code from the earlier sample,
        /// we just use a type cast here.
        /// </summary>
        private HybridAnimancerComponent HybridAnimancer
            => (HybridAnimancerComponent)Character.Animancer;

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

        protected virtual void OnEnable()
        {
            HybridAnimancer.PlayController();
            HybridAnimancer.SetBool(Animations.IsMoving, false);
        }

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