Ejemplo n.º 1
0
        public ServerSessionStateMachine(Contexts contexts, ServerRoom room) :
            base(new ServerSessionStateMachineMonitor(room))
        {
            BackroundloadSettings defaultSettings = BackroundloadSettings.GetServerCurrentSettings();

            AddState(new ServerLoadConfigurationState(contexts, EServerSessionStates.LoadConfig, EServerSessionStates.LoadSubResourceConfig)
                     .WithEnterAction(() =>
            {
                BackroundloadSettings.SetCurrentSettings(BackroundloadSettings.LoadSettsings);
                //Application.targetFrameRate = 1000;
                _logger.WarnFormat("LoadConfig backgroundLoadingPriority:{0}, targetFrameRate:{1}", Application.backgroundLoadingPriority, Application.targetFrameRate);
            })
                     );
            AddState(new ServerLoadSubResourceState(contexts, EServerSessionStates.LoadSubResourceConfig, EServerSessionStates.PreLoad));
            AddState(new ServerPreLoadState(contexts, EServerSessionStates.PreLoad, EServerSessionStates.LoadSceneMapConfig));
            AddState(new ServerLoadMapConfigState(contexts, EServerSessionStates.LoadSceneMapConfig, EServerSessionStates.Gaming));
            AddState(new GameSessionState(contexts, room, EServerSessionStates.Gaming, EServerSessionStates.Gaming)
                     .WithEnterAction(() =>
            {
                BackroundloadSettings.SetCurrentSettings(defaultSettings);
                //Application.targetFrameRate = SharedConfig.ServerFrameRate;
                _logger.WarnFormat("Gaming backgroundLoadingPriority:{0}, targetFrameRate:{1}", Application.backgroundLoadingPriority, Application.targetFrameRate);
            })
                     );
            Initialize((int)EServerSessionStates.LoadConfig);
        }
        public ServerSessionStateMachine(Contexts contexts, ServerRoom room) : base(
                new ServerSessionStateMachineMonitor(room))
        {
            BackroundloadSettings defaultSettings = BackroundloadSettings.GetServerCurrentSettings();

            AddState(new ServerLoadConfigurationState(contexts, EServerSessionStates.LoadConfig,
                                                      EServerSessionStates.LoadSubResourceConfig).WithEnterAction(() =>
            {
                BackroundloadSettings.SetCurrentSettings(BackroundloadSettings.LoadSettsings);
                //Application.targetFrameRate = 1000;
                _logger.WarnFormat("LoadConfig backgroundLoadingPriority:{0}, targetFrameRate:{1}",
                                   Application.backgroundLoadingPriority, Application.targetFrameRate);
            }));
            AddState(new ServerLoadSubResourceState(contexts, EServerSessionStates.LoadSubResourceConfig,
                                                    EServerSessionStates.PreLoad));
            AddState(new ServerPreLoadState(contexts, EServerSessionStates.PreLoad,
                                            EServerSessionStates.LoadOptionConfig));
            AddState(new ServerOptionLoadState(contexts, EServerSessionStates.LoadOptionConfig, EServerSessionStates.LoadSceneMapConfig));
            AddState(new ServerLoadMapConfigState(contexts, EServerSessionStates.LoadSceneMapConfig,
                                                  EServerSessionStates.Gaming));
            AddState(new GameSessionState(contexts, room, EServerSessionStates.Gaming, EServerSessionStates.Gaming)
                     .WithEnterAction(() =>
            {
                BackroundloadSettings.SetCurrentSettings(defaultSettings);
                if (SharedConfig.DisableGc)
                {
                    SingletonManager.Get <gc_manager>().disable_gc();
                    SingletonManager.Get <gc_manager>().manual_gc_factor_threshold       = 2.5f;
                    SingletonManager.Get <gc_manager>().manual_gc_bytes_threshold_mb     = 1500;
                    SingletonManager.Get <gc_manager>().manual_gc_min_time_delta_seconds = 60;
                }

                SingletonManager.Get <gc_manager>().gc_collect();
                //Application.targetFrameRate = SharedConfig.ServerFrameRate;
                _logger.WarnFormat("Gaming backgroundLoadingPriority:{0}, targetFrameRate:{1}",
                                   Application.backgroundLoadingPriority, Application.targetFrameRate);
            }).WithLevelAction(() =>
            {
                if (SharedConfig.DisableGc)
                {
                    SingletonManager.Get <gc_manager>().enable_gc();
                }

                SingletonManager.Get <gc_manager>().gc_collect();
            }));
            Initialize((int)EServerSessionStates.LoadConfig);
        }