// controls the PearModule public static void SetPearModule(Part _part2, PearPowerController _pPC) { PearModule pM = _part2.GetComponent <PearModule>(); ModuleDeployablePart mDP = _part2.GetComponent <ModuleDeployablePart>(); PearPowerController pPC = _pPC; if (pPC.isPowerOn && mDP.deployState == ModuleDeployablePart.DeployState.RETRACTED || mDP.deployState == ModuleDeployablePart.DeployState.RETRACTING) { pM.Events["ExtendAll"].active = true; pM.Events["RetractAll"].active = false; } else if (pPC.isPowerOn && mDP.deployState == ModuleDeployablePart.DeployState.EXTENDED || mDP.deployState == ModuleDeployablePart.DeployState.EXTENDING) { pM.Events["ExtendAll"].active = false; pM.Events["RetractAll"].active = true; } else if (!pPC.isPowerOn || mDP.deployState == ModuleDeployablePart.DeployState.BROKEN) { pM.Events["ExtendAll"].active = false; pM.Events["RetractAll"].active = false; } }
// power button controller public static void PowerTogglePressed(Part _part, int sender) { PearPowerController pPC = _part.GetComponent <PearPowerController>(); if (HighLogic.LoadedSceneIsEditor) { if (pPC.isPowerOn) { pPC.isPowerOn = false; pPC.pearStatus = "OFFLINE"; } else { pPC.isPowerOn = true; pPC.pearStatus = "Active"; } } else if (HighLogic.LoadedSceneIsFlight) { if (!pPC.isPowerOn && sender == 0) { pPC.isPowerOn = false; pPC.pearStatus = "OFFLINE"; } else if (pPC.isPowerOn && sender == 0) { pPC.isPowerOn = true; pPC.pearStatus = "Active"; } else if (pPC.isPowerOn && sender == 1) { pPC.isPowerOn = false; pPC.pearStatus = "OFFLINE"; } else if (!pPC.isPowerOn && sender == 1) { pPC.isPowerOn = true; pPC.pearStatus = "Active"; } SetPearModule(_part, pPC); } }