Example #1
0
        // Startup
        private void Start()
        {
            if (!RuntimeUtility.KopernicusConfig.UseKopernicusAsteroidSystem.ToLower().Equals("stock"))
            {
                // Kill old Scenario Discoverable Objects without editing the collection while iterating through the same collection
                // @Squad: I stab you with a try { } catch { } block.

                if (HighLogic.CurrentGame.RemoveProtoScenarioModule(typeof(ScenarioDiscoverableObjects)))
                {
                    // RemoveProtoScenarioModule doesn't remove the actual Scenario; workaround!
                    foreach (Object o in
                             Resources.FindObjectsOfTypeAll(typeof(ScenarioDiscoverableObjects)))
                    {
                        ScenarioDiscoverableObjects scenario = (ScenarioDiscoverableObjects)o;
                        scenario.StopAllCoroutines();
                        Destroy(scenario);
                    }
                }
                if (RuntimeUtility.KopernicusConfig.UseKopernicusAsteroidSystem.ToLower().Equals("true"))
                {
                    Debug.Log("[Kopernicus] Using Kopernicus Asteroid Spawner.");
                    foreach (Asteroid asteroid in Asteroids)
                    {
                        StartCoroutine(AsteroidDaemon(asteroid));
                    }
                }
                else if (RuntimeUtility.KopernicusConfig.UseKopernicusAsteroidSystem.ToLower().Equals("false"))
                {
                    Debug.Log("[Kopernicus] Asteroid Spawners disabled.  Unless external spawner mod is installed no discoverable objects will be spawned.");
                }
                else
                {
                    Injector.DisplayWarning();
                    throw new InvalidCastException("Invalid value for Enum UseKopernicusAsteroidSystem.  Valid values are true, false, and stock.");
                }
            }
            else if (RuntimeUtility.KopernicusConfig.UseKopernicusAsteroidSystem.ToLower().Equals("stock"))
            {
                Debug.Log("[Kopernicus] Using stock Squad Asteroid Spawner.");
            }
        }
Example #2
0
        // Startup
        private void Start()
        {
            // Kill old Scenario Discoverable Objects without editing the collection while iterating through the same collection
            // @Squad: I stab you with a try { } catch { } block.
            if (HighLogic.CurrentGame.RemoveProtoScenarioModule(typeof(ScenarioDiscoverableObjects)))
            {
                // RemoveProtoScenarioModule doesn't remove the actual Scenario; workaround!
                foreach (Object o in
                         Resources.FindObjectsOfTypeAll(typeof(ScenarioDiscoverableObjects)))
                {
                    ScenarioDiscoverableObjects scenario = (ScenarioDiscoverableObjects)o;
                    scenario.StopAllCoroutines();
                    Destroy(scenario);
                }
                Debug.Log("[Kopernicus] ScenarioDiscoverableObjects successfully removed.");
            }

            foreach (Asteroid asteroid in Asteroids)
            {
                StartCoroutine(AsteroidDaemon(asteroid));
            }
        }