diff --git a/README.md b/README.md index 82bed51..ff6f0e0 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,11 @@ added to a config file or edited in the persistent.sfs file. ## CHANGELOG +9 April 2018 - v4.0.4 + +* Fixed: Flashing lights blink rapidly after warp during flight (Issue #8). + +*** 7 April 2018 - v4.0.3 * Implement correct symmetry updating behavior for the point/spot toggle (Issue #7). diff --git a/Source/AviationLights.cs b/Source/AviationLights.cs index ba36809..4695463 100644 --- a/Source/AviationLights.cs +++ b/Source/AviationLights.cs @@ -170,9 +170,9 @@ public void Start() } Intensity = Mathf.Clamp(Intensity, 0.0f, 8.0f); - FlashOn = Mathf.Max(FlashOn, 0.0f); - FlashOff = Mathf.Max(FlashOff, 0.0f); - Interval = Mathf.Max(Interval, 0.0f); + FlashOn = Mathf.Max(FlashOn, 0.01f); + FlashOff = Mathf.Max(FlashOff, 0.01f); + Interval = Mathf.Max(Interval, 0.01f); Range = Mathf.Max(Range, 0.0f); Color.x = Mathf.Clamp01(Color.x); @@ -482,9 +482,14 @@ public void Update() { if (vessel.RequestResource(part, resourceId, EnergyReq * TimeWarp.deltaTime, true) < EnergyReq * TimeWarp.deltaTime * 0.5f) { - mainLight.intensity = 0.0f; + UpdateLights(false); return; } + else if (mainLight.intensity == 0.0f && navLightSwitch == (int)NavLightState.On) + { + // All other nav lights will reset below, but the On case is different. + UpdateLights(true); + } } elapsedTime += TimeWarp.deltaTime; @@ -500,7 +505,7 @@ public void Update() // Lights are in 'Flash' mode if (elapsedTime >= nextInterval) { - elapsedTime -= nextInterval; + elapsedTime = elapsedTime % nextInterval; flashCounter = (flashCounter + 1) & 1; @@ -514,7 +519,7 @@ public void Update() // Lights are in 'Double Flash' mode if (elapsedTime >= nextInterval) { - elapsedTime -= nextInterval; + elapsedTime = elapsedTime % nextInterval; flashCounter = (flashCounter + 1) & 3; @@ -528,7 +533,7 @@ public void Update() // Lights are in 'Interval' mode if (elapsedTime >= Interval) { - elapsedTime -= Interval; + elapsedTime = elapsedTime % Interval; flashCounter = (flashCounter + 1) & 1; UpdateLights((flashCounter & 1) == 1); @@ -559,7 +564,7 @@ public void Update() // Lights are in 'Flash' mode if (elapsedTime >= nextInterval) { - elapsedTime -= nextInterval; + elapsedTime = elapsedTime % nextInterval; flashCounter = (flashCounter + 1) & 1; @@ -571,7 +576,7 @@ public void Update() // Lights are in 'Double Flash' mode if (elapsedTime >= nextInterval) { - elapsedTime -= nextInterval; + elapsedTime = elapsedTime % nextInterval; flashCounter = (flashCounter + 1) & 3; @@ -583,7 +588,7 @@ public void Update() // Lights are in 'Interval' mode if (elapsedTime >= Interval) { - elapsedTime -= Interval; + elapsedTime = elapsedTime % Interval; flashCounter = (flashCounter + 1) & 1; } @@ -597,7 +602,7 @@ public void Update() Color newColor = new Color(Color.x, Color.y, Color.z); if (lensMaterial.Length > 0) { - Color newEmissiveColor = (lightsOn) ? new Color(Color.x, Color.y, Color.z) : XKCDColors.Black; + Color newEmissiveColor = (lightsOn) ? newColor : XKCDColors.Black; for (int i = 0; i < lensMaterial.Length; ++i) { lensMaterial[i].SetColor(colorProperty, newColor); diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 533fffa..af777fc 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -17,7 +17,7 @@ // 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("4.0.3")] +[assembly: AssemblyVersion("4.0.4")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from