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

Commit 2afa3c9

Browse files
committed
Scale EnergyReq based on Intensity
Also update notes for 4.0.6 release and KSP 1.6.0
1 parent 85ed726 commit 2afa3c9

5 files changed

Lines changed: 23 additions & 13 deletions

File tree

GameData/AviationLights/Parts/aviation_light.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PART
5656
Interval = 1.0
5757

5858
//Energy consumption rate
59-
EnergyReq = 0.005
59+
EnergyReq = 0.020
6060

6161
SpotAngle = 170
6262
LightRotation = 0, 180, 0

GameData/AviationLights/Plugins/AviationLights.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"KSP_VERSION_MAX":
2222
{
2323
"MAJOR": 1,
24-
"MINOR": 5,
24+
"MINOR": 6,
2525
"PATCH": 99
2626
}
2727
}

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The upgrade should not cause any loss of vessels.
6969

7070
### Localization
7171

72-
Aviation Lights 4.0 and later support localization. The currently supported languages are en-us.
72+
Aviation Lights 4.0 and later support localization. The currently supported languages are en-us and es-es.
7373

7474
Translations would be appreciated.
7575

@@ -81,11 +81,6 @@ will update the legacy lights so they are available in the editor. If you do no
8181
installation, and you do not have any vessels currently using those lights, feel free to delete the
8282
AviationLights/Parts/lights folder. The new light is in AviationLights/Parts.
8383

84-
### KSP 1.3.1
85-
86-
AviationLights 4.0 may work in KSP 1.3.1 using the legacy lights. However, the new part does not work correctly in KSP 1.3.1.
87-
You are welcome to try this configuration, but it is not supported.
88-
8984
### B9 Part Switcher
9085

9186
If you wish to use B9 Part Switcher instead of the stock part variants feature, rename MM_B9PartSwitch.nocfg to
@@ -253,7 +248,8 @@ and the Intensity and Range may be changed with the Type Preset control. In add
253248
directly by enabling Advanced Tweakables.
254249

255250
* **Color**: The RGB color of the light. Valid values are from 0 to 1 for each channel.
256-
* **Intensity**: The intensity of the light. Brighter lights should use larger values. Valid numbers range from 0 to 8. Nav lights use 0.5.
251+
* **Intensity**: The intensity of the light. Brighter lights should use larger values. Valid numbers range from 0 to 8. Nav lights use 0.5. Energy consumption
252+
is affected by Intensity.
257253
* **Range**: The range of the light, in meters.
258254

259255
### Flash Timing
@@ -272,8 +268,13 @@ a new one. All times are measured in seconds.
272268
The resource fields control the resource type and amount consumed per second. By default, the parts require ElectricCharge, but they do not
273269
consume energy.
274270

271+
EnergyReq is affected by the Intensity of the light. The EnergyReq listed in the part config is the amount of resources required for a light
272+
with an Intensity of 1.0. EnergyReq is scaled by the square of the Intensity, with a minimum scale of 0.25. For example, a Nav Light that has an EnergyReq of 0.020
273+
and an Intensity of 0.5 will actually use 0.005 EC (= 0.020 x (0.5 x 0.5)). An Intensity of 2.0 will consume 4x the listed EnergyReq.
274+
275275
* **Resource**: The name (from the RESOURCE_DEFINITION) of the resource consumed when this light is on.
276-
* **EnergyReq**: The amount of the resource consumed per second while switched on. If this value is zero, the light does not consume any resources.
276+
* **EnergyReq**: The amount of the resource consumed per second while switched on for a light of Intensity = 1.0. If this value is zero, the light does not consume any resources.
277+
Intensity modifies this value.
277278

278279
### Advanced
279280

@@ -291,6 +292,12 @@ added to a config file or edited in the persistent.sfs file.
291292

292293
## CHANGELOG
293294

295+
21 December 2018 - v4.0.6
296+
297+
* Added es-es localization courtesy fitiales. Pull request #15.
298+
* Scaled energy consumption based on light intensity. Issue #13.
299+
300+
***
294301
16 October 2018 - v4.0.5.1
295302

296303
* Recompiled against KSP 1.5.0.

Source/AviationLights.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class TypePreset
3939

4040
[KSPField]
4141
public float EnergyReq = 0.0f;
42+
public float actualEnergyReq = 0.0f;
4243

4344
[KSPField]
4445
public float SpotAngle = 0.0f;
@@ -170,6 +171,7 @@ public void Start()
170171
}
171172

172173
Intensity = Mathf.Clamp(Intensity, 0.0f, 8.0f);
174+
actualEnergyReq = EnergyReq * Mathf.Max(0.25f, Intensity * Intensity);
173175
FlashOn = Mathf.Max(FlashOn, 0.01f);
174176
FlashOff = Mathf.Max(FlashOff, 0.01f);
175177
Interval = Mathf.Max(Interval, 0.01f);
@@ -428,6 +430,7 @@ private void TypePresetChanged(BaseField field, object oldFieldValueObj)
428430
Interval = newtype.interval;
429431
Intensity = newtype.intensity;
430432
Range = newtype.range;
433+
actualEnergyReq = EnergyReq * Mathf.Max(0.25f, Intensity * Intensity);
431434

432435
if (applySymmetry)
433436
{
@@ -481,9 +484,9 @@ public void Update()
481484
{
482485
if (HighLogic.LoadedSceneIsFlight)
483486
{
484-
if (navLightSwitch != (int)NavLightState.Off && EnergyReq > 0.0f && TimeWarp.deltaTime > 0.0f)
487+
if (navLightSwitch != (int)NavLightState.Off && actualEnergyReq > 0.0f && TimeWarp.deltaTime > 0.0f)
485488
{
486-
if (vessel.RequestResource(part, resourceId, EnergyReq * TimeWarp.deltaTime, true) < EnergyReq * TimeWarp.deltaTime * 0.5f)
489+
if (vessel.RequestResource(part, resourceId, actualEnergyReq * TimeWarp.deltaTime, true) < actualEnergyReq * TimeWarp.deltaTime * 0.5f)
487490
{
488491
UpdateLights(false);
489492
return;

Source/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// You can specify all the values or you can default the Build and Revision Numbers
1818
// by using the '*' as shown below:
1919
// [assembly: AssemblyVersion("1.0.*")]
20-
[assembly: AssemblyVersion("4.0.5.1")]
20+
[assembly: AssemblyVersion("4.0.6")]
2121

2222
// Setting ComVisible to false makes the types in this assembly not visible
2323
// to COM components. If you need to access a type in this assembly from

0 commit comments

Comments
 (0)