Merge remote-tracking branch 'upstream/master' into for105
Merge remote-tracking branch 'upstream/master' into for105

 Binary files a/Assets/Plugins/KerbalEngineer.Unity.dll and b/Assets/Plugins/KerbalEngineer.Unity.dll differ
--- a/Assets/Prefabs/FlightMenu.prefab
+++ b/Assets/Prefabs/FlightMenu.prefab
@@ -354,8 +354,8 @@
   m_Transition: 1
   m_Colors:
     m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
-    m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
-    m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
+    m_HighlightedColor: {r: .467545569, g: 1, b: .448529422, a: 1}
+    m_PressedColor: {r: .800000072, g: 1, b: 0, a: 1}
     m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
     m_ColorMultiplier: 1
     m_FadeDuration: .100000001
@@ -377,7 +377,7 @@
     m_PersistentCalls:
       m_Calls:
       - m_Target: {fileID: 11415294}
-        m_MethodName: SetControlBar
+        m_MethodName: SetControlBarVisible
         m_Mode: 0
         m_Arguments:
           m_ObjectArgument: {fileID: 0}
@@ -445,8 +445,8 @@
   m_Transition: 1
   m_Colors:
     m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
-    m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
-    m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
+    m_HighlightedColor: {r: .467545569, g: 1, b: .448529422, a: 1}
+    m_PressedColor: {r: .800000072, g: 1, b: 0, a: 1}
     m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
     m_ColorMultiplier: 1
     m_FadeDuration: .100000001
@@ -812,8 +812,8 @@
   m_Transition: 1
   m_Colors:
     m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
-    m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
-    m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
+    m_HighlightedColor: {r: .467545569, g: 1, b: .448529422, a: 1}
+    m_PressedColor: {r: .800000072, g: 1, b: 0, a: 1}
     m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
     m_ColorMultiplier: 1
     m_FadeDuration: .100000001
@@ -835,7 +835,7 @@
     m_PersistentCalls:
       m_Calls:
       - m_Target: {fileID: 11415294}
-        m_MethodName: SetShowEngineer
+        m_MethodName: SetDisplayStackVisible
         m_Mode: 0
         m_Arguments:
           m_ObjectArgument: {fileID: 0}
@@ -1269,7 +1269,7 @@
       objectReference: {fileID: 0}
     - target: {fileID: 0}
       propertyPath: m_SlowFadeDuration
-      value: .300000012
+      value: .200000003
       objectReference: {fileID: 0}
     - target: {fileID: 0}
       propertyPath: m_ContentTransform

--- a/Assets/Prefabs/FlightMenuSection.prefab
+++ b/Assets/Prefabs/FlightMenuSection.prefab
@@ -202,8 +202,8 @@
   m_Transition: 1
   m_Colors:
     m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
-    m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
-    m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
+    m_HighlightedColor: {r: .467545569, g: 1, b: .448529422, a: 1}
+    m_PressedColor: {r: .800000072, g: 1, b: 0, a: 1}
     m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
     m_ColorMultiplier: 1
     m_FadeDuration: .100000001
@@ -276,8 +276,8 @@
   m_Transition: 1
   m_Colors:
     m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
-    m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
-    m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
+    m_HighlightedColor: {r: .467545569, g: 1, b: .448529422, a: 1}
+    m_PressedColor: {r: .800000072, g: 1, b: 0, a: 1}
     m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
     m_ColorMultiplier: 1
     m_FadeDuration: .100000001
@@ -651,6 +651,42 @@
       propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
       value: SetEditorVisible
       objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_NormalColor.r
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_NormalColor.b
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_HighlightedColor.r
+      value: .467545569
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_HighlightedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_HighlightedColor.b
+      value: .448529422
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_NormalColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_PressedColor.r
+      value: .800000072
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_PressedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 0}
+      propertyPath: m_Colors.m_PressedColor.b
+      value: 0
+      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_ParentPrefab: {fileID: 0}
   m_RootGameObject: {fileID: 130812}

--- a/Assets/Scenes/main.unity
+++ b/Assets/Scenes/main.unity
@@ -347,9 +347,65 @@
       propertyPath: m_SizeDelta.y
       value: 54
       objectReference: {fileID: 0}
-    - target: {fileID: 11465882, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
-      propertyPath: m_Text
-      value: NEW CUSTOM SECTION
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
+      value: SetControlBarVisible
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: onValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
+      value: SetDisplayStackVisible
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.r
+      value: .467545569
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.b
+      value: .448529422
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.r
+      value: .800000072
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.b
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 11485338, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.a
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.r
+      value: .467545569
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_HighlightedColor.b
+      value: .448529422
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.r
+      value: .800000072
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.g
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 11415068, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}
+      propertyPath: m_Colors.m_PressedColor.b
+      value: 0
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_ParentPrefab: {fileID: 100100000, guid: a41f85cb0b8964f43947e85b3e833c0f, type: 2}

--- a/KerbalEngineer.Unity/CanvasGroupFader.cs
+++ b/KerbalEngineer.Unity/CanvasGroupFader.cs
@@ -28,7 +28,7 @@
         private CanvasGroup m_CanvasGroup;
         private IEnumerator m_FadeCoroutine;
 
