Пример #1
0
        private void OnGameStateCreated(Game game)
        {
            LastKSC.CreateSettings(game);
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                ProtoScenarioModule m = HighLogic.CurrentGame.scenarios.FirstOrDefault(m => m.moduleName == "LastKSC");

                if (m == null)
                {
                    return;
                }

                LastKSC l = (LastKSC)m.Load(ScenarioRunner.Instance);
                bool    noSite;
                if (!string.IsNullOrEmpty(l.lastSite))
                {
                    // found a site, load it
                    ConfigNode site = Sites.GetSiteByName(l.lastSite);
                    if (site == null)
                    {
                        l.lastSite = Sites.defaultSite;
                        noSite     = true;
                    }
                    else
                    {
                        KSCSwitcher.SetSiteAndResetCamera(site);
                        Debug.Log("KSCSwitcher set the launch site to the last site, " + l.lastSite);
                        return;
                    }
                }
                else
                {
                    l.lastSite = Sites.defaultSite;
                    noSite     = true;
                }
                if (noSite)
                {
                    if (!string.IsNullOrEmpty(Sites.defaultSite))
                    {
                        ConfigNode site = Sites.GetSiteByName(Sites.defaultSite);
                        if (site == null)
                        {
                            Debug.LogError("KSCSwitcher found a default site name but could not retrieve the site config: " + Sites.defaultSite);
                            return;
                        }
                        else
                        {
                            KSCSwitcher.SetSiteAndResetCamera(site);
                            Debug.Log("KSCSwitcher set the initial launch site to the default" + Sites.defaultSite);
                        }
                    }
                }
            }
        }
Пример #2
0
        void onGameStateCreated(Game game)
        {
            LastKSC.CreateSettings(game);
            bool noSite = false;

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                foreach (ProtoScenarioModule m in HighLogic.CurrentGame.scenarios)
                {
                    if (m.moduleName == "LastKSC")
                    {
                        LastKSC l = (LastKSC)m.Load(ScenarioRunner.Instance);
                        if (l.lastSite.Length > 0)
                        {
                            // found a site, load it
                            ConfigNode site = Sites.getSiteByName(l.lastSite);
                            if (site == null)
                            {
                                l.lastSite = Sites.defaultSite;
                                noSite     = true;
                            }
                            else
                            {
                                KSCSwitcher.setSite(site);
                                Debug.Log("KSCSwitcher set the launch site to " + l.lastSite);
                                return;
                            }
                        }
                        else
                        {
                            l.lastSite = Sites.defaultSite;
                            noSite     = true;
                        }
                        if (noSite)
                        {
                            if (Sites.defaultSite.Length > 0)
                            {
                                ConfigNode site = Sites.getSiteByName(Sites.defaultSite);
                                if (site == null)
                                {
                                    Debug.LogError("KSCSwitcher found a default site name but could not retrieve the site config: " + Sites.defaultSite);
                                    return;
                                }
                                else
                                {
                                    KSCSwitcher.setSite(site);
                                    Debug.Log("KSCSwitcher set the initial launch site to " + Sites.defaultSite);
                                }
                            }
                        }
                    }
                }
            }
        }