Esempio n. 1
0
        public void Init(ScattererCelestialBody scattererBody)
        {
            parentCelestialBody  = scattererBody.celestialBody;
            sunColor             = scattererBody.sunColor;
            flatScaledSpaceModel = scattererBody.flatScaledSpaceModel;
            usesCloudIntegration = scattererBody.usesCloudIntegration;
            hasOcean             = scattererBody.hasOcean;

            sunCelestialBody = Scatterer.Instance.scattererCelestialBodiesManager.CelestialBodies.SingleOrDefault(_cb => _cb.GetName() == scattererBody.mainSunCelestialBody);

            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {
                parentScaledTransform = Utils.GetMainMenuObject(scattererBody.celestialBodyName).transform;
                parentLocalTransform  = Utils.GetMainMenuObject(scattererBody.celestialBodyName).transform;
            }
            else
            {
                parentScaledTransform = scattererBody.transform;
                parentLocalTransform  = scattererBody.celestialBody.transform;
            }

            FindEclipseCasters(scattererBody);
            FindPlanetShineSources(scattererBody);

            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {
                GameObject _go = Utils.GetMainMenuObject(parentCelestialBody.name);
                if (_go)
                {
                    MeshRenderer _mr = _go.GetComponent <MeshRenderer> ();
                    if (_mr)
                    {
                        var sctBodyTransform = ScaledSpace.Instance.transform.FindChild(parentCelestialBody.name);
                        m_radius = (_go.transform.localScale.x / sctBodyTransform.localScale.x) * parentCelestialBody.Radius;
                    }
                }
            }
            else
            {
                m_radius = parentCelestialBody.Radius;
            }

            InitSkyAndOceanNodes();
        }
Esempio n. 2
0
 void FindEclipseCasters(ScattererCelestialBody scattererBody)
 {
     if (Scatterer.Instance.mainSettings.useEclipses)
     {
         for (int k = 0; k < scattererBody.eclipseCasters.Count; k++)
         {
             var cc = Scatterer.Instance.scattererCelestialBodiesManager.CelestialBodies.SingleOrDefault(_cb => _cb.GetName() == scattererBody.eclipseCasters [k]);
             if (cc == null)
             {
                 Utils.LogDebug("Eclipse caster " + scattererBody.eclipseCasters [k] + " not found for " + scattererBody.celestialBodyName);
             }
             else
             {
                 eclipseCasters.Add(cc);
                 Utils.LogDebug("Added eclipse caster " + scattererBody.eclipseCasters [k] + " for " + scattererBody.celestialBodyName);
             }
         }
     }
 }
Esempio n. 3
0
 void FindPlanetShineSources(ScattererCelestialBody scattererBody)
 {
     if (Scatterer.Instance.mainSettings.usePlanetShine)
     {
         for (int k = 0; k < scattererBody.planetshineSources.Count; k++)
         {
             var cc = Scatterer.Instance.scattererCelestialBodiesManager.CelestialBodies.SingleOrDefault(_cb => _cb.GetName() == scattererBody.planetshineSources [k].bodyName);
             if (cc == null)
             {
                 Utils.LogDebug("planetshine source " + scattererBody.planetshineSources [k].bodyName + " not found for " + scattererBody.celestialBodyName);
             }
             else
             {
                 AtmoPlanetShineSource src = scattererBody.planetshineSources [k];
                 src.body = cc;
                 scattererBody.planetshineSources [k].body = cc;
                 planetshineSources.Add(src);
                 Utils.LogDebug("Added planetshine source" + scattererBody.planetshineSources [k].bodyName + " for " + scattererBody.celestialBodyName);
             }
         }
     }
 }
Esempio n. 4
0
        void OnDestroy()
        {
            if (isActive)
            {
                if (usePlanetShine)
                {
                    foreach (PlanetShineLight _aLight in celestialLightSources)
                    {
                        _aLight.OnDestroy();
                        UnityEngine.Object.Destroy(_aLight);
                    }
                }

                for (int i = 0; i < scattererCelestialBodies.Count; i++)
                {
                    ScattererCelestialBody cur = scattererCelestialBodies [i];
                    if (cur.active)
                    {
                        cur.m_manager.OnDestroy();
                        UnityEngine.Object.Destroy(cur.m_manager);
                        cur.m_manager = null;
//						ReactivateAtmosphere(cur.transformName,cur.originalPlanetMaterialBackup);
                        cur.active = false;
                    }
                }

                if (ambientLightScript)
                {
                    ambientLightScript.restoreLight();
                    Component.Destroy(ambientLightScript);
                }

                if (customDepthBuffer)
                {
                    customDepthBuffer.OnDestroy();
                    Component.Destroy(customDepthBuffer);
                    UnityEngine.Object.Destroy(customDepthBuffer);
                    customDepthBufferTexture.Release();
                    UnityEngine.Object.Destroy(customDepthBufferTexture);
                }

                if (refractionCam)
                {
                    refractionCam.OnDestroy();
                    Component.Destroy(refractionCam);
                    UnityEngine.Object.Destroy(refractionCam);
                    refractionTexture.Release();
                    UnityEngine.Object.Destroy(refractionTexture);
                }

                if (useGodrays)
                {
                    if (godrayDepthTexture)
                    {
                        if (godrayDepthTexture.IsCreated())
                        {
                            godrayDepthTexture.Release();
                        }
                        UnityEngine.Object.Destroy(godrayDepthTexture);
                    }
                }


                if (farCamera)
                {
                    if (nearCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(nearCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (farCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(farCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }


                    if (scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)))
                    {
                        Component.Destroy(scaledSpaceCamera.gameObject.GetComponent(typeof(Wireframe)));
                    }
                }


                if (fullLensFlareReplacement && customSunFlareAdded)
                {
                    foreach (SunFlare customSunFlare in customSunFlares)
                    {
                        customSunFlare.cleanUp();
                        Component.Destroy(customSunFlare);
                    }

                    //re-enable stock sun flares
                    global::SunFlare[] stockFlares = (global::SunFlare[])global::SunFlare.FindObjectsOfType(typeof(global::SunFlare));
                    foreach (global::SunFlare _flare in stockFlares)
                    {
                        if (sunflaresList.Contains(_flare.sun.name))
                        {
                            _flare.sunFlare.enabled = true;
                        }
                    }
                }

                inGameWindowLocation = new Vector2(windowRect.x, windowRect.y);
                saveSettings();
            }

            else if (mainMenu)
            {
                //replace EVE cloud shaders when leaving main menu to game
                if (integrateWithEVEClouds)
                {
                    ShaderReplacer.Instance.replaceEVEshaders();
                }

                mainMenuWindowLocation = new Vector2(windowRect.x, windowRect.y);
                saveSettings();
            }


            UnityEngine.Object.Destroy(GUItool);
        }