Beispiel #1
0
 public void Update()
 {
     if (controller == null || wheel == null)
     {
         return;
     }
     if (controller.wheelState == KSPWheelState.DEPLOYED)
     {
         if (animationControl.state != KSPWheelState.DEPLOYED)
         {
             animationControl.setToAnimationState(KSPWheelState.DEPLOYED, false);
         }
         //calculate the speed at which to play the animation
         float speed = 0f;
         int   len   = controller.wheelData.Length;
         for (int i = 0; i < len; i++)
         {
             speed += Mathf.Abs(controller.wheelData[i].wheel.linearVelocity);
         }
         speed /= len;
         speed /= controller.maxSpeed;
         speed *= Mathf.Sign(wheel.rpm);
         if (invertAnimation)
         {
             speed = -speed;
         }
         animationControl.setAnimSpeedMult(speed);
         //update the effect for the current 'speed percent' value
         if (!string.IsNullOrEmpty(effectName))
         {
             part.Effect(effectName, speed);
         }
         animationControl.updateAnimationState();
     }
     else
     {
         if (!string.IsNullOrEmpty(effectName))
         {
             part.Effect(effectName, 0f);
         }
     }
 }
Beispiel #2
0
        private void setupAnimationController()
        {
            animationControl = new WheelAnimationHandler(this, animationName, animationSpeed, animationLayer, controller.wheelState, invertAnimation, WrapMode.Once);
            ConfigNode node = ConfigNode.Parse(configNodeData);

            if (node != null)
            {
                node = node.nodes[0];
                if (node != null)
                {
                    ConfigNode[] animNodes = node.GetNodes("ANIMATION");
                    animationControl.loadSecondaryAnimations(animNodes);
                }
            }
            animationControl.setToAnimationState(controller.wheelState, false);
        }
Beispiel #3
0
        private void setupAnimationController()
        {
            animationControl = new WheelAnimationHandler(this, animationName, animationSpeed, animationLayer, controller.wheelState, false, wrap? WrapMode.Loop : WrapMode.PingPong);
            ConfigNode node = ConfigNode.Parse(configNodeData);

            if (node != null)
            {
                node = node.nodes[0];
                if (node != null)
                {
                    ConfigNode[] animNodes = node.GetNodes("ANIMATION");
                    animationControl.loadSecondaryAnimations(animNodes);
                }
            }
            animationControl.setToAnimationState(controller.wheelState == KSPWheelState.DEPLOYED?KSPWheelState.DEPLOYED : KSPWheelState.RETRACTED, false);
        }
Beispiel #4
0
 private void toggleDeploy()
 {
     if (animationControl == null)
     {
         MonoBehaviour.print("Animation control is null!");
         return;
     }
     if (oneShotAnimation && oneShotTriggered)
     {
         return;
     }
     if ((controller.wheelState == KSPWheelState.DEPLOYED || controller.wheelState == KSPWheelState.DEPLOYING) && checkResourceUse(KSPWheelState.RETRACTING))
     {
         changeWheelState(KSPWheelState.RETRACTING);
         animationControl.setToAnimationState(controller.wheelState, false);
         if (collider != null)
         {
             collider.enabled = true;
         }
         if (!string.IsNullOrEmpty(retractEffect))
         {
             part.Effect(retractEffect, 1f);
         }
         if (!string.IsNullOrEmpty(retractedEffect))
         {
             part.Effect(retractedEffect, 0f);
         }
         if (!string.IsNullOrEmpty(deployEffect))
         {
             part.Effect(deployEffect, 0f);
         }
         if (!string.IsNullOrEmpty(deployedEffect))
         {
             part.Effect(deployedEffect, 0f);
         }
         oneShotTriggered = oneShotTriggered || HighLogic.LoadedSceneIsFlight;
     }
     else if ((controller.wheelState == KSPWheelState.RETRACTED || controller.wheelState == KSPWheelState.RETRACTING) && checkResourceUse(KSPWheelState.DEPLOYING))
     {
         changeWheelState(KSPWheelState.DEPLOYING);
         animationControl.setToAnimationState(controller.wheelState, false);
         if (collider != null)
         {
             collider.enabled = true;
         }
         if (!string.IsNullOrEmpty(retractEffect))
         {
             part.Effect(retractEffect, 0f);
         }
         if (!string.IsNullOrEmpty(retractedEffect))
         {
             part.Effect(retractedEffect, 0f);
         }
         if (!string.IsNullOrEmpty(deployEffect))
         {
             part.Effect(deployEffect, 1f);
         }
         if (!string.IsNullOrEmpty(deployedEffect))
         {
             part.Effect(deployedEffect, 0f);
         }
         oneShotTriggered = oneShotTriggered || HighLogic.LoadedSceneIsFlight;
     }
 }