Esempio n. 1
0
        private void ApplyToMainMenu()
        {
            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {
                GameObject go = Tools.GetMainMenuObject(body);

                if (go != null && go.transform != mainMenuBodyTransform)
                {
                    mainMenuCamera = GameObject.FindObjectsOfType <Camera>().First(c => (c.cullingMask & (1 << go.layer)) > 0 && c.isActiveAndEnabled);

                    if (layer2D != null)
                    {
                        if (mainMenuLayer != null)
                        {
                            mainMenuLayer.Remove();
                        }
                        mainMenuBodyTransform = go.transform;
                        mainMenuLayer         = layer2D.CloneForMainMenu(go);
                        CloudsManager.Log(this.name + " Applying to main menu!");
                    }
                }
                else if (go == null)
                {
                    CloudsManager.Log("Cannot find " + body + " to apply to main Menu!");
                }
                else if (mainMenuBodyTransform == go.transform)
                {
                    CloudsManager.Log("Already Applied to main Menu!");
                }
            }
        }
        internal Clouds2D CloneForMainMenu(GameObject mainMenuBody)
        {
            Clouds2D mainMenu = new Clouds2D();

            mainMenu.macroCloudMaterial = this.macroCloudMaterial;
            mainMenu.shadowMaterial     = this.shadowMaterial;
            mainMenu.isMainMenu         = true;

            if (mainMenuBody.name.EndsWith("(Clone)"))
            {
                // There is a race condition with Kopernicus. Sometimes, it
                // will have cloned a body that already had clouds. Hide old clouds.
                for (var c = 0; c < mainMenuBody.transform.childCount; ++c)
                {
                    var child = mainMenuBody.transform.GetChild(c).gameObject;
                    if (child.name.StartsWith("EVE ") && child.name.EndsWith("(Clone)"))
                    {
                        child.SetActive(false);
                    }
                }
            }

            mainMenu.Apply(this.celestialBody, mainMenuBody.transform, this.cloudsMat, this.CloudMesh.name, this.radius, this.arc, (Tools.Layer)mainMenuBody.layer);

            return(mainMenu);
        }
        internal Clouds2D CloneForMainMenu(GameObject mainMenuBody)
        {
            Clouds2D mainMenu = new Clouds2D();

            mainMenu.macroCloudMaterial = this.macroCloudMaterial;
            mainMenu.shadowMaterial     = this.shadowMaterial;
            mainMenu.isMainMenu         = true;
            mainMenu.Apply(this.celestialBody, mainMenuBody.transform, this.cloudsMat, this.radius, (Tools.Layer)mainMenuBody.layer);

            return(mainMenu);
        }
Esempio n. 4
0
        private void SceneLoaded(GameScenes scene)
        {
            if (scene != GameScenes.SPACECENTER && scene != GameScenes.FLIGHT)
            {
                this.OnSphereInactive();
                sphere.isActive = false;
            }
            if (scene != GameScenes.SPACECENTER && scene != GameScenes.FLIGHT && scene != GameScenes.TRACKSTATION && scene != GameScenes.MAINMENU)
            {
                this.OnSphereInactive();
                sphere.isActive = false;
                this.enabled    = false;
            }
            else
            {
                this.enabled = true;
            }

            if (scene == GameScenes.MAINMENU)
            {
                ApplyToMainMenu();
            }
            else
            {
                if (mainMenuLayer != null)
                {
                    mainMenuLayer.Remove();
                }
                mainMenuLayer = null;
            }

            if (scene == GameScenes.SPACECENTER || scene == GameScenes.FLIGHT)
            {
                Camera[] cameras = Camera.allCameras;
                foreach (Camera cam in cameras)
                {
                    if (cam.name == "Camera 01" || cam.name == "Camera 00")
                    {
                        cam.depthTextureMode = DepthTextureMode.Depth;
                    }
                }
                if (ScaledCamera.Instance != null && ScaledCamera.Instance.GetComponent <Camera>() != null)
                {
                    ScaledCamera.Instance.GetComponent <Camera>().depthTextureMode = DepthTextureMode.Depth;
                }
            }

            if (scene == GameScenes.FLIGHT)
            {
                StartCoroutine(DelayedCheckForSphereInactive());
            }
        }
