Version 1.6
Version 1.6

file:b/.gitattributes (new)
--- /dev/null
+++ b/.gitattributes
@@ -1,1 +1,13 @@
+* text=auto
+* eol=lf
 
+# These files are text and should be normalized (convert crlf => lf)
+*.cs      text diff=csharp
+*.cfg     text
+*.csproj  text eol=crlf
+*.sln     text eol=crlf
+
+# Images should be treated as binary
+# (binary is a macro for -text -diff)
+*.png     binary
+

--- a/GameData/QuantumStrutsContinued/Parts/QuantumStruts/quantumStrut/part.cfg
+++ b/GameData/QuantumStrutsContinued/Parts/QuantumStruts/quantumStrut/part.cfg
@@ -76,9 +76,10 @@
 		StartColor = 57, 146, 181
 		EndColor = 11, 29, 36
 		StartSize = 0.03
-		EndSize = 0.0025
+		EndSize = 0.015
 
 		Start = 0,0,0
 		Dir = 0,1,0
 	}
 }
+

--- a/GameData/QuantumStrutsContinued/Parts/QuantumStruts/strutGun/part.cfg
+++ b/GameData/QuantumStrutsContinued/Parts/QuantumStruts/strutGun/part.cfg
@@ -82,3 +82,4 @@
 		Dir = 0,1,0
 	}
 }
+

--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -57,5 +57,5 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.4.*")]
+[assembly: AssemblyVersion("1.6.*")]
 

--- a/QuantumStrut.cs
+++ b/QuantumStrut.cs
@@ -26,8 +26,6 @@
 // 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.
-
-#define DEBUG
 
 using KSP;
 using System;
@@ -42,7 +40,6 @@
 		Strut strut = null;
 		GameObject lineObj;
 		LineRenderer lr;
-		bool Editor = false;
 		int I = 0;
 
 		#region Fields
@@ -66,7 +63,14 @@
 		[KSPField(isPersistant = false)]
 		public float StartSize = 0.03f;
 		[KSPField(isPersistant = false)]
-		public float EndSize = 0.0075f;
+		public float EndSize = 0.015f;
+
+		[KSPField(
+			isPersistant = false, guiActiveEditor = true,
+			guiName = "Max. Strut Length", guiUnits = "m", guiFormat = "F0"
+		)]
+		[UI_FloatRange(minValue = 2f, maxValue = 50f, stepIncrement = 2f)]
+		public float MaxStrutLength = 10f;
 
 		#endregion
 
@@ -185,21 +189,19 @@
 
 			if (!Util.isValid(LaserMaterial))
 				LaserMaterial = new Material(Shader.Find("Particles/Additive"));
