Example #1
0
 private void OnMapExited()
 {
     if (_body != FlightGlobals.currentMainBody)
     {
         OnDemandStorage.DisableBodyCBMaps(_body.transform.name);
     }
 }
Example #2
0
            // Load the Map
            public void Load()
            {
                // Check if the Map is already loaded
                if (IsLoaded)
                {
                    return;
                }

                // Load the Map
                Texture2D map = OnDemandStorage.LoadTexture(Path, false, false, false);

                // If the map isn't null
                if (map != null)
                {
                    CreateMap(Depth, map);
                    timer          = new Timer(60000d);
                    timer.Elapsed += delegate(object sender, ElapsedEventArgs e) { Unload(); };
                    timer.Start();
                    IsLoaded = true;
                    Debug.Log("[OD] Map " + name + " enabling self. Path = " + Path);
                    return;
                }

                // Return nothing
                Debug.Log("[OD] ERROR: Failed to load map " + name + " at path " + Path);
            }
Example #3
0
 private void OnVesselLoad(Vessel vessel)
 {
     if (vessel.mainBody == _body)
     {
         OnDemandStorage.EnableBodyCBMaps(_body.transform.name);
     }
     else
     {
         OnDemandStorage.DisableBodyCBMaps(_body.transform.name);
     }
 }
Example #4
0
 private void OnGameSceneLoadRequested(GameScenes scene)
 {
     if (scene == GameScenes.TRACKSTATION)
     {
         OnDemandStorage.EnableBodyCBMaps(_body.transform.name);
     }
     else
     {
         OnDemandStorage.DisableBodyCBMaps(_body.transform.name);
     }
 }
Example #5
0
            private void OnVesselSOIChanged(GameEvents.HostedFromToAction <Vessel, CelestialBody> action)
            {
                if ([email protected] == _body.transform.name)
                {
                    OnDemandStorage.DisableBodyCBMaps(_body.transform.name);
                }

                if ([email protected] == _body.transform.name)
                {
                    OnDemandStorage.EnableBodyCBMaps(_body.transform.name);
                }
            }
            // Disabling
            public override void OnSphereInactive()
            {
                // Don't update, if the Injector is still running
                if (!isLoaded)
                {
                    return;
                }

                // Enable the maps
                if (OnDemandStorage.DisableBody(sphere.name))
                {
                    isLoaded = false;
                    Debug.Log("[OD] Disabling Body " + base.sphere.name + ": " + isLoaded);
                }
            }
            // Enabling
            public override void OnQuadPreBuild(PQ quad)
            {
                // Don't update, if the Injector is still running
                if (isLoaded)
                {
                    return;
                }

                // Enable the maps
                if (OnDemandStorage.EnableBody(sphere.name))
                {
                    isLoaded = true;
                    Debug.Log("[OD] Enabling Body " + base.sphere.name + ": " + isLoaded);
                }
            }
Example #8
0
            void UnloadTextures()
            {
                Debug.Log("[OD] <--- ScaledSpaceDemand.UnloadTextures destroying " + texture + " and " + normals);
                // Kill Diffuse
                if (OnDemandStorage.TextureExists(texture))
                {
                    DestroyImmediate(scaledRenderer.material.GetTexture("_MainTex"));
                }

                // Kill Normals
                if (OnDemandStorage.TextureExists(normals))
                {
                    DestroyImmediate(scaledRenderer.material.GetTexture("_BumpMap"));
                }

                // Flags
                isLoaded = false;
            }
Example #9
0
            void LoadTextures()
            {
                Debug.Log("[OD] --> ScaledSpaceDemand.LoadTextures loading " + texture + " and " + normals);
                // Load Diffuse
                if (OnDemandStorage.TextureExists(texture))
                {
                    scaledRenderer.material.SetTexture("_MainTex", OnDemandStorage.LoadTexture(texture, false, true, true));
                }

                // Load Normals
                if (OnDemandStorage.TextureExists(normals))
                {
                    scaledRenderer.material.SetTexture("_BumpMap", OnDemandStorage.LoadTexture(normals, false, true, false));
                }

                // Flags
                isLoaded = true;
            }
