Пример #1
0
 internal void GetAntennas()
 {
     _antennas.Clear();
     try
     {
         // Added support for RemoteTech antennas
         List <Part> .Enumerator pParts = Vessel.Parts.GetEnumerator();
         while (pParts.MoveNext())
         {
             if (pParts.Current == null)
             {
                 continue;
             }
             if (!pParts.Current.Modules.Contains("ModuleDataTransmitter") && !pParts.Current.Modules.Contains("ModuleRTAntenna"))
             {
                 continue;
             }
             ModAntenna pAntenna = new ModAntenna {
                 SPart = pParts.Current
             };
             IEnumerator pModules = pParts.Current.Modules.GetEnumerator();
             while (pModules.MoveNext())
             {
                 if (pModules.Current == null)
                 {
                     continue;
                 }
                 PartModule pModule = (PartModule)pModules.Current;
                 if (pModule is ModuleDataTransmitter || pModule.moduleName == "ModuleRTAntenna")
                 {
                     pAntenna.XmitterModule = pModule;
                 }
                 if (pModule is ModuleDeployableAntenna ||
                     pModule is ModuleAnimateGeneric && (pModule.Events["Toggle"].guiName == "Extend" || pModule.Events["Toggle"].guiName == "Retract"))
                 {
                     pAntenna.AnimateModule = pModule;
                 }
             }
             if (pAntenna.AnimateModule != null)
             {
                 _antennas.Add(pAntenna);
             }
         }
         pParts.Dispose();
     }
     catch (Exception ex)
     {
         SMUtils.LogMessage(string.Format("Error in GetAntennas().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
     }
 }
Пример #2
0
        internal List <Part> GetSelectedVesselsParts(List <ModDockedVessel> modDockedVessels, List <string> selectedResources)
        {
            List <Part> resourcePartList = new List <Part>();

            if (modDockedVessels == null || modDockedVessels.Count <= 0 || selectedResources == null ||
                selectedResources.Count <= 0)
            {
                return(resourcePartList);
            }
            try
            {
                List <ModDockedVessel> .Enumerator dVessels = modDockedVessels.GetEnumerator();
                while (dVessels.MoveNext())
                {
                    if (dVessels.Current == null)
                    {
                        continue;
                    }
                    List <Part> .Enumerator mdvParts = dVessels.Current.VesselParts.GetEnumerator();
                    while (mdvParts.MoveNext())
                    {
                        if (mdvParts.Current == null)
                        {
                            continue;
                        }
                        if (selectedResources.Count > 1 && mdvParts.Current.Resources.Contains(selectedResources[0]) && mdvParts.Current.Resources.Contains(selectedResources[1]))
                        {
                            resourcePartList.Add(mdvParts.Current);
                        }
                        else if (mdvParts.Current.Resources.Contains(selectedResources[0]))
                        {
                            resourcePartList.Add(mdvParts.Current);
                        }
                    }
                    mdvParts.Dispose();
                }
                dVessels.Dispose();
            }
            catch (Exception ex)
            {
                SMUtils.LogMessage(string.Format("Error in GetSelectedVesselParts().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
                resourcePartList = new List <Part>();
            }
            return(resourcePartList);
        }
Пример #3
0
 internal void GetSolarPanels()
 {
     _solarPanels.Clear();
     try
     {
         List <Part> .Enumerator pParts = Vessel.Parts.GetEnumerator();
         while (pParts.MoveNext())
         {
             if (pParts.Current == null)
             {
                 continue;
             }
             IEnumerator 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);
             }
         }
         pParts.Dispose();
     }
     catch (Exception ex)
     {
         SMUtils.LogMessage(string.Format("Error in GetSolarPanels().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
     }
 }
Пример #4
0
 internal void GetLights()
 {
     _lights.Clear();
     try
     {
         List <Part> .Enumerator pParts = Vessel.Parts.GetEnumerator();
         while (pParts.MoveNext())
         {
             if (pParts.Current == null)
             {
                 continue;
             }
             if (!pParts.Current.Modules.Contains("ModuleLight"))
             {
                 continue;
             }
             IEnumerator pModules = pParts.Current.Modules.GetEnumerator();
             while (pModules.MoveNext())
             {
                 if (pModules.Current == null)
                 {
                     continue;
                 }
                 PartModule pModule = (PartModule)pModules.Current;
                 if (pModule.moduleName != "ModuleLight")
                 {
                     continue;
                 }
                 ModLight pLight = new ModLight
                 {
                     LightModule = pModule,
                     SPart       = pParts.Current
                 };
                 _lights.Add(pLight);
             }
         }
         pParts.Dispose();
     }
     catch (Exception ex)
     {
         SMUtils.LogMessage(string.Format("Error in GetLights().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
     }
 }
Пример #5
0
 internal void GetHatches()
 {
     _hatches.Clear();
     try
     {
         List <ICLSPart> .Enumerator hParts = SMAddon.ClsAddon.Vessel.Parts.GetEnumerator();
         while (hParts.MoveNext())
         {
             if (hParts.Current == null)
             {
                 continue;
             }
             IEnumerator hModules = hParts.Current.Part.Modules.GetEnumerator();
             while (hModules.MoveNext())
             {
                 if (hModules.Current == null)
                 {
                     continue;
                 }
                 PartModule pModule = (PartModule)hModules.Current;
                 if (pModule.moduleName != "ModuleDockingHatch")
                 {
                     continue;
                 }
                 ModHatch pHatch = new ModHatch
                 {
                     HatchModule = (PartModule)hModules.Current,
                     ClsPart     = hParts.Current
                 };
                 _hatches.Add(pHatch);
             }
         }
         hParts.Dispose();
     }
     catch (Exception ex)
     {
         SMUtils.LogMessage(string.Format("Error in GetHatches().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
     }
 }
Пример #6
0
        internal List <Part> GetDockedVesselParts(DockedVesselInfo vesselInfo)
        {
            List <Part> vesselpartList = new List <Part>();

            try
            {
                if (vesselInfo != null)
                {
                    Part vesselRoot =
                        (from p in Vessel.parts where p.flightID == vesselInfo.rootPartUId select p).SingleOrDefault();
                    if (vesselRoot != null)
                    {
                        //vesselpartList = (from p in Vessel.parts where p.launchID == vesselRoot.launchID select p).ToList();
                        GetChildren(vesselRoot, ref vesselpartList);
                    }
                }
            }
            catch (Exception ex)
            {
                SMUtils.LogMessage(string.Format("Error in GetSelectedVesselParts().\r\nError:  {0}", ex), SMUtils.LogType.Error, true);
                vesselpartList = new List <Part>();
            }
            return(vesselpartList);
        }