private static void SetAnimatorParameterP3(Animator animator, FsmOutput output, NetworkAnimatorComponent latestValue)
        {
            var index       = latestValue.AnimatorParameterIndex[output.TargetHash];
            var latestParam = latestValue.AnimatorParameters[index];

            _animatorP3Changed = SetAnimatorParameter(animator, output, latestParam) || _animatorP3Changed;
        }
        private static void SetAnimatorParameterP1(Animator animator, FsmOutput output, FpAnimStatusComponent latestValue)
        {
            var index       = latestValue.AnimatorParameterIndex[output.TargetHash];
            var latestParam = latestValue.AnimatorParameters[index];

            var isChange = SetAnimatorParameter(animator, output, latestParam);

            _animatorP1Changed     = isChange || _animatorP1Changed;
            _animatorP1NeedUpdate |= (isChange && output.UpdateImmediate);
        }
        private static bool SetInt(Animator animator, FsmOutput output, NetworkAnimatorParameter latetstParam)
        {
            if (CompareParamHistory(output, latetstParam))
            {
                animator.SetInteger(output.TargetHash, output.IntValue);

                return(true);
            }

            return(false);
        }
 private static void SetCommonOut(PlayerEntity player, FsmOutput output)
 {
     if ((output.View & CharacterView.FirstPerson) != 0)
     {
         SetAnimatorParameterP1(player.firstPersonAnimator.UnityAnimator, output, player.fpAnimStatus);
     }
     if ((output.View & CharacterView.ThirdPerson) != 0)
     {
         SetAnimatorParameterP3(player.thirdPersonAnimator.UnityAnimator, output, player.networkAnimator);
     }
 }
        public void AddOutput(FsmOutput output)
        {
            _fsmOutput[_fsmOutputIndex].CopyFrom(output);
            _fsmOutput[_fsmOutputIndex].Valid = true;

            _fsmOutputIndex++;
            if (_fsmOutputIndex >= _fsmOutput.Count)
            {
                _fsmOutput.Add(new FsmOutput());
            }
        }
        private static bool SetBool(Animator animator, FsmOutput output, NetworkAnimatorParameter latetstParam)
        {
            if (CompareParamHistory(output, latetstParam))
            {
                animator.SetBool(output.TargetHash, output.BoolValue);
                if (output.UpdateImmediate)
                {
                    animator.Update(0);
                }
                return(true);
            }

            return(false);
        }
        private static bool CompareParamHistory(FsmOutput newValue, NetworkAnimatorParameter latestValue)
        {
            bool ret = false;

            switch (newValue.Type)
            {
            case FsmOutputType.Bool:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.BoolValue, latestValue.BoolValue);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to bool:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.BoolValue,newValue.BoolValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Bool,
                                         newValue.BoolValue,
                                         newValue.TargetHash);
                }


                break;

            case FsmOutputType.Float:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.FloatValue, latestValue.FloatValue, 0.001f);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to FloatValue:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.FloatValue,newValue.FloatValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Float,
                                         newValue.FloatValue,
                                         newValue.TargetHash);
                }



                break;

            case FsmOutputType.Int:
                ret = !CompareUtility.IsApproximatelyEqual(newValue.IntValue, latestValue.IntValue);
                if (ret)
                {
                    //Logger.ErrorFormat("change due to IntValue:{0}, from:{1},to:{2}", newValue.TargetHash, latestValue.IntValue,newValue.IntValue);
                    latestValue.SetParam(AnimatorControllerParameterType.Int,
                                         newValue.IntValue,
                                         newValue.TargetHash);
                }



                break;
            }

            return(ret);
        }
        private static void SetAnimatorParameterP3(Animator animator, FsmOutput output, NetworkAnimatorComponent latestValue)
        {
            if (!latestValue.AnimatorParameterIndex.ContainsKey(output.TargetHash))
            {
                Logger.ErrorFormat("animator param is not found:{0}!!!", output.Target);
            }
            var index       = latestValue.AnimatorParameterIndex[output.TargetHash];
            var latestParam = latestValue.AnimatorParameters[index];

            var isChange = SetAnimatorParameter(animator, output, latestParam);

            _animatorP3Changed     = isChange || _animatorP3Changed;
            _animatorP3NeedUpdate |= (isChange && output.UpdateImmediate);
        }
        private static void SetLayerWeightOut(PlayerEntity player, FsmOutput output)
        {
            if ((output.View & CharacterView.FirstPerson) != 0)
            {
                SetLayerWeight(player.firstPersonAnimator.UnityAnimator, output);
                _animatorP1Changed = true;
            }

            if ((output.View & CharacterView.ThirdPerson) != 0)
            {
                SetLayerWeight(player.thirdPersonAnimator.UnityAnimator, output);
                _animatorP3Changed = true;
                //Logger.InfoFormat("change due to SetLayerWeight");
            }
        }
        private static bool SetAnimatorParameter(Animator animator, FsmOutput output, NetworkAnimatorParameter latestValue)
        {
            bool ret = false;

            switch (output.Type)
            {
            case FsmOutputType.Bool:
                ret = SetBool(animator, output, latestValue);
                break;

            case FsmOutputType.Float:
                ret = SetFloat(animator, output, latestValue);
                break;

            case FsmOutputType.Int:
                ret = SetInt(animator, output, latestValue);
                break;
            }

            return(ret);
        }
 private static bool SetLayerWeight(Animator animator, FsmOutput output)
 {
     animator.SetLayerWeight(output.IntValue, output.FloatValue);
     return(true);
 }
 private static void SetLayerWeight(Animator animator, FsmOutput output)
 {
     animator.SetLayerWeight(output.IntValue, output.FloatValue);
 }