コード例 #1
0
 static public void UpdateChildren(Part p, string recoveryOwner, bool entireVessel = false)
 {
     foreach (Part child in p.children)
     {
         if (!idUtil.IsDecoupler(child))
         {
             ControllingRecoveryModule crm = child.FindModuleImplementing <ControllingRecoveryModule>();
             if (crm == null)
             {
                 Log.Info("Missing module ControllingRecoveryModule");
             }
             crm.RecoveryOwner = recoveryOwner;
             UpdateChildren(child, recoveryOwner, entireVessel);
         }
         else
         {
             if (entireVessel)
             {
                 // get child, and call using child and it's recoveryOwner
                 RecoveryIDModule ridm = child.FindModuleImplementing <RecoveryIDModule>();
                 UpdateChildren(child, ridm.RecoveryOwner, true);
             }
         }
     }
 }
コード例 #2
0
 void onVesselLoaded(Vessel v)
 {
     Log.dbg("onVesselLoaded");
     if (v == null || v.rootPart == null)
     {
         return;
     }
     if (!registeredMods.Contains("StageRecovery"))
     {
         return;
     }
     if (!idUtil.IsDecoupler(v.rootPart))
     {
         ControllingRecoveryModule m = v.rootPart.FindModuleImplementing <ControllingRecoveryModule>();
         if (m != null)
         {
             idUtil.UpdateChildren(v.rootPart, m.RecoveryOwner, true);
         }
     }
     else
     {
         RecoveryIDModule m = v.rootPart.FindModuleImplementing <RecoveryIDModule>();
         if (m != null)
         {
             idUtil.UpdateChildren(v.rootPart, m.RecoveryOwner, true);
         }
     }
 }
コード例 #3
0
 void onVesselWasModified(Vessel v)
 {
     Log.dbg("onVesselWasModified");
     if (!idUtil.IsDecoupler(v.rootPart))
     {
         ControllingRecoveryModule m = v.rootPart.FindModuleImplementing <ControllingRecoveryModule>();
         if (m != null)
         {
             idUtil.UpdateChildren(v.rootPart, m.RecoveryOwner, true);
         }
     }
     else
     {
         RecoveryIDModule m = v.rootPart.FindModuleImplementing <RecoveryIDModule>();
         idUtil.UpdateChildren(v.rootPart, v.rootPart.FindModuleImplementing <RecoveryIDModule>().RecoveryOwner, true);
     }
 }
コード例 #4
0
 void UpdateEventsAndSymmetry(bool updateSym = false)
 {
     if (HighLogic.LoadedSceneIsEditor | HighLogic.LoadedSceneIsFlight)
     {
         Events["CycleRecoveryOwner"].guiName = "RecoveryOwner: " + RecoveryOwner;
         if (updateSym)
         {
             if (this.part.symmetryCounterparts.Count > 0)
             {
                 foreach (var p in this.part.symmetryCounterparts)
                 {
                     RecoveryIDModule ridm = p.FindModuleImplementing <RecoveryIDModule>();
                     ridm.updateRecoveryOwner(RecoveryOwner);
                 }
             }
         }
         UpdateChildren(part);
     }
 }
コード例 #5
0
 void getNextSeparator()
 {
     Log.Info("RecoveryIDVesselModule: getNextSeparator, vessel: " + v.name + "   currentStage: " + v.currentStage.ToString() + "   last stage: " + v.currentStage.ToString());
     foreach (Part p in v.Parts)
     {
         if (p.inverseStage >= v.currentStage - 1)
         {
             if (idUtil.IsDecoupler(p))
             {
                 RecoveryIDModule m = p.FindModuleImplementing <RecoveryIDModule>();
                 if (m != null)
                 {
                     recoveryOwner = m.RecoveryOwner;
                     return;
                 }
             }
         }
     }
 }
コード例 #6
0
        public string ControllingMod(Vessel v)
        {
            if (v.name.StartsWith("Ast."))
            {
                Log.Info("Vessel: Asteroid");
                return("");
            }

            Log.Info("ControllingMod, vessel: " + v.name);
            if (!v.loaded)
            {
                Log.Info("Vessel is unloaded");
                foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots)
                {
                    Log.Info("ProtoPartsnapshot, currentStage: " + v.currentStage.ToString() + "  stageIndex: " + p.stageIndex.ToString() + "  inverseStageIndex: " + p.inverseStageIndex.ToString());
                    if (p.inverseStageIndex >= v.currentStage - 1)
                    {
                        if (idUtil.IsDecoupler(p))
                        {
                            ProtoPartModuleSnapshot m = p.modules.FirstOrDefault(mod => mod.moduleName == "RecoveryIDModule");

                            // FindModuleImplementing<RecoveryIDModule>();
                            if (m != null /*&& m.moduleRef != null */)
                            {
                                Log.Info("Part: " + p.partInfo.name + ", decoupler, Returning: " + m.moduleValues.GetValue("recoveryOwner"));
                                return(m.moduleValues.GetValue("recoveryOwner"));
                                //return ((RecoveryIDModule)m.moduleRef).RecoveryOwner;
                            }
                        }
                        else
                        {
                            if (p.modules.Count > 0)
                            {
                                {
                                    ProtoPartModuleSnapshot m = p.modules.FirstOrDefault(mod => mod.moduleName == "ControllingRecoveryModule");
                                    if (m != null /* && m.moduleRef != null */)
                                    {
                                        Log.Info("Part: " + p.partInfo.name + ", part,  Returning: " + m.moduleValues.GetValue("recoveryOwner"));
                                        return(m.moduleValues.GetValue("recoveryOwner"));
                                        //return ((RecoveryIDModule)m.moduleRef).RecoveryOwner;
                                    }
                                }
                            }
                            else
                            {
                                Log.Info("ControllingRecoveryModule not found");
                                return("ControllingRecoveryModule not found");
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Part p in v.Parts)
                {
                    if (p.inverseStage >= v.currentStage - 1)
                    {
                        if (idUtil.IsDecoupler(p))
                        {
                            RecoveryIDModule m = p.FindModuleImplementing <RecoveryIDModule>();
                            if (m != null)
                            {
                                Log.Info("Part: " + p.partInfo.name + ", Returning: " + m.RecoveryOwner);
                                return(m.RecoveryOwner);
                            }
                        }
                        else
                        {
                            ControllingRecoveryModule m = p.FindModuleImplementing <ControllingRecoveryModule>();
                            if (m != null)
                            {
                                Log.Info("Part: " + p.partInfo.name + ", Returning: " + m.RecoveryOwner);
                                return(m.RecoveryOwner);
                            }
                        }
                    }
                }
            }
            Log.Info("returning null");
            return(null);
        }