//init the module of the windows public override void OnStart(PartModule.StartState state) { //find the dependent module dependent = (PlanetaryModule)this.part.GetComponent("PlanetaryModule"); if ((dependent != null)) { //switch the IVA when not in editor mode if (state != StartState.Editor) { //switch to the extended internal if (dependent.status.Equals("Deployed")) { SetVisibleInternal(extendedInternalNode, false); isInternalPacked = false; respawnCrew = true; } else { SetVisibleInternal(packedInternalNode, false); isInternalPacked = false; } } } base.OnStart(state); }
public void OnDestroy() { //free referenced module dependent = null; }
//----------------methods----------------- public override void OnStart(PartModule.StartState state) { base.OnStart(state); //find the animation anim = part.FindModelAnimators(animationName)[0]; //find the dependent module dependent = (PlanetaryModule)this.part.GetComponent("PlanetaryModule"); if (anim != null) //Only Init when an animation is available { if (!hasBeenInitialized) // Run Only on first launch { nextIsReverse = false; animationTime = 0f; anim[animationName].normalizedTime = 0f; hasBeenInitialized = true; } // make sure you stay in your place on launch, and don't start going in the wrong direction if deployed/retracted if (nextIsReverse) { anim[animationName].speed = 1f; if (animationTime == 0f) { animationTime = 1f; } if (animationTime == 1f) { lightStatus = "On"; } else { lightStatus = "Turning on"; } } else { if (animationTime == 0f) { lightStatus = "Off"; } else { lightStatus = "Turning off"; } anim[animationName].speed = -1f; } //set up animation state according to persistent values anim[animationName].layer = layer; anim.Play(animationName); anim[animationName].normalizedTime = animationTime; //Settings for the GUI if (nextIsReverse) { Events["toggleAnimation"].guiName = endEventGUIName; } else { Events["toggleAnimation"].guiName = startEventGUIName; } //check whether the element can be active or not bool bShowGUI = true; if (dependent != null) { bShowGUI = dependent.status.Equals("Deployed"); } Events["toggleAnimation"].guiActiveEditor = availableInEditor; Events["toggleAnimation"].guiActiveUnfocused = availableInEVA && bShowGUI; Events["toggleAnimation"].guiActive = availableInVessel && bShowGUI; Events["toggleAnimation"].unfocusedRange = EVArange; } else //When the animation can not be found deactivate it in the GUI { Events["toggleAnimation"].guiActiveEditor = false; Events["toggleAnimation"].guiActive = false; Events["toggleAnimation"].guiActiveUnfocused = false; Debug.Log("KBILightAnimation: Animation not found: " + animationName); } }
//----------------methods----------------- public override void OnStart(PartModule.StartState state) { base.OnStart(state); //find the animation anim = part.FindModelAnimators(animationName).FirstOrDefault(); //find the dependent module dependent = (PlanetaryModule)this.part.GetComponent("PlanetaryModule"); if (anim != null) //Only Init when an animation is available { if (!hasBeenInitialized) // Run Only on first launch { nextIsReverse = false; animationTime = 0f; anim[animationName].normalizedTime = 0f; hasBeenInitialized = true; } // make sure you stay in your place on launch, and don't start going in the wrong direction if deployed/retracted if (nextIsReverse) { anim[animationName].speed = 1f; if (animationTime == 0f) { animationTime = 1f; } if (animationTime == 1f) { lightStatus = "On"; } else { lightStatus = "Turning on"; } } else { if (animationTime == 0f) { lightStatus = "Off"; } else { lightStatus = "Turning off"; } anim[animationName].speed = -1f; } //set up animation state according to persistent values anim[animationName].layer = layer; anim.Play(animationName); anim[animationName].normalizedTime = animationTime; //Settings for the GUI if (nextIsReverse) { Events["toggleAnimation"].guiName = endEventGUIName; } else { Events["toggleAnimation"].guiName = startEventGUIName; } //check whether the element can be active or not bool bShowGUI = true; if (dependent != null) { bShowGUI = dependent.status.Equals("Deployed"); } Events["toggleAnimation"].guiActiveEditor = availableInEditor; Events["toggleAnimation"].guiActiveUnfocused = availableInEVA && bShowGUI; Events["toggleAnimation"].guiActive = availableInVessel && bShowGUI; Events["toggleAnimation"].unfocusedRange = EVArange; } else //When the animation can not be found deactivate it in the GUI { Events["toggleAnimation"].guiActiveEditor = false; Events["toggleAnimation"].guiActive = false; Events["toggleAnimation"].guiActiveUnfocused = false; Debug.Log("KBILightAnimation: Animation not found: " + animationName); } }
public void OnDestroy() { //free referenced module dependent = null; }