Ejemplo n.º 1
0
    public Vector3 ApplyTorsoPose(float torsoTonus, float headTonus, float torsoBend, float lift)
    {
        lift       *= Mathf.Clamp01(timeSinceUnconsious / 3f) * Mathf.Clamp01(timeSinceOffGround * 0.2f + 0.8f);
        torsoTonus *= Mathf.Clamp01(timeSinceUnconsious);
        torsoTonus *= 2f;
        headTonus  *= 2f;
        float num  = human.weight * 0.8f * lift;
        float num2 = human.controls.targetPitchAngle;

        if (human.hasGrabbed)
        {
            num2 = (num2 + 80f) * 0.5f - 80f;
        }
        HumanMotion2.AlignLook(ragdoll.partHead, Quaternion.Euler(num2, human.controls.targetYawAngle, 0f), 2f * headTonus, 10f * headTonus);
        if (human.onGround || human.state == HumanState.Climb)
        {
            torsoBend *= 40f;
            HumanMotion2.AlignLook(ragdoll.partChest, Quaternion.Euler(human.controls.targetPitchAngle + torsoBend, human.controls.targetYawAngle, 0f), 2f * torsoTonus, 10f * torsoTonus);
            HumanMotion2.AlignLook(ragdoll.partWaist, Quaternion.Euler(human.controls.targetPitchAngle + torsoBend / 2f, human.controls.targetYawAngle, 0f), 1f * torsoTonus, 15f * torsoTonus);
            HumanMotion2.AlignLook(ragdoll.partHips, Quaternion.Euler(human.controls.targetPitchAngle, human.controls.targetYawAngle, 0f), 0.5f * torsoTonus, 20f * torsoTonus);
        }
        float num3 = 0f;

        if (human.targetDirection.y > 0f)
        {
            num3 = human.targetDirection.y * 0.25f;
            if (human.onGround && human.ragdoll.partLeftHand.sensor.grabBody != null)
            {
                num3 *= 1.5f;
            }
            if (human.onGround && human.ragdoll.partRightHand.sensor.grabBody != null)
            {
                num3 *= 1.5f;
            }
        }
        else
        {
            num3 = 0f - human.targetDirection.y;
        }
        Vector3 vector  = Mathf.Lerp(0.2f, 0f, num3) * num * headTonus * Vector3.up;
        Vector3 vector2 = Mathf.Lerp(0.6f, 0f, num3) * num * torsoTonus * Vector3.up;
        Vector3 vector3 = Mathf.Lerp(0.2f, 0.5f, num3) * num * torsoTonus * Vector3.up;
        Vector3 vector4 = Mathf.Lerp(0f, 0.5f, num3) * num * torsoTonus * Vector3.up;

        if (human.controls.leftGrab)
        {
            UnblockArmBehindTheBack(ragdoll.partLeftHand, -1f);
        }
        if (human.controls.rightGrab)
        {
            UnblockArmBehindTheBack(ragdoll.partRightHand, 1f);
        }
        ragdoll.partHead.rigidbody.SafeAddForce(vector);
        ragdoll.partChest.rigidbody.SafeAddForce(vector2);
        ragdoll.partWaist.rigidbody.SafeAddForce(vector3);
        ragdoll.partHips.rigidbody.SafeAddForce(vector4);
        StabilizeHorizontal(ragdoll.partHips.rigidbody, ragdoll.partBall.rigidbody, 1f * lift * Mathf.Lerp(1f, 0.25f, Mathf.Abs(num3)));
        StabilizeHorizontal(ragdoll.partHead.rigidbody, ragdoll.partBall.rigidbody, 0.2f * lift * Mathf.Lerp(1f, 0f, Mathf.Abs(num3)));
        return(-(vector + vector2 + vector3 + vector4));
    }