コード例 #1
0
        private void Awake()
        {
            if (instance != null && instance != this)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;
        }
コード例 #2
0
        private void Start()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                running = false;
                Destroy(gameObject);
            }

            if (!SEP_Utilities.partModulesLoaded)
            {
                SEP_Utilities.loadPartModules();
            }

            if (!SEP_Utilities.antennaModulesLoaded)
            {
                SEP_Utilities.loadAntennaParts();
            }

            if (!SEP_Utilities.spritesLoaded)
            {
                StartCoroutine(loadSprites());
            }

            if (ResearchAndDevelopment.GetTechnologyState(transmissionNode) == RDTech.State.Available)
            {
                transmissionUpgrade = true;
            }
            else
            {
                transmissionUpgrade = false;
            }

            if (running)
            {
                Destroy(gameObject);
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                StartCoroutine(attachWindowListener());
            }

            instance = this;

            running = true;

            usingCommNet = HighLogic.CurrentGame.Parameters.Difficulty.EnableCommNet;

            GameEvents.onLevelWasLoaded.Add(onReady);
            GameEvents.OnGameSettingsApplied.Add(onSettingsApplied);
        }
コード例 #3
0
        private void Start()
        {
            GameScenes scene = HighLogic.LoadedScene;

            if (scene == GameScenes.MAINMENU)
            {
                if (!SEP_Utilities.partModulesLoaded)
                {
                    SEP_Utilities.loadPartModules();
                }

                if (!SEP_Utilities.UIWindowReflectionLoaded)
                {
                    SEP_Utilities.assignReflectionMethod();
                }
            }

            if (!(scene == GameScenes.FLIGHT || scene == GameScenes.TRACKSTATION || scene == GameScenes.SPACECENTER))
            {
                running = false;
                Destroy(gameObject);
            }

            if (ResearchAndDevelopment.GetTechnologyState(transmissionNode) == RDTech.State.Available)
            {
                transmissionUpgrade = true;
            }
            else
            {
                transmissionUpgrade = false;
            }

            if (running)
            {
                Destroy(gameObject);
            }

            if (scene == GameScenes.FLIGHT)
            {
                StartCoroutine(attachWindowListener());
            }

            instance = this;

            running = true;

            GameEvents.onLevelWasLoaded.Add(onReady);
        }
コード例 #4
0
        private void OnDestroy()
        {
            if (instance == this)
            {
                instance = null;
            }

            GameEvents.onLevelWasLoaded.Remove(onReady);
            GameEvents.OnGameSettingsApplied.Remove(onSettingsApplied);

            var handlers = experiments.Values.SelectMany(e => e).ToList();

            int l = handlers.Count;

            for (int i = 0; i < l; i++)
            {
                SEP_ExperimentHandler handler = handlers[i];

                handler.OnDestroy();
            }
        }