Converted foreach->for throughout.
Converted foreach->for throughout.

--- a/EVAManager.cs
+++ b/EVAManager.cs
@@ -49,7 +49,7 @@
 		private List<ConfigAction> evaConfigs;
 		private List<ConfigAction> passQueue;
 
-		private Part evaPart;
+		private List<Part> evaParts;
 
 		private Pass pass;
 
@@ -57,6 +57,7 @@
 		{
 			pass = Pass.Collect;
 			this.passQueue = new List<ConfigAction>();
+			this.evaParts = new List<Part>();
 		}
 
 		public virtual void Update()
@@ -77,16 +78,22 @@
 				this.passQueue.Clear();
 			}
 
+			ConfigAction action;
+
 			switch (pass)
 			{
 				case Pass.Collect:
-					foreach (var loadedPart in PartLoader.LoadedPartsList)
-					{
-						if (loadedPart.name.ToLower() == "kerbaleva")
+					AvailablePart loadedPart;
+					for (int idx = 0; idx < PartLoader.LoadedPartsList.Count; idx++)
+					{
+						loadedPart = PartLoader.LoadedPartsList[operatorIdx];
+						string lowerName = loadedPart.name.ToLower();
+
+						if (lowerName == "kerbaleva" || lowerName == "kerbalevafemale")
 						{
 							this.LogDebug("Found {0}", loadedPart.name);
 
-							evaPart = loadedPart.partPrefab;
+							evaParts.Add(loadedPart.partPrefab);
 
 							#if DEBUG
 							log = Tools.DebugLogger.New(this);
@@ -113,7 +120,10 @@
 							log.Print();
 							#endif
 
-							break;
+							if (this.evaParts.Count == 2)
+							{
+								break;
+							}
 						}
 					}
 
@@ -121,8 +131,11 @@
 
 					Regex rgx = new Regex(patchPattern);
 
-					foreach (var urlConfig in GameDatabase.Instance.root.AllConfigs)
-					{
+					UrlDir.UrlConfig urlConfig;
+					IEnumerator<UrlDir.UrlConfig> enumerator = GameDatabase.Instance.root.AllConfigs.GetEnumerator();
+					while (enumerator.MoveNext())
+					{
+						urlConfig = enumerator.Current;
 						Tools.PostDebugMessage(
 							this,
 							"Checking urlconfig; name: {0}, type: {1}, config.name: {2}",
@@ -155,8 +168,9 @@
 					pass = Pass.Delete;
 					break;
 				case Pass.Delete:
-					foreach (ConfigAction action in this.evaConfigs)
-					{
+					for (int idx = 0; idx < this.evaConfigs.Count; idx++)
+					{
+						action = this.evaConfigs[idx];
 						if (action.Operator == "DELETE")
 						{
 							this.LogDebug("Trying delete action on {0}", action);
@@ -170,10 +184,12 @@
 							switch (action.ClassType)
 							{
 								case MODULE:
-									this.delModuleByName(action.MatchName);
+									this.delModuleByName(evaParts[0], action.MatchName);
+									this.delModuleByName(evaParts[1], action.MatchName);
 									break;
 								case RESOURCE:
-									this.delResourceByName(action.MatchName);
+									this.delResourceByName(evaParts[0], action.MatchName);
+									this.delResourceByName(evaParts[1], action.MatchName);
 									break;
 								default:
 									this.LogWarning("Class type '{0}' not implemented for 'delete' action.",
@@ -186,8 +202,9 @@
 					pass = Pass.Edit;
 					break;
 				case Pass.Edit:
-					foreach (ConfigAction action in this.evaConfigs)
-					{
+					for (int idx = 0; idx < this.evaConfigs.Count; idx++)
+					{
+						action = this.evaConfigs[idx];
 						if (action.Operator == "EDIT")
 						{
 							this.LogDebug("Trying edit action on {0}", action);
@@ -201,10 +218,12 @@
 							switch (action.ClassType)
 							{
 								case MODULE:
-									this.editModuleByNameFromConfig(action.MatchName, action.Node);
+									this.editModuleByNameFromConfig(evaParts[0], action.MatchName, action.Node);
+									this.editModuleByNameFromConfig(evaParts[1], action.MatchName, action.Node);
 									break;
 								case RESOURCE:
-									this.editResourceByNameFromConfig(action.MatchName, action.Node);
+									this.editResourceByNameFromConfig(evaParts[0], action.MatchName, action.Node);
+									this.editResourceByNameFromConfig(evaParts[1], action.MatchName, action.Node);
 									break;
 								default:
 									this.LogWarning("Class type '{0}' not implemented for 'delete' action.",
@@ -216,8 +235,9 @@
 					pass = Pass.Insert;
 					break;
 				case Pass.Insert:
-					foreach (ConfigAction action in this.evaConfigs)
-					{
+					for (int idx = 0; idx < this.evaConfigs.Count; idx++)
+					{
+						action = this.evaConfigs[idx];
 						if (action.Operator == empty)
 						{
 							if (action.MatchName != string.Empty)
@@ -229,10 +249,12 @@
 							switch (action.ClassType)
 							{
 								case MODULE:
-									this.addModuleFromConfig(action.Node);
+									this.addModuleFromConfig(evaParts[0], action.Node);
+									this.addModuleFromConfig(evaParts[1], action.Node);
 									break;
 								case RESOURCE:
-									this.addResourceFromConfig(action.Node);
+									this.addResourceFromConfig(evaParts[0], action.Node);
+									this.addResourceFromConfig(evaParts[1], action.Node);
 									break;
 								default:
 									this.LogWarning("Class type '{0}' not implemented for 'add' action.",
@@ -276,7 +298,7 @@
 			}
 		}
 
-		private void addModuleFromConfig(ConfigNode evaModuleNode)
+		private void addModuleFromConfig(Part evaPart, ConfigNode evaModuleNode)
 		{
 			string moduleName;
 
@@ -335,7 +357,7 @@
 			}
 		}
 
-		private void addResourceFromConfig(ConfigNode evaResourceNode)
+		private void addResourceFromConfig(Part evaPart, ConfigNode evaResourceNode)
 		{
 			string resourceName;
 
@@ -382,9 +404,9 @@
 			}
 		}
 
-		private void delModuleByName(string matchName)
-		{
-			PartModule module = this.matchFirstModuleByName(matchName);
+		private void delModuleByName(Part evaPart, string matchName)
+		{
+			PartModule module = this.matchFirstModuleByName(evaPart, matchName);
 
 			if (module != null)
 			{
@@ -392,9 +414,9 @@
 			}
 		}
 
-		private void delResourceByName(string matchName)
-		{
-			PartResource resource = this.matchFirstResourceByName(matchName);
+		private void delResourceByName(Part evaPart, string matchName)
+		{
+			PartResource resource = this.matchFirstResourceByName(evaPart, matchName);
 
 			if (resource != null)
 			{
@@ -407,9 +429,9 @@
 			}
 		}
 
-		private void editModuleByNameFromConfig(string matchName, ConfigNode config)
-		{
-			PartModule module = this.matchFirstModuleByName(matchName);
+		private void editModuleByNameFromConfig(Part evaPart, string matchName, ConfigNode config)
+		{
+			PartModule module = this.matchFirstModuleByName(evaPart, matchName);
 
 			if (module != null)
 			{
@@ -439,9 +461,9 @@
 			}
 		}
 
-		private void editResourceByNameFromConfig(string matchName, ConfigNode config)
-		{
-			PartResource resource = this.matchFirstResourceByName(matchName);
+		private void editResourceByNameFromConfig(Part evaPart, string matchName, ConfigNode config)
+		{
+			PartResource resource = this.matchFirstResourceByName(evaPart, matchName);
 
 			if (resource != null)
 			{
@@ -471,12 +493,15 @@
 			}
 		}
 
-		private PartModule matchFirstModuleByName(string matchName)
+		private PartModule matchFirstModuleByName(Part evaPart, string matchName)
 		{
 			Regex rgx = new Regex(@matchName);
 
-			foreach (PartModule module in evaPart.GetComponents<PartModule>())
-			{
+			PartModule[] modules = evaPart.GetComponents<PartModule>();
+			PartModule module;
+			for (int idx = 0; idx < modules.Length; idx++)
+			{
+				module = modules[idx];
 				Match match = rgx.Match(module.GetType().Name);
 
 				if (match.Success)
@@ -488,12 +513,15 @@
 			return null;
 		}
 
-		private PartResource matchFirstResourceByName(string matchName)
+		private PartResource matchFirstResourceByName(Part evaPart, string matchName)
 		{
 			Regex rgx = new Regex(@matchName);
 
-			foreach (PartResource resource in evaPart.GetComponents<PartResource>())
-			{
+			PartResource[] resources = evaPart.GetComponents<PartResource>();
+			PartResource resource;
+			for (int idx = 0; idx < resources.Length; idx++)
+			{
+				resource = resources[idx];
 				Match match = rgx.Match(resource.resourceName);
 
 				Tools.PostDebugMessage(
@@ -515,8 +543,10 @@
 		{
 			bool success = true;
 
-			foreach (ConfigNode.Value cfgValue in config.values)
-			{
+			ConfigNode.Value cfgValue;
+			for (int idx = 0; idx < config.values.Count; idx++)
+			{
+				cfgValue = config.values[idx];
 				try
 				{
 					var namedField = obj.GetType().GetField(cfgValue.name,
@@ -565,8 +595,10 @@
 
 		private ConfigNode mergeConfigs(ConfigNode source, ConfigNode target)
 		{
-			foreach (ConfigNode.Value value in target.values)
-			{
+			ConfigNode.Value value;
+			for (int idx = 0; idx < target.values.Count; idx++)
+			{
+				value = target.values[idx];
 				if (source.HasValue(value.name))
 				{
 					source.RemoveValue(value.name);
@@ -600,14 +632,22 @@
 
 			source.AddValue("name", module.GetType().Name);
 
-			foreach (var field in module.GetType().GetFields(
+			System.Reflection.FieldInfo[] fieldInfos = module.GetType().GetFields(
 				System.Reflection.BindingFlags.Public |
 				System.Reflection.BindingFlags.NonPublic |
 				System.Reflection.BindingFlags.Instance
-			))
-			{
-				foreach (object attr in field.GetCustomAttributes(true))
-				{
+			);
+			System.Reflection.FieldInfo field;
+			for (int fIdx = 0; fIdx < fieldInfos.Length; fIdx++)
+			{
+				field = fieldInfos[fIdx];
+
+				object[] attrs = field.GetCustomAttributes(true);
+				object attr;
+				for (int aIdx = 0; aIdx < attrs.Length; aIdx++)
+				{
+					attr = attrs[aIdx];
+
 					if (attr is KSPField)
 					{
 						source.AddValue(field.Name, field.GetValue(module));

--- a/EVAManager.csproj
+++ b/EVAManager.csproj
@@ -23,7 +23,6 @@
     <ConsolePause>false</ConsolePause>
     <CustomCommands>
       <CustomCommands>
-        <Command type="AfterBuild" command="xcopy /y ${ProjectDir}\EVAManager.cfg ${ProjectDir}\GameData\EVAManager\" />
         <Command type="AfterBuild" command="xcopy /y ${TargetFile} ${ProjectDir}\GameData\EVAManager\" />
       </CustomCommands>
     </CustomCommands>
@@ -38,7 +37,6 @@
     <CustomCommands>
       <CustomCommands>
         <Command type="AfterBuild" command="xcopy /y ${TargetFile} ${ProjectDir}\GameData\EVAManager\" />
-        <Command type="AfterBuild" command="xcopy /y ${ProjectDir}\EVAManager.cfg ${ProjectDir}\GameData\EVAManager\" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
@@ -51,7 +49,7 @@
     <ConsolePause>false</ConsolePause>
     <CustomCommands>
       <CustomCommands>
-        <Command type="AfterBuild" command="cp -vfa ${ProjectDir}/EVAManager.cfg ${TargetFile} ${ProjectDir}/GameData/EVAManager/" />
+        <Command type="AfterBuild" command="cp -vfa ${TargetFile} ${ProjectDir}/GameData/EVAManager/" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
@@ -66,7 +64,7 @@
     <ConsolePause>false</ConsolePause>
     <CustomCommands>
       <CustomCommands>
-        <Command type="AfterBuild" command="cp -vfa ${ProjectDir}/EVAManager.cfg ${TargetFile} ${ProjectDir}/GameData/EVAManager/" />
+        <Command type="AfterBuild" command="cp -vfa ${TargetFile} ${ProjectDir}/GameData/EVAManager/" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
@@ -102,6 +100,9 @@
     </MonoDevelop>
   </ProjectExtensions>
   <ItemGroup>
-    <None Include="GameData\EVAManager\EVAManager.cfg" />
+    <Folder Include="GameData\EVAManager\" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="GameData\EVAManager\EVAManager.cfg.example" />
   </ItemGroup>
 </Project>

--- a/GameData/EVAManager/EVAManager.cfg
+++ /dev/null
@@ -1,74 +1,1 @@
-// EVAManager
-//
-// EVAPartModule.cfg
-//
-// Copyright © 2014, toadicus
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-//    this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation and/or other
-//    materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-DELETE_EVA_RESOURCE[EVA\sPropellant] {}
-
-EVA_RESOURCE
-{
-	name = EVA Propellant
-	amount = 0
-	maxAmount = 5
-}
-
-@PART[*]:HAS[#CrewCapacity[1]]
-{
-	RESOURCE
-	{
-		name = EVA Propellant
-		amount = 5
-		maxAmount = 5
-	}
-}
-
-@PART[*]:HAS[#CrewCapacity[2]]
-{
-	RESOURCE
-	{
-		name = EVA Propellant
-		amount = 10
-		maxAmount = 10
-	}
-}
-
-@PART[*]:HAS[#CrewCapacity[3]]
-{
-	RESOURCE
-	{
-		name = EVA Propellant
-		amount = 15
-		maxAmount = 15
-	}
-}
-
-@PART[*]:HAS[#CrewCapacity[4]]
-{
-	RESOURCE
-	{
-		name = EVA Propellant
-		amount = 20
-		maxAmount = 20
-	}
-}
-

--- /dev/null
+++ b/GameData/EVAManager/EVAManager.cfg.example
@@ -1,1 +1,55 @@
+// EVAManager
+//
+// EVAManager.cfg
+//
+// Copyright © 2014, toadicus
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+//    this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation and/or other
+//    materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+// This is a fun proof-of-concept patch set that adds EVA Propellant to parts that house Kerbals.  This requires you to
+// ration EVA fuel over the course of a mission inside of individual jaunts.  If you like the idea, rename this file to
+// remove the .example extension!
+
+DELETE_EVA_RESOURCE[EVA\sPropellant] {}
+
+EVA_RESOURCE
+{
+	name = EVA Propellant
+	amount = 0
+	maxAmount = 5
+}
+
+@PART[*]:HAS[#CrewCapacity[>0]]
+{
+	RESOURCE
+	{
+		name = EVA Propellant
+		amount = 5
+		@amount *= #$/CrewCapacity$
+		maxAmount = 5
+		@maxAmount *= #$/CrewCapacity$
+	}
+}
+
+@RESOURCE_DEFINITION[EVA*Propellant]
+{
+	@density = 0.000807
+}
+

 Binary files a/GameData/EVAManager/EVAManager.dll and /dev/null differ