示例#1
0
        private bool canSitFromCurrentState()
        {
            AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator);

            return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || LocomotionUtils.IsSwimming(animatorStateInfo));
        }
示例#2
0
 private void LateUpdate()
 {
     if (!Active)
     {
         return;
     }
     if (curState == State.Resurfacing || curState == State.QuickResurfacing)
     {
         base.transform.position += animator.deltaPosition;
         base.transform.rotation  = getSmoothFaceCameraRotation();
     }
     else
     {
         if (curState == State.Interacting)
         {
             return;
         }
         if (curState != State.ExitingWater && !LocomotionUtils.IsSwimming(LocomotionUtils.GetAnimatorStateInfo(animator)))
         {
             animator.SetTrigger(AnimationHashes.Params.Swim);
         }
         LocomotionPrimitive.PrimitiveOutput output = swim.GetOutput();
         Vector3    vector   = output.wsDeltaPos;
         Quaternion rotation = output.wsRotation;
         if (isInShallowWater)
         {
             vector *= mutableData.ShallowWaterSwimSpeedMultiplier;
         }
         if (curState == State.ExitingWater)
         {
             rotation = Quaternion.LookRotation(new Vector3(base.transform.forward.x, 0f, base.transform.forward.z), Vector3.up);
             rotation = Quaternion.Slerp(base.transform.rotation, rotation, 5f * Time.deltaTime);
             vector   = animator.deltaPosition;
         }
         else
         {
             if (curState == State.ReactingToHit)
             {
                 rotation = getSmoothFaceCameraRotation();
             }
             vector += impulses.GetOutput().wsVelocity *Time.deltaTime;
             if (!isInShallowWater && mutableData.FreezeAxis != SwimControllerData.FreezeAxisType.None)
             {
                 vector[(int)mutableData.FreezeAxis] = mutableData.FreezeDist;
             }
         }
         Vector3 position = base.transform.position;
         base.transform.rotation = rotation;
         if (vector != Vector3.zero)
         {
             characterController.Move(vector);
         }
         if (curState != 0)
         {
             return;
         }
         Vector3 position2;
         if (isInShallowWater)
         {
             position2               = base.transform.position;
             position2.y             = logicalSurfaceHeight;
             base.transform.position = position2;
         }
         else
         {
             if (mutableData.FreezeAxis != SwimControllerData.FreezeAxisType.None && !isCloseToSurface())
             {
                 position2 = base.transform.position;
                 position2[(int)mutableData.FreezeAxis] = Mathf.Lerp(position2[(int)mutableData.FreezeAxis], mutableData.FreezeDist, 5f * Time.deltaTime);
                 if (Mathf.Abs(position2[(int)mutableData.FreezeAxis] - mutableData.FreezeDist) < 0.01f)
                 {
                     position2[(int)mutableData.FreezeAxis] = mutableData.FreezeDist;
                 }
                 base.transform.position = position2;
             }
             if (base.transform.position.y >= logicalSurfaceHeight && curState != State.PostResurfacing)
             {
                 position2               = base.transform.position;
                 position2.y             = logicalSurfaceHeight;
                 base.transform.position = position2;
                 if (LocomotionUtils.IsTurboing(animator.GetCurrentAnimatorStateInfo(0)))
                 {
                     animator.SetTrigger(AnimationHashes.Params.AbortTorpedo);
                 }
             }
         }
         applyIK();
     }
 }