Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for KSP 1.1 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Source/LightsOut/LOAmbient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class LOAmbient {
Color originalAmbientLight;
LightmapData[] originalLightmapData;
Material originalSkybox;
float originalAmbientIntensity;

public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameObjects, Camera camera, int layer) {
mainCamera = camera;
Expand All @@ -29,14 +30,15 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb
originalAmbientLight = RenderSettings.ambientLight;
originalSkybox = RenderSettings.skybox;
originalLightmapData = LightmapSettings.lightmaps;
originalAmbientIntensity = RenderSettings.ambientIntensity;

// Create fake skybox
skyCamera = new GameObject("NightSkyboxCamera", typeof(Camera));
skyCamera.camera.depth = mainCamera.depth - 1;
skyCamera.camera.clearFlags = CameraClearFlags.Skybox;
skyCamera.camera.cullingMask = 0;

nightSkyboxMaterial = new Material(originalSkybox);
skyCamera.GetComponent<Camera>().depth = mainCamera.depth - 1;
skyCamera.GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
skyCamera.GetComponent<Camera>().cullingMask = 0;
nightSkyboxMaterial = new Material(originalSkybox);

// GalaxyTex_PositiveX should be viewed outside window
Debug.Log("LightsOut: Loading Night Sky Textures");
Expand Down Expand Up @@ -104,8 +106,8 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb
ChangeLayersRecursively(gameObject, newLayer, "Component_611_4");
ChangeLayersRecursively(gameObject, newLayer, "Component_611_5");
ChangeLayersRecursively(gameObject, newLayer, "Component_611_6");
//ChangeLayersRecursively(gameObject, newLayer, "Component_749_1"); // Glow from Side Lights!
//ChangeLayersRecursively(gameObject, newLayer, "Component_750_1"); // Lights!
ChangeLayersRecursively(gameObject, newLayer, "Component_749_1"); // Glow from Side Lights!
ChangeLayersRecursively(gameObject, newLayer, "Component_750_1"); // Lights!
}
break;
}
Expand All @@ -114,8 +116,10 @@ public LOAmbient(EditorFacility facility, EditorLevel level, GameObject[] gameOb

public void SetAmbientMode(EditorTime time) {
if (time == EditorTime.Night) {
RenderSettings.ambientLight = new Color(0.15f, 0.15f, 0.15f);

RenderSettings.ambientLight = new Color(0.05f, 0.05f, 0.05f);
RenderSettings.fog = false;
RenderSettings.ambientIntensity = 0.05f;
mainCamera.clearFlags = CameraClearFlags.Nothing;
LightmapSettings.lightmaps = new LightmapData[] { };

Expand All @@ -125,6 +129,7 @@ public void SetAmbientMode(EditorTime time) {
RenderSettings.ambientLight = originalAmbientLight;
RenderSettings.fog = true;
RenderSettings.skybox = originalSkybox;
RenderSettings.ambientIntensity = originalAmbientIntensity;
mainCamera.clearFlags = originalClearFlags;
LightmapSettings.lightmaps = originalLightmapData;

Expand Down
57 changes: 34 additions & 23 deletions Source/LightsOut/LOExternalLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:53:55.158] Light 5: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON
//[LOG 17:53:55.159] Parent: Day Lights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" },
new LightToChange(){ name = "Spotlight", parentName = "Day Lights" }
};
new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" },
new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, //
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" }
};
break;

case EditorLevel.Level2:
Expand All @@ -57,10 +59,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:56:18.874] Light 7: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON
//[LOG 17:56:18.875] Parent: Day Lights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" },
new LightToChange(){ name = "Spotlight", parentName = "Day Lights" },
new LightToChange(){ name = "roofFill", parentName = "Day Lights" }
};
new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" },
new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, //
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" }
};
break;

case EditorLevel.Level3:
Expand All @@ -85,9 +88,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:58:21.712] Light 9: Spotlight, RGBA(1.000, 1.000, 1.000, 1.000), Default ON
//[LOG 17:58:21.713] Parent: Day Lights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightSun", parentName = "Day Lights" },
new LightToChange(){ name = "Spotlight", parentName = "Day Lights" }
};
new LightToChange(){ name = "SpotlightCraft", parentName = "Day Lights" },
new LightToChange(){ name = "SpotlightSun", parentName = "VAB_interior_modern" }, //
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Shadow Light", parentName = "Day Lights" }
};
break;
}
}
Expand All @@ -111,9 +116,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:54:50.077] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default OFF
//[LOG 17:54:50.078] Parent: Editors_DayLights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" },
new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" }
};
new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" }
};
break;

case EditorLevel.Level2:
Expand All @@ -134,9 +141,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:57:04.724] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default OFF
//[LOG 17:57:04.725] Parent: Editors_DayLights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" },
new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" }
};
new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" }
};
break;

case EditorLevel.Level3:
Expand All @@ -157,10 +166,11 @@ public LOExternalLights(EditorFacility facility, EditorLevel level) {
//[LOG 17:59:41.833] Light 7: SpotlightWindow, RGBA(0.866, 0.863, 0.903, 1.000), Default ON
//[LOG 17:59:41.834] Parent: Editors_DayLights
lightsToChange = new List<LightToChange>() {
new LightToChange(){ name = "SpotlightCraft", parentName = "Editors_DayLights" },
new LightToChange(){ name = "SpotlightExteriorSun", parentName = "Editors_DayLights" },
new LightToChange(){ name = "SpotlightWindow", parentName = "Editors_DayLights" }
};
new LightToChange(){ name = "Realtime_SpotlightCraft", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_ExteriorSun", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_SpotlightScenery", parentName = "Lighting_Realtime" },
new LightToChange(){ name = "Realtime_Shadow Light", parentName = "Lighting_Realtime" }
};
break;
}
}
Expand All @@ -172,9 +182,10 @@ public void SetExternalLightsMode(EditorTime time, Light[] lights) {
foreach (LightToChange lightToChange in lightsToChange) {
if (light.name.Equals(lightToChange.name, StringComparison.Ordinal)
&& light.transform.parent.gameObject.name.Equals(lightToChange.parentName, StringComparison.Ordinal)) {
light.enabled = (time == EditorTime.Day ? true : false);
}
}
light.enabled = (time == EditorTime.Day ? true : false);
//Debug.Log("Light: " + light.name + ", Parent: " + light.transform.parent.gameObject.name + ", " + light.color + ", Default " + (light.enabled ? "ON" : "OFF"));
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/LightsOut/LOShaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LOShaders(EditorFacility facility, EditorLevel level, GameObject[] gameOb

List<string> defaultShaders = new List<string>() {
"KSP/Emissive/Specular",
"KSP/Emissive/Bumped",
"KSP/Bumped",
"KSP/Emissive/Diffuse"
};

Expand Down
3 changes: 2 additions & 1 deletion Source/LightsOut/LightsOut.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using KSP.UI.Screens;
using System;
using System.Collections.Generic;
using UnityEngine;

Expand Down