public override void SetDefaultInputState()
 {
     this.currentInputState.Reset();
     if (this.Grounded())
     {
         return;
     }
     if (!this.IsMounted())
     {
         this.currentInputState.throttle = -1f;
     }
     else
     {
         float single  = Vector3.Dot(Vector3.up, base.transform.right);
         float single1 = Vector3.Dot(Vector3.up, base.transform.forward);
         this.currentInputState.roll = (single < 0f ? 1f : 0f);
         BaseHelicopterVehicle.HelicopterInputState helicopterInputState = this.currentInputState;
         helicopterInputState.roll = helicopterInputState.roll - (single > 0f ? 1f : 0f);
         if (single1 < 0f)
         {
             this.currentInputState.pitch = -1f;
             return;
         }
         if (single1 > 0f)
         {
             this.currentInputState.pitch = 1f;
             return;
         }
     }
 }
    public virtual void MovementUpdate()
    {
        BaseHelicopterVehicle.HelicopterInputState helicopterInputState = this.currentInputState;
        this.currentThrottle = Mathf.Lerp(this.currentThrottle, helicopterInputState.throttle, 2f * Time.fixedDeltaTime);
        this.currentThrottle = Mathf.Clamp(this.currentThrottle, -0.8f, 1f);
        this.rigidBody.AddRelativeTorque(new Vector3(helicopterInputState.pitch * this.torqueScale.x, helicopterInputState.yaw * this.torqueScale.y, helicopterInputState.roll * this.torqueScale.z), ForceMode.Force);
        this.avgThrust = Mathf.Lerp(this.avgThrust, this.engineThrustMax * this.currentThrottle, Time.fixedDeltaTime * this.thrustLerpSpeed);
        float single         = Mathf.Clamp01(Vector3.Dot(base.transform.up, Vector3.up));
        float single1        = Mathf.InverseLerp(this.liftDotMax, 1f, single);
        float serviceCeiling = this.GetServiceCeiling();

        this.avgTerrainHeight = Mathf.Lerp(this.avgTerrainHeight, TerrainMeta.HeightMap.GetHeight(base.transform.position), Time.deltaTime);
        float single2 = 1f - Mathf.InverseLerp(this.avgTerrainHeight + serviceCeiling - 20f, this.avgTerrainHeight + serviceCeiling, base.transform.position.y);

        single1 *= single2;
        float   single3  = 1f - Mathf.InverseLerp(this.altForceDotMin, 1f, single);
        Vector3 vector3  = (((Vector3.up * this.engineThrustMax) * this.liftFraction) * this.currentThrottle) * single1;
        Vector3 vector31 = base.transform.up - Vector3.up;
        Vector3 vector32 = ((vector31.normalized * this.engineThrustMax) * this.currentThrottle) * single3;
        float   single4  = this.rigidBody.mass * -Physics.gravity.y;

        this.rigidBody.AddForce(((base.transform.up * single4) * single1) * this.hoverForceScale, ForceMode.Force);
        this.rigidBody.AddForce(vector3, ForceMode.Force);
        this.rigidBody.AddForce(vector32, ForceMode.Force);
    }
 public virtual void PilotInput(InputState inputState, BasePlayer player)
 {
     this.currentInputState.Reset();
     this.currentInputState.throttle = (inputState.IsDown(BUTTON.FORWARD) ? 1f : 0f);
     BaseHelicopterVehicle.HelicopterInputState helicopterInputState = this.currentInputState;
     helicopterInputState.throttle = helicopterInputState.throttle - (inputState.IsDown(BUTTON.BACKWARD) || inputState.IsDown(BUTTON.DUCK) ? 1f : 0f);
     this.currentInputState.pitch  = inputState.current.mouseDelta.y;
     this.currentInputState.roll   = -inputState.current.mouseDelta.x;
     this.currentInputState.yaw    = (inputState.IsDown(BUTTON.RIGHT) ? 1f : 0f);
     BaseHelicopterVehicle.HelicopterInputState helicopterInputState1 = this.currentInputState;
     helicopterInputState1.yaw    = helicopterInputState1.yaw - (inputState.IsDown(BUTTON.LEFT) ? 1f : 0f);
     this.currentInputState.pitch = this.MouseToBinary(this.currentInputState.pitch);
     this.currentInputState.roll  = this.MouseToBinary(this.currentInputState.roll);
     this.lastPlayerInputTime     = Time.time;
 }
 public override void PilotInput(InputState inputState, BasePlayer player)
 {
     base.PilotInput(inputState, player);
     if (!base.IsOn() && !this.IsStartingUp() && base.HasDriver() && inputState.IsDown(BUTTON.FORWARD) && this.HasFuel(false))
     {
         this.EngineStartup();
     }
     this.currentInputState.groundControl = inputState.IsDown(BUTTON.DUCK);
     if (this.currentInputState.groundControl)
     {
         this.currentInputState.roll     = 0f;
         this.currentInputState.throttle = (inputState.IsDown(BUTTON.FORWARD) ? 1f : 0f);
         BaseHelicopterVehicle.HelicopterInputState helicopterInputState = this.currentInputState;
         helicopterInputState.throttle = helicopterInputState.throttle - (inputState.IsDown(BUTTON.BACKWARD) ? 1f : 0f);
     }
 }
    public virtual void MovementUpdate()
    {
        BaseHelicopterVehicle.HelicopterInputState currentInputState = this.currentInputState;
        this.currentThrottle = Mathf.Lerp(this.currentThrottle, currentInputState.throttle, 2f * Time.get_fixedDeltaTime());
        this.currentThrottle = Mathf.Clamp(this.currentThrottle, -0.8f, 1f);
        this.rigidBody.AddRelativeTorque(new Vector3(currentInputState.pitch * (float)this.torqueScale.x, currentInputState.yaw * (float)this.torqueScale.y, currentInputState.roll * (float)this.torqueScale.z), (ForceMode)0);
        this.avgThrust = Mathf.Lerp(this.avgThrust, this.engineThrustMax * this.currentThrottle, Time.get_fixedDeltaTime() * this.thrustLerpSpeed);
        float num1           = Mathf.Clamp01(Vector3.Dot(((Component)this).get_transform().get_up(), Vector3.get_up()));
        float num2           = Mathf.InverseLerp(this.liftDotMax, 1f, num1);
        float serviceCeiling = this.GetServiceCeiling();

        this.avgTerrainHeight = Mathf.Lerp(this.avgTerrainHeight, TerrainMeta.HeightMap.GetHeight(((Component)this).get_transform().get_position()), Time.get_deltaTime());
        float   num3      = 1f - Mathf.InverseLerp((float)((double)this.avgTerrainHeight + (double)serviceCeiling - 20.0), this.avgTerrainHeight + serviceCeiling, (float)((Component)this).get_transform().get_position().y);
        float   num4      = num2 * num3;
        float   num5      = 1f - Mathf.InverseLerp(this.altForceDotMin, 1f, num1);
        Vector3 vector3_1 = Vector3.op_Multiply(Vector3.op_Multiply(Vector3.op_Multiply(Vector3.op_Multiply(Vector3.get_up(), this.engineThrustMax), this.liftFraction), this.currentThrottle), num4);
        Vector3 vector3_2 = Vector3.op_Subtraction(((Component)this).get_transform().get_up(), Vector3.get_up());
        Vector3 vector3_3 = Vector3.op_Multiply(Vector3.op_Multiply(Vector3.op_Multiply(((Vector3) ref vector3_2).get_normalized(), this.engineThrustMax), this.currentThrottle), num5);

        this.rigidBody.AddForce(Vector3.op_Multiply(Vector3.op_Multiply(Vector3.op_Multiply(((Component)this).get_transform().get_up(), this.rigidBody.get_mass() * (float)-Physics.get_gravity().y), num4), this.hoverForceScale), (ForceMode)0);
        this.rigidBody.AddForce(vector3_1, (ForceMode)0);
        this.rigidBody.AddForce(vector3_3, (ForceMode)0);
    }
