Esempio n. 1
0
        /// <summary>
        /// 创建一个模块
        /// </summary>
        /// <param name="moduleType">模块类型</param>
        /// <param name="args">模块启动参数</param>
        /// <returns>模块</returns>
        private static IGameModule CreateModule(Type moduleType, params object[] args)
        {
            // 加载依赖模块
            var dependenceModules = moduleType.GetCustomAttributes <DependenceModuleAttribute>();

            if (dependenceModules != null)
            {
                if (!m_DependenceDic.TryGetValue(moduleType.Name, out List <Type> modules))
                {
                    modules = new List <Type>();
                    m_DependenceDic.Add(moduleType.Name, modules);
                }
                foreach (var item in dependenceModules)
                {
                    modules.Add(item.moduleType);
                    AddModule(item.moduleType, item.args);
                }
            }

            // 加载模块
            IGameModule module = (IGameModule)Activator.CreateInstance(moduleType, args);

            if (module == null)
            {
                throw new Exception(moduleType.Name + " is not a module");
            }

            return(module);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建一个模块
        /// </summary>
        /// <param name="moduleType"></param>
        /// <returns></returns>
        private static IGameModule CreateModule(Type moduleType)
        {
            IGameModule module = (IGameModule)Activator.CreateInstance(moduleType);

            if (module == null)
            {
                throw new Exception(moduleType.Name + " is not a module");
            }

            LinkedListNode <IGameModule> current = m_GameModules.First;

            while (current != null)
            {
                if (module.Priority > current.Value.Priority)
                {
                    break;
                }

                current = current.Next;
            }

            if (current != null)
            {
                m_GameModules.AddBefore(current, module);
            }
            else
            {
                m_GameModules.AddLast(module);
            }

            return(module);
        }
Esempio n. 3
0
        public bool onSessionCmd(ISession s, object sCtx, string cls, string method, object par)
        {
            AEPlayer p = null;

            if (!_players.TryGetValue(s.sessionID, out p))
            {
                s.lastErrorCode = AEErrorCode.ERR_SESSOIN_PLAYER_NOT_EXIST;
                s.lastErrorMsg  = "game [" + this.name + "] onSessionCmd sid [" + s.sessionID + "] player not exist!";
                Debug.logger.log(LogType.LOG_ERR, s.lastErrorMsg);
                return(false);
            }

            IGameModule m = getGameModule(cls);

            if (m == null)
            {
                if (this.name == "SHOutGame" && cls == "webGame")
                {
                    s.lastErrorCode = AEErrorCode.ERR_SESSION_NEED_LOGIN;
                    s.lastErrorMsg  = "need login!";
                }
                else
                {
                    s.lastErrorCode = AEErrorCode.ERR_SYS_SERVER_INTERNAL_ERROR;
                    s.lastErrorMsg  = "game [" + this.name + "] onSessionCmd sid [" + s.sessionID + "] game module[" + cls + "] not exist!";
                }
                if (method != "refreshUser" && method != "logout")
                {
                    Debug.logger.log(LogType.LOG_ERR, s.lastErrorMsg);
                }
                return(false);
            }

            return(m.onPlayerCmd(p, sCtx, method, par));
        }
        private static IGameModule CreateModule(Type type)
        {
            int         hash       = type.GetHashCode();
            IGameModule gameModule = (IGameModule)Activator.CreateInstance(type);

            _allModules[hash] = gameModule;

            //获取含IUpdate的模块
            var update = gameModule as IUpdate;

            if (update != null)
            {
                _allUpdates.Add(update);
            }

            //获取含IFixedUpdate的模块
            var fixedUpdate = gameModule as IFixedUpdate;

            if (fixedUpdate != null)
            {
                _allFixedUpdates.Add(fixedUpdate);
            }

            //获取所有退出应用的模块
            var applicationquit = gameModule as IApplicationQuit;

            if (applicationquit != null)
            {
                _allApplicationQuits.Add(applicationquit);
            }

            return(gameModule);
        }
Esempio n. 5
0
 public UserCmdExecuteManagerSystem(IGameModule gameModule,
                                    IUserCmdExecuteSystemHandler handler)
 {
     _systems = gameModule.UserCmdExecuteSystems;
     _handler = handler;
     Init();
 }
Esempio n. 6
0
 protected void AddModule(IGameModule module)
 {
     ModuleGenerated(this, new ModuleEventArg()
     {
         Module = module
     });
 }
        public UserCmdParallelExecuteManagerSystem(IGameModule gameModule,
                                                   IUserCmdExecuteSystemHandler handler,
                                                   IGameStateProcessorFactory gameStateProcessorFactory,
                                                   int threadCount)
        {
            _systems   = new List <IUserCmdExecuteSystem>();
            _taskInfos = new List <TaskInfo>();
            _systems.Add(new UserCmdPreExecuteSystem(gameStateProcessorFactory));
            _systems.AddRange(gameModule.UserCmdExecuteSystems);
            _systems.Add(new UserCmdPostExecuteSystem());

            _handler = handler;
            int count = _systems.Count;

            _systemsPool = new List <IUserCmdExecuteSystem> [threadCount];
            InitTask(threadCount, count);
            _mainThread = new WorkThread("Main", _systems);
            WorkThread[] slaveThreads = new WorkThread[threadCount];
            for (var i = 0; i < threadCount; i++)
            {
                slaveThreads[i] = new WorkThread("Slave", _systemsPool[i]);
            }

            _taskDisparcher = new TaskDispatcher(threadCount, _mainThread, slaveThreads, _taskInfos);

            _mainThread.Name = "MainThread";
            _mainThread.SetTaskDisparcher(_taskDisparcher);
            for (var i = 0; i < threadCount; i++)
            {
                slaveThreads[i].SetTaskDisparcher(_taskDisparcher);
                slaveThreads[i].Name = string.Format("SlaveThreads:{0}", i);
            }

            _taskDisparcher.Start();
        }
Esempio n. 8
0
        public ClientMainFeature(string name,
                                 IGameModule topLevelGameModule,
                                 ISyncLatestManager syncLatestManager,
                                 IPlaybackManager playbackManager,
                                 IPredictionInitManager userPredictionInitManager,
                                 IUserPredictionInfoProvider predicatoinInfoProvider,
                                 ISimulationTimer simulationTimer,
                                 IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler,
                                 IVehicleExecutionSelector vehicleExecutionSelector,
                                 ICommonSessionObjects commonSessionObjects) : base(name)
        {
            topLevelGameModule.Init();

            Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager));
            Add(new EntityCreateSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));



            Add(new SyncLatestSystem(syncLatestManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            if (!SharedConfig.IsOffline)
            {
                Add(new PlaybackInitSystem(playbackManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            }
            Add(new PlaybackSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));

            //添加游戏状态更新处理
            Add(new GameStateUpdateSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));

            // 需要在playback之后,因为要根据车的位置更新人的位置
            // 要在predicte之前,因为要根据车的位置,更像摄像机位置
            Add(new PhysicsInitSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.CmdFrameStep));
            Add(new PhysicsUpdateSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.CmdFrameStep));


            Add(new VehicleCmdExecuteManagerSystem(vehicleExecutionSelector, topLevelGameModule, vehicleCmdExecuteSystemHandler, simulationTimer, false, SharedConfig.ServerAuthorative).WithExecFrameStep(EEcecuteStep.CmdFrameStep));
            Add(new UserPrePredictionSystem(topLevelGameModule,
                                            predicatoinInfoProvider,
                                            userPredictionInitManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); //每帧执行的cmd要放在回滚之前,不然会导致多执行帧
            Add(new PhysicsPostUpdateSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.CmdFrameStep));
            Add(new PredictionInitSystem(userPredictionInitManager).WithExecFrameStep(EEcecuteStep.CmdFrameStep));
            Add(new UserPredictionSystem(topLevelGameModule,
                                         predicatoinInfoProvider,
                                         userPredictionInitManager).WithExecFrameStep(EEcecuteStep.CmdFrameStep));


            Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep));

            Add(new GamePlaySystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.CmdFrameStep));

            Add(new RenderSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            Add(new UiSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.UIFrameStep));
            Add(new UiHfrSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));

            Add(new CommonLifeTimeSystem(commonSessionObjects.GameContexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            Add(new CommoTickImmutabblitySystem(commonSessionObjects.GameContexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            Add(new EntityCleanUpSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));

            Add(new CommonDestroySystem(commonSessionObjects).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
        }
Esempio n. 9
0
        public ProfileFeature(IGameModule topLevelGameModule,
                              ICommonSessionObjects commonSessionObjects)
        {
            topLevelGameModule.Init();

            Add(new RenderSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
            Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep));
        }
Esempio n. 10
0
            public ProfilePreparationFeature(string name,
                                             IGameModule topLevelGameModule,
                                             ICommonSessionObjects commonSessionObjects) : base(name)
            {
                topLevelGameModule.Init();

                Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager));
            }
