Skip to content

Update FNModulePrecooler.cs for more functionality #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions FNPlugin/FNModulePreecooler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,64 @@ public override void OnStart(PartModule.StartState state) {
List<ModuleResourceIntake> mres = attach_node.attachedPart.FindModulesImplementing<ModuleResourceIntake>().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<ModuleResourceIntake> mres = part.FindModulesImplementing<ModuleResourceIntake>().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<ModuleResourceIntake> mres = attach_node.attachedPart.FindModulesImplementing<ModuleResourceIntake>().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<ModuleResourceIntake> mres = attach_node.attachedPart.FindModulesImplementing<ModuleResourceIntake>().Where(mre => mre.resourceName == "IntakeAir").ToList();
if (mres.Count > 0)
{
attachedIntake = mres.First();
break;
}
}
}
}
}

/*
* End edits by attosecond
*/

part.force_activate();
}

Expand Down