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

using System;
using UnityEngine;

namespace Animancer
{
    /// <inheritdoc/>
    /// https://kybernetik.com.au/animancer/api/Animancer/Float3ControllerTransition
    [Serializable]
#if ! UNITY_EDITOR
    [System.Obsolete(Validate.ProOnlyMessage)]
#endif
    public class Float3ControllerTransition : ControllerTransition<Float3ControllerState>,
        ICopyable<Float3ControllerTransition>
    {
        /************************************************************************************************************************/

        [SerializeField]
        private string _ParameterNameX;

        /// <summary>[<see cref="SerializeField"/>] The name that will be used to access <see cref="ParameterX"/>.</summary>
        public ref string ParameterNameX => ref _ParameterNameX;

        /// <summary>The name of the serialized backing field of <see cref="ParameterNameX"/>.</summary>
        public const string ParameterNameXField = nameof(_ParameterNameX);

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

        [SerializeField]
        private string _ParameterNameY;

        /// <summary>[<see cref="SerializeField"/>] The name that will be used to access <see cref="ParameterY"/>.</summary>
        public ref string ParameterNameY => ref _ParameterNameY;

        /// <summary>The name of the serialized backing field of <see cref="ParameterNameY"/>.</summary>
        public const string ParameterNameYField = nameof(_ParameterNameY);

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

        [SerializeField]
        private string _ParameterNameZ;

        /// <summary>[<see cref="SerializeField"/>] The name that will be used to access <see cref="ParameterZ"/>.</summary>
        public ref string ParameterNameZ => ref _ParameterNameZ;

        /// <summary>The name of the serialized backing field of <see cref="ParameterNameZ"/>.</summary>
        public const string ParameterNameZField = nameof(_ParameterNameZ);

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

        /// <summary>Creates a new <see cref="Float3ControllerTransition"/>.</summary>
        public Float3ControllerTransition() { }

        /// <summary>Creates a new <see cref="Float3ControllerTransition"/> with the specified Animator Controller and parameters.</summary>
        public Float3ControllerTransition(RuntimeAnimatorController controller,
            string parameterNameX, string parameterNameY, string parameterNameZ)
        {
            Controller = controller;
            _ParameterNameX = parameterNameX;
            _ParameterNameY = parameterNameY;
            _ParameterNameZ = parameterNameZ;
        }

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

        /// <inheritdoc/>
        public override Float3ControllerState CreateState()
            => State = new(Controller, _ParameterNameX, _ParameterNameY, _ParameterNameZ, ActionsOnStop)
            {
                SerializedParameterBindings = ParameterBindings
            };

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

        /// <inheritdoc/>
        public override Transition<Float3ControllerState> Clone(CloneContext context)
            => new Float3ControllerTransition();

        /// <inheritdoc/>
        public sealed override void CopyFrom(ControllerTransition<Float3ControllerState> copyFrom, CloneContext context)
            => this.CopyFromBase(copyFrom, context);

        /// <inheritdoc/>
        public virtual void CopyFrom(Float3ControllerTransition copyFrom, CloneContext context)
        {
            base.CopyFrom(copyFrom, context);

            if (copyFrom == null)
            {
                _ParameterNameX = default;
                _ParameterNameY = default;
                _ParameterNameZ = default;
                return;
            }

            _ParameterNameX = copyFrom._ParameterNameX;
            _ParameterNameY = copyFrom._ParameterNameY;
            _ParameterNameZ = copyFrom._ParameterNameZ;
        }

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

