public class EntityVHelicopterRebirth : EntityVehicleRebirth { public override void Init(int _entityClass) { //Log.Out("EntityVHelicopterRebirth-Init START"); base.Init(_entityClass); Transform meshTransform = this.vehicle.GetMeshTransform(); this.topPropT = meshTransform.Find("Origin/TopPropellerJoint"); this.rearPropT = meshTransform.Find("Origin/BackPropellerJoint"); } public override void PhysicsInputMove() { //Log.Out("EntityVHelicopterRebirth-PhysicsInputMove START"); if (this.vehicle.GetFuelPercent() == 0f) { //Log.Out("EntityVHelicopterRebirth-PhysicsInputMove 1"); return; } if (this.vehicle.FindPart("engine").IsBroken()) { //Log.Out("EntityVHelicopterRebirth-PhysicsInputMove 2"); return; } float deltaTime = Time.deltaTime; this.vehicleRB.velocity *= 0.995f; this.vehicleRB.velocity += new Vector3(0f, -0.002f, 0f); this.vehicleRB.angularVelocity *= 0.97f; if (this.movementInput != null) { //Log.Out("EntityVHelicopterRebirth-PhysicsInputMove 3"); this.vehicleRB.AddForce(0f, Mathf.Lerp(0.1f, 1.005f, this.topRPM / 3f) * -Physics.gravity.y * deltaTime, 0f, (ForceMode)2); float num = 1f; if (this.movementInput.running) { num *= 6f; } this.wheelMotor = this.movementInput.moveForward; this.vehicleRB.AddRelativeForce(0f, 0f, this.wheelMotor * num * 0.1f, (ForceMode)2); float num2; if (this.movementInput.lastInputController) { num2 = this.movementInput.moveStrafe * num; } else { num2 = this.movementInput.moveStrafe * num; } this.vehicleRB.AddRelativeTorque(0f, num2 * 0.03f, 0f, (ForceMode)2); if (this.movementInput.jump) { this.vehicleRB.AddRelativeForce(0f, 0.03f * num, 0f, (ForceMode)2); this.vehicleRB.AddRelativeTorque(-0.01f, 0f, 0f, (ForceMode)2); } if (this.movementInput.down) { this.vehicleRB.AddRelativeForce(0f, -0.03f * num, 0f, (ForceMode)2); this.vehicleRB.AddRelativeTorque(0.01f, 0f, 0f, (ForceMode)2); } } if (base.HasDriver) { //Log.Out("EntityVHelicopterRebirth-PhysicsInputMove 4"); this.topRPM += 0.6f * deltaTime; this.topRPM = Mathf.Min(this.topRPM, 3f); return; } this.topRPM *= 0.99f; } protected void SetWheelsForces(float motorTorque, float brakeTorque) { //Log.Out("EntityVHelicopterRebirth-SetWheelsForces START"); if (this.vehicle.GetFuelPercent() == 0f) { //Log.Out("EntityVHelicopterRebirth-SetWheelsForces 1"); return; } if (this.vehicle.FindPart("engine").IsBroken()) { //Log.Out("EntityVHelicopterRebirth-SetWheelsForces 2"); return; } //Log.Out("EntityVHelicopterRebirth-SetWheelsForces this.wheels.Length: " + this.wheels.Length); for (int i = 0; i < this.wheels.Length; i++) { EntityVehicle.Wheel wheel = this.wheels[i]; wheel.wheelC.motorTorque = motorTorque; wheel.wheelC.brakeTorque = 0f; } } public override void UpdateWheelsSteering() { //Log.Out("EntityVHelicopterRebirth-UpdateWheelsSteering START"); this.wheels[0].wheelC.steerAngle = this.wheelDir; } public override void Update() { //Log.Out("EntityVHelicopterRebirth-SetWheelsForces START"); base.Update(); if (this.vehicle.GetFuelPercent() == 0f) { //Log.Out("EntityVHelicopterRebirth-Update 1"); return; } if (this.vehicle.FindPart("engine").IsBroken()) { //Log.Out("EntityVHelicopterRebirth-Update 2"); return; } if (base.HasDriver && this.rearPropT) { Vector3 localEulerAngles = this.rearPropT.localEulerAngles; localEulerAngles.z += 2880f * Time.deltaTime; this.rearPropT.localEulerAngles = localEulerAngles; } if (this.topRPM > 0.1f && this.topPropT) { Vector3 localEulerAngles2 = this.topPropT.localEulerAngles; localEulerAngles2.y += this.topRPM * 360f * Time.deltaTime; this.topPropT.localEulerAngles = localEulerAngles2; } } private const float cTopRPMMax = 3f; private Transform topPropT; private float topRPM; private Transform rearPropT; }