Esempio n. 1
0
 public void Start()
 {
     if (!CompatibilityChecker.IsCompatible())
     {
         isCompatible = false;
         return;
     }
     if (afg == null)
     {
         afg = findAFG();
     }
     //print("[AFGEditor] Start()");
     windowStyle = new GUIStyle(HighLogic.Skin.window);
     windowStyle.stretchHeight = true;
 }
Esempio n. 2
0
        public void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                isCompatible = false;
                return;
            }

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

            GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged);
            GameEvents.onVesselSituationChange.Add(OnVesselSituationChanged);
        }
Esempio n. 3
0
        public void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                isCompatible = false;
                return;
            }
            if (!(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.SPACECENTER))
            {
                return;
            }
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM"))
            {
                RSSSettings = node;
            }

            GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged);
        }
Esempio n. 4
0
        public void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                isCompatible = false;
                return;
            }
            if (!(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.SPACECENTER))
            {
                return;
            }
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM"))
            {
                RSSSettings = node;
            }

            if (RSSSettings != null)
            {
                RSSSettings.TryGetValue("dumpOrbits", ref dumpOrbits);
            }

            UpdateAtmospheres();
            GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged);
        }
Esempio n. 5
0
        public void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                isCompatible = false;
                return;
            }
            if (HighLogic.LoadedScene.Equals(GameScenes.MAINMENU))
            {
                ready = true;
            }
            if (!ready)
            {
                return;
            }

            if (HighLogic.LoadedSceneHasPlanetarium && PlanetariumCamera.fetch)
            {
                print("*RSS* Fixing PCam. Min " + PlanetariumCamera.fetch.minDistance + ", Max " + PlanetariumCamera.fetch.maxDistance + ". Start " + PlanetariumCamera.fetch.startDistance + ", zoom " + PlanetariumCamera.fetch.zoomScaleFactor);
                PlanetariumCamera.fetch.maxDistance = 1e10f;
                print("Fixed. Min " + PlanetariumCamera.fetch.minDistance + ", Max " + PlanetariumCamera.fetch.maxDistance + ". Start " + PlanetariumCamera.fetch.startDistance + ", zoom " + PlanetariumCamera.fetch.zoomScaleFactor);
            }
            // HoneyFox
            if (HighLogic.LoadedSceneHasPlanetarium && MapView.fetch != null)
            {
                try
                {
                    ConfigNode camNode = null;
                    foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEMSETTINGS"))
                    {
                        camNode = node;
                    }
                    if (camNode != null)
                    {
                        camNode.TryGetValue("max3DlineDrawDist", ref MapView.fetch.max3DlineDrawDist);
                    }
                }
                catch (Exception e)
                {
                    print("MapView fixing failed: " + e.Message);
                }
            }
            if (HighLogic.LoadedSceneIsEditor)
            {
                StartCoroutine(EditorBoundsFixer());
            }
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                PQSCity ksc = null;
                foreach (PQSCity city in Resources.FindObjectsOfTypeAll(typeof(PQSCity)))
                {
                    if (city.name == "KSC")
                    {
                        ksc = city;
                        break;
                    }
                }
                if (ksc == null)
                {
                    Debug.Log("*RSS* could not find KSC to fix the camera.");
                    return;
                }
                foreach (SpaceCenterCamera2 cam in Resources.FindObjectsOfTypeAll(typeof(SpaceCenterCamera2)))
                {
                    if (ksc.repositionToSphere || ksc.repositionToSphereSurface)
                    {
                        CelestialBody Kerbin = FlightGlobals.Bodies.Find(body => body.name == ksc.sphere.name);
                        if (Kerbin == null)
                        {
                            Debug.Log("*RSS* could not find find the CelestialBody specified as KSC's sphere.");
                            return;
                        }
                        double nomHeight = Kerbin.pqsController.GetSurfaceHeight((Vector3d)ksc.repositionRadial.normalized) - Kerbin.Radius;
                        if (ksc.repositionToSphereSurface)
                        {
                            nomHeight += ksc.repositionRadiusOffset;
                        }
                        cam.altitudeInitial = 0f - (float)nomHeight;
                    }
                    else
                    {
                        cam.altitudeInitial = 0f - (float)ksc.repositionRadiusOffset;
                    }
                    cam.ResetCamera();
                    Debug.Log("*RSS* fixed the Space Center camera.");
                }
            }
        }
 public void Start()
 {
     if (!CompatibilityChecker.IsCompatible())
     {
         return;
     }
     if (!fixedSolar && HighLogic.LoadedScene.Equals(GameScenes.MAINMENU))
     {
         fixedSolar = true;
         print("*RSS* Fixing Solar Panels");
         if (PartLoader.LoadedPartsList != null)
         {
             ConfigNode curveNode = null;
             foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEMSETTINGS"))
             {
                 curveNode = node.GetNode("powerCurve");
             }
             if (curveNode != null)
             {
                 foreach (Part p in Resources.FindObjectsOfTypeAll(typeof(Part)))
                 {
                     try
                     {
                         if (p.Modules.Contains("ModuleDeployableSolarPanel"))
                         {
                             ModuleDeployableSolarPanel sp = (ModuleDeployableSolarPanel)(p.Modules["ModuleDeployableSolarPanel"]);
                             FixSP(sp, curveNode);
                             print("Fixed " + p.name + " (" + p.partInfo.title + ")");
                         }
                     }
                     catch (Exception e)
                     {
                         print("Solar panel fixing failed for " + p.name + ": " + e.Message);
                     }
                 }
                 ConfigNode[] allParts = GameDatabase.Instance.GetConfigNodes("PART");
                 for (int j = 0; j < allParts.Count(); j++)
                 {
                     try
                     {
                         ConfigNode pNode = allParts[j];
                         if (pNode.nodes == null || pNode.nodes.Count <= 0)
                         {
                             continue;
                         }
                         for (int i = 0; i < pNode.nodes.Count; i++)
                         {
                             ConfigNode node = pNode.nodes[i];
                             if (node.name.Equals("MODULE"))
                             {
                                 if (node.HasValue("name") && node.GetValue("name").Equals("ModuleDeployableSolarPanel"))
                                 {
                                     node.RemoveNode("powerCurve");
                                     node.AddNode(curveNode);
                                     print("Fixed part config " + pNode.GetValue("name") + " (" + pNode.GetValue("title") + ")");
                                 }
                             }
                         }
                     }
                     catch (Exception e)
                     {
                         print("Solar panel fixing of part confignodes failed: " + e.Message);
                     }
                 }
             }
             try
             {
                 EditorPartList.Instance.Refresh();
             }
             catch
             {
             }
         }
     }
 }
Esempio 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);
                }
            }
        }