public void SwitchMoveState(BaseRidableAnimal.RunState newState)
 {
     if (newState == this.currentRunState)
     {
         return;
     }
     this.currentRunState = newState;
     this.timeInMoveState = 0f;
     base.SetFlag(BaseEntity.Flags.Reserved8, this.currentRunState == BaseRidableAnimal.RunState.sprint, false, false);
 }
 public override void Load(BaseNetworkable.LoadInfo info)
 {
     base.Load(info);
     if (info.msg.ioEntity != null)
     {
         this.staminaSeconds           = info.msg.ioEntity.genericFloat1;
         this.currentMaxStaminaSeconds = info.msg.ioEntity.genericFloat2;
         if (!info.fromDisk)
         {
             this.currentRunState = (BaseRidableAnimal.RunState)info.msg.ioEntity.genericInt1;
         }
     }
 }
    public void UpdateMovement()
    {
        RaycastHit raycastHit;
        Vector3    vector3;
        Vector3    vector31;
        float      single = this.WaterFactor();

        if (single > 1f && !base.IsDestroyed)
        {
            base.Kill(BaseNetworkable.DestroyMode.None);
            return;
        }
        if (single >= 0.3f && this.currentRunState > BaseRidableAnimal.RunState.run)
        {
            this.currentRunState = BaseRidableAnimal.RunState.run;
        }
        else if (single >= 0.45f && this.currentRunState > BaseRidableAnimal.RunState.walk)
        {
            this.currentRunState = BaseRidableAnimal.RunState.walk;
        }
        if (Time.time - this.lastInputTime > 3f)
        {
            this.currentRunState = BaseRidableAnimal.RunState.stopped;
            this.desiredRotation = 0f;
        }
        float   desiredVelocity = this.GetDesiredVelocity();
        Vector3 vector32        = Vector3.forward * Mathf.Sign(desiredVelocity);

        base.transform.hasChanged = true;
        float single1 = Mathf.InverseLerp(1f, 12f, this.GetObstacleDistance());
        float single2 = Mathf.Min(Mathf.Clamp01(Mathf.Min(1f - Mathf.InverseLerp(20f, 35f, Vector3.Angle(Vector3.up, this.averagedUp)) + 0.2f, single1)) * this.GetRunSpeed(), desiredVelocity);
        float single3 = (single2 < this.currentSpeed ? 3f : 1f);

        this.currentSpeed = Mathf.Lerp(this.currentSpeed, single2, Time.deltaTime * single3);
        if (Mathf.Abs(this.currentSpeed) < 2f && desiredVelocity == 0f)
        {
            this.currentSpeed = Mathf.MoveTowards(this.currentSpeed, 0f, Time.deltaTime * 2f);
        }
        if (single1 == 0f)
        {
            this.currentSpeed = 0f;
        }
        float single4 = 1f - Mathf.InverseLerp(2f, 7f, this.currentSpeed);

        single4 = (single4 + 1f) / 2f;
        base.transform.Rotate(Vector3.up, this.desiredRotation * Time.fixedDeltaTime * this.turnSpeed * single4);
        Vector3 vector33 = base.transform.TransformDirection(vector32);
        Vector3 vector34 = vector33.normalized;
        float   single5  = this.currentSpeed * Time.fixedDeltaTime;
        Vector3 vector35 = base.transform.position + ((vector33 * single5) * Mathf.Sign(this.currentSpeed));

        this.currentVelocity = vector33 * this.currentSpeed;
        this.UpdateGroundNormal();
        if (this.currentSpeed > 0f || this.timeAlive < 2f)
        {
            if (!Physics.SphereCast(this.animalFront.transform.position, this.obstacleDetectionRadius, vector34, out raycastHit, single5, 1503731969))
            {
                if (!TransformUtil.GetGroundInfo(vector35 + (Vector3.up * 1.25f), out vector3, out vector31, 3f, 278986753, null))
                {
                    this.currentSpeed = 0f;
                    return;
                }
                this.MarkDistanceTravelled(single5);
                base.transform.position = vector3;
                Quaternion quaternion = QuaternionEx.LookRotationForcedUp(base.transform.forward, this.averagedUp);
                Vector3    vector36   = quaternion.eulerAngles;
                if (vector36.z > 180f)
                {
                    vector36.z -= 360f;
                }
                else if (vector36.z < -180f)
                {
                    vector36.z += 360f;
                }
                vector36.z = Mathf.Clamp(vector36.z, -10f, 10f);
                base.transform.rotation = Quaternion.Euler(vector36);
                return;
            }
            this.currentSpeed = 0f;
        }
    }