-
-			if (state == StartState.Docked)
-				CheckHit();
-
-			if (state == StartState.Editor)
-			{
-				Editor = true;
-				RenderingManager.AddToPostDrawQueue(0, DrawBuildOverlay);
-				InitLaser();
-			}
-			else
-			{
-				Editor = false;
-				RenderingManager.RemoveFromPostDrawQueue(0, DrawBuildOverlay);
-				DestroyLaser();
+			
+			switch (state)
+			{
+				case StartState.Editor:
+					InitLaser();
+					break;
+				case StartState.Docked:
+					CheckHit();
+					DestroyLaser();
+					break;
+				default:
+					DestroyLaser();
+					break;
 			}
 
 			base.OnStart(state);
@@ -208,6 +210,24 @@
 		public override bool IsStageable()
 		{
 			return false;
+		}
+
+		public void Update()
+		{
+			if (strut != null && !strut.isDestroyed)
+			{
+				if (PowerConsumption == 0 || (Util.GetEnergy(part.vessel) > PowerConsumption * TimeWarp.fixedDeltaTime && part.RequestResource(
+					"ElectricCharge",
+					PowerConsumption * TimeWarp.fixedDeltaTime
+				) > 0))
+				{
+					strut.Update();
+				}
+				else
+				{
+					strut.Destroy();
+				}
+			}
 		}
 
 		public void FixedUpdate()
@@ -219,17 +239,7 @@
 			{
 				I = I + 1 % 255;
 
-				if (strut != null && !strut.isDestroyed)
-				{
-					if (PowerConsumption == 0 || (Util.GetEnergy(part.vessel) > PowerConsumption * TimeWarp.fixedDeltaTime && part.RequestResource(
-						    "ElectricCharge",
-						    PowerConsumption * TimeWarp.fixedDeltaTime
-					    ) > 0))
-						strut.Update();
-					else
-						strut.Destroy();
-				}
-				else
+				if (strut == null || strut.isDestroyed)
 				{
 					if ((I % 10) == 0)
 					{
@@ -249,6 +259,23 @@
 			base.OnUpdate();
 		}
 
+		public void OnGUI()
+		{
+			if (HighLogic.LoadedSceneIsEditor && Util.isValid(part))
+			{
+				this.DrawBuildOverlay();
+			}
+			else
+			{
+				DestroyLaser();
+			}
+		}
+
+		public void OnDestroy()
+		{
+			DestroyLaser();
+		}
+
 		void CheckHit()
 		{
 			if (HighLogic.LoadedSceneIsEditor)
@@ -280,7 +307,7 @@
 				Logging.PostDebugMessage(this, "Got transforms.  Checking for raycast hit.");
 
 				UnityEngine.RaycastHit info = new RaycastHit();
-				bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, 10);
+				bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, MaxStrutLength);
 
 				if (hit)
 				{
@@ -329,7 +356,7 @@
 				lineObj = new GameObject();
 
 				lr = lineObj.AddComponent<LineRenderer>();
-				lr.useWorldSpace = true;
+				lr.useWorldSpace = false;
 
 				lr.material = material;
 				lr.SetColors(startColor, endColor);
@@ -338,7 +365,7 @@
 				lr.SetVertexCount(2);
 				lr.SetPosition(0, Vector3.zero);
 				lr.SetPosition(1, Vector3.zero);
-				lr.castShadows = false;
+				lr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
 				lr.receiveShadows = true;
 			}
 		}
@@ -354,44 +381,33 @@
 
 		public void DrawBuildOverlay()
 		{
-			if (Util.isValid(part))
-			{
-				if (!Editor)
-					return;
-
-				if (Util.isValid(lr))
-				{
-					Vector3 dir = getTransform().TransformDirection(Dir);
-					Vector3 start = getTransform().TransformPoint(Start);
-
-					UnityEngine.RaycastHit info = new RaycastHit();
-					bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, 10);
-					if (hit && IsEnabled)
-					{
-						if (Util.isValid(material))
-							lr.material = material;
-
-						lr.SetColors(startColor, endColor);
-						lr.SetWidth(StartSize, EndSize);
-
-						lr.SetPosition(0, start);
-						lr.SetPosition(1, info.point);
-					}
-					else
-					{
-						lr.material = LaserMaterial;
-						lr.SetColors(Color.red, Color.red);
-						lr.SetWidth(0.01f, 0.01f);
-
-						lr.SetPosition(0, start);
-						lr.SetPosition(1, start + (dir * 10));
-					}
-				}
-			}
-			else
-			{
-				DestroyLaser();
-				RenderingManager.RemoveFromPostDrawQueue(0, DrawBuildOverlay);
+			if (Util.isValid(lr))
+			{
+				Vector3 dir = getTransform().TransformDirection(Dir);
+				Vector3 start = getTransform().TransformPoint(Start);
+
+				UnityEngine.RaycastHit info = new RaycastHit();
+				bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, MaxStrutLength);
+				if (hit && IsEnabled)
+				{
+					if (Util.isValid(material))
+						lr.material = material;
+
+					lr.SetColors(startColor, endColor);
+					lr.SetWidth(StartSize, EndSize);
+
+					lr.SetPosition(0, start);
+					lr.SetPosition(1, info.point);
+				}
+				else
+				{
+					lr.material = LaserMaterial;
+					lr.SetColors(Color.red, Color.red);
+					lr.SetWidth(0.01f, 0.01f);
+
+					lr.SetPosition(0, start);
+					lr.SetPosition(1, start + (dir * MaxStrutLength));
+				}
 			}
 		}
 	}

--- a/QuantumStrutsContinued.csproj
+++ b/QuantumStrutsContinued.csproj
@@ -135,6 +135,12 @@
       <HintPath>..\_KSPAssemblies\UnityEngine.dll</HintPath>
       <Private>False</Private>
     </Reference>
+    <Reference Include="KSPUtil">
+      <HintPath>..\_KSPAssemblies\KSPUtil.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEngine.UI">
+      <HintPath>..\_KSPAssemblies\UnityEngine.UI.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <None Include="GameData\QuantumStrutsContinued\Parts\QuantumStruts\quantumStrut\part.cfg" />

file:a/Strut.cs -> file:b/Strut.cs
--- a/Strut.cs
+++ b/Strut.cs
@@ -149,7 +149,7 @@
 			if (parent.vessel.parts.Contains(target))
 			{
 				joint = parent.parent.gameObject.AddComponent<ConfigurableJoint>();
-				joint.connectedBody = target.rigidbody;
+				joint.connectedBody = target.Rigidbody;
 
 				joint.anchor = new Vector3(
 					0,
@@ -171,7 +171,7 @@
 				LineObj.name = "quantumstrut";
 
 				lr = LineObj.AddComponent<LineRenderer>();
-				lr.useWorldSpace = true;
+				lr.useWorldSpace = false;
 
 				Material = QuantumStrut.LaserMaterial;
 				StartColor = Color.white;