diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d08241..444aa4d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 1.12 (March 8th, 2019):
+* [Fix #19] Compatibility with ReStock mod.
+
# 1.11 (January 12th, 2019):
* [Enhancement] Add Portuguese localization (PT_br).
* [Fix #16] Parts without bulkheadProfiles breaks KSP 1.6.
diff --git a/Deps/ModuleManager.3.1.3.dll b/Deps/ModuleManager.3.1.3.dll
deleted file mode 100644
index 9b9fd80..0000000
Binary files a/Deps/ModuleManager.3.1.3.dll and /dev/null differ
diff --git a/Deps/ModuleManager.4.0.2.dll b/Deps/ModuleManager.4.0.2.dll
new file mode 100644
index 0000000..3ef00da
Binary files /dev/null and b/Deps/ModuleManager.4.0.2.dll differ
diff --git a/Patches/MM-StockLights.cfg b/Patches/MM-StockLights.cfg
index b50c09e..2f69a5e 100644
--- a/Patches/MM-StockLights.cfg
+++ b/Patches/MM-StockLights.cfg
@@ -1,4 +1,5 @@
-@PART[spotLight1,spotLight2]:NEEDS[SurfaceLights]
+// Stock parts need animation patching.
+@PART[spotLight1,spotLight2]:NEEDS[!ReStock]
{
@MODULE[ModuleLight]
{
@@ -10,3 +11,18 @@
}
@tags ^= :^:cck-lights
}
+
+// ReStock'ed parts can support colored lenses naturally.
+// See: https://github.com/PorktoberRevolution/ReStocked
+@PART[spotLight1,spotLight2]:NEEDS[ReStock]
+{
+ @MODULE[ModuleLight]
+ {
+ @name = ModuleColoredLensLight
+ %lightR = 1.0
+ %lightG = 0.9
+ %lightB = 0.8
+ lensBrightness = 0.4
+ }
+ @tags ^= :^:cck-lights
+}
diff --git a/Source/ModuleColoredLensLight.cs b/Source/ModuleColoredLensLight.cs
index 546a429..d6cd8f3 100644
--- a/Source/ModuleColoredLensLight.cs
+++ b/Source/ModuleColoredLensLight.cs
@@ -4,6 +4,7 @@
// License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
using System;
+using System.Linq;
using UnityEngine;
namespace SurfaceLights {
@@ -43,17 +44,6 @@ namespace SurfaceLights {
///
///
public class ModuleColoredLensLight : ModuleLight {
- /// Light's material.
- protected Material lightMaterial {
- get {
- if (!_lightMaterial) {
- _lightMaterial = part.FindModelComponent().material;
- }
- return _lightMaterial;
- }
- }
- Material _lightMaterial;
-
/// Defines minimum white color level.
/// See module remarks with regard to changing this value from as script.
///
@@ -80,8 +70,11 @@ public override void OnAwake() {
/// Updates the emissive color of the material so that it matches the light color.
///
public virtual void UpdateLightTextureColor() {
- var newColor = GetLightTextureColor();
- lightMaterial.SetColor("_EmissiveColor", newColor);
+ // By default, update all the emissive materials.
+ part.FindModelComponents()
+ .Where(r => r.material.HasProperty("_EmissiveColor"))
+ .ToList()
+ .ForEach(r => r.material.SetColor("_EmissiveColor", GetLightTextureColor()));
}
/// Returns a color to set on the emission texture.
diff --git a/Source/ModuleStockLightColoredLens.cs b/Source/ModuleStockLightColoredLens.cs
index 2185e6f..4914fcf 100644
--- a/Source/ModuleStockLightColoredLens.cs
+++ b/Source/ModuleStockLightColoredLens.cs
@@ -14,6 +14,16 @@ namespace SurfaceLights {
/// parts ignores color settings and resets emissive color to default.
///
public class ModuleStockLightColoredLens : ModuleColoredLensLight {
+
+ /// The model path for animation to adjust the emission color.
+ ///
+ /// It's the model that contains the light's lens. It may change from model to model, but this
+ /// module was designed specifically for the game stock parts! So keep this string in sync
+ /// with the stock models.
+ ///
+ ///
+ const string EmissiveLensModelPath = "";
+
///
public override void OnLoad(ConfigNode node) {
base.OnLoad(node);
@@ -32,9 +42,9 @@ void ReplaceLigthOnOffAnimation(Animation animation) {
Debug.LogFormat("Replacing animation clip in part {0} for {1}", part, animation.clip.name);
var clip = animation.clip;
clip.ClearCurves();
- clip.SetCurve("", typeof(Material), "_EmissiveColor.a",
+ clip.SetCurve(EmissiveLensModelPath, typeof(Material), "_EmissiveColor.a",
AnimationCurve.EaseInOut(0, 0, 1.0f, 1.0f));
- clip.SetCurve("spotlight", typeof(Light), "m_Intensity",
+ clip.SetCurve(lightName, typeof(Light), "m_Intensity",
AnimationCurve.EaseInOut(0, 0, 1.0f, 1.0f));
}
}
diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs
index e1e2796..c8f6d6d 100644
--- a/Source/Properties/AssemblyInfo.cs
+++ b/Source/Properties/AssemblyInfo.cs
@@ -24,8 +24,8 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
-[assembly: AssemblyVersion ("1.11.*")]
-[assembly: AssemblyInformationalVersion ("1.11 for KSP v1.6+")]
+[assembly: AssemblyVersion ("1.12.*")]
+[assembly: AssemblyInformationalVersion ("1.12 for KSP v1.6+")]
[assembly: Guid ("a4d0ab40-75bd-44fb-80bc-f50c194faf4c")]
-[assembly: KSPAssembly ("SurfaceLights", 1, 11)]
+[assembly: KSPAssembly ("SurfaceLights", 1, 12)]
[assembly: AssemblyFlags (AssemblyNameFlags.PublicKey | AssemblyNameFlags.EnableJITcompileOptimizer)]
diff --git a/Source/SurfaceLights.csproj b/Source/SurfaceLights.csproj
index 9d57ea8..811bd1b 100644
--- a/Source/SurfaceLights.csproj
+++ b/Source/SurfaceLights.csproj
@@ -76,6 +76,6 @@
- IF EXIST "Q:\GameData" xcopy "$(TargetPath)" "Q:\GameData\SurfaceLights\Plugins\" /Y
+ IF EXIST "Q:\GameData\SurfaceLights" xcopy "$(TargetDir)*.dll" "Q:\GameData\SurfaceLights\Plugins\" /Y
\ No newline at end of file
diff --git a/SurfaceLights.version b/SurfaceLights.version
index c99719a..216f104 100644
--- a/SurfaceLights.version
+++ b/SurfaceLights.version
@@ -19,9 +19,9 @@
"NAME": "Surface Mounted Lights",
"URL": "https://raw.githubusercontent.com/ihsoft/SurfaceLights/master/SurfaceLights.version",
"VERSION": {
- "BUILD": 3656,
+ "BUILD": 42726,
"MAJOR": 1,
- "MINOR": 11,
- "PATCH": 6951
+ "MINOR": 12,
+ "PATCH": 7006
}
}
\ No newline at end of file
diff --git a/Tools/publish_curseforge_args.txt b/Tools/publish_curseforge_args.txt
index 8a9a29f..6327625 100644
--- a/Tools/publish_curseforge_args.txt
+++ b/Tools/publish_curseforge_args.txt
@@ -3,4 +3,4 @@
--changelog=../CHANGELOG.md
--versions=latest_all_builds
--title=SurfaceLights {tag}
---archive=../SurfaceLights_v1.11.zip
+--archive=../SurfaceLights_v1.12.zip
diff --git a/Tools/publish_github_args.txt b/Tools/publish_github_args.txt
index 1d521a9..f3f01ff 100644
--- a/Tools/publish_github_args.txt
+++ b/Tools/publish_github_args.txt
@@ -4,4 +4,4 @@
--changelog=../CHANGELOG.md
--as_draft
--title=SurfaceLights v{tag}
---archive=../SurfaceLights_v1.11.zip
+--archive=../SurfaceLights_v1.12.zip
diff --git a/Tools/publish_spacedock_args.txt b/Tools/publish_spacedock_args.txt
index 7277ab1..bedd640 100644
--- a/Tools/publish_spacedock_args.txt
+++ b/Tools/publish_spacedock_args.txt
@@ -2,4 +2,4 @@
--login=<>
--changelog=../CHANGELOG.md
--ksp_version=latest
---archive=../SurfaceLights_v1.11.zip
+--archive=../SurfaceLights_v1.12.zip