private void Update() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); curFacing = base.transform.forward; curFacing.y = 0f; curFacing.Normalize(); updateFX(); bool flag = LocomotionUtils.IsIdling(animatorStateInfo); if (isInTorpedoState) { lerpSpin(); if (!LocomotionUtils.IsTurboing(animatorStateInfo)) { isInTorpedoState = false; wsLastSteerDir = wsSteerDir; torpedoBubbles.Stop(); } } else if (LocomotionUtils.IsTurboing(animatorStateInfo)) { isInTorpedoState = true; curSpin = 0f; if (!IsInShallowWater) { torpedoBubbles.Play(); } } if (wsSteerDir != Vector3.zero) { speedMultAnimParam += mutableData.Accel * Time.deltaTime; } else if (flag) { speedMultAnimParam = mutableData.MinSpeedMult; } if (flag) { Momentum = Vector3.Lerp(Momentum, Vector3.zero, mutableData.DragSmoothing * Time.deltaTime); if ((double)Momentum.magnitude < 0.25) { Momentum = Vector3.zero; } } else { Momentum = (base.transform.position - prevPos) / Time.deltaTime; desiredFacing = wsSteerDir; } speedMultAnimParam = Mathf.Clamp(speedMultAnimParam, mutableData.MinSpeedMult, 1f); anim.SetFloat(AnimationHashes.Params.SwimSpeedMult, speedMultAnimParam); anim.SetFloat(AnimationHashes.Params.SwimSpeed, wsSteerDir.magnitude); prevPos = base.transform.position; }
private void OnAnimatorMove() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); if (wsSteerDir != Vector3.zero) { Quaternion identity = Quaternion.identity; if (LocomotionUtils.IsTurboing(animatorStateInfo)) { identity = Quaternion.LookRotation(wsLastSteerDir, wsUpDir); identity = Quaternion.AngleAxis(curSpin, wsLastSteerDir) * identity; } else { identity = Quaternion.LookRotation(wsSteerDir); } Output.wsRotation = Quaternion.Slerp(base.transform.rotation, identity, mutableData.RotationSmoothing * Time.deltaTime); } else if (!IsInShallowWater) { Quaternion identity = Quaternion.LookRotation(-cameraTransform.forward, cameraTransform.up); Output.wsRotation = Quaternion.Slerp(base.transform.rotation, identity, mutableData.RotationSmoothing * Time.deltaTime); } else if (snapToDesiredFacing) { if (Vector3.Angle(curFacing, desiredFacing) < 1f) { snapToDesiredFacing = false; } TurnToDesiredFacing(mutableData.RotationSmoothing); } else { Output.wsRotation = base.transform.rotation; } if (LocomotionUtils.IsIdling(animatorStateInfo)) { Output.wsDeltaPos = Momentum * Time.deltaTime; } else if (LocomotionUtils.IsTurboing(animatorStateInfo)) { Output.wsDeltaPos = anim.deltaPosition; } else { Output.wsDeltaPos = anim.deltaPosition * stickMagnitude; } }