internal void GetSolarPanels() { _solarPanels.Clear(); try { foreach (Part pPart in SMAddon.vessel.Parts) { foreach (PartModule pModule in pPart.Modules) { if (pModule.moduleName == "ModuleDeployableSolarPanel") { ModuleDeployableSolarPanel iModule = (ModuleDeployableSolarPanel)pModule; if (iModule.Events["Extend"].active || iModule.Events["Retract"].active) { ModSolarPanel pPanel = new ModSolarPanel(); pPanel.PanelModule = pModule; pPanel.SPart = pPart; _solarPanels.Add(pPanel); } } } } } catch (Exception ex) { Utilities.LogMessage(string.Format("Error in GetSolarPanels().\r\nError: {0}", ex.ToString()), "Error", true); } }
internal void GetSolarPanels() { _solarPanels.Clear(); try { List <Part> .Enumerator pParts = Vessel.Parts.GetEnumerator(); while (pParts.MoveNext()) { if (pParts.Current == null) { continue; } List <PartModule> .Enumerator pModules = pParts.Current.Modules.GetEnumerator(); while (pModules.MoveNext()) { if (pModules.Current == null) { continue; } PartModule pModule = (PartModule)pModules.Current; if (pModule.moduleName != "ModuleDeployableSolarPanel") { continue; } ModuleDeployableSolarPanel iModule = (ModuleDeployableSolarPanel)pModule; if (!iModule.Events["Extend"].active && !iModule.Events["Retract"].active) { continue; } ModSolarPanel pPanel = new ModSolarPanel { PanelModule = pModule, SPart = pParts.Current }; _solarPanels.Add(pPanel); } pModules.Dispose(); } pParts.Dispose(); } catch (Exception ex) { SmUtils.LogMessage($"Error in GetSolarPanels().\r\nError: {ex}", SmUtils.LogType.Error, true); } }
internal void GetSolarPanels() { _solarPanels.Clear(); try { List <Part> .Enumerator pParts = Vessel.Parts.GetEnumerator(); while (pParts.MoveNext()) { if (pParts.Current == null) { continue; } List <ModuleDeployableSolarPanel> .Enumerator pModules = pParts.Current.FindModulesImplementing <ModuleDeployableSolarPanel>().GetEnumerator(); while (pModules.MoveNext()) { ModuleDeployableSolarPanel solarPanel = pModules.Current; if (solarPanel == null) { continue; } if (!solarPanel.Events["Extend"].active && !solarPanel.Events["Retract"].active) { continue; } ModSolarPanel pPanel = new ModSolarPanel { PanelModule = solarPanel, SPart = pParts.Current }; _solarPanels.Add(pPanel); } pModules.Dispose(); } pParts.Dispose(); } catch (Exception ex) { SmUtils.LogMessage($"Error in GetSolarPanels().\r\nError: {ex}", SmUtils.LogType.Error, true); } }