public static bool IsOn(PartModule light) { switch (light.moduleName) { case "ModuleColorChanger": case "ModuleColorChangerConsumer": ModuleColorChanger castMCC = (ModuleColorChanger)light; return(castMCC.animState); case "ModuleLight": case "ModuleStockLightColoredLens": case "ModuleMultiPointSurfaceLight": case "ModuleColoredLensLight": ModuleLight castML = (ModuleLight)light; return(castML.isOn); case "ModuleAnimateGeneric": case "ModuleAnumateGenericConsumer": ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light; return(!castMAG.animSwitch); case "WBILight": return((bool)light.GetType().InvokeMember("isDeployed", BindingFlags.GetField, null, light, null)); case "ModuleKELight": return((bool)light.GetType().InvokeMember("isOn", BindingFlags.GetField, null, light, null)); default: return(false); } }
public override void OnStart(PartModule.StartState state) { this.part.force_activate(); if (ModuleID != "") { colorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == ModuleID); } // Set up the UI slider var range = (UI_FloatRange)this.Fields["dischargeActual"].uiControlEditor; range.minValue = DischargeRate * DischargeRateMinimumScalar; range.maxValue = DischargeRate; range = (UI_FloatRange)this.Fields["dischargeActual"].uiControlFlight; range.minValue = DischargeRate * DischargeRateMinimumScalar; range.maxValue = DischargeRate; // Set up the discharge rate if (FirstLoad) { this.dischargeActual = DischargeRate; FirstLoad = false; } if (colorChanger != null) { colorChanger.SetScalar(CurrentCharge / MaximumCharge); } // Prepare the localization Events["ShowCapacitorControl"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleUI")); Events["Discharge"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_Discharge")); Events["Enable"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_EnableCharge")); Events["Disable"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Event_DisableCharge")); Actions["DischargeAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_Discharge")); Actions["EnableAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_EnableCharge")); Actions["DisableAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_DisableCharge")); Actions["ToggleAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleCharge")); Actions["TogglePanelAction"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Action_ToggleUI")); Fields["dischargeActual"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Field_DischargeRate")); Fields["CapacitorStatus"].guiName = string.Format("{0}", Localizer.Format("#LOC_NFElectrical_ModuleDischargeCapacitor_Field_Status")); if (HighLogic.LoadedSceneIsFlight) { DoCatchup(); assignedGroups = new List <int>(); for (int i = 0; i < CapacitorGroups.Length; i++) { assignedGroups.Add((int)CapacitorGroups[i]); } } }
public void Start() { heatModule = ModuleUtils.FindHeatModule(this.part, systemHeatModuleID); scalarModule = part.GetComponents <ModuleColorChanger>().ToList().Find(x => x.moduleID == scalarModuleID); if (maxTempAnimation == -1f) { maxTempAnimation = (float)part.maxTemp; } maxTempAnimation -= draperPoint; }
/// <summary> /// Special handling for ModuleColorChanger. Needs special handling because we can't go by the GUI /// name of the action, at least not if it's the root part. Reason: that module changes the GUI name /// at start time, which happens *after* the part being created. /// </summary> /// <param name="part"></param> /// <param name="colorChangerModule"></param> /// <param name="defaultActionGroupModule"></param> private static void handleDefaultGroupsForColorChangerModule( Part part, ModuleColorChanger colorChangerModule, ModuleDefaultActionGroup defaultActionGroupModule) { if (colorChangerModule.toggleName != defaultActionGroupModule.actionGuiName) return; BaseAction toggleAction = colorChangerModule.Actions["ToggleAction"]; Logging.Log("Updating action groups for " + part.name + "/" + colorChangerModule.moduleName + "/" + toggleAction.guiName + " to include " + defaultActionGroupModule.defaultActionGroup); toggleAction.actionGroup |= defaultActionGroupModule.defaultActionGroup; toggleAction.defaultActionGroup |= defaultActionGroupModule.defaultActionGroup; }
public void Start() { core = GetComponent <ModuleCoreHeat>(); if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { if (fuelModuleID != "") { fuelColorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == fuelModuleID); } if (wasteModuleID != "") { wasteColorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == wasteModuleID); } } }
void GetLightingModules() { Logging.DLog(logMsg: $"Kuddle: GetLightingModules"); // Check for lightable modules if (part.Modules.Contains <ModuleColorChanger>()) { ModuleColorChanger partM = part.Modules.GetModule <ModuleColorChanger>(); modulesLight.Add(partM); } if (part.Modules.Contains <ModuleLight>()) { foreach (ModuleLight partM in part.Modules.GetModules <ModuleLight>()) { modulesLight.Add(partM); } } if (part.Modules.Contains <ModuleAnimateGeneric>()) { foreach (ModuleAnimateGeneric partM in part.Modules.GetModules <ModuleAnimateGeneric>()) { modulesLight.Add(partM); } } if (part.Modules.Contains("WBILight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "WBILight") { modulesLight.Add(partM); } } } if (part.Modules.Contains("ModuleKELight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "ModuleKELight") { modulesLight.Add(partM); } } } }
protected void setupLightGUI() { WBILight light = this.part.FindModuleImplementing <WBILight>(); if (light != null) { light.Events["ToggleAnimation"].active = isDeployed; } ModuleColorChanger colorChanger = this.part.FindModuleImplementing <ModuleColorChanger>(); if (colorChanger != null) { colorChanger.Events["ToggleEvent"].active = isDeployed; } //Dirty the GUI MonoUtilities.RefreshContextWindows(this.part); }
public override void OnStart(StartState state) { if (state == StartState.Editor && state == StartState.None && state == StartState.PreLaunch) { return; } lights1 = part.FindModuleImplementing <ModuleAnimateGeneric>(); lights2 = part.FindModuleImplementing <ModuleColorChanger>(); if (lights1 != null) { pModule = lights1; } else if (lights2 != null) { pModule = lights1; } base.OnStart(state); }
public void Start() { Events["StoreWaste"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Field_Store_Name", WasteResourceName); Events["StoreFuel"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Field_Store_Name", FuelResourceName); Events["CollectWaste"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Field_Collect_Name", WasteResourceName); Events["CollectFuel"].guiName = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Field_Collect_Name", FuelResourceName); if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { if (fuelModuleID != "") { fuelColorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == fuelModuleID); } if (wasteModuleID != "") { wasteColorChanger = this.GetComponents <ModuleColorChanger>().ToList().Find(i => i.moduleID == wasteModuleID); } } }
public static void Off(PartModule light) { switch (light.moduleName) { case "ModuleColorChanger": case "ModuleColorChangerConsumer": ModuleColorChanger castMCC = (ModuleColorChanger)light; if (castMCC.animState) { castMCC.ToggleEvent(); } break; case "ModuleLight": case "ModuleStockLightColoredLens": case "ModuleMultiPointSurfaceLight": case "ModuleColoredLensLight": ModuleLight castML = (ModuleLight)light; castML.LightsOff(); break; case "ModuleAnimateGeneric": case "ModuleAnumateGenericConsumer": ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light; castMAG.Toggle(); break; case "WBILight": light.GetType().InvokeMember("TurnOffLights", BindingFlags.InvokeMethod, null, light, null); break; case "ModuleNavLight": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 0 }); break; case "ModuleKELight": light.GetType().InvokeMember("LightsOff", BindingFlags.InvokeMethod, null, light, null); break; } }
private IEnumerator FindLightPart() { modulesLight = new List <PartModule> (); stateLight = new List <bool?>(); int iSearch = -1; yield return(new WaitForSeconds(.1f)); foreach (Part part in vessel.Parts) { iSearch++; if (iSearch >= CLSettings.maxSearch) { yield return(new WaitForSeconds(.1f)); iSearch = 0; } // Check for retractable landing gear/whell if (part.Modules.Contains <ModuleStatusLight> ()) { break; } // Check for lightable modules if (part.Modules.Contains <ModuleColorChanger> ()) { ModuleColorChanger partM = part.Modules.GetModule <ModuleColorChanger> (); if (Regex.IsMatch(partM.toggleName, "light", RegexOptions.IgnoreCase)) { modulesLight.Add(partM); if (partM.animState) { stateLight.Add(true); } else { stateLight.Add(false); } } } if (part.Modules.Contains <ModuleLight> ()) { foreach (ModuleLight partM in part.Modules.GetModules <ModuleLight>()) { modulesLight.Add(partM); if (partM.isOn) { stateLight.Add(true); } else { stateLight.Add(false); } } } if (part.Modules.Contains <ModuleAnimateGeneric> ()) { foreach (ModuleAnimateGeneric partM in part.Modules.GetModules <ModuleAnimateGeneric>()) { if (Regex.IsMatch(partM.actionGUIName, "light", RegexOptions.IgnoreCase)) { modulesLight.Add(partM); if (partM.animSwitch == false) { stateLight.Add(true); } else { stateLight.Add(false); } } } } if (part.Modules.Contains("WBILight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "WBILight") { modulesLight.Add(partM); stateLight.Add(null); } } } if (part.Modules.Contains("ModuleNavLight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "ModuleNavLight") { modulesLight.Add(partM); stateLight.Add(null); } } } if (part.Modules.Contains("ModuleKELight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "ModuleKELight") { modulesLight.Add(partM); stateLight.Add((bool)partM.GetType().InvokeMember("isOn", System.Reflection.BindingFlags.GetField, null, partM, null)); } } } } }
private IEnumerator FindLightPart() { modulesLight = new List <PartModule> (); int iSearch = -1; yield return(new WaitForSeconds(.1f)); foreach (Part part in vessel.Parts) { iSearch++; if (iSearch >= CLSettings.maxSearch) { yield return(new WaitForSeconds(.1f)); iSearch = 0; } // Check if the part is a landing gear/wheel if (part.Modules.Contains <ModuleStatusLight> ()) { continue; } // Check if part is uncrewed if (part.CrewCapacity == 0 || !CLSettings.useTransferCrew) { if (part.Modules.Contains <ModuleColorChanger> ()) { ModuleColorChanger partM = part.Modules.GetModule <ModuleColorChanger> (); if (Regex.IsMatch(partM.toggleName, "light", RegexOptions.IgnoreCase)) { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } if (part.Modules.Contains <ModuleLight> ()) { foreach (ModuleLight partM in part.Modules.GetModules <ModuleLight>()) { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } if (part.Modules.Contains <ModuleAnimateGeneric> ()) { foreach (ModuleAnimateGeneric partM in part.Modules.GetModules <ModuleAnimateGeneric>()) { if (Regex.IsMatch(partM.actionGUIName, "light", RegexOptions.IgnoreCase)) { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } } if (part.Modules.Contains("WBILight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "WBILight") { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } } if (part.Modules.Contains("ModuleNavLight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "ModuleNavLight") { if (!CLSettings.beaconOnEngine || (part.name != "lightbeacon.amber" && part.name != "lightbeacon.red")) { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } } } if (part.Modules.Contains("ModuleKELight")) { foreach (PartModule partM in part.Modules) { if (partM.ClassName == "ModuleKELight") { if (CLSettings.onlyNoAGpart) { if (!partM.Actions.Contains(KSPActionGroup.Light)) { modulesLight.Add(partM); } } else { modulesLight.Add(partM); } } } } } } }
public static void On(PartModule light) { if (!settingsLoaded) { LoadSettings(); } switch (light.moduleName) { case "ModuleColorChanger": case "ModuleColorChangerConsumer": ModuleColorChanger castMCC = (ModuleColorChanger)light; if (!castMCC.animState) { castMCC.ToggleEvent(); } break; case "ModuleLight": case "ModuleStockLightColoredLens": case "ModuleMultiPointSurfaceLight": case "ModuleColoredLensLight": ModuleLight castML = (ModuleLight)light; castML.LightsOn(); break; case "ModuleAnimateGeneric": case "ModuleAnimateGenericConsumer": ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light; if (castMAG.animSwitch) { castMAG.Toggle(); } break; case "WBILight": light.GetType().InvokeMember("TurnOnLights", BindingFlags.InvokeMethod, null, light, null); break; case "ModuleNavLight": if (generalSettings.useAviationLightsEffect && GameSettingsLive.inSunlight) { switch (light.part.name) { case "lightbeacon.amber": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.beaconAmber) }); break; case "lightbeacon.red": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.beaconRed) }); break; case "lightnav.blue": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navBlue) }); break; case "lightnav.green": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navGreen) }); break; case "lightnav.red": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navRed) }); break; case "lightnav.white": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navWhite) }); break; case "lightstrobe.white": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.strobeWhite) }); break; default: light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 4 }); break; } } else { light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 4 }); } break; case "ModuleKELight": light.GetType().InvokeMember("LightsOn", BindingFlags.InvokeMethod, null, light, null); break; } }
public ModuleAnimateGenericEC(ModuleColorChanger light, double extra_Cost) { colorChanger = light; this.extra_Cost = extra_Cost; }