public ClientSceneObjectModule(Contexts contexts, ICommonSessionObjects sessionObjects) { AddSystem(new SceneObjectLoadSystem(contexts, sessionObjects)); AddSystem(new SceneObjectCastTargetLoadSystem(contexts.sceneObject)); AddSystem(new SceneObjectCleanupSystem(contexts)); AddSystem(new FreeObjectLoadSystem(contexts.freeMove)); AddSystem(new FreeObjectCleanUpSystem(contexts.freeMove)); AddSystem(new MapObjCleanUpSystem(contexts)); AddSystem(new FreeObjectPositionUpdateSystem(contexts)); if (!SharedConfig.DisableDoor) { AddSystem(new TriggerObjectUpdateSystem(contexts)); } AddSystem(new DoorPlaybackSystem(contexts)); AddSystem(new ClientDestructibleObjectUpdateSystem(contexts)); if (SharedConfig.IsOffline) { AddSystem(new CreateMapObjSystem(contexts)); AddSystem(new DoorRotateSystem(contexts)); } AddSystem(new DoorTriggerSystem(contexts, new ClientDoorListener(contexts))); AddSystem(new ClientSceneObjectRenderSystem(contexts)); AddSystem(new ColliderCounterSystem(contexts)); }
public SceneConfigLoadModule(Contexts context, ISessionState sessionState, ICommonSessionObjects sessionObjects, bool IsServer) { _isServer = IsServer; AddSystem(new SceneConfigInitSystem(sessionState, sessionObjects)); }
public static PlayerEntity CreateNewServerPlayerEntity(PlayerContext playerContext, ICommonSessionObjects commonSessionObjects, IEntityIdGenerator entityIdGenerator, Vector3 position, IPlayerInfo playerInfo, bool allowReconnect) { if (allowReconnect) { var players = playerContext.GetEntitiesWithPlayerToken(playerInfo.Token); foreach (var player in players) { player.userCmdSeq.LastCmdSeq = 0; player.latestAdjustCmd.ClientSeq = -1; player.latestAdjustCmd.ServerSeq = -1; player.time.ClientTime = 0; player.vehicleCmdSeq.LastCmdSeq = 0; return(player); } } var entityId = entityIdGenerator.GetNextEntityId(); playerInfo.EntityId = entityId; var playerEntity = CreateNewPlayerEntity(playerContext, position, playerInfo, true, false); // 在角色Entity上追加 KeepWatchForAOIComponent,以记录 视线内残留对象 以及 其加入字典的时间 // 只应用于Server playerEntity.AddKeepWatchForAOI(new Util.WatchDict(playerEntity.entityKey.Value)); return(playerEntity); }
public SceneConfigInitSystem(ISessionState sessionState, ICommonSessionObjects sessionObjects) { _sessionState = sessionState; _sessionState.CreateExitCondition(typeof(SceneConfigInitSystem)); MapConfigManager.Generate(sessionObjects.RoomInfo.MapId, ReduceFinishTimes); _logger.InfoFormat("SceneConfigInitSystem :mapId:{0}", sessionObjects.RoomInfo.MapId); }
public static PlayerEntity CreateNewServerPlayerEntity(PlayerContext playerContext, ICommonSessionObjects commonSessionObjects, IEntityIdGenerator entityIdGenerator, Vector3 position, IPlayerInfo playerInfo, bool allowReconnect) { if (allowReconnect) { var players = playerContext.GetEntitiesWithPlayerToken(playerInfo.Token); foreach (var player in players) { player.userCmdSeq.LastCmdSeq = 0; player.latestAdjustCmd.ClientSeq = -1; player.latestAdjustCmd.ServerSeq = -1; player.time.ClientTime = 0; player.vehicleCmdSeq.LastCmdSeq = 0; return(player); } } var entityId = entityIdGenerator.GetNextEntityId(); playerInfo.EntityId = entityId; return(CreateNewPlayerEntity(playerContext, position, playerInfo, true, false)); }
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 SceneResourceLoadingFeature(string name, IGameModule topLevelGameModule, ICommonSessionObjects commonSessionObjects) : base(name) { topLevelGameModule.Init(); Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager)); }
public TerrainRendererInitSystem(ICommonSessionObjects commonSession, ClientSessionObjectsComponent clientSession) { _commonSession = commonSession; _clientSession = clientSession; _renderer = new TerrainRenderer(); _clientSession.TerrainRenderer = _renderer; }
public ProfileFeature(IGameModule topLevelGameModule, ICommonSessionObjects commonSessionObjects) { topLevelGameModule.Init(); Add(new RenderSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager).WithExecFrameStep(EEcecuteStep.NormalFrameStep)); }
public ProfilePreparationFeature(string name, IGameModule topLevelGameModule, ICommonSessionObjects commonSessionObjects) : base(name) { topLevelGameModule.Init(); Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager)); }
public LoadRequestManagerSystem( ICommonSessionObjects commonSesionObjects) { _driver = new LoadRequestManagerDriver( commonSesionObjects.LoadRequestManager, commonSesionObjects.GameObjectPool, commonSesionObjects.AssetPool); }
// private static readonly AssetInfo GroundProbFlashAsset = new AssetInfo("effect/common", "GroundPropFlash"); public SceneObjectLoadSystem(Contexts contexts, ICommonSessionObjects sessionObjects) : base( contexts.sceneObject) { _assetManager = sessionObjects.AssetManager; _playerContext = contexts.player; _simpleLoadHandler = new SimpleLoadRespondHander(contexts); _weaponLoadHandler = new LoadWeaponRespondHandler(contexts); }
private void ResetContexts(bool dispose) { ICommonSessionObjects sessionObjects = ContextsWrapper.contexts.session.commonSession; foreach (var entity in ContextsWrapper.contexts.player.GetEntities()) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } foreach (var entity in ContextsWrapper.contexts.mapObject.GetEntities()) { if (dispose || !entity.hasReset) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } else { entity.reset.ResetAction(entity); } } foreach (var entity in ContextsWrapper.contexts.sceneObject.GetEntities()) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } foreach (var entity in ContextsWrapper.contexts.freeMove.GetEntities()) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } foreach (var entity in ContextsWrapper.contexts.bullet.GetEntities()) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } foreach (var entity in ContextsWrapper.contexts.sound.GetEntities()) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } foreach (var entity in ContextsWrapper.contexts.vehicle.GetEntities()) { if (entity.hasEntityKey) { DestroyEntity(sessionObjects, entity); entity.isFlagDestroy = true; } } ContextsWrapper.contexts.session.currentTimeObject.CurrentTime = 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)); }
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 static PlayerEntity CreateNewServerPlayerEntity(PlayerContext playerContext, ICommonSessionObjects commonSessionObjects, IEntityIdGenerator entityIdGenerator, Vector3 position, IPlayerInfo playerInfo) { var entityId = entityIdGenerator.GetNextEntityId(); playerInfo.EntityId = entityId; return(CreateNewPlayerEntity(playerContext, commonSessionObjects.WeaponModeLogic, position, playerInfo, true, false)); }
public CommonDestroySystem(ICommonSessionObjects sessionObjects) { _sessionObjects = sessionObjects; foreach (var info in _sessionObjects.GameContexts.AllContexts) { if (info.CanContainComponent <FlagDestroyComponent>()) { _groups.Add(info.CreateGameGroup <FlagDestroyComponent>()); } } }
public ClientPreparePlayerMainFeature(string name, IGameModule topLevelGameModule, ICommonSessionObjects commonSessionObjects) : base(name) { topLevelGameModule.Init(); Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager)); Add(new EntityCreateSystem(topLevelGameModule)); Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager)); Add(new EntityCleanUpSystem(topLevelGameModule)); Add(new CommonDestroySystem(commonSessionObjects)); }
private void DestroyEntity(ICommonSessionObjects sessionObjects, Entity entity) { foreach (var comp in entity.GetComponents()) { if (comp is IAssetComponent) { ((IAssetComponent)comp).Recycle(sessionObjects.AssetManager); } } if (sessionObjects.AssetManager != null) { sessionObjects.AssetManager.LoadCancel(entity); } }
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 ClientPreLoginFeature( string name, IGameModule topLevelGameModule, ICommonSessionObjects sessionObjects) : base(name) { topLevelGameModule.Init(); Add(new ModuleInitSystem(topLevelGameModule, sessionObjects.AssetManager)); Add(new EntityCreateSystem(topLevelGameModule)); Add(new UnityAssetManangerSystem(sessionObjects)); Add(new ResourceLoadSystem(topLevelGameModule, sessionObjects.AssetManager)); Add(new RenderSystem(topLevelGameModule)); Add(new CommonLifeTimeSystem(sessionObjects.GameContexts)); Add(new EntityCleanUpSystem(topLevelGameModule)); Add(new CommonDestroySystem(sessionObjects)); }
private void DestroyEntity(ICommonSessionObjects sessionObjects, Entity entity) { foreach (var comp in entity.GetComponents()) { if (comp is IAssetComponent) { try { ((IAssetComponent)comp).Recycle(sessionObjects.AssetManager); } catch (Exception e) { _logger.ErrorFormat("RecycleEntitys {0}", e); } } } if (sessionObjects.AssetManager != null) { sessionObjects.AssetManager.LoadCancel(entity); } entity.Destroy(); }
public ClientWorldShiftPostProcessSystem(ICommonSessionObjects session) { _session = session; }
public SurvivalModeLogicFactory(Contexts contexts, ICommonSessionObjects commonSessionObjects) { _contexts = contexts; _commonSessionObjects = commonSessionObjects; }
public UserCmdGameModule(Contexts contexts, ICompensationWorldFactory compensationWorldFactory, IBulletHitHandler bulletHitHandler, IMeleeHitHandler meleeHitHandler, IThrowingHitHandler throwingHitHandler, ICommonSessionObjects commonSessionObjects, Motors motors) { if (SharedConfig.IsServer) { AddSystem(new PlayerSyncStageSystem(contexts)); } if (!SharedConfig.IsServer) { AddSystem(new PlayerSynchronizeFromComponentSystem()); } else { AddSystem(new ServerSynchronizeFromComponentSystem()); } AddSystem(new PlayerClientTimeSystem()); AddSystem(new PlayerGrenadeInventorySyncSystem()); //AddSystem(new CameraUpdateArchorSystem(contexts)); AddSystem(new PlayerRotateLimitSystem()); AddSystem(new CameraPreUpdateSystem(contexts, motors)); AddSystem(new BulletSimulationSystem(contexts, compensationWorldFactory, bulletHitHandler)); AddSystem(new PlayerAttackSystem(contexts)); AddSystem(new MeleeAttackSystem(contexts, compensationWorldFactory, meleeHitHandler)); AddSystem(new ThrowingSimulationSystem(contexts, compensationWorldFactory, throwingHitHandler, contexts.session.entityFactoryObject.SoundEntityFactory)); AddSystem(new PlayerBulletGenerateSystem(contexts)); AddSystem(new PlayerWeaponSwitchSystem(contexts)); AddSystem(new PlayerWeaponDrawSystem(contexts)); AddSystem(new PlayerWeapnStateUpdateSystem(contexts)); if (!SharedConfig.IsServer) { AddSystem(new PlayerSkyMoveStateUpdateSystem(contexts)); } else { AddSystem(new ServerPlayerSkyMoveStateUpdateSystem(contexts)); } // AddSystem(new PlayerMoveByRootMotionSystem()); AddSystem(new CreatePlayerLifeStateDataSystem()); if (!SharedConfig.IsServer) { AddSystem(new PlayerMoveSystem(contexts)); } else { AddSystem(new ServerMoveSystem(contexts)); } if (!SharedConfig.IsServer) { AddSystem(new PlayerSpecialZoneEventSystem(contexts)); } else { AddSystem(new ServerSpecialZoneEventSystem(contexts)); } AddSystem(new PlayerControlledVehicleUserCmdExecuteSystem()); AddSystem(new UpdatePlayerPositionOnVehicle(contexts)); //AddSystem(new PlayerCameraInputSystem(contexts.player)); AddSystem(new VehicleRideSystem(contexts)); if (!SharedConfig.IsServer) { AddSystem(new VehicleCameraUpdateSystem(contexts)); } AddSystem(new PlayerOxygenEnergySystem(contexts.vehicle)); AddSystem(new PlayerCustomInputUpdateSystem()); AddSystem(new PlayerAutoMoveSystem()); AddSystem(new PlayerClimbActionSystem()); if (!SharedConfig.IsServer) { AddSystem(new PlayerStateUpdateSystem(contexts)); } else { AddSystem(new PlayerServerStateUpdateSystem(contexts)); } if (!SharedConfig.IsServer) { AddSystem(new PlayerMoveByRootMotionSystem()); } else { AddSystem(new ServerMoveByRootMotionSystem()); } AddSystem(new PlayerFirstAppearanceUpdateSystem()); AddSystem(new PlayerAppearanceUpdateSystem()); if (!SharedConfig.IsServer) { AddSystem(new PlayerCharacterBoneUpdateSystem()); } else { AddSystem(new ServerCharacterBoneUpdateSystem()); } AddSystem(new PlayerHoldBreathSystem()); AddSystem(new PlayerAvatarSystem()); if (!SharedConfig.IsServer) { AddSystem(new PlayerSynchronizeToComponentSystem()); } AddSystem(new PlayerBuffUpdateSystem(contexts)); AddSystem(new PlayerFallDamageSystem(contexts)); AddSystem(new PlayerSaveSystem(contexts)); AddSystem(new PlayerStatisticsSystem()); AddSystem(new CameraUpdateArchorSystem(contexts)); if (!SharedConfig.IsServer) { AddSystem(new CameraUpdateSystem(contexts, motors)); } else { AddSystem(new ServerCameraUpdateSystem(contexts, motors)); } AddSystem(new PlayerStateTipSystem(contexts)); AddSystem(new PlayerActionInterruptSystem()); AddSystem(new PlayerBagSwitchSystem(commonSessionObjects)); if (!SharedConfig.IsServer) { AddSystem(new CameraPostUpdateSystem(contexts.player, contexts.vehicle, contexts.freeMove)); } else { AddSystem(new ServerPostCameraUpdateSystem(contexts)); } AddSystem(new PlayerSoundPlaySystem(contexts)); }
public ClientScenePostprocessorSystem(ICommonSessionObjects session) { _session = session; }
public PlayerBagSwitchSystem(ICommonSessionObjects commonSessionObjects, Contexts contexts) { _commonSessionObjects = commonSessionObjects; _contexts = contexts; }
public OfflineGamePlay(Contexts contexts, ICommonSessionObjects sessionObjects) { _contexts = contexts; _sessionObjects = sessionObjects; }
public SimpleLoadBulletSystem(Contexts contexts, ICommonSessionObjects sessionObjects) : base(contexts.player) { this._contexts = contexts; this._sessonObjects = sessionObjects; }
public BulletReloadSystem(Contexts contexts, ICommonSessionObjects sessionObjects) { this._contexts = contexts; this._sessonObjects = sessionObjects; }