diff --git a/FNPlugin/FNModulePreecooler.cs b/FNPlugin/FNModulePreecooler.cs index 27b84b48..64a61ac9 100644 --- a/FNPlugin/FNModulePreecooler.cs +++ b/FNPlugin/FNModulePreecooler.cs @@ -20,9 +20,64 @@ public override void OnStart(PartModule.StartState state) { List mres = attach_node.attachedPart.FindModulesImplementing().Where(mre => mre.resourceName == "IntakeAir").ToList(); if(mres.Count > 0) { attachedIntake = mres.First(); + break; //added by attosecond 3/10/14 -- no need to keep the loop going if we found what we wanted } } } + + /*Added by attosecond 3/10/14. Code checks if this is an "all-in-one" intake + precooler part, also checks + * parts attached to children and parent parts for intakes, on the assumption that the child/parent parts can + * transfer the intake air to the precooler */ + + //first check if this is an all-in-one part + if (attachedIntake == null) + { + List mres = part.FindModulesImplementing().Where(mre => mre.resourceName == "IntakeAir").ToList(); + if (mres.Count > 0) + attachedIntake = mres.First(); + } + + //now check all parts attached to the parent part + if (attachedIntake == null) + { + foreach (AttachNode attach_node in part.parent.attachNodes) + { + if (attach_node.attachedPart != null && attach_node.attachedPart != part) + { + List mres = attach_node.attachedPart.FindModulesImplementing().Where(mre => mre.resourceName == "IntakeAir").ToList(); + if (mres.Count > 0) + { + attachedIntake = mres.First(); + break; + } + } + } + } + + //and do the same for child parts + if (attachedIntake == null) + { + foreach (Part childpart in part.children) + { + foreach (AttachNode attach_node in childpart.attachNodes) + { + if (attach_node.attachedPart != null && attach_node.attachedPart != part) + { + List mres = attach_node.attachedPart.FindModulesImplementing().Where(mre => mre.resourceName == "IntakeAir").ToList(); + if (mres.Count > 0) + { + attachedIntake = mres.First(); + break; + } + } + } + } + } + + /* + * End edits by attosecond + */ + part.force_activate(); }