public bool PlayAnimation(AnimationBaseDefinition definition, UnityAction callback = null, bool forceAnimation = false)
        {
            if (currentState == null)
            {
                return(false);
            }

            if (!forceAnimation && currentAnimation != null && definition.animationLabel == currentAnimation.label)
            {
                LogFormat("ActorAnimatorController: Try to trigger Animation twice '{0}'", definition.animationLabel);
                return(false);
            }

            // --- Search Animation ---
            AnimationObject animationObj = currentState.GetAnimation(definition);

            // --- Play Animation ---
            bool status = false;

            if (animationObj != null && animationObj.clip != null)
            {
                status = PlayAnimation(animationObj, callback, forceAnimation);
            }
            else if (animationObj != null && animationObj.clip == null)
            {
                LogErrorFormat("{0}[{2}] (ActorAnimatorController): AnimationClip is not set '{1}'", name, animationObj.label, currentState.Name);
            }
            else
            {
                LogErrorFormat("{0}[{2}] (ActorAnimatorController): Animation is not found: '{1}'", name, definition.animationLabel, currentState.Name);
            }

            return(status);
        }
        public override bool PlayModularAnimation(string label, ActorAnimatorLayer layer, string subState, UnityAction callback = null)
        {
            AnimationObject         animationObj = null;
            AnimationBaseDefinition definition   = new AnimationBaseDefinition(label);
            ModularBaseState        modularState = null;
            int  layerIndex = -1;
            bool status     = false;

            if (!IsModularStateExisting(layer, subState, out modularState, out layerIndex))
            {
                LogErrorFormat("{0}[{2}] (ActorAnimatorController): ModularLayer not found '{1}'.", name, layer, currentState.Name);
                return(status);
            }

            // Get Animation
            animationObj = modularState.GetAnimation(definition);

            // --- Play Animation ---
            if (animationObj != null && animationObj.clip != null)
            {
                LogFormat("{0} (ActorAnimatorController): Play Modular Animation: '{1}'", name, animationObj.label);

                // Set Animation
                animator.SetBool(modularState.Name, true);
                animator.SetTrigger(animationObj.label); // Play Animation

                // FadeIn LayerWeight
                float layerWeight = animator.GetLayerWeight(layerIndex);

                if (layerWeight < 1f)
                {
                    if (modularState.fadeInDuration > 0f)
                    {
                        StartCoroutine(BlendLayer(layerIndex, animator.GetLayerWeight(layerIndex), 1f, modularState.fadeInDuration));
                    }
                    else
                    {
                        animator.SetLayerWeight(layerIndex, 1f);
                    }
                }

                status = true;

                // Set Callback
                currentModularAnimationCallbacks[0] = callback; // layerIndex - 1
            }
            else
            {
                LogErrorFormat("{0}[{2}] (ActorAnimatorController): ModularAnimationClip is not set '{1}'. Reset weight to '0'.", name, label, currentState.Name);
                animator.SetTrigger(string.Format("{0}_Reset", modularState.Name));
                animator.SetBool(modularState.Name, false);

                // Reset LayerWeight
                animator.SetLayerWeight(layerIndex, 0f);
            }

            return(status);
        }
 public virtual int GetBlendValue(AnimationBaseDefinition definition)
 {
     return(currentState.GetBlendValue(definition));
 }
 public AnimationObject GetAnimation(AnimationBaseDefinition definition)
 {
     return(currentState.GetAnimation(definition));
 }