Esempio n. 11
0
            public SceneResourceLoadingFeature(string name,
                                               IGameModule topLevelGameModule,
                                               ICommonSessionObjects commonSessionObjects) : base(name)
            {
                topLevelGameModule.Init();

                Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager));
            }
        public IGameModule AddModule(Type itfType, Type modType)
        {
            CheckModuleType(modType);
            IGameModule mod = (IGameModule)Activator.CreateInstance(modType);

            AddModule(itfType, mod);
            return(mod);
        }
Esempio n. 13
0
        public UserCmdUpdateMsgExecuteManagerSystem(IGameModule gameModule,
                                                    IUserCmdExecuteSystemHandler handler, ISyncUpdateLatestMsgHandler syncUpdateLatestMsgHandler)
        {
            _systems = gameModule.UserCmdExecuteSystems;
            _handler = handler;
            _syncUpdateLatestMsgHandler = syncUpdateLatestMsgHandler;

            Init();
        }
Esempio n. 14
0
        public ServerPrepareFeature(string name,
                                    IGameModule topLevelGameModule, IUnityAssetManager assetManager) : base(name)
        {
            topLevelGameModule.Init();
            Add(new ModuleInitSystem(topLevelGameModule, assetManager));
            Add(new EntityCreateSystem(topLevelGameModule));

            Add(new ResourceLoadSystem(topLevelGameModule, assetManager));
        }