-        public bool fading
+        public bool IsFading
         {
             get
             {
@@ -88,6 +88,9 @@
         /// </summary>
         private IEnumerator FadeCoroutine(float from, float to, float duration, Action callback)
         {
+            // wait for end of frame so that only the last call to fade that frame is honoured.
+            yield return new WaitForEndOfFrame();
+
             float progress = 0.0f;
 
             while (progress <= 1.0f)

--- a/KerbalEngineer.Unity/Flight/FlightMenu.cs
+++ b/KerbalEngineer.Unity/Flight/FlightMenu.cs
@@ -45,7 +45,6 @@
         private float m_SlowFadeDuration = 1.0f;
 
         private IFlightAppLauncher m_FlightAppLauncher;
-
         private RectTransform m_RectTransform;
 
         public void OnPointerEnter(PointerEventData eventData)
@@ -56,7 +55,7 @@
         public void OnPointerExit(PointerEventData eventData)
         {
             // slow-fade out if the application launcher button is off
-            if (m_FlightAppLauncher != null && m_FlightAppLauncher.isOn == false)
+            if (m_FlightAppLauncher != null && m_FlightAppLauncher.IsOn == false)
             {
                 FadeTo(0.0f, m_SlowFadeDuration, Destroy);
             }
@@ -92,11 +91,22 @@
         /// <summary>
         ///     Sets the control bar visiblity.
         /// </summary>
-        public void SetControlBar(bool visible)
+        public void SetControlBarVisible(bool visible)
         {
             if (m_FlightAppLauncher != null)
             {
-                m_FlightAppLauncher.controlBar = visible;
+                m_FlightAppLauncher.IsControlBarVisible = visible;
+            }
+        }
+
+        /// <summary>
+        ///     Sets the display stack visibility.
+        /// </summary>
+        public void SetDisplayStackVisible(bool visible)
+        {
+            if (m_FlightAppLauncher != null)
+            {
+                m_FlightAppLauncher.IsDisplayStackVisible = visible;
             }
         }
 
@@ -117,17 +127,6 @@
             CreateSectionControls(m_FlightAppLauncher.GetCustomSections());
         }
 
-        /// <summary>
-        ///     Sets the display stack visibility.
-        /// </summary>
-        public void SetShowEngineer(bool visible)
-        {
-            if (m_FlightAppLauncher != null)
-            {
-                m_FlightAppLauncher.showEngineer = visible;
-            }
-        }
-
         protected override void Awake()
         {
             base.Awake();
@@ -151,8 +150,8 @@
             }
 
             // set toggle states to match the actual states
-            SetToggle(m_ShowEngineerToggle, m_FlightAppLauncher.showEngineer);
-            SetToggle(m_ControlBarToggle, m_FlightAppLauncher.controlBar);
+            SetToggle(m_ShowEngineerToggle, m_FlightAppLauncher.IsDisplayStackVisible);
+            SetToggle(m_ControlBarToggle, m_FlightAppLauncher.IsControlBarVisible);
 
             // update anchor position
             if (m_RectTransform != null)

--- a/KerbalEngineer.Unity/Flight/FlightMenuSection.cs
+++ b/KerbalEngineer.Unity/Flight/FlightMenuSection.cs
@@ -37,7 +37,7 @@
         /// <summary>
         ///     Gets or sets the section's editor visibility.
         /// </summary>
-        public bool editorVisible
+        public bool IsEditorVisible
         {
             get
             {
@@ -117,7 +117,7 @@
             // display name
             if (m_DisplayText != null)
             {
-                m_DisplayText.text = m_Section.Name;
+                m_DisplayText.text = m_Section.Name.ToUpperInvariant();
             }
 
             // editor visible

--- a/KerbalEngineer.Unity/Flight/IFlightAppLauncher.cs
+++ b/KerbalEngineer.Unity/Flight/IFlightAppLauncher.cs
@@ -23,11 +23,11 @@
 
     public interface IFlightAppLauncher
     {
-        bool controlBar { get; set; }
+        bool IsControlBarVisible { get; set; }
 
-        bool isOn { get; }
+        bool IsDisplayStackVisible { get; set; }
 
-        bool showEngineer { get; set; }
+        bool IsOn { get; }
 
         void ClampToScreen(RectTransform rectTransform);
 

--- a/KerbalEngineer/AppLauncherButton.cs
+++ b/KerbalEngineer/AppLauncherButton.cs
@@ -30,7 +30,7 @@
         /// <summary>
         ///     Gets or sets the toggle button state.
         /// </summary>
-        public bool isOn
+        public bool IsOn
         {
             get
             {
@@ -77,7 +77,7 @@
                 m_Button.Enable();
             }
         }
-        
+
         /// <summary>
         ///     Gets the anchor position for pop-up content.
         /// </summary>
@@ -87,7 +87,7 @@
             {
                 return Vector3.zero;
             }
-            
+
             Vector3 anchor = m_Button.GetAnchor();
 
             anchor.x -= 3.0f;
@@ -104,29 +104,29 @@
 
             if (m_Button != null && m_Button.toggleButton.CurrentState != UIRadioButton.State.False)
             {
+                m_Button.SetFalse();
+            }
+        }
+
+        /// <summary>
+        ///     Enables and sets the button to on.
+        /// </summary>
+        public void SetOn()
+        {
+            Enable();
+
+            if (m_Button != null && m_Button.toggleButton.CurrentState != UIRadioButton.State.True)
+            {
                 m_Button.SetTrue();
             }
         }
 
-        /// <summary>
-        ///     Enables and sets the button to on.
-        /// </summary>
-        public void SetOn()
-        {
-            Enable();
-
-            if (m_Button != null && m_Button.toggleButton.CurrentState != UIRadioButton.State.True)
-            {
-                m_Button.SetTrue();
-            }
-        }
-
         protected virtual void Awake()
         {
             // cache icon texture
-            if (m_IconTexture == null && AssetBundleLoader.images != null)
-            {
-                m_IconTexture = AssetBundleLoader.images.LoadAsset<Texture2D>("app-launcher-icon");
+            if (m_IconTexture == null && AssetBundleLoader.Images != null)
+            {
+                m_IconTexture = AssetBundleLoader.Images.LoadAsset<Texture2D>("app-launcher-icon");
             }
 
             // subscribe event listeners

--- a/KerbalEngineer/AssetBundleLoader.cs
+++ b/KerbalEngineer/AssetBundleLoader.cs
@@ -29,7 +29,7 @@
         /// <summary>
         ///     Gets the loaded images asset bundle.
         /// </summary>
-        public static AssetBundle images
+        public static AssetBundle Images
         {
             get
             {
@@ -40,7 +40,7 @@
         /// <summary>
         ///     Gets the loaded prefabs asset bundle.
         /// </summary>
-        public static AssetBundle prefabs
+        public static AssetBundle Prefabs
         {
             get
             {

--- a/KerbalEngineer/Editor/BuildAppLauncher.cs
+++ b/KerbalEngineer/Editor/BuildAppLauncher.cs
@@ -48,7 +48,7 @@
             if (EditorLogic.RootPart != null)
             {
                 // set button state based on existing visibility
-                isOn = BuildAdvanced.Instance.Visible;
+                IsOn = BuildAdvanced.Instance.Visible;
             }
             else
             {

--- a/KerbalEngineer/Flight/FlightAppLauncher.cs
+++ b/KerbalEngineer/Flight/FlightAppLauncher.cs
@@ -35,7 +35,7 @@
         /// <summary>
         ///     Gets the current instance of the FlightAppLauncher object.
         /// </summary>
-        public static FlightAppLauncher instance
+        public static FlightAppLauncher Instance
         {
             get
             {
@@ -52,9 +52,25 @@
         }
 
         /// <summary>
+        ///     Gets a list of custom sections.
+        /// </summary>
+        IList<ISectionModule> IFlightAppLauncher.GetCustomSections()
+        {
+            return new List<ISectionModule>(SectionLibrary.CustomSections.ToArray());
+        }
+
+        /// <summary>
+        ///     Gets a list of stock sections.
+        /// </summary>
+        public IList<ISectionModule> GetStockSections()
+        {
+            return new List<ISectionModule>(SectionLibrary.StockSections.ToArray());
+        }
+
+        /// <summary>
         ///     Gets or sets the control bar's visibility.
         /// </summary>
-        public bool controlBar
+        public bool IsControlBarVisible
         {
             get
             {
@@ -75,25 +91,9 @@
         }
 
         /// <summary>
-        ///     Gets a list of custom sections.
-        /// </summary>
-        IList<ISectionModule> IFlightAppLauncher.GetCustomSections()
-        {
-            return new List<ISectionModule>(SectionLibrary.CustomSections.ToArray());
-        }
-
-        /// <summary>
-        ///     Gets a list of stock sections.
-        /// </summary>
-        public IList<ISectionModule> GetStockSections()
-        {
-            return new List<ISectionModule>(SectionLibrary.StockSections.ToArray());
-        }
-
-        /// <summary>
         ///     Gets or sets the display stack's visibility.
         /// </summary>
-        public bool showEngineer
+        public bool IsDisplayStackVisible
         {
             get
             {
@@ -140,9 +140,9 @@
             m_Instance = this;
 
             // cache menu prefab
-            if (m_MenuPrefab == null && AssetBundleLoader.prefabs != null)
-            {
-                m_MenuPrefab = AssetBundleLoader.prefabs.LoadAsset<GameObject>("FlightMenu");
+            if (m_MenuPrefab == null && AssetBundleLoader.Prefabs != null)
+            {
+                m_MenuPrefab = AssetBundleLoader.Prefabs.LoadAsset<GameObject>("FlightMenu");
             }
         }
 
@@ -158,7 +158,7 @@
 
         protected override void OnHoverOut()
         {
-            if (isOn == false)
+            if (IsOn == false)
             {
                 Close();
             }

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Miscellaneous/LogSimToggle.cs
@@ -1,1 +1,56 @@
+// 
+//     Kerbal Engineer Redux
+// 
+//     Copyright (C) 2014 CYBUTEK
+// 
+//     This program is free software: you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation, either version 3 of the License, or
+//     (at your option) any later version.
+// 
+//     This program is distributed in the hope that it will be useful,
+//     but WITHOUT ANY WARRANTY; without even the implied warranty of
+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//     GNU General Public License for more details.
+// 
+//     You should have received a copy of the GNU General Public License
+//     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+// 
 
+namespace KerbalEngineer.Flight.Readouts.Miscellaneous
+{
+    #region Using Directives
+
+    using Sections;
+    using UnityEngine;
+    using VesselSimulator;
+
+    #endregion
+
+    public class LogSimToggle : ReadoutModule
+    {
+        #region Constructors
+
+        public LogSimToggle()
+        {
+            this.Name = "Log Simulation";
+            this.Category = ReadoutCategory.GetCategory("Miscellaneous");
+            this.HelpString = "Shows a button that allows you to make the next run of the simulation code dump extra debugging output.";
+            this.IsDefault = false;
+        }
+
+        #endregion
+
+        #region Methods
+
+        public override void Draw(SectionModule section)
+        {
+            GUILayout.BeginHorizontal();
+            GUILayout.Label("Log Simulation: ", this.NameStyle);
+            SimManager.logOutput = GUILayout.Toggle(SimManager.logOutput, "ENABLED", this.ButtonStyle);
+            GUILayout.EndHorizontal();
+        }
+
+        #endregion
+    }
+}

--- a/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
+++ b/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
@@ -192,6 +192,7 @@
                 readouts.Add(new SimulationDelay());
                 readouts.Add(new VectoredThrustToggle());
                 readouts.Add(new SystemTime());
+                readouts.Add(new LogSimToggle());
 
                 LoadHelpStrings();
             }

--- a/KerbalEngineer/Flight/Readouts/Surface/HorizontalSpeed.cs
+++ b/KerbalEngineer/Flight/Readouts/Surface/HorizontalSpeed.cs
@@ -45,11 +45,12 @@
 
         public override void Draw(SectionModule section)
         {
-            // Used to do this but the bug-fix to horizontalSrfSpeed in KSP 1.0.3 actually made it worse so workaround
-            //this.DrawLine(FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToSpeed(), section.IsHud);
-            var ves = FlightGlobals.ActiveVessel;
-            double horizSpeed = Math.Sqrt(ves.srfSpeed * ves.srfSpeed - ves.verticalSpeed * ves.verticalSpeed);
-            this.DrawLine(horizSpeed.ToSpeed(), section.IsHud);
+            this.DrawLine(FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToSpeed(), section.IsHud);
+
+            // This workaround was used for KSP 1.0.3 and 1.0.4 where horizontalSrfSpeed was really badly broken
+            //var ves = FlightGlobals.ActiveVessel;
+            //double horizSpeed = Math.Sqrt(ves.srfSpeed * ves.srfSpeed - ves.verticalSpeed * ves.verticalSpeed);
+            //this.DrawLine(horizSpeed.ToSpeed(), section.IsHud);
         }
 
         #endregion

--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -54,6 +54,7 @@
     <Compile Include="Flight\ActionMenuGui.cs" />
     <Compile Include="Flight\FlightAppLauncher.cs" />
     <Compile Include="Flight\Presets\Preset.cs" />
+    <Compile Include="Flight\Readouts\Miscellaneous\LogSimToggle.cs" />
     <Compile Include="Flight\Readouts\Miscellaneous\SystemTime.cs" />
     <Compile Include="Flight\Readouts\Miscellaneous\VectoredThrustToggle.cs" />
     <Compile Include="Flight\Readouts\Miscellaneous\Separator.cs" />

--- a/KerbalEngineer/TapeDriveAnimator.cs
+++ b/KerbalEngineer/TapeDriveAnimator.cs
@@ -1,7 +1,7 @@
 // 
 //     Kerbal Engineer Redux
 // 
-//     Copyright (C) 2014 CYBUTEK
+//     Copyright (C) 2016 CYBUTEK
 // 
 //     This program is free software: you can redistribute it and/or modify
 //     it under the terms of the GNU General Public License as published by
@@ -12,382 +12,392 @@
 //     but WITHOUT ANY WARRANTY; without even the implied warranty of
 //     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //     GNU General Public License for more details.
-// 
 //     You should have received a copy of the GNU General Public License
 //     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-// 
-
-#region Using Directives
-
-using UnityEngine;
-
-using Random = System.Random;
-
-#endregion
+//  
 
 namespace KerbalEngineer
 {
+    using UnityEngine;
+    using Random = System.Random;
+
     public class TapeDriveAnimator : PartModule
     {
-        #region Public Fields
-
-        [KSPField] public string Lights1 = "";
-        [KSPField] public float Lights1Speed = 0;
-        [KSPField] public string Lights2 = "";
-        [KSPField] public float Lights2Speed = 0;
-        [KSPField] public string Lights3 = "";
-        [KSPField] public float Lights3Speed = 0;
-        [KSPField] public string Lights4 = "";
-        [KSPField] public float Lights4Speed = 0;
-        [KSPField] public string Lights5 = "";
-        [KSPField] public float Lights5Speed = 0;
-        [KSPField] public string Lights6 = "";
-        [KSPField] public float Lights6Speed = 0;
-        [KSPField] public int MaxReelSpeed = 0;
-        [KSPField] public int MaxRepeatTime = 0;
-        [KSPField] public int MinReelSpeed = 0;
-        [KSPField] public int MinRepeatTime = 0;
-        [KSPField] public string Reel1 = "";
-        [KSPField] public float Reel1SpeedRatio = 1;
-        [KSPField] public string Reel2 = "";
-        [KSPField] public float Reel2SpeedRatio = 1;
-        [KSPField] public float RepeatTimeDenominator = 1;
-        [KSPField] public float SpeedChangeAmount = 0;
-        [KSPField] public float SpeedDeadZone = 0;
-        [KSPField] public float SpeedStopZone = 0;
-        [KSPField] public bool UseBakedAnimation = false;
-
-        #endregion
-
-        #region Private Fields
-
-        private float currentTime;
-        private float deltaTime;
-        private Shader lights1ShaderOff;
-        private Transform lights1Transform;
-        private Shader lights2ShaderOff;
-        private Transform lights2Transform;
-        private Shader lights3ShaderOff;
-        private Transform lights3Transform;
-        private Shader lights4ShaderOff;
-        private Transform lights4Transform;
-        private Shader lights5ShaderOff;
-        private Transform lights5Transform;
-        private Shader lights6ShaderOff;
-        private Transform lights6Transform;
-        private Shader lightsShaderOn;
-        private Random random;
-        private Transform reel1Transform;
-        private Transform reel2Transform;
-        private float repeatTime;
-        private bool sceneIsEditor;
-        private float speed;
-        private float targetSpeed;
-        private Renderer renderer;
-        private Light light;
-
-        #endregion
-
-        #region Properties
-
-        private bool isRunning;
+        [KSPField]
+        public string Lights1 = string.Empty;
+
+        [KSPField]
+        public float Lights1Speed = 0;
+
+        [KSPField]
+        public string Lights2 = string.Empty;
+
+        [KSPField]
+        public float Lights2Speed = 0;
+
+        [KSPField]
+        public string Lights3 = string.Empty;
+
+        [KSPField]
+        public float Lights3Speed = 0;
+
+        [KSPField]
+        public string Lights4 = string.Empty;
+
+        [KSPField]
+        public float Lights4Speed = 0;
+
+        [KSPField]
+        public string Lights5 = string.Empty;
+
+        [KSPField]
+        public float Lights5Speed = 0;
+
+        [KSPField]
+        public string Lights6 = string.Empty;
+
+        [KSPField]
+        public float Lights6Speed = 0;
+
+        [KSPField]
+        public int MaxReelSpeed = 0;
+
+        [KSPField]
+        public int MaxRepeatTime = 0;
+
+        [KSPField]
+        public int MinReelSpeed = 0;
+
+        [KSPField]
+        public int MinRepeatTime = 0;
+
+        [KSPField]
+        public string Reel1 = string.Empty;
+
+        [KSPField]
+        public float Reel1SpeedRatio = 1;
+
+        [KSPField]
+        public string Reel2 = string.Empty;
+
+        [KSPField]
+        public float Reel2SpeedRatio = 1;
+
+        [KSPField]
+        public float RepeatTimeDenominator = 1;
+
+        [KSPField]
+        public float SpeedChangeAmount = 0;
+
+        [KSPField]
+        public float SpeedDeadZone = 0;
+
+        [KSPField]
+        public float SpeedStopZone = 0;
+
+        [KSPField]
+        public bool UseBakedAnimation = false;
+
+        private Shader m_ButtonLightOffShader;
+        private Shader m_ButtonLightOnShader;
+        private Material m_ButtonSet1Material;
+        private Material m_ButtonSet2Material;
+        private Material m_ButtonSet3Material;
+        private Material m_ButtonSet4Material;
+        private Material m_ButtonSet5Material;
+        private Material m_ButtonSet6Material;
+        private float m_CurrentTime;
+        private float m_DeltaTime;
+        private bool m_IsRunning;
+        private Random m_Random;
+        private Transform m_Reel1Transform;
+        private Transform m_Reel2Transform;
+        private float m_RepeatTime;
+        private bool m_SceneIsEditor;
+        private float m_Speed;
+        private float m_TargetSpeed;
 
         public bool IsRunning
         {
-            get { return this.isRunning; }
+            get
+            {
+                return m_IsRunning;
+            }
             set
             {
-                this.isRunning = value;
-
-                if (this.isRunning)
-                {
-                    if (this.UseBakedAnimation)
+                m_IsRunning = value;
+
+                if (m_IsRunning)
+                {
+                    if (UseBakedAnimation)
                     {
-                        this.StartBakedAnimation();
+                        StartBakedAnimation();
                     }
                 }
                 else
                 {
-                    if (this.UseBakedAnimation)
+                    if (UseBakedAnimation)
                     {
-                        this.StopBakedAnimation();
+                        StopBakedAnimation();
                     }
                 }
             }
         }
 
-        #endregion
-
-        #region Initialisation
-
         public override void OnStart(StartState state)
         {
-            renderer = GetComponent<Renderer>();
-
-            this.random = new Random();
-
-            this.StopBakedAnimation();
-            this.IsRunning = false;
+            m_Random = new Random();
+
+            StopBakedAnimation();
+            IsRunning = false;
 
             if (HighLogic.LoadedSceneIsEditor)
             {
-                this.part.OnEditorAttach += this.OnEditorAttach;
-                this.part.OnEditorDetach += this.OnEditorDetach;
-
-                this.sceneIsEditor = true;
-
-                if (this.part.parent != null)
-                {
-                    this.IsRunning = true;
+                part.OnEditorAttach += OnEditorAttach;
+                part.OnEditorDetach += OnEditorDetach;
+
+                m_SceneIsEditor = true;
+
+                if (part.parent != null)
+                {
+                    IsRunning = true;
                 }
             }
             else if (HighLogic.LoadedSceneIsFlight)
             {
-                this.IsRunning = true;
-            }
-
-            if (!this.UseBakedAnimation)
-            {
-                this.InitialiseReels();
-                this.InitialiseLights();
-            }
+                IsRunning = true;
+            }
+
+            if (UseBakedAnimation == false)
+            {
+                InitialiseReels();
+                InitialiseLights();
+            }
+        }
+
+        public override void OnUpdate()
+        {
+            if (UseBakedAnimation)
+            {
+                return;
+            }
+
+            m_DeltaTime = m_SceneIsEditor ? Time.deltaTime : TimeWarp.deltaTime;
+
+            if (TimeWarp.CurrentRate != 1.0f && TimeWarp.WarpMode != TimeWarp.Modes.LOW)
+            {
+                return;
+            }
+
+            if (IsRunning)
+            {
+                UpdateTimerCycle();
+                UpdateSpeed();
+                UpdateReels();
+                UpdateLights();
+            }
+            else
+            {
+                m_TargetSpeed = 0;
+
+                if (m_Speed != 0)
+                {
+                    UpdateSpeed();
+                    UpdateReels();
+                    UpdateLights();
+                }
+            }
+        }
+
+        private static void SetShaderOnMaterial(Material material, Shader shader)
+        {
+            if (material != null && shader != null)
+            {
+                material.shader = shader;
+            }
+        }
+
+        private Material GetMaterialOnModelTransform(string transformName)
+        {
+            Transform modelTransform = GetModelTransform(transformName);
+            if (modelTransform != null)
+            {
+                Renderer renderer = modelTransform.GetComponent<Renderer>();
+                if (renderer != null)
+                {
+                    return renderer.material;
+                }
+            }
+
+            return null;
+        }
+
+        private Transform GetModelTransform(string transformName)
+        {
+            if (string.IsNullOrEmpty(transformName) == false)
+            {
+                return part.FindModelTransform(transformName);
+            }
+
+            return null;
+        }
+
+        private void InitialiseLights()
+        {
+            m_ButtonSet1Material = GetMaterialOnModelTransform(Lights1);
+            m_ButtonSet2Material = GetMaterialOnModelTransform(Lights2);
+            m_ButtonSet3Material = GetMaterialOnModelTransform(Lights3);
+            m_ButtonSet4Material = GetMaterialOnModelTransform(Lights4);
+            m_ButtonSet5Material = GetMaterialOnModelTransform(Lights5);
+            m_ButtonSet6Material = GetMaterialOnModelTransform(Lights6);
+
+            m_ButtonLightOffShader = Shader.Find("KSP/Specular");
+            m_ButtonLightOnShader = Shader.Find("KSP/Unlit");
         }
 
         private void InitialiseReels()
         {
-            if (this.Reel1 != "")
-            {
-                this.reel1Transform = this.part.FindModelTransform(this.Reel1);
-            }
-
-            if (this.Reel2 != "")
-            {
-                this.reel2Transform = this.part.FindModelTransform(this.Reel2);
-            }
-        }
-
-        private void InitialiseLights()
-        {
-            if (this.Lights1 != "")
-            {
-                this.lights1Transform = this.part.FindModelTransform(this.Lights1);
-                this.lights1ShaderOff = renderer.material.shader;
-            }
-
-            if (this.Lights2 != "")
-            {
-                this.lights2Transform = this.part.FindModelTransform(this.Lights2);
-                this.lights2ShaderOff = renderer.material.shader;
-            }
-
-            if (this.Lights3 != "")
-            {
-                this.lights3Transform = this.part.FindModelTransform(this.Lights3);
-                this.lights3ShaderOff = renderer.material.shader;
-            }
-
-            if (this.Lights4 != "")
-            {
-                this.lights4Transform = this.part.FindModelTransform(this.Lights4);
-                this.lights4ShaderOff = renderer.material.shader;
-            }
-
-            if (this.Lights5 != "")
-            {
-                this.lights5Transform = this.part.FindModelTransform(this.Lights5);
-                this.lights5ShaderOff = renderer.material.shader;
-            }
-
-            if (this.Lights6 != "")
-            {
-                this.lights6Transform = this.part.FindModelTransform(this.Lights6);
-                this.lights6ShaderOff = renderer.material.shader;
-            }
-
-            this.lightsShaderOn = Shader.Find("Unlit/Texture");
-        }
-
-        #endregion
-
-        #region Updating
-
-        public override void OnUpdate()
-        {
-            if (!this.UseBakedAnimation)
-            {
-                this.deltaTime = this.sceneIsEditor ? Time.deltaTime : TimeWarp.deltaTime;
-
-                if (TimeWarp.CurrentRate != 1.0f && TimeWarp.WarpMode != TimeWarp.Modes.LOW)
-                {
-                    return;
-                }
-
-                if (this.IsRunning)
-                {
-                    this.UpdateTimerCycle();
-                    this.UpdateSpeed();
-                    this.UpdateReels();
-                    this.UpdateLights();
+            if (string.IsNullOrEmpty(Reel1) == false)
+            {
+                m_Reel1Transform = part.FindModelTransform(Reel1);
+            }
+
+            if (string.IsNullOrEmpty(Reel2) == false)
+            {
+                m_Reel2Transform = part.FindModelTransform(Reel2);
+            }
+        }
+
+        private void OnEditorAttach()
+        {
+            IsRunning = true;
+        }
+
+        private void OnEditorDetach()
+        {
+            IsRunning = false;
+        }
+
+        private void StartBakedAnimation()
+        {
+            foreach (Animation animator in part.FindModelAnimators())
+            {
+                animator.Play();
+            }
+        }
+
+        private void StopBakedAnimation()
+        {
+            foreach (Animation animator in part.FindModelAnimators())
+            {
+                animator.Stop();
+            }
+        }
+
+        private void Update()
+        {
+            if (m_SceneIsEditor)
+            {
+                OnUpdate();
+            }
+        }
+
+        private void UpdateButtonMaterial(Material material, float targetSpeed)
+        {
+            if (material == null)
+            {
+                return;
+            }
+
+            bool lightsOn;
+
+            if (targetSpeed > 0)
+            {
+                lightsOn = (m_Speed > targetSpeed);
+            }
+            else if (targetSpeed < 0)
+            {
+                lightsOn = (m_Speed < targetSpeed);
+            }
+            else
+            {
+                lightsOn = (m_Speed == 0);
+            }
+
+            SetShaderOnMaterial(material, lightsOn ? m_ButtonLightOnShader : m_ButtonLightOffShader);
+        }
+
+        private void UpdateLights()
+        {
+            UpdateButtonMaterial(m_ButtonSet1Material, Lights1Speed);
+            UpdateButtonMaterial(m_ButtonSet2Material, Lights2Speed);
+            UpdateButtonMaterial(m_ButtonSet3Material, Lights3Speed);
+            UpdateButtonMaterial(m_ButtonSet4Material, Lights4Speed);
+            UpdateButtonMaterial(m_ButtonSet5Material, Lights5Speed);
+            UpdateButtonMaterial(m_ButtonSet6Material, Lights6Speed);
+        }
+
+        private void UpdateReels()
+        {
+            if (m_Reel1Transform != null && m_Speed != 0)
+            {
+                m_Reel1Transform.transform.Rotate(Vector3.right, m_Speed * Reel1SpeedRatio);
+            }
+
+            if (m_Reel2Transform != null && m_Speed != 0)
+            {
+                m_Reel2Transform.transform.Rotate(Vector3.right, m_Speed * Reel2SpeedRatio);
+            }
+        }
+
+        private void UpdateSpeed()
+        {
+            if (m_Speed < m_TargetSpeed)
+            {
+                if (m_Speed < m_TargetSpeed - SpeedDeadZone)
+                {
+                    m_Speed += SpeedChangeAmount * m_DeltaTime;
                 }
                 else
                 {
-                    this.targetSpeed = 0;
-
-                    if (this.speed != 0)
-                    {
-                        this.UpdateSpeed();
-                        this.UpdateReels();
-                        this.UpdateLights();
-                    }
-                }
-            }
-        }
-
-        private void Update()
-        {
-            if (this.sceneIsEditor)
-            {
-                this.OnUpdate();
-            }
-        }
-
-        private void OnEditorAttach()
-        {
-            this.IsRunning = true;
-        }
-
-        private void OnEditorDetach()
-        {
-            this.IsRunning = false;
-        }
-
-        private void StopBakedAnimation()
-        {
-            foreach (var animator in this.part.FindModelAnimators())
-            {
-                animator.Stop();
-            }
-        }
-
-        private void StartBakedAnimation()
-        {
-            foreach (var animator in this.part.FindModelAnimators())
-            {
-                animator.Play();
+                    m_Speed = m_TargetSpeed;
+                }
+            }
+            else if (m_Speed > m_TargetSpeed)
+            {
+                if (m_Speed > m_TargetSpeed + SpeedDeadZone)
+                {
+                    m_Speed -= SpeedChangeAmount * m_DeltaTime;
+                }
+                else
+                {
+                    m_Speed = m_TargetSpeed;
+                }
             }
         }
 
         private void UpdateTimerCycle()
         {
-            this.currentTime += this.deltaTime;
-
-            if (this.currentTime >= this.repeatTime)
-            {
-                this.targetSpeed = this.random.Next(this.MinReelSpeed, this.MaxReelSpeed);
-
-                if (this.targetSpeed > -this.SpeedStopZone && this.targetSpeed < this.SpeedStopZone)
-                {
-                    this.targetSpeed = 0;
-                }
-
-                this.repeatTime = this.random.Next(this.MinRepeatTime, this.MaxRepeatTime);
-
-                if (this.RepeatTimeDenominator != 0)
-                {
-                    this.repeatTime /= this.RepeatTimeDenominator;
-                }
-
-                this.currentTime -= this.repeatTime;
-            }
-        }
-
-        private void UpdateSpeed()
-        {
-            if (this.speed < this.targetSpeed)
-            {
-                if (this.speed < this.targetSpeed - this.SpeedDeadZone)
-                {
-                    this.speed += this.SpeedChangeAmount * this.deltaTime;
-                }
-                else
-                {
-                    this.speed = this.targetSpeed;
-                }
-            }
-            else if (this.speed > this.targetSpeed)
-            {
-                if (this.speed > this.targetSpeed + this.SpeedDeadZone)
-                {
-                    this.speed -= this.SpeedChangeAmount * this.deltaTime;
-                }
-                else
-                {
-                    this.speed = this.targetSpeed;
-                }
-            }
-        }
-
-        private void UpdateReels()
-        {
-            if (this.reel1Transform != null && this.speed != 0)
-            {
-                this.reel1Transform.transform.Rotate(Vector3.right, this.speed * this.Reel1SpeedRatio);
-            }
-
-            if (this.reel2Transform != null && this.speed != 0)
-            {
-                this.reel2Transform.transform.Rotate(Vector3.right, this.speed * this.Reel2SpeedRatio);
-            }
-        }
-
-        private void UpdateLights()
-        {
-            if (this.lights1Transform != null)
-            {
-                this.UpdateLightTransform(this.lights1Transform, this.lightsShaderOn, this.lights1ShaderOff, this.Lights1Speed);
-            }
-            if (this.lights2Transform != null)
-            {
-                this.UpdateLightTransform(this.lights2Transform, this.lightsShaderOn, this.lights2ShaderOff, this.Lights2Speed);
-            }
-            if (this.lights3Transform != null)
-            {
-                this.UpdateLightTransform(this.lights3Transform, this.lightsShaderOn, this.lights3ShaderOff, this.Lights3Speed);
-            }
-            if (this.lights4Transform != null)
-            {
-                this.UpdateLightTransform(this.lights4Transform, this.lightsShaderOn, this.lights4ShaderOff, this.Lights4Speed);
-            }
-            if (this.lights5Transform != null)
-            {
-                this.UpdateLightTransform(this.lights5Transform, this.lightsShaderOn, this.lights5ShaderOff, this.Lights5Speed);
-            }
-            if (this.lights6Transform != null)
-            {
-                this.UpdateLightTransform(this.lights6Transform, this.lightsShaderOn, this.lights6ShaderOff, this.Lights6Speed);
-            }
-        }
-
-        private void UpdateLightTransform(Component lights, Shader on, Shader off, float targetSpeed)
-        {
-            bool lightsOn;
-
-            if (targetSpeed > 0)
-            {
-                lightsOn = (this.speed > targetSpeed);
-            }
-            else if (targetSpeed < 0)
-            {
-                lightsOn = (this.speed < targetSpeed);
-            }
-            else
-            {
-                lightsOn = (this.speed == 0);
-            }
-
-            lights.GetComponent<Renderer>().material.shader = lightsOn ? @on : off;
-        }
-
-        #endregion
+            m_CurrentTime += m_DeltaTime;
+
+            if (m_CurrentTime >= m_RepeatTime)
+            {
+                m_TargetSpeed = m_Random.Next(MinReelSpeed, MaxReelSpeed);
+
+                if (m_TargetSpeed > -SpeedStopZone && m_TargetSpeed < SpeedStopZone)
+                {
+                    m_TargetSpeed = 0;
+                }
+
+                m_RepeatTime = m_Random.Next(MinRepeatTime, MaxRepeatTime);
+
+                if (RepeatTimeDenominator != 0)
+                {
+                    m_RepeatTime /= RepeatTimeDenominator;
+                }
+
+                m_CurrentTime -= m_RepeatTime;
+            }
+        }
     }
 }

--- a/KerbalEngineer/VesselSimulator/EngineSim.cs
+++ b/KerbalEngineer/VesselSimulator/EngineSim.cs
@@ -72,26 +72,30 @@
         }
 
         public static EngineSim New(PartSim theEngine,
-                         double atmosphere,
-                         float machNumber,
-                         float maxFuelFlow,
-                         float minFuelFlow,
-                         float thrustPercentage,
-                         Vector3 vecThrust,
-                         FloatCurve atmosphereCurve,
-                         bool atmChangeFlow,
-                         FloatCurve atmCurve,
-                         FloatCurve velCurve,
-                         float currentThrottle,
-                         float IspG,
-                         bool throttleLocked,
-                         List<Propellant> propellants,
-                         bool active,
-                         float resultingThrust,
-                         List<Transform> thrustTransforms,
-                        LogMsg log)
-        {
-            EngineSim engineSim = pool.Borrow();
+									ModuleEngines engineMod,
+									double atmosphere,
+									float machNumber,
+									bool vectoredThrust,
+									bool fullThrust,
+									LogMsg log)
+        {
+            float maxFuelFlow = engineMod.maxFuelFlow;
+            float minFuelFlow = engineMod.minFuelFlow;
+            float thrustPercentage = engineMod.thrustPercentage;
+            Vector3 vecThrust = CalculateThrustVector(vectoredThrust ? engineMod.thrustTransforms : null, log);
+            FloatCurve atmosphereCurve = engineMod.atmosphereCurve;
+            bool atmChangeFlow = engineMod.atmChangeFlow;
+            FloatCurve atmCurve = engineMod.useAtmCurve ? engineMod.atmCurve : null;
+            FloatCurve velCurve = engineMod.useVelCurve ? engineMod.velCurve : null;
+            float currentThrottle = engineMod.currentThrottle;
+            float IspG = engineMod.g;
+            bool throttleLocked = engineMod.throttleLocked || fullThrust;
+            List<Propellant> propellants = engineMod.propellants;
+            bool active = engineMod.isOperational;
+            float resultingThrust = engineMod.resultingThrust;
+            List<Transform> thrustTransforms = engineMod.thrustTransforms;
+			
+			EngineSim engineSim = pool.Borrow();
 
             engineSim.isp = 0.0;
             engineSim.maxMach = 0.0f;
@@ -120,7 +124,7 @@
                     log.buf.AppendFormat("actual  = {0:g6}\n", engineSim.actualThrust);
                 }
 
-                if (throttleLocked)
+				if (throttleLocked)
                 {
                     if (log != null) log.buf.AppendLine("throttleLocked is true, using thrust for flowRate");
                     flowRate = GetFlowRate(engineSim.thrust, engineSim.isp);
@@ -129,7 +133,8 @@
                 {
                     if (currentThrottle > 0.0f && engineSim.partSim.isLanded == false)
                     {
-                        if (log != null) log.buf.AppendLine("throttled up and not landed, using actualThrust for flowRate");
+						// TODO: This bit doesn't work for RF engines
+						if (log != null) log.buf.AppendLine("throttled up and not landed, using actualThrust for flowRate");
                         flowRate = GetFlowRate(engineSim.actualThrust, engineSim.isp);
                     }
                     else
@@ -203,6 +208,32 @@
 
             return engineSim;
         }
+
+		private static Vector3 CalculateThrustVector(List<Transform> thrustTransforms, LogMsg log)
+		{
+			if (thrustTransforms == null)
+			{
+				return Vector3.forward;
+			}
+
+			Vector3 thrustvec = Vector3.zero;
+			for (int i = 0; i < thrustTransforms.Count; ++i)
+			{
+				Transform trans = thrustTransforms[i];
+
+				if (log != null) log.buf.AppendFormat("Transform = ({0:g6}, {1:g6}, {2:g6})   length = {3:g6}\n", trans.forward.x, trans.forward.y, trans.forward.z, trans.forward.magnitude);
+
+				thrustvec -= trans.forward;
+			}
+
+			if (log != null) log.buf.AppendFormat("ThrustVec  = ({0:g6}, {1:g6}, {2:g6})   length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude);
+
+			thrustvec.Normalize();
+
+			if (log != null) log.buf.AppendFormat("ThrustVecN = ({0:g6}, {1:g6}, {2:g6})   length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude);
+
+			return thrustvec;
+		}
 
         public ResourceContainer ResourceConsumptions
         {

--- a/KerbalEngineer/VesselSimulator/PartSim.cs
+++ b/KerbalEngineer/VesselSimulator/PartSim.cs
@@ -234,27 +234,13 @@
                     {
                         if (log != null) log.buf.AppendLine("Module: " + engine.moduleName);
 
-                        Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);
-
                         EngineSim engineSim = EngineSim.New(
                             this,
-                            atmosphere,
+							engine,
+							atmosphere,
                             (float)mach,
-                            engine.maxFuelFlow,
-                            engine.minFuelFlow,
-                            engine.thrustPercentage,
-                            thrustvec,
-                            engine.atmosphereCurve,
-                            engine.atmChangeFlow,
-                            engine.useAtmCurve ? engine.atmCurve : null,
-                            engine.useVelCurve ? engine.velCurve : null,
-                            engine.currentThrottle,
-                            engine.g,
-                            engine.throttleLocked || fullThrust,
-                            engine.propellants,
-                            engine.isOperational,
-                            engine.resultingThrust,
-                            engine.thrustTransforms,
+							vectoredThrust,
+							fullThrust,
                             log);
                         allEngines.Add(engineSim);
                     }
@@ -268,28 +254,14 @@
                     ModuleEngines engine = engines[i];
                     if (log != null) log.buf.AppendLine("Module: " + engine.moduleName);
 
-                    Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);
-
                     EngineSim engineSim = EngineSim.New(
                         this,
+						engine,
                         atmosphere,
                         (float)mach,
-                        engine.maxFuelFlow,
-                        engine.minFuelFlow,
-                        engine.thrustPercentage,
-                        thrustvec,
-                        engine.atmosphereCurve,
-                        engine.atmChangeFlow,
-                        engine.useAtmCurve ? engine.atmCurve : null,
-                        engine.useVelCurve ? engine.velCurve : null,
-                        engine.currentThrottle,
-                        engine.g,
-                        engine.throttleLocked || fullThrust,
-                        engine.propellants,
-                        engine.isOperational,
-                        engine.resultingThrust,
-                        engine.thrustTransforms,
-                        log);
+						vectoredThrust,
+						fullThrust,
+						log);
                     allEngines.Add(engineSim);
                 }
             }

 Binary files a/Output/KerbalEngineer/KerbalEngineer and b/Output/KerbalEngineer/KerbalEngineer differ
 Binary files a/Output/KerbalEngineer/KerbalEngineer.Unity.dll and b/Output/KerbalEngineer/KerbalEngineer.Unity.dll differ
 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ
 Binary files a/Output/KerbalEngineer/prefabs and b/Output/KerbalEngineer/prefabs differ
--- a/Output/KerbalEngineer/prefabs.manifest
+++ b/Output/KerbalEngineer/prefabs.manifest
@@ -1,9 +1,9 @@
 ManifestFileVersion: 0
-CRC: 3151923579
+CRC: 3889460463
 Hashes:
   AssetFileHash:
     serializedVersion: 2
-    Hash: 190dda20513d4497692c3a813ba1392f
+    Hash: dc7af1c2d3aa8684359541d179f53bae
   TypeTreeHash:
     serializedVersion: 2
     Hash: a43c45227b2ed7e5db39229032ceda8b