protected void updateCounterparts()
 {
     foreach (Part symmetryPart in this.part.symmetryCounterparts)
     {
         WBIRotationController rotator = symmetryPart.GetComponent <WBIRotationController>();
         if (rotator != null)
         {
             rotator.targetAngle   = targetAngle;
             rotator.rotationState = rotationState;
             rotationStateInt      = (int)rotationState;
             rotator.state         = kRotating;
         }
     }
 }
예제 #2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            //Get rotor transforms
            rotorTransform = this.part.FindModelTransform(rotorTransformName);

            //Setup RCS
            rcsModule = this.part.FindModuleImplementing <ModuleRCSFX>();

            //Setup events
            WBIRotationController rotationController = this.part.FindModuleImplementing <WBIRotationController>();

            if (rotationController != null)
            {
                mirrorRotation = rotationController.mirrorRotation;
                rotationController.onRotatorMirrored += MirrorRotation;
            }

            //Get the rotation axis
            if (string.IsNullOrEmpty(rotorRotationAxis) == false)
            {
                string[] axisValues = rotorRotationAxis.Split(',');
                float    value;
                if (axisValues.Length == 3)
                {
                    if (float.TryParse(axisValues[0], out value))
                    {
                        rotationAxis.x = value;
                    }
                    if (float.TryParse(axisValues[1], out value))
                    {
                        rotationAxis.y = value;
                    }
                    if (float.TryParse(axisValues[2], out value))
                    {
                        rotationAxis.z = value;
                    }
                }
            }

            //Set gui visible state
            SetGUIVisible(guiVisible);

            //Rotor transforms
            setupRotorTransforms();
        }
예제 #3
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            //Get rotor transforms
            rotorTransform = this.part.FindModelTransform(rotorTransformName);

            //Setup engine(s)
            setupEngines();

            //Setup events
            WBIRotationController rotationController = this.part.FindModuleImplementing <WBIRotationController>();

            if (rotationController != null)
            {
                mirrorRotation = rotationController.mirrorRotation;
                rotationController.onRotatorMirrored += MirrorRotation;
            }

            WBIHoverController hoverController = this.part.FindModuleImplementing <WBIHoverController>();

            if (hoverController != null)
            {
                hoverController.onHoverUpdate += onHoverUpdate;
            }

            //Get the rotation axis
            if (string.IsNullOrEmpty(rotorRotationAxis) == false)
            {
                string[] axisValues = rotorRotationAxis.Split(',');
                float    value;
                if (axisValues.Length == 3)
                {
                    if (float.TryParse(axisValues[0], out value))
                    {
                        rotationAxis.x = value;
                    }
                    if (float.TryParse(axisValues[1], out value))
                    {
                        rotationAxis.y = value;
                    }
                    if (float.TryParse(axisValues[2], out value))
                    {
                        rotationAxis.z = value;
                    }
                }
            }

            //Set gui visible state
            SetGUIVisible(guiVisible);

            //Setup actions
            if (!actionsVisible)
            {
                Actions["ToggleThrustTransformAction"].actionGroup = KSPActionGroup.None;
                Actions["ToggleThrustTransformAction"].active      = false;
            }

            //Setup the thrust transform
            if (canReverseThrust)
            {
                fwdThrustTransform = this.part.FindModelTransform(thrustTransform);
                revThrustTransform = this.part.FindModelTransform(reverseThrustTransform);

                if (fwdThrustTransform != null && revThrustTransform != null)
                {
                    SetupThrustTransform();
                    SetupAnimation();
                }

                else
                {
                    Actions["ToggleThrustTransformAction"].actionGroup = KSPActionGroup.None;
                    Events["ToggleThrustTransform"].active             = false;
                    Actions["ToggleThrustTransformAction"].active      = false;
                }
            }
            else
            {
                fwdThrustTransform = this.part.FindModelTransform(thrustTransform);
                revThrustTransform = fwdThrustTransform;
            }

            //Rotor transforms
            setupRotorTransforms();
        }