Exemplo n.º 1
0
            // Patches all light sources
            private void SetActive(GameScenes scene)
            {
                GameObject sunLight       = GameObject.Find("SunLight");
                GameObject scaledSunLight = GameObject.Find("Scaledspace SunLight");

                if (sunLight && scaledSunLight)
                {
                    Light light       = sunLight.GetComponent <Light>();
                    Light scaledLight = scaledSunLight.GetComponent <Light>();
                    if (sunlightColor != null)
                    {
                        light.color = sunlightColor;
                    }

                    if (sunlightIntensity != float.NaN)
                    {
                        light.intensity = sunlightIntensity;
                    }

                    if (sunlightShadowStrength != float.NaN)
                    {
                        light.shadowStrength = sunlightShadowStrength;
                    }

                    if (scaledSunlightColor != null)
                    {
                        scaledLight.color = scaledSunlightColor;
                    }

                    if (scaledSunlightIntensity != float.NaN)
                    {
                        scaledLight.intensity = scaledSunlightIntensity;
                    }

                    if (scene == GameScenes.FLIGHT)
                    {
                        GameObject IVASun = GameObject.Find("IVASun");
                        if (IVASun)
                        {
                            Light IVALight = IVASun.GetComponent <Light>();
                            if (IVASunColor != null)
                            {
                                IVALight.color = IVASunColor;
                            }
                            if (IVASunIntensity != float.NaN)
                            {
                                IVALight.intensity = IVASunIntensity;
                            }
                        }
                    }

                    DynamicAmbientLight ambientLight = FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;
                    if (ambientLightColor != null && ambientLight)
                    {
                        ambientLight.vacuumAmbientColor = ambientLightColor;
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Applies the ambient color.
        /// </summary>
        public void ApplyAmbient()
        {
            DynamicAmbientLight ambientLight = FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;

            if (ambientLight)
            {
                ambientLight.vacuumAmbientColor = ambientLightColor;
            }
        }
Exemplo n.º 3
0
 public void Start()
 {
     PlanetShine.PlanetShine.ambientLight = Object.FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;
     this.vacuumColor = new Color(this.config.vacuumLightLevel, this.config.vacuumLightLevel, this.config.vacuumLightLevel);
     if (Object.op_Inequality((Object)PlanetShine.PlanetShine.ambientLight, (Object)null))
     {
         PlanetShine.PlanetShine.ambientLight.vacuumAmbientColor = (__Null)this.vacuumColor;
     }
     this.CreateAlbedoLights();
     this.CreateDebugLines();
 }
Exemplo n.º 4
0
 public void Start()
 {
     ambientLight = FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;
     vacuumColor  = new Color(config.vacuumLightLevel, config.vacuumLightLevel, config.vacuumLightLevel);
     if (ambientLight != null)
     {
         ambientLight.vacuumAmbientColor = vacuumColor;
     }
     CreateAlbedoLights();
     CreateDebugLines();
 }
Exemplo n.º 5
0
 private void UpdateAmbientLights()
 {
     if (!Object.op_Inequality((Object)PlanetShine.PlanetShine.ambientLight, (Object)null))
     {
         return;
     }
     this.vacuumColor.r = (__Null)(double)(this.vacuumColor.g = this.vacuumColor.b = (__Null)this.config.vacuumLightLevel);
     PlanetShine.PlanetShine.ambientLight.vacuumAmbientColor = (__Null)this.vacuumColor;
     if (PlanetShine.PlanetShine.renderEnabled && !MapView.get_MapIsEnabled())
     {
         DynamicAmbientLight ambientLight = PlanetShine.PlanetShine.ambientLight;
         ambientLight.vacuumAmbientColor = (__Null)Color.op_Addition((Color)ambientLight.vacuumAmbientColor, Color.op_Multiply(this.atmosphereAmbientEffect * this.visibleLightAngleEffect, this.bodyColor));
         RenderSettings.set_ambientLight(Color.op_Multiply(RenderSettings.get_ambientLight(), (float)(1.0 - (double)this.config.groundAmbientOverrideRatio * (double)this.bodyGroundAmbientOverride)));
         RenderSettings.set_ambientLight(Color.op_Addition(RenderSettings.get_ambientLight(), Color.op_Multiply(Color.op_Multiply((Color)PlanetShine.PlanetShine.ambientLight.vacuumAmbientColor, this.config.groundAmbientOverrideRatio), this.bodyGroundAmbientOverride)));
     }
 }
Exemplo n.º 6
0
        public void Start()
        {
            if (Instance != null)
                Destroy (Instance.gameObject);
            Instance = this;

            ambientLight = FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;

            vacuumColor = new Color (config.vacuumLightLevel, config.vacuumLightLevel, config.vacuumLightLevel);
            if (ambientLight != null) {
                ambientLight.vacuumAmbientColor = vacuumColor;
            }

            CreateAlbedoLights ();
            CreateDebugLines ();
        }
Exemplo n.º 7
0
        void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                return;
            }
            //The lights are instantiated on each scene startup, unlike planets which instantiate at the beginning of the game
            //so a more specific check has to be performed
            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                ConfigNode RSSSettings = null;

                foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEMSETTINGS"))
                {
                    RSSSettings = node;
                }

                if (RSSSettings == null)
                {
                    print("*RSS* REALSOLARSYSTEMSETTINGS node not found, could not load light settings!");
                    return;
                }

                GameObject sunLight       = GameObject.Find("SunLight");
                GameObject scaledSunLight = GameObject.Find("Scaledspace SunLight");

                if (sunLight != null)
                {
                    print("*RSS* LightShifter: Found sunlight and scaled sunlight, shifting...");

                    if (RSSSettings.HasValue("sunlightColor"))
                    {
                        try {
                            Vector4 col = KSPUtil.ParseVector4(RSSSettings.GetValue("sunlightColor"));
                            Color   c   = new Color(col.x, col.y, col.z, col.w);
                            sunLight.light.color = c;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as color4: original text: " + RSSSettings.GetValue("sunlightColor") + " --- exception " + e.Message);
                        }
                    }

                    if (RSSSettings.HasValue("sunlightIntensity"))
                    {
                        try {
                            float f = float.Parse(RSSSettings.GetValue("sunlightIntensity"));
                            sunLight.light.intensity = f;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as float: original text: " + RSSSettings.GetValue("sunlightIntensity") + " --- exception " + e.Message);
                        }
                    }

                    if (RSSSettings.HasValue("sunlightShadowStrength"))
                    {
                        try {
                            float f = float.Parse(RSSSettings.GetValue("sunlightShadowStrength"));
                            sunLight.light.shadowStrength = f;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as float: original text: " + RSSSettings.GetValue("sunlightShadowStrength") + " --- exception " + e.Message);
                        }
                    }

                    if (RSSSettings.HasValue("scaledSunlightColor"))
                    {
                        try {
                            Vector4 col = KSPUtil.ParseVector4(RSSSettings.GetValue("scaledSunlightColor"));
                            Color   c   = new Color(col.x, col.y, col.z, col.w);
                            scaledSunLight.light.color = c;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as color4: original text: " + RSSSettings.GetValue("scaledSunlightColor") + " --- exception " + e.Message);
                        }
                    }

                    if (RSSSettings.HasValue("scaledSunlightIntensity"))
                    {
                        try {
                            float f = float.Parse(RSSSettings.GetValue("scaledSunlightIntensity"));
                            scaledSunLight.light.intensity = f;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as float: original text: " + RSSSettings.GetValue("scaledSunlightIntensity") + " --- exception " + e.Message);
                        }
                    }
                }
                else
                {
                    print("*RSS* LightShifter: Couldn't find either sunlight or scaled sunlight");
                }

                if (HighLogic.LoadedScene == GameScenes.FLIGHT)
                {
                    GameObject IVASun = GameObject.Find("IVASun");

                    if (IVASun != null)
                    {
                        print("LightShifter: Found IVA sun, shifting...");

                        if (RSSSettings.HasValue("IVASunColor"))
                        {
                            try {
                                Vector4 col = KSPUtil.ParseVector4(RSSSettings.GetValue("IVASunColor"));
                                Color   c   = new Color(col.x, col.y, col.z, col.w);
                                IVASun.light.color = c;
                            } catch (Exception e) {
                                print("*RSS* Error parsing as color4: original text: " + RSSSettings.GetValue("IVASunColor") + " --- exception " + e.Message);
                            }
                        }

                        if (RSSSettings.HasValue("IVASunIntensity"))
                        {
                            try {
                                float f = float.Parse(RSSSettings.GetValue("IVASunIntensity"));
                                IVASun.light.intensity = f;
                            } catch (Exception e) {
                                print("*RSS* Error parsing as float: original text: " + RSSSettings.GetValue("IVASunIntensity") + " --- exception " + e.Message);
                            }
                        }
                    }
                    else
                    {
                        print("*RSS* LightShifter: No IVA sun found.");
                    }
                }

                LensFlare sunLightFlare = sunLight.gameObject.GetComponent <LensFlare>();

                if (sunLightFlare != null)
                {
                    print("*RSS* LightShifter: Shifting LensFlare");

                    if (RSSSettings.HasValue("sunlightLensFlareColor"))
                    {
                        try {
                            Vector4 col = KSPUtil.ParseVector4(RSSSettings.GetValue("sunlightLensFlareColor"));
                            Color   c   = new Color(col.x, col.y, col.z, col.w);
                            sunLightFlare.color = c;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as color4: original text: " + RSSSettings.GetValue("sunlightLensFlareColor") + " --- exception " + e.Message);
                        }
                    }
                }

                DynamicAmbientLight ambientLight = FindObjectOfType(typeof(DynamicAmbientLight)) as DynamicAmbientLight;

                //Funny story behind locating this one. When I was typing "Light l" in the foreach function earlier, one of the suggestions
                //from the autocomplete was DynamicAmbientLight. Saved me a lot of trial and error looking for it to be sure.

                if (ambientLight != null)
                {
                    print("*RSS* LightShifter: Found DynamicAmbientLight. Shifting...");

                    if (RSSSettings.HasValue("ambientLightColor"))
                    {
                        try {
                            Vector4 col = KSPUtil.ParseVector4(RSSSettings.GetValue("ambientLightColor"));
                            Color   c   = new Color(col.x, col.y, col.z, col.w);
                            ambientLight.vacuumAmbientColor = c;
                        } catch (Exception e) {
                            print("*RSS* Error parsing as color4: original text: " + RSSSettings.GetValue("ambientLightColor") + " --- exception " + e.Message);
                        }
                    }
                }
                else
                {
                    print("*RSS* LightShifter: Couldn't find DynamicAmbientLight");
                }
                Sun sun = Sun.Instance;
                if (sun != null)
                {
                    if (RSSSettings.HasValue("dumpBrightnessCurve"))
                    {
                        print("**DUMP** Sun AU: " + sun.AU);
                        for (int i = 0; i < sun.brightnessCurve.keys.Length; i++)
                        {
                            Keyframe k = sun.brightnessCurve.keys[i];
                            print("Key " + k.time + ", " + k.value + ", " + k.inTangent + "," + k.outTangent + " : mode " + k.tangentMode);
                        }
                    }
                    if (RSSSettings.HasNode("sunBrightnessCurve"))
                    {
                        AnimationCurve newCurve = Utils.LoadAnimationCurve(RSSSettings.GetNode("sunBrightnessCurve"));
                    }
                    RSSSettings.TryGetValue("sunAU", ref sun.AU);
                }
            }
        }