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)); }
public UserCmdMergeSystem(Contexts contexts) { _vehicleCmdGenerator = new UnityVehicleCmdGenerator(contexts.userInput.userInputManager.Instance); _playerContext = contexts.player; _simulationTimer = contexts.session.clientSessionObjects.SimulationTimer; _contexts = contexts; }
public VehicleCmdExecuteManagerSystem(IVehicleExecutionSelector vehicleSelector, IGameModule gameModule, IVehicleCmdExecuteSystemHandler handler, ISimulationTimer simulationTimer, bool isServer, bool serverAuthorative) { _systems = gameModule.VehicleCmdExecuteSystems; _handler = handler; _simulationTimer = simulationTimer; _vehicleSelector = vehicleSelector; _isServer = isServer; _serverAuthorative = serverAuthorative; _profiler = CustomProfilerFactory.CreateProfiler(this); Init(); }
public override Systems CreateUpdateSystems(IContexts contexts) { if (Camera.main == null) { throw new Exception("Camera.main is null"); } Contexts _contexts = (Contexts)contexts; _gameModule = GameModuleFactory.CreateCompositeGameModule(_contexts); var sessionObjects = _contexts.session.clientSessionObjects; ISyncLatestManager syncLatestManager = sessionObjects.SyncLatestManager; IPlaybackManager playbackManager = sessionObjects.PlaybackManager; IPredictionInitManager predictionInitManager = sessionObjects.UserPredictionInitManager; IUserPredictionInfoProvider predicatoinInfoProvider = sessionObjects.UserPredictionInfoProvider; ISimulationTimer simulationTimer = sessionObjects.SimulationTimer; var systems = new Feature("LoginSuccState"); systems.Add(new InputCollectSystem(_contexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); systems.Add(new MouseLockSystem(_contexts)); systems.Add(new DriveTimeSystem(_contexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); systems.Add(new ClientFreeCmdGenerateSystem(_contexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); systems.Add(new UserCmdCollectSystem(_contexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); // systems.Add(new ClientCameraPreUpdateSystem(_contexts.vehicle, _contexts.freeMove,_contexts.player, motors).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); systems.Add(new PlayerInterceptCmdSystem(_contexts).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); systems.Add(new UserCmdMergeSystem(_contexts).WithExecFrameStep(EEcecuteStep.CmdFrameStep)); //Test systems.Add(new TerrainTestSystem(_contexts)); ////// systems.Add(new AutoTerrainNavigatorSystem(_contexts)); systems.Add(new MinRendererSetSystem(_contexts)); systems.Add(new WoodConflictSystem(_contexts)); systems.Add(new ClientMainFeature( "LoginSuccSystems", _gameModule, syncLatestManager, playbackManager, predictionInitManager, predicatoinInfoProvider, simulationTimer, sessionObjects.VehicleCmdExecuteSystemHandler, new ClientVehicleExecutionSelector(_contexts), _contexts.session.commonSession)); /*车辆命令走老流程*/ systems.Add(new UserCmdSendSystem(_contexts).WithExecFrameStep(EEcecuteStep.CmdFrameStep)); /*用户的命令*/ systems.Add(new UserCmdUpdateSystem(_contexts).WithExecFrameStep(EEcecuteStep.CmdFrameStep)); return(systems); }
public ServerMainFeature( string name, IGameModule topLevelGameModule, IUserCmdExecuteSystemHandler userCmdExecuteSystemHandler, IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler, ISimulationTimer simluationTimer, IVehicleExecutionSelector vehicleExecutionSelector, ICommonSessionObjects sessionObjects, IRoom room) : base(name) { topLevelGameModule.Init(); Add(new ModuleInitSystem(topLevelGameModule, sessionObjects.LoadRequestManager)); Add(new EntityCreateSystem(topLevelGameModule)); Add(new GameStateUpdateSystem(topLevelGameModule)); Add(new PhysicsInitSystem(topLevelGameModule)); Add(new PhysicsUpdateSystem(topLevelGameModule)); Add(new VehicleCmdExecuteManagerSystem(vehicleExecutionSelector, topLevelGameModule, vehicleCmdExecuteSystemHandler, simluationTimer, true, SharedConfig.ServerAuthorative)); Add(new PhysicsPostUpdateSystem(topLevelGameModule)); #if (true) // Add(new UserCmdExecuteManagerSystem(topLevelGameModule, // userCmdExecuteSystemHandler, // sessionObjects.GameStateProcessorFactory)); Add(new UserCmdUpdateMsgExecuteManagerSystem(topLevelGameModule, userCmdExecuteSystemHandler, new SyncUpdateLatestMsgHandler())); #else Add(new UserCmdParallelExecuteManagerSystem(topLevelGameModule, userCmdExecuteSystemHandler, sessionObjects.GameStateProcessorFactory, 4)); #endif Add(new LoadRequestManagerSystem(sessionObjects)); Add(new ResourceLoadSystem(topLevelGameModule, sessionObjects.LoadRequestManager)); Add(new GamePlaySystem(topLevelGameModule)); Add(new CommonLifeTimeSystem(sessionObjects.GameContexts)); Add(new EntityCleanUpSystem(topLevelGameModule)); Add(new CommonDestroySystem(sessionObjects)); Add(new FreeGameRuleSystem(room)); Add(new SendSnapshotSystem(room)); Add(new CompensationSnapshotSystem(room)); }
public override Systems CreateUpdateSystems(IContexts contexts) { if (Camera.main == null) { throw new Exception("Camera.main is null"); } Contexts _contexts = (Contexts)contexts; _gameModule = GameModuleFactory.CreateCompositeGameModule(_contexts); var sessionObjects = _contexts.session.clientSessionObjects; SyncLastestManager netSyncManager = sessionObjects.NetSyncManager; PlaybackManager playbackManager = sessionObjects.PlaybackManager; var predictionManager = sessionObjects.UserPredictionManager; var predicatoinProvider = sessionObjects.UserPredictionProvider; ISimulationTimer simulationTimer = sessionObjects.SimulationTimer; var systems = new Feature("LoginSuccState"); systems.Add(new DriveTimeSystem(_contexts)); systems.Add(new PrepareSnapshotPairSystem(_contexts)); systems.Add(new ClientUserCmdFeature("UserCmd", _contexts)); systems.Add(new ClientProfileFeature("Profile", _contexts)); if (SharedConfig.IsReplay) { systems.Add(new UserCmdReplaySystem(_contexts)); systems.Add(new PrepareSnapshotPairSystem(_contexts)); } systems.Add(new ClientMainFeature( "LoginSuccSystems", _gameModule, netSyncManager, playbackManager, predictionManager, predicatoinProvider, simulationTimer, sessionObjects.VehicleCmdExecuteSystemHandler, new ClientVehicleExecutionSelector(_contexts), _contexts.session.commonSession)); /*车辆命令走老流程*/ systems.Add(new UserCmdSendSystem(_contexts).WithExecFrameStep(EEcecuteStep.CmdFrameStep)); /*用户的命令*/ systems.Add(new UserCmdUpdateSystem(_contexts).WithExecFrameStep(EEcecuteStep.CmdFrameStep)); return(systems); }
public SimulationTimeSyncServer(ISimulationTimer simulationTimer, Action <INetworkChannel, SimulationTimeMessage> sendMethod) { _simulationTimer = simulationTimer; _sendMethod = sendMethod; }