コード例 #1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            //Get the animations
            deployStowAnimation = this.part.FindModuleImplementing <ModuleAnimateGenericSFX>();
            if (deployStowAnimation != null)
            {
                deployStowAnimation.Events["Toggle"].guiActiveEditor    = false;
                deployStowAnimation.Events["Toggle"].guiActive          = false;
                deployStowAnimation.Events["Toggle"].guiActiveUnfocused = false;
            }
            List <WBIAnimation> wbiAnimations = this.part.FindModulesImplementing <WBIAnimation>();

            foreach (WBIAnimation wbiAnim in wbiAnimations)
            {
                if (wbiAnim.animationName == upDownAnimationName)
                {
                    upDownAnimation = wbiAnim;
                    break;
                }
            }
            if (upDownAnimation != null)
            {
                upDownAnimation.showGui(false);
            }
            UpdateGUI();
        }
コード例 #2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            //Deploy/Stow animation
            animation = this.part.FindModuleImplementing <ModuleAnimateGenericSFX>();
            if (animation != null)
            {
                animation.Events["Toggle"].guiActive       = false;
                animation.Events["Toggle"].guiActiveEditor = false;
            }

            //Get the rotation transforms
            if (string.IsNullOrEmpty(centrifugeName) || string.IsNullOrEmpty(counterTorqueName))
            {
                return;
            }
            centrifugeTransform    = this.part.FindModelTransform(centrifugeName);
            counterTorqueTransform = this.part.FindModelTransform(counterTorqueName);

            //Get the rotation vector
            if (string.IsNullOrEmpty(rotationAxis) == false)
            {
                try
                {
                    string[] axisValues = rotationAxis.Split(new char[] { ',' });
                    rotationAxisVec = new Vector3(float.Parse(axisValues[0]), float.Parse(axisValues[1]), float.Parse(axisValues[2]));
                }
                catch
                {
                    rotationAxisVec = new Vector3(0, 0, 1.0f);
                }
            }

            else
            {
                rotationAxisVec = new Vector3(0, 0, 1.0f);
            }

            //Get rotation helpers
            List <WBIIVARotationHelper> helpers = this.part.FindModulesImplementing <WBIIVARotationHelper>();

            if (helpers.Count > 0)
            {
                rotationHelpers = helpers.ToArray();
            }

            //Calculate max degrees per second
            maxDegPerSec        = rotationsPerMinute * 6.0f;
            maxDegPerSecCounter = maxDegPerSec * counterTorqueSpeedMultiplier;

            //Set state
            centrifugeState = (CentrifugeStates)rotationState;

            //Update GUI
            if (centrifugeState == CentrifugeStates.Spinning)
            {
                Events["ToggleCentrifuge"].guiName = stopCentrifugeName;
            }
            else
            {
                Events["ToggleCentrifuge"].guiName = startCentrifugeName;
            }
            Events["ToggleArms"].guiName = animation.Events["Toggle"].guiName;
            if (centrifugeState == CentrifugeStates.Stopped)
            {
                Events["ToggleArms"].guiActive = true;
            }
            else
            {
                Events["ToggleArms"].guiActive = false;
            }
        }