Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Fix flash behavior after warp.
Browse files Browse the repository at this point in the history
Issue #8
  • Loading branch information
MOARdV committed Apr 9, 2018
1 parent 93955ad commit 3c073f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
27 changes: 16 additions & 11 deletions Source/AviationLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -500,7 +505,7 @@ public void Update()
// Lights are in 'Flash' mode
if (elapsedTime >= nextInterval)
{
elapsedTime -= nextInterval;
elapsedTime = elapsedTime % nextInterval;

flashCounter = (flashCounter + 1) & 1;

Expand All @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -559,7 +564,7 @@ public void Update()
// Lights are in 'Flash' mode
if (elapsedTime >= nextInterval)
{
elapsedTime -= nextInterval;
elapsedTime = elapsedTime % nextInterval;

flashCounter = (flashCounter + 1) & 1;

Expand All @@ -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;

Expand All @@ -583,7 +588,7 @@ public void Update()
// Lights are in 'Interval' mode
if (elapsedTime >= Interval)
{
elapsedTime -= Interval;
elapsedTime = elapsedTime % Interval;

flashCounter = (flashCounter + 1) & 1;
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c073f0

Please sign in to comment.