Example #10
0
            // Enabling
            public override void OnQuadPreBuild(PQ quad)
            {
                // It is supposed to be loaded now so clear the unload time
                unloadTime = 0;

                // Don't update, if the Injector is still running
                if (isLoaded)
                {
                    return;
                }

                // Enable the maps
                if (OnDemandStorage.EnableBodyPQS(sphere.name))
                {
                    isLoaded = true;
                    Debug.Log("[OD] Enabling Body " + base.sphere.name + ": " + isLoaded);
                }
            }
            void LateUpdate()
            {
                // If we aren't loaded or we're not wanting to unload then do nothing
                if (!isLoaded || unloadTime == 0)
                {
                    return;
                }

                // If we're past the unload time then unload
                if (System.Diagnostics.Stopwatch.GetTimestamp() > unloadTime)
                {
                    // Disable the maps
                    if (OnDemandStorage.DisableBody(sphere.name))
                    {
                        Debug.Log("[OD] Disabling Body " + base.sphere.name + ": " + isLoaded);
                    }
                    isLoaded = false;
                }
            }
Example #12
0
        public void UnloadTextures()
        {
            Debug.Log("[OD] <--- ScaledSpaceDemand.UnloadTextures destroying " + texture + " and " + normals);

            // Kill Diffuse
            if (OnDemandStorage.TextureExists(texture))
            {
                DestroyImmediate(scaledRenderer.sharedMaterial.GetTexture(MainTex));
            }

            // Kill Normals
            if (OnDemandStorage.TextureExists(normals))
            {
                DestroyImmediate(scaledRenderer.sharedMaterial.GetTexture(BumpMap));
            }

            // Events
            Events.OnScaledSpaceUnload.Fire(this);

            // Flags
            isLoaded = false;
        }
Example #13
0
            // Load the Map
            public void Load()
            {
                // Check if the Map is already loaded
                if (IsLoaded)
                {
                    return;
                }

                // Load the Map
                Texture2D map = OnDemandStorage.LoadTexture(Path, false, false, false);

                // If the map isn't null
                if (map != null)
                {
                    CreateMap(Depth, map);
                    IsLoaded = true;
                    Debug.Log("[OD] ---> Map " + name + " enabling self. Path = " + Path);
                    return;
                }

                // Return nothing
                Debug.Log("[OD] ERROR: Failed to load map " + name + " at path " + Path);
            }
Example #14
0
            // OnBecameInvisible(), kill the texture
            void OnBecameInvisible()
            {
                // If it is already loaded, return
                if (!isLoaded)
                {
                    return;
                }

                // Kill Diffuse
                if (OnDemandStorage.TextureExists(texture))
                {
                    DestroyImmediate(scaledRenderer.material.GetTexture("_MainTex"));
                }

                // Kill Normals
                if (OnDemandStorage.TextureExists(normals))
                {
                    DestroyImmediate(scaledRenderer.material.GetTexture("_BumpMap"));
                }

                // Flags
                isLoaded = false;
            }
Example #15
0
            // OnBecameVisible(), load the texture
            void OnBecameVisible()
            {
                // If it is already loaded, return
                if (isLoaded)
                {
                    return;
                }

                // Load Diffuse
                if (OnDemandStorage.TextureExists(texture))
                {
                    scaledRenderer.material.SetTexture("_MainTex", OnDemandStorage.LoadTexture(texture, false, true, true));
                }

                // Load Normals
                if (OnDemandStorage.TextureExists(normals))
                {
                    scaledRenderer.material.SetTexture("_BumpMap", OnDemandStorage.LoadTexture(normals, false, true, false));
                }

                // Flags
                isLoaded = true;
            }
Example #16
0
        public void LoadTextures()
        {
            Debug.Log("[OD] --> ScaledSpaceDemand.LoadTextures loading " + texture + " and " + normals);

            // Load Diffuse
            if (OnDemandStorage.TextureExists(texture))
            {
                scaledRenderer.sharedMaterial.SetTexture(MainTex,
                                                         OnDemandStorage.LoadTexture(texture, false, true, true));
            }

            // Load Normals
            if (OnDemandStorage.TextureExists(normals))
            {
                scaledRenderer.sharedMaterial.SetTexture(BumpMap,
                                                         OnDemandStorage.LoadTexture(normals, false, true, false));
            }

            // Events
            Events.OnScaledSpaceLoad.Fire(this);

            // Flags
            isLoaded = true;
        }
Example #17
0
 private void OnMapEntered()
 {
     OnDemandStorage.EnableBodyCBMaps(_body.transform.name);
 }
Example #18
0
 private void OnGameSceneLoadRequested(GameScenes scene)
 {
     OnDemandStorage.DisableBodyCBMaps(_body.transform.name);
 }