Esempio n. 5
0
 public void Remove()
 {
     if (layer2D != null)
     {
         layer2D.Remove();
     }
     if (mainMenuLayer != null)
     {
         mainMenuLayer.Remove();
     }
     if (layerVolume != null)
     {
         layerVolume.Remove();
     }
     layer2D               = null;
     mainMenuLayer         = null;
     layerVolume           = null;
     volumeApplied         = false;
     this.enabled          = false;
     this.sphere           = null;
     this.transform.parent = null;
     GameEvents.OnMapExited.Remove(ExitMapView);
     GameEvents.onGameSceneLoadRequested.Remove(SceneLoaded);
 }
Esempio n. 6
0
        internal void Apply(String body, CloudsMaterial cloudsMaterial, Clouds2D layer2D, CloudsVolume layerVolume, float altitude, Vector3d speed, Vector3d detailSpeed, Vector3 offset, Matrix4x4 rotationAxis, bool killBodyRotation)
        {
            this.body             = body;
            this.cloudsMaterial   = cloudsMaterial;
            this.layer2D          = layer2D;
            this.layerVolume      = layerVolume;
            this.altitude         = altitude;
            this.offset           = -offset;
            this.rotationAxis     = rotationAxis;
            this.killBodyRotation = killBodyRotation;

            celestialBody            = Tools.GetCelestialBody(body);
            scaledCelestialTransform = Tools.GetScaledTransform(body);
            PQS pqs = null;

            if (celestialBody != null && celestialBody.pqsController != null)
            {
                pqs = celestialBody.pqsController;
            }
            else
            {
                CloudsManager.Log("No PQS! Instanciating one.");
                pqs = PQSManagerClass.GetPQS(body);
            }
            CloudsManager.Log("PQS Applied");
            if (pqs != null)
            {
                this.sphere           = pqs;
                this.transform.parent = pqs.transform;
                this.requirements     = PQS.ModiferRequirements.Default;
                this.modEnabled       = true;
                this.order           += 10;

                this.transform.localPosition = Vector3.zero;
                this.transform.localRotation = Quaternion.identity;
                this.transform.localScale    = Vector3.one;
                this.radius = (altitude + celestialBody.Radius);


                double circumference = 2f * Mathf.PI * radius;
                mainPeriod   = -(speed) / circumference;
                detailPeriod = -(detailSpeed) / circumference;

                if (layer2D != null)
                {
                    this.layer2D.Apply(celestialBody, scaledCelestialTransform, cloudsMaterial, this.name, (float)radius);
                }

                if (!pqs.isActive || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                {
                    this.OnSphereInactive();
                }
                else
                {
                    this.OnSphereActive();
                }
                this.OnSetup();
                pqs.EnableSphere();
            }
            else
            {
                CloudsManager.Log("PQS is null somehow!?");
            }

            GameEvents.OnMapExited.Add(ExitMapView);
            GameEvents.onGameSceneLoadRequested.Add(SceneLoaded);

            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {
                ApplyToMainMenu();
            }
        }
        private void SceneLoaded(GameScenes scene)
        {
            if (scene != GameScenes.SPACECENTER && scene != GameScenes.FLIGHT)
            {
                this.OnSphereInactive();
                sphere.isActive = false;
            }
            if (scene != GameScenes.SPACECENTER && scene != GameScenes.FLIGHT && scene != GameScenes.TRACKSTATION && scene != GameScenes.MAINMENU)
            {
                this.OnSphereInactive();
                sphere.isActive = false;
                this.enabled = false;
            }
            else
            {
                this.enabled = true;
            }

            if (scene == GameScenes.MAINMENU)
            {
                ApplyToMainMenu();
            }
            else
            {
                if (mainMenuLayer != null)
                {
                    mainMenuLayer.Remove();
                }
                mainMenuLayer = null;
            }

            if(scene == GameScenes.SPACECENTER || scene == GameScenes.FLIGHT)
            {
                Camera[] cameras = Camera.allCameras;
                foreach (Camera cam in cameras)
                {
                    if (cam.name == "Camera 01" || cam.name == "Camera 00")
                    {
                        cam.depthTextureMode = DepthTextureMode.Depth;
                    }
                }
                if (ScaledCamera.Instance != null && ScaledCamera.Instance.GetComponent<Camera>() != null)
                {
                    ScaledCamera.Instance.GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
                }
            }
        }
        private void ApplyToMainMenu()
        {
            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {

                GameObject go = Tools.GetMainMenuObject(body);

                if (go != null && go.transform != mainMenuBodyTransform)
                {
                    mainMenuCamera = GameObject.FindObjectsOfType<Camera>().First(c => ( c.cullingMask & (1<<go.layer) ) > 0 && c.isActiveAndEnabled);

                    if (layer2D != null)
                    {
                        if (mainMenuLayer != null)
                        {
                            mainMenuLayer.Remove();
                        }
                        mainMenuBodyTransform = go.transform;
                        mainMenuLayer = layer2D.CloneForMainMenu(go);
                        CloudsManager.Log(this.name + " Applying to main menu!");
                    }
                }
                else if (go == null)
                {
                    CloudsManager.Log("Cannot Find to apply to main Menu!");
                }
                else if (mainMenuBodyTransform == go.transform)
                {
                    CloudsManager.Log("Already Applied to main Menu!");
                }
            }
        }
        internal void Apply(String body, CloudsMaterial cloudsMaterial, Clouds2D layer2D, CloudsVolume layerVolume, float altitude, Vector3d speed, Vector3d detailSpeed, Vector3 offset, Matrix4x4 rotationAxis, bool killBodyRotation)
        {
            this.body = body;
            this.cloudsMaterial = cloudsMaterial;
            this.layer2D = layer2D;
            this.layerVolume = layerVolume;
            this.altitude = altitude;
            this.offset = -offset;
            this.rotationAxis = rotationAxis;
            this.killBodyRotation = killBodyRotation;

            celestialBody = Tools.GetCelestialBody(body);
            scaledCelestialTransform = Tools.GetScaledTransform(body);
            PQS pqs = null;
            if (celestialBody != null && celestialBody.pqsController != null)
            {
                pqs = celestialBody.pqsController;
            }
            else
            {
                CloudsManager.Log("No PQS! Instanciating one.");
                pqs = PQSManagerClass.GetPQS(body);
            }
            CloudsManager.Log("PQS Applied");
            if (pqs != null)
            {
                this.sphere = pqs;
                this.transform.parent = pqs.transform;
                this.requirements = PQS.ModiferRequirements.Default;
                this.modEnabled = true;
                this.order += 10;

                this.transform.localPosition = Vector3.zero;
                this.transform.localRotation = Quaternion.identity;
                this.transform.localScale = Vector3.one;
                this.radius = (altitude + celestialBody.Radius);

                double circumference = 2f * Mathf.PI * radius;
                mainPeriod = -(speed) / circumference;
                detailPeriod = -(detailSpeed) / circumference;

                if (layer2D != null)
                {
                    this.layer2D.Apply(celestialBody, scaledCelestialTransform, cloudsMaterial, (float)radius);
                }

                if (!pqs.isActive || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                {
                    this.OnSphereInactive();
                }
                else
                {
                    this.OnSphereActive();
                }
                this.OnSetup();
                pqs.EnableSphere();
            }
            else
            {
                CloudsManager.Log("PQS is null somehow!?");
            }

            GameEvents.OnMapExited.Add(ExitMapView);
            GameEvents.onGameSceneLoadRequested.Add(SceneLoaded);

            if (HighLogic.LoadedScene == GameScenes.MAINMENU)
            {
                ApplyToMainMenu();
            }
        }
 public void Remove()
 {
     if (layer2D != null)
     {
         layer2D.Remove();
     }
     if(mainMenuLayer != null)
     {
         mainMenuLayer.Remove();
     }
     if (layerVolume != null)
     {
         layerVolume.Remove();
     }
     layer2D = null;
     mainMenuLayer = null;
     layerVolume = null;
     volumeApplied = false;
     this.enabled = false;
     this.sphere = null;
     this.transform.parent = null;
     GameEvents.OnMapExited.Remove(ExitMapView);
     GameEvents.onGameSceneLoadRequested.Remove(SceneLoaded);
 }
 internal Clouds2D CloneForMainMenu(GameObject mainMenuBody)
 {
     Clouds2D mainMenu = new Clouds2D();
     mainMenu.macroCloudMaterial = this.macroCloudMaterial;
     mainMenu.shadowMaterial = this.shadowMaterial;
     mainMenu.isMainMenu = true;
     mainMenu.Apply(this.celestialBody, mainMenuBody.transform, this.cloudsMat, this.radius, (Tools.Layer)mainMenuBody.layer);
     
     return mainMenu;
 }