Esempio n. 15
0
        public void Settup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <Slot.Games.FuDaoLe.Module>();

            module = new Slot.Games.FuDaoLe.Module(logger);
        }
Esempio n. 16
0
            public PreloadFeature(string name,
                                  IGameModule topLevelGameModule,
                                  ICommonSessionObjects commonSessionObjects) : base(name)
            {
                topLevelGameModule.Init();

                Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager));
                Add(new UnityAssetManangerSystem(commonSessionObjects));
                Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager));
            }
Esempio n. 17
0
        public void Settup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <FortunePackModule>();

            module = new FortunePackModule(logger);
        }
Esempio n. 18
0
        public void Settup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <BonusBearModule.Engine>();

            module = new BonusBearModule.Engine(logger);
        }
Esempio n. 19
0
        public void Settup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <Games.DragonRiches.DragonRichesModule>();

            module = new Games.DragonRiches.DragonRichesModule(logger);
        }
Esempio n. 20
0
 private void StartModule(IGameModule module)
 {
     try
     {
         module.StartModule();
     }
     catch (Exception e)
     {
         _logger.LogError(e);
     }
 }
Esempio n. 21
0
        public void Settup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .AddDistributedMemoryCache()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <BuffaloModule>();

            module = new BuffaloModule(logger);
        }
        public void AddModule(Type itfType, IGameModule mod)
        {
            CheckInterfaceType(itfType);
            Type modType = mod.GetType();

            if (!itfType.IsAssignableFrom(modType))
            {
                throw new ArgumentException($"Module({modType.Name}) is not implemented by interface({itfType.Name}).");
            }
            _modules.Add(itfType, mod);
        }
Esempio n. 23
0
 public UserCmdExecuteManagerSystem(IGameModule gameModule,
                                    IUserCmdExecuteSystemHandler handler,
                                    IGameStateProcessorFactory gameStateProcessorFactory)
 {
     _systems = gameModule.UserCmdExecuteSystems;
     _handler = handler;
     _gameStateProcessorFactory = gameStateProcessorFactory;
     _stateProviderPool         = gameStateProcessorFactory.GetProviderPool();
     _statePool = gameStateProcessorFactory.GetStatePool();
     Init();
 }
