private void StandAnimation(Vector3 torsoFeedback, float tonus) { HumanMotion2.AlignToVector(ragdoll.partLeftThigh, -ragdoll.partLeftThigh.transform.up, Vector3.up, 10f * tonus); HumanMotion2.AlignToVector(ragdoll.partRightThigh, -ragdoll.partRightThigh.transform.up, Vector3.up, 10f * tonus); HumanMotion2.AlignToVector(ragdoll.partLeftLeg, -ragdoll.partLeftLeg.transform.up, Vector3.up, 10f * tonus); HumanMotion2.AlignToVector(ragdoll.partRightLeg, -ragdoll.partRightLeg.transform.up, Vector3.up, 10f * tonus); ragdoll.partBall.rigidbody.SafeAddForce(torsoFeedback * 0.2f); ragdoll.partLeftFoot.rigidbody.SafeAddForce(torsoFeedback * 0.4f); ragdoll.partRightFoot.rigidbody.SafeAddForce(torsoFeedback * 0.4f); ragdoll.partBall.rigidbody.angularVelocity = Vector3.zero; }
public void Align(Rigidbody body, Vector3 pos, Vector3 dir) { float num = 1f - (pos - base.transform.position).magnitude / radius; if (!(num < 0f)) { num = Mathf.Pow(num, power); body.AddForceAtPosition(((base.transform.position - pos).normalized * springSnap - body.GetPointVelocity(pos) * body.mass * 1f) * num, pos); HumanMotion2.AlignToVector(body, dir, base.transform.forward, springAlign); } }
private Vector3 AnimateLeg(HumanSegment thigh, HumanSegment leg, HumanSegment foot, float phase, Vector3 torsoFeedback, float tonus) { tonus *= 20f; phase -= Mathf.Floor(phase); if (phase < 0.2f) { HumanMotion2.AlignToVector(thigh, thigh.transform.up, human.controls.walkDirection + Vector3.down, 3f * tonus); HumanMotion2.AlignToVector(leg, thigh.transform.up, -human.controls.walkDirection - Vector3.up, tonus); Vector3 vector = Vector3.up * 20f; foot.rigidbody.SafeAddForce(vector); return(-vector); } if (phase < 0.5f) { HumanMotion2.AlignToVector(thigh, thigh.transform.up, human.controls.walkDirection, 2f * tonus); HumanMotion2.AlignToVector(leg, thigh.transform.up, human.controls.walkDirection, 3f * tonus); } else { if (phase < 0.7f) { Vector3 vector2 = torsoFeedback * 0.2f; foot.rigidbody.SafeAddForce(vector2); HumanMotion2.AlignToVector(thigh, thigh.transform.up, human.controls.walkDirection + Vector3.down, tonus); HumanMotion2.AlignToVector(leg, thigh.transform.up, Vector3.down, tonus); return(-vector2); } if (phase < 0.9f) { Vector3 vector3 = torsoFeedback * 0.2f; foot.rigidbody.SafeAddForce(vector3); HumanMotion2.AlignToVector(thigh, thigh.transform.up, -human.controls.walkDirection + Vector3.down, tonus); HumanMotion2.AlignToVector(leg, thigh.transform.up, -human.controls.walkDirection + Vector3.down, tonus); return(-vector3); } HumanMotion2.AlignToVector(thigh, thigh.transform.up, -human.controls.walkDirection + Vector3.down, tonus); HumanMotion2.AlignToVector(leg, thigh.transform.up, -human.controls.walkDirection, tonus); } return(Vector3.zero); }
private void AnimateHand(HumanSegment arm, HumanSegment forearm, HumanSegment hand, float phase, float tonus, bool right) { tonus *= 50f * human.controls.walkSpeed; phase -= Mathf.Floor(phase); Vector3 a = Quaternion.Euler(0f, human.controls.targetYawAngle, 0f) * Vector3.forward; Vector3 vector = Quaternion.Euler(0f, human.controls.targetYawAngle, 0f) * Vector3.right; if (!right) { vector = -vector; } if (phase < 0.5f) { HumanMotion2.AlignToVector(arm, arm.transform.up, Vector3.down + vector / 2f, 3f * tonus); HumanMotion2.AlignToVector(forearm, forearm.transform.up, a / 2f - vector, 3f * tonus); } else { HumanMotion2.AlignToVector(arm, arm.transform.up, -a + vector / 2f, 3f * tonus); HumanMotion2.AlignToVector(forearm, forearm.transform.up, a + Vector3.down, 3f * tonus); } }
private void LiftBody(HumanSegment hand, Rigidbody body) { if (human.GetComponent <GroundManager>().IsStanding(body.gameObject) || body.tag == "NoLift") { return; } float num = 0.5f + 0.5f * Mathf.InverseLerp(0f, 100f, body.mass); Vector3 vector = (human.targetLiftDirection.ZeroY() * maxPushForce).SetY(Mathf.Max(0f, human.targetLiftDirection.y) * maxLiftForce); float magnitude = (hand.transform.position - body.worldCenterOfMass).magnitude; float num2 = num; float num3 = 1f; float d = 1f; Carryable component = body.GetComponent <Carryable>(); if (component != null) { num2 *= component.liftForceMultiplier; num3 = component.forceHalfDistance; d = component.damping; if (num3 <= 0f) { throw new InvalidOperationException("halfdistance cant be 0 or less!"); } } float num4 = num3 / (num3 + magnitude); vector *= num2; vector *= num4; body.SafeAddForce(vector); hand.rigidbody.SafeAddForce(-vector * 0.5f); ragdoll.partChest.rigidbody.SafeAddForce(-vector * 0.5f); body.SafeAddTorque(-body.angularVelocity * liftDamp * d, ForceMode.Acceleration); body.SafeAddTorque(-body.angularVelocity.normalized * body.angularVelocity.sqrMagnitude * liftDampSqr * d, ForceMode.Acceleration); if (!(component != null) || component.aiming == CarryableAiming.None) { return; } Vector3 vector2 = human.targetLiftDirection; if (component.limitAlignToHorizontal) { vector2.y = 0f; vector2.Normalize(); } Vector3 vector3 = (component.aiming != CarryableAiming.ForwardAxis) ? (body.worldCenterOfMass - hand.transform.position).normalized : body.transform.forward; float aimSpring = component.aimSpring; float num5 = (!(component.aimTorque < float.PositiveInfinity)) ? aimSpring : component.aimTorque; if (!component.alwaysForward) { float num6 = Vector3.Dot(vector3, vector2); if (num6 < 0f) { vector2 = -vector2; num6 = 0f - num6; } num5 *= Mathf.Pow(num6, component.aimAnglePower); } else { float num7 = Vector3.Dot(vector3, vector2); num7 = 0.5f + num7 / 2f; num5 *= Mathf.Pow(num7, component.aimAnglePower); } if (component.aimDistPower != 0f) { num5 *= Mathf.Pow((body.worldCenterOfMass - hand.transform.position).magnitude, component.aimDistPower); } HumanMotion2.AlignToVector(body, vector3, vector2, aimSpring, num5); }
private void ProcessHand(ScanMem mem, HumanSegment arm, HumanSegment forearm, HumanSegment hand, Vector3 worldPos, float extend, bool grab, float animationPhase, bool right) { double num = 0.1 + (double)(0.14f * Mathf.Abs(human.controls.targetPitchAngle - mem.grabAngle) / 80f); double num2 = num * 2.0; if (CheatCodes.climbCheat) { num2 = (num /= 4.0); } if (grab && !hand.sensor.grab) { if ((double)mem.grabTime > num) { mem.pos = arm.transform.position; } else { grab = false; } } if (hand.sensor.grab && !grab) { mem.grabTime = 0f; mem.grabAngle = human.controls.targetPitchAngle; } else { mem.grabTime += Time.fixedDeltaTime; } hand.sensor.grab = ((double)mem.grabTime > num2 && grab); if (extend > 0.2f) { bool flag = false; hand.sensor.targetPosition = worldPos; Vector3 vector = worldPos; mem.shoulder = arm.transform.position; mem.hand = hand.transform.position; if (hand.sensor.grabJoint == null) { worldPos = FindTarget(mem, worldPos, out hand.sensor.grabFilter); } PlaceHand(arm, hand, worldPos, active: true, hand.sensor.grabJoint != null, hand.sensor.grabBody); if (hand.sensor.grabBody != null) { LiftBody(hand, hand.sensor.grabBody); } hand.sensor.grabPosition = worldPos; } else { hand.sensor.grabFilter = null; if (human.state == HumanState.Walk) { AnimateHand(arm, forearm, hand, animationPhase, 1f, right); } else if (human.state == HumanState.FreeFall) { Vector3 targetDirection = human.targetDirection; targetDirection.y = 0f; HumanMotion2.AlignToVector(arm, arm.transform.up, -targetDirection, 2f); HumanMotion2.AlignToVector(forearm, forearm.transform.up, targetDirection, 2f); } else { Vector3 targetDirection2 = human.targetDirection; targetDirection2.y = 0f; HumanMotion2.AlignToVector(arm, arm.transform.up, -targetDirection2, 20f); HumanMotion2.AlignToVector(forearm, forearm.transform.up, targetDirection2, 20f); } } }
private void ProcessHand(HandMuscles.ScanMem mem, HumanSegment arm, HumanSegment forearm, HumanSegment hand, Vector3 worldPos, float extend, bool grab, float animationPhase, bool right) { double num = 0.1 + (double)(0.14f * Mathf.Abs(this.human.controls.targetPitchAngle - mem.grabAngle) / 80f); double num2 = num * 2.0; if (CheatCodes.climbCheat) { num = (num2 = num / 4.0); } if (grab && !hand.sensor.grab) { if ((double)mem.grabTime > num) { mem.pos = arm.transform.position; } else { grab = false; } } if (hand.sensor.grab && !grab) { mem.grabTime = 0f; mem.grabAngle = this.human.controls.targetPitchAngle; } else { mem.grabTime += Time.fixedDeltaTime; } hand.sensor.grab = ((double)mem.grabTime > num2 && grab); if (this.human.mod_vo.isBoxing && extend < 0.2f) { hand.sensor.targetPosition = worldPos; mem.shoulder = arm.transform.position; mem.hand = hand.transform.position; this.maxPushForce *= 3f; if (hand.sensor.grabJoint == null) { worldPos = this.FindTarget(mem, worldPos, out hand.sensor.grabFilter); } this.PlaceHand(arm, hand, worldPos, true, hand.sensor.grabJoint != null, hand.sensor.grabBody); if (hand.sensor.grabBody != null) { this.LiftBody(hand, hand.sensor.grabBody); } hand.sensor.grabPosition = worldPos; return; } if (extend > 0.2f) { hand.sensor.targetPosition = worldPos; mem.shoulder = arm.transform.position; mem.hand = hand.transform.position; if (hand.sensor.grabJoint == null) { worldPos = this.FindTarget(mem, worldPos, out hand.sensor.grabFilter); } this.PlaceHand(arm, hand, worldPos, true, hand.sensor.grabJoint != null, hand.sensor.grabBody); if (hand.sensor.grabBody != null) { this.LiftBody(hand, hand.sensor.grabBody); } hand.sensor.grabPosition = worldPos; return; } hand.sensor.grabFilter = null; if (this.human.state == HumanState.Walk) { this.AnimateHand(arm, forearm, hand, animationPhase, 1f, right); return; } if (this.human.state == HumanState.FreeFall) { Vector3 targetDirection = this.human.targetDirection; targetDirection.y = 0f; HumanMotion2.AlignToVector(arm, arm.transform.up, -targetDirection, 2f); HumanMotion2.AlignToVector(forearm, forearm.transform.up, targetDirection, 2f); return; } if (this.human.mod_vo.isBoxing) { return; } Vector3 targetDirection2 = this.human.targetDirection; targetDirection2.y = 0f; HumanMotion2.AlignToVector(arm, arm.transform.up, -targetDirection2, 20f); HumanMotion2.AlignToVector(forearm, forearm.transform.up, targetDirection2, 20f); }