Beispiel #6
0
    public override void SetDefaultInputState()
    {
        this.currentInputState.Reset();
        Vector3 moveTarget = this.GetMoveTarget();
        Vector3 vector3    = Vector3.Cross(base.transform.right, Vector3.up);
        Vector3 vector31   = Vector3.Cross(Vector3.up, vector3);
        float   single     = -Vector3.Dot(Vector3.up, base.transform.right);
        float   single1    = Vector3.Dot(Vector3.up, base.transform.forward);
        float   single2    = Vector3Ex.Distance2D(base.transform.position, moveTarget);
        float   single3    = base.transform.position.y;
        float   single4    = this.currentDesiredAltitude;
        Vector3 vector32   = base.transform.position + (base.transform.forward * 10f);

        vector32.y = single4;
        Vector3 vector33 = Vector3Ex.Direction2D(moveTarget, base.transform.position);
        float   single5  = -Vector3.Dot(vector33, vector31);
        float   single6  = Vector3.Dot(vector33, vector3);
        float   single7  = Mathf.InverseLerp(0f, 25f, single2);

        if (single6 <= 0f)
        {
            float single8 = 1f - Mathf.InverseLerp(0f, this.maxTiltAngle, single1);
            this.currentInputState.pitch = 1f * single6 * single8 * single7;
        }
        else
        {
            float single9 = Mathf.InverseLerp(-this.maxTiltAngle, 0f, single1);
            this.currentInputState.pitch = 1f * single6 * single9 * single7;
        }
        if (single5 <= 0f)
        {
            float single10 = 1f - Mathf.InverseLerp(0f, this.maxTiltAngle, single);
            this.currentInputState.roll = 1f * single5 * single10 * single7;
        }
        else
        {
            float single11 = Mathf.InverseLerp(-this.maxTiltAngle, 0f, single);
            this.currentInputState.roll = 1f * single5 * single11 * single7;
        }
        float single12 = Mathf.Abs(single4 - single3);
        float single13 = 1f - Mathf.InverseLerp(10f, 30f, single12);

        this.currentInputState.pitch *= single13;
        this.currentInputState.roll  *= single13;
        float single14 = this.maxTiltAngle;
        float single15 = Mathf.InverseLerp(0f + Mathf.Abs(this.currentInputState.pitch) * single14, single14 + Mathf.Abs(this.currentInputState.pitch) * single14, Mathf.Abs(single1));

        BaseHelicopterVehicle.HelicopterInputState helicopterInputState = this.currentInputState;
        helicopterInputState.pitch = helicopterInputState.pitch + single15 * (single1 < 0f ? -1f : 1f);
        float single16 = Mathf.InverseLerp(0f + Mathf.Abs(this.currentInputState.roll) * single14, single14 + Mathf.Abs(this.currentInputState.roll) * single14, Mathf.Abs(single));

        BaseHelicopterVehicle.HelicopterInputState helicopterInputState1 = this.currentInputState;
        helicopterInputState1.roll = helicopterInputState1.roll + single16 * (single < 0f ? -1f : 1f);
        if (this.aimDirOverride || single2 > 30f)
        {
            Vector3 vector34 = (this.aimDirOverride ? this.GetAimDirectionOverride() : Vector3Ex.Direction2D(this.GetMoveTarget(), base.transform.position));
            Vector3 vector35 = (this.aimDirOverride ? this.GetAimDirectionOverride() : Vector3Ex.Direction2D(this.GetMoveTarget(), base.transform.position));
            float   single17 = Vector3.Dot(vector31, vector34);
            float   single18 = Vector3.Angle(vector3, vector35);
            float   single19 = Mathf.InverseLerp(0f, 70f, Mathf.Abs(single18));
            this.currentInputState.yaw = (single17 > 0f ? 1f : 0f);
            BaseHelicopterVehicle.HelicopterInputState helicopterInputState2 = this.currentInputState;
            helicopterInputState2.yaw   = helicopterInputState2.yaw - (single17 < 0f ? 1f : 0f);
            this.currentInputState.yaw *= single19;
        }
        float single20 = Mathf.InverseLerp(5f, 30f, single2);

        this.currentInputState.throttle = single20;
    }