Esempio n. 24
0
 public ServerPrepareFeature(
     string name,
     IGameModule topLevelGameModule,
     ICommonSessionObjects commonSessionObjects) : base(name)
 {
     topLevelGameModule.Init();
     Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.LoadRequestManager));
     Add(new EntityCreateSystem(topLevelGameModule));
     Add(new LoadRequestManagerSystem(commonSessionObjects));
     Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.LoadRequestManager));
 }
 public UserCmdUpdateMsgExecuteManagerSystem(IGameModule gameModule,
                                             IServerUserCmdList handler, ISyncUpdateLatestMsgHandler syncUpdateLatestMsgHandler)
 {
     _systems = gameModule.UserCmdExecuteSystems;
     _handler = handler;
     _syncUpdateLatestMsgHandler = syncUpdateLatestMsgHandler;
     _syncToEntityProfile        =
         SingletonManager.Get <DurationHelp>().GetCustomProfileInfo("UserPrediction_SyncToEntity");
     _filtedInputProfile =
         SingletonManager.Get <DurationHelp>().GetCustomProfileInfo("UserPrediction_FiltedInput");
     Init();
 }
        //        private PlayerStateCollectorPool gameStateProcessorFactory;
        //        private IStateProviderPool stateProviderPool;
        //        private IPlayerStateMap playerStateMap;

        public UserPredictionSystem(IGameModule gameModule, AbstractPredictionProvider provider,
                                    PredictionManager predictionManager)
        {
            logger.Info("start");
            this.provider          = provider;
            this.predictionManager = predictionManager;
            systems = gameModule.UserCmdExecuteSystems;
            //            gameStateProcessorFactory = gameStateProcessorFactory;
            //            stateProviderPool = gameStateProcessorFactory.GetProviderPool();
            //            playerStateMap = gameStateProcessorFactory.GetStatePool();
            Init();
        }
Esempio n. 27
0
 public UserPrePredictionSystem(IGameModule gameModule,
                                IUserPredictionInfoProvider handler,
                                IPredictionInitManager predictionInitManager)
 {
     _logger.Info("start");
     _predicatoinInfoProvider = handler;
     _predictionInitManager   = predictionInitManager;
     //_gameStateProcessorFactory = gameStateProcessorFactory;
     //_stateProviderPool = gameStateProcessorFactory.GetProviderPool();
     //_playerStateMap = gameStateProcessorFactory.GetStatePool();
     _systems = gameModule.BeforeUserCmdExecuteSystems;
     Init();
 }
Esempio n. 28
0
 private IEnumerator InitializeModularSystems(Transform systemsParent)
 {
     // Setup Additional Systems as needed
     //Debug.Log("Loading Modular Systems");
     foreach (var module in gameModules)
     {
         if (module is IGameModule)
         {
             IGameModule gameModule = module as IGameModule;
             yield return(gameModule.LoadModule());
         }
     }
 }
Esempio n. 29
0
 public FrmCredits(IGameModule module, ExtensionManifest[] extensions)
 {
     InitializeComponent();
     textBox1.Text = $"Loaded extensions:\r\nGame module : {module.ModuleName}\r\n";
     foreach (var ext in extensions)
     {
         textBox1.Text += $"\r\n{ext.ModuleName} by {ext.Author}\r\n";
         if (ext.ExtraText != null)
         {
             textBox1.Text += $"{ext.ExtraText}\r\n";
         }
     }
 }
Esempio n. 30
0
 private IEnumerator InitializeModularSystems(Transform systemsParent)
 {
     Debug.Log("Loading modular systems...");
     foreach (Component c in GameModules)
     {
         if (c is IGameModule)
         {
             IGameModule module = (IGameModule)c;
             yield return(module.LoadModule());
         }
     }
     yield return(null);
 }
Esempio n. 31
0
        private void OnGameModuleChanged()
        {
            if (_game != null)
                throw new InvalidOperationException();

            _game = GameModule;
            _internalModule = (IInternalGameModule)GameModule;

            _drawingSurface = new DrawingSurface();
            _drawingSurface.Loaded += OnDrawingSurfaceLoaded;
            _drawingSurface.Unloaded += OnDrawingSurfaceUnloaded;

            _drawingSurface.LoadContent += OnLoadContent;
            _drawingSurface.Draw += OnDraw;
            _drawingSurface.MouseMove += OnMouseMove;
            _drawingSurface.MouseDown += OnMouseDown;

            KeyDown += OnKeyDown;
            Content = _drawingSurface;
        }
 protected void AddModule(IGameModule module)
 {
     ModuleGenerated(this, new ModuleEventArg() {Module = module});
 }
Esempio n. 33
0
 private void SetModule(IGameModule module)
 {
     m_CurrentModule = module;
     m_CurrentModule.ModuleCompleted += delegate(object sender, SuccessEventArg arg)
     {
         if (arg.Success)
         {
             AdvanceToNextGameState();
         }
         else
         {
             SetModule(new EndGameModule(Observer,Table));
         }
     };
     m_CurrentModule.ModuleGenerated += (sender, arg) => m_Modules.Enqueue(arg.Module);
     m_CurrentModule.InitModule();
 }
Esempio n. 34
0
 public void Add(IGameModule module)
 {
     _shardModules.Add(module);
 }