ModuleTweakableDockingNode: Added support for tweaking minRollDot for acquire and capture.
ModuleTweakableDockingNode: Added support for tweaking minRollDot for acquire and capture.

--- a/TweakableDockingNode/ModuleTweakableDockingNode.cs
+++ b/TweakableDockingNode/ModuleTweakableDockingNode.cs
@@ -34,11 +34,7 @@
 
 namespace TweakableEverything
 {
-	#if DEBUG
-	public class ModuleTweakableDockingNode : DebugPartModule
-	#else
 	public class ModuleTweakableDockingNode : PartModule
-	#endif
 	{
 		/*
 		 * Ctor
@@ -58,7 +54,8 @@
 			this.undockEjectionForce = -1;
 			this.minDistanceToReEngage = -1;
 
-			this.maxRollAngle = 90f;
+			this.maxCaptureRollAngle = 90f;
+			this.maxAcquireRollAngle = 90f;
 		}
 
 		/*
@@ -83,22 +80,39 @@
 		[KSPField(isPersistant = false)]
 		public bool AlwaysAllowStack;
 
-		[KSPField(isPersistant = true)]
-		public float minRollDotProduct;
+		[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true)]
+		public float minCaptureRollDotProduct;
 
 		/// <summary>
-		/// Maximum roll angle of separation for docking, in degrees.
+		/// Maximum roll angle of separation for docking capture, in degrees.
 		/// </summary>
 		[KSPField(
 			isPersistant = false,
-			guiName = "Maximum Roll Angle",
+			guiName = "Max Capture Roll Angle",
 			guiUnits = "°", guiFormat = "F0",
 			guiActive = true, guiActiveEditor = true
 		)]
 		[UI_FloatRange(minValue = 0, maxValue = 90, stepIncrement = 5f, scene = UI_Scene.Editor)]
-		public float maxRollAngle;
-
-		public float lastMaxRollAngle;
+		public float maxCaptureRollAngle;
+
+		public float lastMaxCaptureRollAngle;
+
+		[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true)]
+		public float minAcquireRollDotProduct;
+
+		/// <summary>
+		/// Maximum roll angle of separation for docking acquisition, in degrees.
+		/// </summary>
+		[KSPField(
+			isPersistant = false,
+			guiName = "Max Acquire Roll Angle",
+			guiUnits = "°", guiFormat = "F0",
+			guiActive = true, guiActiveEditor = true
+		)]
+		[UI_FloatRange(minValue = 0, maxValue = 90, stepIncrement = 5f, scene = UI_Scene.Editor)]
+		public float maxAcquireRollAngle;
+
+		public float lastMaxAcquireRollAngle;
 
 		// Stores the open/closed state of the shield.
 		protected bool lastOpenState;
@@ -190,24 +204,12 @@
 		// Runs when each new part is started.
 		public override void OnStart(StartState st)
 		{
-			this.dockingNodeModule = (ModuleDockingNode)base.part.Modules["ModuleDockingNode"];
-
-			PartModule needle;
-
-			for (int idx = 0; idx < base.part.Modules.Count; idx++)
-			{
-				needle = base.part.Modules[idx];
-
-				if (needle is ModuleAnimateGeneric)
-				{
-					if (((ModuleAnimateGeneric)needle).animationName == this.deployAnimationControllerName)
-					{
-						this.deployAnimation = (ModuleAnimateGeneric)needle;
-						break;
-					}
-				}
-			}
-
+			if (!this.part.tryGetFirstModuleOfType<ModuleDockingNode>(out this.dockingNodeModule))
+			{
+				return;
+			}
+
+			this.deployAnimation = this.part.getFirstModuleOfType<ModuleAnimateGeneric>();
 			// If we've loaded a deployAnimationControllerName from the cfg...
 
 			// Start the underlying ModuleDockingNode.
@@ -251,13 +253,20 @@
 				prefabModule.minDistanceToReEngage
 			);
 
-			this.Fields["maxRollAngle"].uiControlFlight.controlEnabled = false;
-
-			this.maxRollAngle = Mathf.Acos(this.minRollDotProduct) * 180f / Mathf.PI;
-			this.dockingNodeModule.acquireMinRollDot = this.minRollDotProduct * this.minRollDotProduct;
-			this.dockingNodeModule.captureMinRollDot = this.minRollDotProduct;
-
-			this.lastMaxRollAngle = this.maxRollAngle;
+			this.Fields["maxCaptureRollAngle"].uiControlFlight.controlEnabled = false;
+			this.Fields["maxAcquireRollAngle"].uiControlFlight.controlEnabled = false;
+
+			this.maxCaptureRollAngle = Mathf.Acos(this.minCaptureRollDotProduct) * 180f / Mathf.PI;
+			this.dockingNodeModule.captureMinRollDot = Mathf.Min(this.minCaptureRollDotProduct, 0.99995f);
+
+			this.maxAcquireRollAngle = Mathf.Acos(this.minAcquireRollDotProduct) * 180f / Mathf.PI;
+			this.dockingNodeModule.acquireMinRollDot = Mathf.Min(this.minAcquireRollDotProduct, 0.99995f);
+
+			this.dockingNodeModule.Fields["captureMinRollDot"].guiActive = true;
+			this.dockingNodeModule.Fields["captureMinRollDot"].guiActiveEditor = true;
+
+			this.lastMaxCaptureRollAngle = this.maxCaptureRollAngle;
+			this.lastMaxAcquireRollAngle = this.maxAcquireRollAngle;
 
 			// If we have a tweakable AttachNode, use it.
 			if (this.TDNnodeName != string.Empty)
@@ -335,12 +344,23 @@
 					}
 				}
 
-				if (this.maxRollAngle != this.lastMaxRollAngle)
-				{
-					this.minRollDotProduct = Mathf.Cos(this.maxRollAngle * Mathf.PI / 180f);
-					this.dockingNodeModule.acquireMinRollDot = this.minRollDotProduct * this.minRollDotProduct;
-					this.dockingNodeModule.captureMinRollDot = this.minRollDotProduct;
-					this.lastMaxRollAngle = this.maxRollAngle;
+				if (this.maxCaptureRollAngle != this.lastMaxCaptureRollAngle)
+				{
+					this.minCaptureRollDotProduct = Mathf.Cos(this.maxCaptureRollAngle * Mathf.PI / 180f);
+					this.dockingNodeModule.captureMinRollDot = this.minCaptureRollDotProduct;
+					this.lastMaxCaptureRollAngle = this.maxCaptureRollAngle;
+				}
+
+				if (this.maxCaptureRollAngle > this.maxAcquireRollAngle)
+				{
+					this.maxAcquireRollAngle = this.maxCaptureRollAngle;
+				}
+
+				if (this.maxAcquireRollAngle != this.lastMaxAcquireRollAngle)
+				{
+					this.minAcquireRollDotProduct = Mathf.Cos(this.maxAcquireRollAngle * Mathf.PI / 180f);
+					this.dockingNodeModule.acquireMinRollDot = this.minAcquireRollDotProduct;
+					this.lastMaxAcquireRollAngle = this.maxAcquireRollAngle;
 				}
 			}