private void CalculateVelocity() { Vector3G vector3G = new Vector3G(); double num = (double)Time.time - (double)this.lastVelocityCalc; Character character = base.idMain; Vector3 vector3 = (!character ? base.transform.position : character.origin); Vector3G vector3G1 = new Vector3G(ref vector3); double num1 = 1 / num; vector3G.x = num1 * (vector3G1.x - this.lastPosPrecise.x); vector3G.y = num1 * (vector3G1.y - this.lastPosPrecise.y); vector3G.z = num1 * (vector3G1.z - this.lastPosPrecise.z); Matrix4x4G matrix4x4G = new Matrix4x4G(base.transform.worldToLocalMatrix); Matrix4x4G.Mult3x3(ref vector3G, ref matrix4x4G, out this.localVelocityPrecise); this.lastVelocityCalc = Time.time; this.speedPrecise = Math.Sqrt(this.localVelocityPrecise.x * this.localVelocityPrecise.x + this.localVelocityPrecise.z * this.localVelocityPrecise.z); if (this.speedPrecise >= (double)this.movement.configuration.minMoveSpeed) { double num2 = 1 / this.speedPrecise; this.movementNormalPrecise.x = (double)this.localVelocity.x * num2; this.movementNormalPrecise.y = (double)this.localVelocity.z * num2; double num3 = this.anglePrecise; this.anglePrecise = Math.Atan2(this.movementNormalPrecise.x, this.movementNormalPrecise.y) / 3.14159265358979 * 180; float single = this.movement.configuration.maxTurnSpeed; if (single > 0f && this.anglePrecise != num3 && this.lastAngleSpeedPrecise >= 0.05) { double num4 = (double)Time.deltaTime * (double)single; if (Precise.MoveTowardsAngle(ref num3, ref this.anglePrecise, ref num4, out this.anglePrecise)) { double num5 = this.anglePrecise / 180 * 3.14159265358979; this.movementNormalPrecise.x = Math.Sin(num5); this.movementNormalPrecise.y = Math.Cos(num5); } } this.lastAngleSpeedPrecise = this.speedPrecise; } else { this.speedPrecise = 0; this.movementNormalPrecise.x = 0; this.movementNormalPrecise.y = 0; if (this.lastAngleSpeedPrecise > 0) { float single1 = this.movement.configuration.maxTimeBetweenTurns; float single2 = single1; if (single1 > 0f) { PlayerAnimation playerAnimation = this; playerAnimation.lastAngleSpeedPrecise = playerAnimation.lastAngleSpeedPrecise - (double)(Time.deltaTime / single2); } } } this.lastPosPrecise = vector3G1; this.lastPos = vector3; this.movementNormal = this.movementNormalPrecise.f; this.speed = (float)this.speedPrecise; this.angle = (float)this.anglePrecise; this.localVelocity = this.localVelocityPrecise.f; }
private void GatherInfo(CCMotor motor) { if (motor.isGrounded && !motor.isSliding) { this.groundLocalVelocity = this.localVelocity; this.groundWorldVelocity = this.worldVelocity; this.groundLocalAngularVelocity = this.localAngularVelocity; this.groundLocalVelocityMag = this.localVelocityMag; this.groundWorldVelocityMag = this.worldVelocityMag; this.groundLocalAngularVelocityMag = this.localAngularVelocityMag; } else { this.groundLocalVelocity = new Vector3G(); this.groundWorldVelocity = new Vector3G(); this.groundLocalAngularVelocity = new Vector3G(); this.groundLocalVelocityMag = 0.0; this.groundWorldVelocityMag = 0.0; this.groundLocalAngularVelocityMag = 0.0; } this.inputForce.x = motor.input.moveDirection.x; this.inputForce.y = motor.input.moveDirection.y; this.inputForce.z = motor.input.moveDirection.z; Matrix4x4G.Mult3x3(ref this.inputForce, ref this.worldToLocal, out this.inputForce); this.inputForce.x *= this.cfg.inputForceMultiplier.x; this.inputForce.y *= this.cfg.inputForceMultiplier.y; this.inputForce.z *= this.cfg.inputForceMultiplier.z; }
// Token: 0x06002E36 RID: 11830 RVA: 0x000B0710 File Offset: 0x000AE910 private void GatherInfo(global::CCMotor motor) { if (motor.isGrounded && !motor.isSliding) { this.groundLocalVelocity = this.localVelocity; this.groundWorldVelocity = this.worldVelocity; this.groundLocalAngularVelocity = this.localAngularVelocity; this.groundLocalVelocityMag = this.localVelocityMag; this.groundWorldVelocityMag = this.worldVelocityMag; this.groundLocalAngularVelocityMag = this.localAngularVelocityMag; } else { this.groundLocalVelocity = default(Vector3G); this.groundWorldVelocity = default(Vector3G); this.groundLocalAngularVelocity = default(Vector3G); this.groundLocalVelocityMag = 0.0; this.groundWorldVelocityMag = 0.0; this.groundLocalAngularVelocityMag = 0.0; } this.inputForce.x = (double)motor.input.moveDirection.x; this.inputForce.y = (double)motor.input.moveDirection.y; this.inputForce.z = (double)motor.input.moveDirection.z; Matrix4x4G.Mult3x3(ref this.inputForce, ref this.worldToLocal, ref this.inputForce); this.inputForce.x = this.inputForce.x * (double)this.cfg.inputForceMultiplier.x; this.inputForce.y = this.inputForce.y * (double)this.cfg.inputForceMultiplier.y; this.inputForce.z = this.inputForce.z * (double)this.cfg.inputForceMultiplier.z; }
// Token: 0x06000420 RID: 1056 RVA: 0x00014844 File Offset: 0x00012A44 private void CalculateVelocity() { double num = (double)Time.time - (double)this.lastVelocityCalc; global::Character idMain = base.idMain; Vector3 vector = (!idMain) ? base.transform.position : idMain.origin; Vector3G vector3G; vector3G..ctor(ref vector); double num2 = 1.0 / num; Vector3G vector3G2; vector3G2.x = num2 * (vector3G.x - this.lastPosPrecise.x); vector3G2.y = num2 * (vector3G.y - this.lastPosPrecise.y); vector3G2.z = num2 * (vector3G.z - this.lastPosPrecise.z); Matrix4x4G matrix4x4G; matrix4x4G..ctor(base.transform.worldToLocalMatrix); Matrix4x4G.Mult3x3(ref vector3G2, ref matrix4x4G, ref this.localVelocityPrecise); this.lastVelocityCalc = Time.time; this.speedPrecise = Math.Sqrt(this.localVelocityPrecise.x * this.localVelocityPrecise.x + this.localVelocityPrecise.z * this.localVelocityPrecise.z); if (this.speedPrecise < (double)this.movement.configuration.minMoveSpeed) { this.speedPrecise = 0.0; this.movementNormalPrecise.x = 0.0; this.movementNormalPrecise.y = 0.0; float maxTimeBetweenTurns; if (this.lastAngleSpeedPrecise > 0.0 && (maxTimeBetweenTurns = this.movement.configuration.maxTimeBetweenTurns) > 0f) { this.lastAngleSpeedPrecise -= (double)(Time.deltaTime / maxTimeBetweenTurns); } } else { double num3 = 1.0 / this.speedPrecise; this.movementNormalPrecise.x = (double)this.localVelocity.x * num3; this.movementNormalPrecise.y = (double)this.localVelocity.z * num3; double num4 = this.anglePrecise; this.anglePrecise = Math.Atan2(this.movementNormalPrecise.x, this.movementNormalPrecise.y) / 3.1415926535897931 * 180.0; float maxTurnSpeed = this.movement.configuration.maxTurnSpeed; if (maxTurnSpeed > 0f && this.anglePrecise != num4 && this.lastAngleSpeedPrecise >= 0.05) { double num5 = (double)Time.deltaTime * (double)maxTurnSpeed; if (Precise.MoveTowardsAngle(ref num4, ref this.anglePrecise, ref num5, ref this.anglePrecise)) { double num6 = this.anglePrecise / 180.0 * 3.1415926535897931; this.movementNormalPrecise.x = Math.Sin(num6); this.movementNormalPrecise.y = Math.Cos(num6); } } this.lastAngleSpeedPrecise = this.speedPrecise; } this.lastPosPrecise = vector3G; this.lastPos = vector; this.movementNormal = this.movementNormalPrecise.f; this.speed = (float)this.speedPrecise; this.angle = (float)this.anglePrecise; this.localVelocity = this.localVelocityPrecise.f; }
private void PushPosition() { VectorStamp stamp; VectorStamp stamp2; Vector3 eyesOrigin; Vector3 eulerAngles; Character character; this.worldToLocal.f = this.otherParent.worldToLocalMatrix; this.localToWorld.f = this.otherParent.localToWorldMatrix; stamp.timeStamp = Time.time; stamp.valid = true; if ((this._motor != null) && ((character = this._motor.idMain as Character) != null)) { eulerAngles = character.eyesAngles.eulerAngles; eyesOrigin = character.eyesOrigin; } else { eulerAngles = this.otherParent.eulerAngles; eyesOrigin = this.otherParent.position; } stamp.vector.x = eyesOrigin.x; stamp.vector.y = eyesOrigin.y; stamp.vector.z = eyesOrigin.z; stamp2.vector.x = eulerAngles.x; stamp2.vector.y = eulerAngles.y; stamp2.vector.z = eulerAngles.z; stamp2.timeStamp = Time.time; stamp2.valid = true; if (this.lastPosition.valid && (this.lastPosition.timeStamp != stamp.timeStamp)) { double num = 1.0 / ((double)(stamp.timeStamp - this.lastPosition.timeStamp)); this.worldVelocity.x = (stamp.vector.x - this.lastPosition.vector.x) * num; this.worldVelocity.y = (stamp.vector.y - this.lastPosition.vector.y) * num; this.worldVelocity.z = (stamp.vector.z - this.lastPosition.vector.z) * num; Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, out this.localVelocity); } this.impulseForce.Sample(ref this.localVelocity, stamp.timeStamp); this.lastPosition = stamp; if (this.lastRotation.valid && (this.lastRotation.timeStamp != stamp2.timeStamp)) { double num2 = 1.0 / ((double)(stamp2.timeStamp - this.lastRotation.timeStamp)); Precise.DeltaAngle(ref this.lastRotation.vector.x, ref stamp2.vector.x, out this.localAngularVelocity.x); Precise.DeltaAngle(ref this.lastRotation.vector.y, ref stamp2.vector.y, out this.localAngularVelocity.y); Precise.DeltaAngle(ref this.lastRotation.vector.z, ref stamp2.vector.z, out this.localAngularVelocity.z); this.localAngularVelocity.x *= num2; this.localAngularVelocity.y *= num2; this.localAngularVelocity.z *= num2; } this.impulseTorque.Sample(ref this.localAngularVelocity, stamp2.timeStamp); this.lastRotation = stamp2; this.localVelocityMag = Math.Sqrt(((this.localVelocity.x * this.localVelocity.x) + (this.localVelocity.y * this.localVelocity.y)) + (this.localVelocity.z * this.localVelocity.z)); this.worldVelocityMag = Math.Sqrt(((this.worldVelocity.x * this.worldVelocity.x) + (this.worldVelocity.y * this.worldVelocity.y)) + (this.worldVelocity.z * this.worldVelocity.z)); this.localAngularVelocityMag = Math.Sqrt(((this.localAngularVelocity.x * this.localAngularVelocity.x) + (this.localAngularVelocity.y * this.localAngularVelocity.y)) + (this.localAngularVelocity.z * this.localAngularVelocity.z)); }
// Token: 0x06002E35 RID: 11829 RVA: 0x000B02B8 File Offset: 0x000AE4B8 private void PushPosition() { this.worldToLocal.f = this.otherParent.worldToLocalMatrix; this.localToWorld.f = this.otherParent.localToWorldMatrix; global::HeadBob.VectorStamp vectorStamp; vectorStamp.timeStamp = Time.time; vectorStamp.valid = true; global::Character character; Vector3 eulerAngles; Vector3 vector; if (this._motor && (character = (this._motor.idMain as global::Character))) { eulerAngles = character.eyesAngles.eulerAngles; vector = character.eyesOrigin; } else { eulerAngles = this.otherParent.eulerAngles; vector = this.otherParent.position; } vectorStamp.vector.x = (double)vector.x; vectorStamp.vector.y = (double)vector.y; vectorStamp.vector.z = (double)vector.z; global::HeadBob.VectorStamp vectorStamp2; vectorStamp2.vector.x = (double)eulerAngles.x; vectorStamp2.vector.y = (double)eulerAngles.y; vectorStamp2.vector.z = (double)eulerAngles.z; vectorStamp2.timeStamp = Time.time; vectorStamp2.valid = true; if (this.lastPosition.valid && this.lastPosition.timeStamp != vectorStamp.timeStamp) { double num = 1.0 / (double)(vectorStamp.timeStamp - this.lastPosition.timeStamp); this.worldVelocity.x = (vectorStamp.vector.x - this.lastPosition.vector.x) * num; this.worldVelocity.y = (vectorStamp.vector.y - this.lastPosition.vector.y) * num; this.worldVelocity.z = (vectorStamp.vector.z - this.lastPosition.vector.z) * num; Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, ref this.localVelocity); } this.impulseForce.Sample(ref this.localVelocity, vectorStamp.timeStamp); this.lastPosition = vectorStamp; if (this.lastRotation.valid && this.lastRotation.timeStamp != vectorStamp2.timeStamp) { double num2 = 1.0 / (double)(vectorStamp2.timeStamp - this.lastRotation.timeStamp); Precise.DeltaAngle(ref this.lastRotation.vector.x, ref vectorStamp2.vector.x, ref this.localAngularVelocity.x); Precise.DeltaAngle(ref this.lastRotation.vector.y, ref vectorStamp2.vector.y, ref this.localAngularVelocity.y); Precise.DeltaAngle(ref this.lastRotation.vector.z, ref vectorStamp2.vector.z, ref this.localAngularVelocity.z); this.localAngularVelocity.x = this.localAngularVelocity.x * num2; this.localAngularVelocity.y = this.localAngularVelocity.y * num2; this.localAngularVelocity.z = this.localAngularVelocity.z * num2; } this.impulseTorque.Sample(ref this.localAngularVelocity, vectorStamp2.timeStamp); this.lastRotation = vectorStamp2; this.localVelocityMag = Math.Sqrt(this.localVelocity.x * this.localVelocity.x + this.localVelocity.y * this.localVelocity.y + this.localVelocity.z * this.localVelocity.z); this.worldVelocityMag = Math.Sqrt(this.worldVelocity.x * this.worldVelocity.x + this.worldVelocity.y * this.worldVelocity.y + this.worldVelocity.z * this.worldVelocity.z); this.localAngularVelocityMag = Math.Sqrt(this.localAngularVelocity.x * this.localAngularVelocity.x + this.localAngularVelocity.y * this.localAngularVelocity.y + this.localAngularVelocity.z * this.localAngularVelocity.z); }
private void CalculateVelocity() { Vector3G vectorg2; double num = Time.time - this.lastVelocityCalc; Character idMain = base.idMain; Vector3 v = (idMain == null) ? base.transform.position : idMain.origin; Vector3G vectorg = new Vector3G(ref v); double num2 = 1.0 / num; vectorg2.x = num2 * (vectorg.x - this.lastPosPrecise.x); vectorg2.y = num2 * (vectorg.y - this.lastPosPrecise.y); vectorg2.z = num2 * (vectorg.z - this.lastPosPrecise.z); Matrix4x4G b = new Matrix4x4G(base.transform.worldToLocalMatrix); Matrix4x4G.Mult3x3(ref vectorg2, ref b, out this.localVelocityPrecise); this.lastVelocityCalc = Time.time; this.speedPrecise = Math.Sqrt((this.localVelocityPrecise.x * this.localVelocityPrecise.x) + (this.localVelocityPrecise.z * this.localVelocityPrecise.z)); if (this.speedPrecise < this.movement.configuration.minMoveSpeed) { float num3; this.speedPrecise = 0.0; this.movementNormalPrecise.x = 0.0; this.movementNormalPrecise.y = 0.0; if ((this.lastAngleSpeedPrecise > 0.0) && ((num3 = this.movement.configuration.maxTimeBetweenTurns) > 0f)) { this.lastAngleSpeedPrecise -= Time.deltaTime / num3; } } else { double num4 = 1.0 / this.speedPrecise; this.movementNormalPrecise.x = this.localVelocity.x * num4; this.movementNormalPrecise.y = this.localVelocity.z * num4; double anglePrecise = this.anglePrecise; this.anglePrecise = (Math.Atan2(this.movementNormalPrecise.x, this.movementNormalPrecise.y) / 3.1415926535897931) * 180.0; float maxTurnSpeed = this.movement.configuration.maxTurnSpeed; if (((maxTurnSpeed > 0f) && (this.anglePrecise != anglePrecise)) && (this.lastAngleSpeedPrecise >= 0.05)) { double maxDelta = Time.deltaTime * maxTurnSpeed; if (Precise.MoveTowardsAngle(ref anglePrecise, ref this.anglePrecise, ref maxDelta, out this.anglePrecise)) { double a = (this.anglePrecise / 180.0) * 3.1415926535897931; this.movementNormalPrecise.x = Math.Sin(a); this.movementNormalPrecise.y = Math.Cos(a); } } this.lastAngleSpeedPrecise = this.speedPrecise; } this.lastPosPrecise = vectorg; this.lastPos = v; this.movementNormal = this.movementNormalPrecise.f; this.speed = (float)this.speedPrecise; this.angle = (float)this.anglePrecise; this.localVelocity = this.localVelocityPrecise.f; }
private void PushPosition() { HeadBob.VectorStamp vectorStamp = new HeadBob.VectorStamp(); HeadBob.VectorStamp vectorStamp1 = new HeadBob.VectorStamp(); Vector3 vector3; Vector3 vector31; this.worldToLocal.f = this.otherParent.worldToLocalMatrix; this.localToWorld.f = this.otherParent.localToWorldMatrix; vectorStamp.timeStamp = Time.time; vectorStamp.valid = true; if (this._motor) { Character character = this._motor.idMain as Character; Character character1 = character; if (!character) { goto Label1; } vector31 = character1.eyesAngles.eulerAngles; vector3 = character1.eyesOrigin; goto Label0; } Label1: vector31 = this.otherParent.eulerAngles; vector3 = this.otherParent.position; Label0: vectorStamp.vector.x = (double)vector3.x; vectorStamp.vector.y = (double)vector3.y; vectorStamp.vector.z = (double)vector3.z; vectorStamp1.vector.x = (double)vector31.x; vectorStamp1.vector.y = (double)vector31.y; vectorStamp1.vector.z = (double)vector31.z; vectorStamp1.timeStamp = Time.time; vectorStamp1.valid = true; if (this.lastPosition.valid && this.lastPosition.timeStamp != vectorStamp.timeStamp) { double num = 1 / (double)(vectorStamp.timeStamp - this.lastPosition.timeStamp); this.worldVelocity.x = (vectorStamp.vector.x - this.lastPosition.vector.x) * num; this.worldVelocity.y = (vectorStamp.vector.y - this.lastPosition.vector.y) * num; this.worldVelocity.z = (vectorStamp.vector.z - this.lastPosition.vector.z) * num; Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, out this.localVelocity); } this.impulseForce.Sample(ref this.localVelocity, vectorStamp.timeStamp); this.lastPosition = vectorStamp; if (this.lastRotation.valid && this.lastRotation.timeStamp != vectorStamp1.timeStamp) { double num1 = 1 / (double)(vectorStamp1.timeStamp - this.lastRotation.timeStamp); Precise.DeltaAngle(ref this.lastRotation.vector.x, ref vectorStamp1.vector.x, out this.localAngularVelocity.x); Precise.DeltaAngle(ref this.lastRotation.vector.y, ref vectorStamp1.vector.y, out this.localAngularVelocity.y); Precise.DeltaAngle(ref this.lastRotation.vector.z, ref vectorStamp1.vector.z, out this.localAngularVelocity.z); this.localAngularVelocity.x = this.localAngularVelocity.x * num1; this.localAngularVelocity.y = this.localAngularVelocity.y * num1; this.localAngularVelocity.z = this.localAngularVelocity.z * num1; } this.impulseTorque.Sample(ref this.localAngularVelocity, vectorStamp1.timeStamp); this.lastRotation = vectorStamp1; this.localVelocityMag = Math.Sqrt(this.localVelocity.x * this.localVelocity.x + this.localVelocity.y * this.localVelocity.y + this.localVelocity.z * this.localVelocity.z); this.worldVelocityMag = Math.Sqrt(this.worldVelocity.x * this.worldVelocity.x + this.worldVelocity.y * this.worldVelocity.y + this.worldVelocity.z * this.worldVelocity.z); this.localAngularVelocityMag = Math.Sqrt(this.localAngularVelocity.x * this.localAngularVelocity.x + this.localAngularVelocity.y * this.localAngularVelocity.y + this.localAngularVelocity.z * this.localAngularVelocity.z); }