Ejemplo n.º 1
0
 private void MotorStart(motorWay way)
 {
     KAS_Shared.DebugLog("MotorStart(Rotor) - Start motor...");
     if (!hingeJnt)
     {
         return;
     }
     if (KAS_Shared.RequestPower(this.part, powerDrain))
     {
         //Sound
         if (hingeJnt.motor.targetVelocity == 0)
         {
             fxSndMotorStart.audio.Play();
         }
         if (!fxSndMotor.audio.isPlaying)
         {
             fxSndMotor.audio.Play();
         }
         //Limit config
         ResetLimitsConfig();
         hingeJnt.useLimits = hasLimit;
         JointMotor mtr = new JointMotor();
         //Motor config
         mtr.force    = force;
         mtr.freeSpin = freeSpin;
         if (way == motorWay.Negative)
         {
             if (controlInverted)
             {
                 mtr.targetVelocity = speed;
             }
             else
             {
                 mtr.targetVelocity = -speed;
             }
             stateField = "Going " + negativeWayText;
         }
         if (way == motorWay.Positive)
         {
             if (controlInverted)
             {
                 mtr.targetVelocity = -speed;
             }
             else
             {
                 mtr.targetVelocity = speed;
             }
             stateField = "Going " + positiveWayText;
         }
         hingeJnt.motor = mtr;
         //misc
         hingeJnt.useSpring = false;
         hingeJnt.useMotor  = true;
         rotorActivated     = true;
     }
     else
     {
         if (this.part.vessel == FlightGlobals.ActiveVessel)
         {
             ScreenMessages.PostScreenMessage(this.part.partInfo.title + " stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER);
         }
         stateField = "Insufficient Power";
     }
 }
Ejemplo n.º 2
0
 private void MotorStart(motorWay way)
 {
     KAS_Shared.DebugLog("MotorStart(Rotor) - Start motor...");
     if (!hingeJnt) return;
     if (KAS_Shared.RequestPower(this.part, powerDrain))
     {
         //Sound
         if (hingeJnt.motor.targetVelocity == 0)
         {
             fxSndMotorStart.audio.Play();
         }
         if (!fxSndMotor.audio.isPlaying) fxSndMotor.audio.Play();
         //Limit config
         ResetLimitsConfig();
         hingeJnt.useLimits = hasLimit;
         JointMotor mtr = new JointMotor();
         //Motor config
         mtr.force = force;
         mtr.freeSpin = freeSpin;
         if (way == motorWay.Negative)
         {
             if (controlInverted) mtr.targetVelocity = speed;
             else mtr.targetVelocity = -speed;
             stateField = "Going " + negativeWayText;
         }
         if (way == motorWay.Positive)
         {
             if (controlInverted) mtr.targetVelocity = -speed;
             else mtr.targetVelocity = speed;
             stateField = "Going " + positiveWayText;
         }
         hingeJnt.motor = mtr;
         //misc
         hingeJnt.useSpring = false;
         hingeJnt.useMotor = true;
         rotorActivated = true;
     }
     else
     {
         if (this.part.vessel == FlightGlobals.ActiveVessel)
         {
             ScreenMessages.PostScreenMessage(this.part.partInfo.title + " stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER);
         }
         stateField = "Insufficient Power";
     }
 }