예제 #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 ClientSessionStateMachine(IContexts contexts) :
            base(new ClientSessionStateMachineMonitor(contexts))
        {
            BackroundloadSettings defaultSettings = BackroundloadSettings.GetClientCurrentSettings();

            AddState(new LoadBaseConfigureState(contexts, EClientSessionStates.LoadConfig, EClientSessionStates.LoadSubResourceConfig)
                     .WithEnterAction(() => { BackroundloadSettings.SetCurrentSettings(BackroundloadSettings.LoadSettsings); })
                     );
            AddState(new LoadSubResourceConfigureState(contexts, EClientSessionStates.LoadSubResourceConfig, EClientSessionStates.RequestRoomInfo));
            AddState(new RequestRoomInfoState(contexts, EClientSessionStates.RequestRoomInfo, EClientSessionStates.PreloadResource));
            AddState(new ClientPreLoadState(contexts, EClientSessionStates.PreloadResource, EClientSessionStates.PreparingPlayer));
            AddState(new PreparingPlayerState(contexts, EClientSessionStates.PreparingPlayer, EClientSessionStates.LoadSceneMapConfig));
            AddState(new LoadSceneMapConfig(contexts, EClientSessionStates.LoadSceneMapConfig, EClientSessionStates.LoadOCConfig, false, false));
            AddState(new LoadOCConfigState(contexts, EClientSessionStates.LoadOCConfig, EClientSessionStates.InitUiModule));
            AddState(new InitUiModuleState(contexts, EClientSessionStates.InitUiModule, EClientSessionStates.RequestSnapshot));
            AddState(new WaitSnapshotState(contexts, EClientSessionStates.RequestSnapshot, EClientSessionStates.Running));
            AddState(new LoginSuccState(contexts, EClientSessionStates.Running, EClientSessionStates.Running)
                     .WithEnterAction(() =>
            {
                BackroundloadSettings.SetCurrentSettings(defaultSettings);
                if (SharedConfig.DisableGc)
                {
                    SingletonManager.Get <gc_manager>().disable_gc();
                    SingletonManager.Get <gc_manager>().gc_collect();
                }
            }).WithLevelAction(() =>
            {
                SingletonManager.Get <gc_manager>().enable_gc();
                SingletonManager.Get <gc_manager>().gc_collect();
            })
                     );

            Initialize((int)EClientSessionStates.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);
        }