protected AbstractCommonResourceLoadSystem(IContexts contexts, Queue <RemoveAssetStatus> oldResource) { _oldResource = oldResource; _initializedGroup = GetInitializedGroup(contexts); _uninitializedGroup = GetUninitializedGroup(contexts); _contexts = contexts; }
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 ClientProfileSessionStateMachine(IContexts contexts) : base(new ClientSessionStateMachineMonitor(contexts)) { AddState(new LoadBaseConfigureState(contexts, EClientSessionStates.LoadConfig, EClientSessionStates.RequestRoomInfo)); if (SharedConfig.InSamplingMode) { AddState(new RequestRoomInfoState(contexts, EClientSessionStates.RequestRoomInfo, EClientSessionStates.ProfilePreparation)); AddState(new ProfilePreparationState(contexts, EClientSessionStates.ProfilePreparation, EClientSessionStates.LoadOptionConfig)); AddState(new ClientOptionLoadState(contexts, EClientSessionStates.LoadOptionConfig, EClientSessionStates.LoadSceneMapConfig)); AddState(new LoadSceneMapConfig(contexts, EClientSessionStates.LoadSceneMapConfig, EClientSessionStates.Profile, true, false)); AddState(new ProfileState(contexts, EClientSessionStates.Profile, EClientSessionStates.Profile)); } else { AddState(new RequestRoomInfoState(contexts, EClientSessionStates.RequestRoomInfo, EClientSessionStates.PreparingPlayer)); AddState(new PreparingPlayerState(contexts, EClientSessionStates.PreparingPlayer, EClientSessionStates.LoadSceneMapConfig)); AddState(new LoadSceneMapConfig(contexts, EClientSessionStates.LoadSceneMapConfig, EClientSessionStates.InitUiModule, true, false)); AddState(new InitUiModuleState(contexts, EClientSessionStates.InitUiModule, EClientSessionStates.RequestSnapshot)); AddState(new WaitSnapshotState(contexts, EClientSessionStates.RequestSnapshot, EClientSessionStates.Running)); AddState(new LoginSuccState(contexts, EClientSessionStates.Running, EClientSessionStates.Running)); } Initialize((int)EClientSessionStates.LoadConfig); }
public override Systems CreateUpdateSystems(IContexts contexts1) { var gameModule = new CompositeGameModule(); var contexts = contexts1 as Contexts; var loadSceneSystem = new InitialSceneLoadingSystem(this, contexts, null, true); loadSceneSystem.AsapMode = true; gameModule.AddSystem(loadSceneSystem); gameModule.AddSystem(new InitTriggerObjectManagerSystem(contexts)); gameModule.AddSystem(new ServerScenePostprocessorSystem(contexts.session.commonSession)); //gameModule.AddModule(new ResourcePreloadModule(this)); var featrue = new ServerPrepareFeature("loadMapConfig", gameModule, contexts.session.commonSession.AssetManager); featrue.Add(new MapConfigInitModule(contexts, this)); if (contexts.session.commonSession.RoomInfo.MapId == 2) { contexts.session.commonSession.InitPosition = new Vector3(1906, 20, -1964); } else { contexts.session.commonSession.InitPosition = Vector3.zero; } return(featrue); }
public override Systems CreateOnDrawGizmos(IContexts contexts) { Systems system = new Systems(); system.Add(new GizmosRenderSystem(_gameModule)); return(system); }
public override Systems CreateOnGuiSystems(IContexts contexts) { Systems system = new Systems(); system.Add(new OnGuiSystem(_gameModule)); return(system); }
public override void DoEventClient(IContexts contexts, IEntity entity, IEvent e) { var playerEntity = entity as PlayerEntity; Contexts c = contexts as Contexts; BeenHitEvent ev = e as BeenHitEvent; var playerEntityTarget = c.player.GetEntityWithEntityKey(ev.Target); if (playerEntity != null) { //服务器下发的被击中者调用受击命令 if (playerEntity.entityKey.Value == ev.Target && playerEntity.hasStateInterface) { Logger.DebugFormat("self:{0}, invoke , CanBeenHit:{1}", ev.Target, playerEntity.stateInterface.State.CanBeenHit()); if (playerEntity.stateInterface.State.CanBeenHit()) { playerEntity.stateInterface.State.BeenHit(); } } //自己预测击中的受击者命令,强制使受击者播放受击动画 else { if (playerEntityTarget != null && playerEntityTarget.hasOverrideNetworkAnimator) { Logger.DebugFormat("target:{0}, invoke , IsInjuryAnimatorActive", ev.Target, ev.TriggerTime); playerEntityTarget.overrideNetworkAnimator.IsInjuryAnimatorActive = true; playerEntityTarget.overrideNetworkAnimator.InjuryTriigerTime = ev.TriggerTime; } } } }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = base.CreateUpdateSystems(contexts); systems.Add(new PreloadFeature("ServerPreLoadState", CreateSystems(_contexts), _contexts.session.commonSession)); return(systems); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Feature("ClientOptionLoadState"); systems.Add(new OptionConfigurationInitModule(this, _contexts.session.commonSession.AssetManager)); return(systems); }
public HubController(ILogger <HubController> logger, IBackgroundJobClient backgroundJobClient, ISubscriptions subscriptions, INotifications <HttpResponseMessage> notifications, IContexts contexts) { this.backgroundJobClient = backgroundJobClient ?? throw new ArgumentNullException(nameof(backgroundJobClient)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.subscriptions = subscriptions ?? throw new ArgumentNullException(nameof(subscriptions)); this.notifications = notifications ?? throw new ArgumentNullException(nameof(notifications)); this.contexts = contexts ?? throw new ArgumentNullException(nameof(contexts)); }
public override Systems CreateUpdateSystems(IContexts contexts1) { var contexts = contexts1 as Contexts; var sessionObjects = contexts.session.commonSession; var entityIdGenerator = sessionObjects.EntityIdGenerator; _gameModule = new CompositeGameModule(); _gameModule.AddModule(new ServerPlayerModule(contexts)); _gameModule.AddModule(new ServerEntityInitModule(contexts)); _gameModule.AddModule(new ServerBulletModule(contexts)); IHitBoxEntityManager hitBoxEntityManager = new HitBoxEntityManager(contexts, true); var snapshotSelectorContainer = contexts.session.serverSessionObjects.CompensationSnapshotSelector; ICompensationWorldFactory factory = new ServerCompensationWorldFactory(snapshotSelectorContainer, hitBoxEntityManager); var serverDamageInfoCollector = new ServerDamageInfoCollector(contexts.player); _gameModule.AddModule(new UserCmdGameModule(contexts, factory, new BulletHitHandler(contexts, entityIdGenerator, room.PlayerDamager, serverDamageInfoCollector, contexts.session.entityFactoryObject.SoundEntityFactory, SingletonManager.Get <EnvironmentTypeConfigManager>()), new MeleeHitHandler(contexts, room.PlayerDamager, entityIdGenerator, serverDamageInfoCollector, contexts.session.entityFactoryObject.SoundEntityFactory), new ThrowingHitHandler(contexts, room.PlayerDamager), sessionObjects, MotorsFactory.CraeteMotors(contexts, SingletonManager.Get <CameraConfigManager>().Config))); _gameModule.AddModule(new ServerPostPredictionModule(contexts)); _gameModule.AddModule(new ServerVehicleModule(contexts, contexts.session.serverSessionObjects.VehicleTimer)); _gameModule.AddModule(new ServerGamePlayModule(contexts, room)); _gameModule.AddModule( new ServerSceneObjectModule(contexts, this, sessionObjects.EquipmentEntityIdGenerator)); IUserCmdExecuteSystemHandler userCmdExecuteSystemHandler = new UserCmdExecuteSystemHandler(contexts); IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler = new ServerVehicleCmdExecuteSystemHandler(contexts); var systems = new Feature("GameSessionState"); systems.Add(new PingSystem(contexts)); systems.Add(new ServerMainFeature( "ServerSystems", _gameModule, userCmdExecuteSystemHandler, vehicleCmdExecuteSystemHandler, contexts.session.serverSessionObjects.SimulationTimer, new VehicleExecutionSelector(contexts), sessionObjects, room)); return(systems); }
public void Update(List <IGameEntity> preEntitys, IContexts _newContexts) { try { _contexts = _newContexts; _removeList.Clear(); // _preEntitys_HashSet 进行填充,用于在 Add 函数中判断 是否加入的entity是 上次残留的对象 _preEntitys_HashSet.Clear(); foreach (var entity in preEntitys) { _preEntitys_HashSet.Add(entity.EntityKey); } // 获取 _gameContexts if (_gameContexts == null) { _gameContexts = (_newContexts as Contexts).session.commonSession.GameContexts; } // 遍历残留字典 foreach (var keyValue in _dict) { var entityKey = keyValue.Key; IGameEntity entity = null; //--------------------------------------------------- // 找不到entityKey对应的entity,就标记去除 if (!_gameContexts.TryGetGameEntity(entityKey, out entity)) { _removeList.Add(entityKey); continue; } //--------------------------------------------------- // 不符合条件的就标记去除 if (!keyValue.Value.CanStay(_contexts)) { _removeList.Add(entityKey); continue; } //--------------------------------------------------- preEntitys.Add(entity); } // -----清除被标记的key------------------------------- foreach (var entityKey in _removeList) { _dict.Remove(entityKey); } } catch (Exception e) { _logger.ErrorFormat("当前线程为 {0},异常为:{1}", System.Threading.Thread.CurrentThread.Name, e.Message + "\n" + e.StackTrace); } }
public override Systems CreateUpdateSystems(IContexts contexts) { var systems = new Feature("PreLoadingState"); var contextsImpl = contexts as Contexts; var commonSession = contextsImpl.session.commonSession; systems.Add(new ResourceLoadSystem(new PreLoadModule(this, contexts), commonSession.AssetManager)); return(systems); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Feature("ClientPreLoadState"); systems.Add(new PreloadFeature("ClientPreLoadState", CreateSystems(_contexts, this), _contexts.session.commonSession)); return(systems); }
protected override void InitComponent(PlayerEntity player, IContexts contexts) { var character = DefaultGo.CreateGameObject(player.entityKey.ToString()); character.layer = UnityLayerManager.GetLayerIndex(EUnityLayerName.Player); var cc = PlayerEntityUtility.InitCharacterController(character); var kcc = PlayerEntityUtility.InitKinematicCharacterMotor(character); var characterControllerContext = new CharacterControllerContext( new UnityCharacterController(cc, ModelLoadHandler.InitActionWithOffset(), !player.isFlagSelf), new ProneCharacterController(kcc, new ProneController(), ModelLoadHandler.InitActionWithNoOffset()), new DiveCharacterController(kcc, new DiveController(), ModelLoadHandler.InitActionWithNoOffset()), new SwimCharacterController(kcc, new SwimController(), ModelLoadHandler.InitActionWithNoOffset()) ); var curver = character.AddComponent <AirMoveCurve>(); curver.AireMoveCurve = SingletonManager.Get <CharacterStateConfigManager>().AirMoveCurve; character.AddComponent <EntityReference>(); character.GetComponent <EntityReference>().Init(player.entityAdapter); var comp = character.AddComponent <PlayerVehicleCollision>(); comp.AllContext = contexts as Contexts; var appearanceManager = new AppearanceManager(); var characterControllerManager = new CharacterControllerManager(); characterControllerManager.SetCharacterController(characterControllerContext); var characterBone = new CharacterBoneManager(); characterBone.SetWardrobeController(appearanceManager.GetWardrobeController()); characterBone.SetWeaponController(appearanceManager.GetController <NewWeaponController>()); var weaponController = (NewWeaponController)appearanceManager.GetController <NewWeaponController>(); if (null != weaponController) { weaponController.SetWeaponChangedCallBack(characterBone.CurrentP1WeaponChanged, characterBone.CurrentP3WeaponChanged); weaponController.SetWeaponOrAttachmentDeleteCallBack(characterBone.WeaponOrAttachmentDel); weaponController.SetWeaponOrAttachementAddCallBack(characterBone.WeaponOrAttachmentAdd); weaponController.SetCacheChangeAction(characterBone.CacheChangeCacheAction); } player.AddCharacterControllerInterface(characterControllerManager); player.AddAppearanceInterface(appearanceManager); player.AddCharacterContoller(characterControllerContext); player.AddCharacterBoneInterface(characterBone); player.AddPlayerGameState(PlayerLifeStateEnum.NullState); player.AddPlayerResource(character); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Entitas.Systems(); systems.Add(new RequestSnapshotSystem(_contexts, this)); return(systems); }
public ProfilePreparationState(IContexts contexts, EClientSessionStates state, EClientSessionStates next) : base(contexts, (int)state, (int)next) { Contexts ctx = (Contexts)contexts; var player = ctx.player.CreateEntity(); player.isFlagSelf = true; player.AddPosition(); player.AddOrientation(0, 0, 0, 0, 0); player.AddCameraObj(); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Feature("ProfilePreparationState"); systems.Add(new ProfilePreparationFeature("ProfilePreparationState", CreateSystems(_contexts), _contexts.session.commonSession)); return(systems); }
public ClientSessionStateProgress(IContexts contexts) { _contexts = contexts as Contexts; UiCommon.InitUI(UiRootName); _assetManager = _contexts.session.commonSession.AssetManager; _assetManager.LoadAssetAsync(GetType().ToString(), new AssetInfo(LoadingUiBundleName, LoadingUiAssetName), OnLoadSucc); }
public override Systems CreateUpdateSystems(IContexts contexts) { var systems = new Feature("MapLoadState"); var contextsImpl = contexts as Contexts; var commonSession = contextsImpl.session.commonSession; systems.Add(new SceneResourceLoadingFeature("SceneResourceLoading", CreateSystems(contextsImpl), commonSession)); return(systems); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = base.CreateUpdateSystems(contexts); systems.Add(new PreloadFeature("ClientPreLoadState", CreateSystems(_contexts, this), _contexts.session.commonSession)); systems.Add(new BaseConfigurationInitModule(this, _contexts.session.commonSession.AssetManager)); return(systems); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Entitas.Systems(); systems.Add(new RequestSceneInfoSystem(_contexts, this)); /*MakeWeaponLogicManager(_contexts);*/ return(systems); }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; var systems = new Feature("PreparingPlayer"); systems.Add(new RequestPlayerInfoSystem(_contexts, this)); systems.Add(new ClientPreparePlayerMainFeature("MainFeature", GameModuleFactory.CreatePreparePlayerGameModule(_contexts), _contexts.session.commonSession)); systems.Add(new CheckPreparingPlayerSystem(_contexts, this)); systems.Add(new ResourceLoadSystem(new PreLoadModule(this, contexts), _contexts.session.commonSession.AssetManager)); return(systems); }
public override void DoEventServer(IContexts contexts, IEntity entity, IEvent e) { (entity as PlayerEntity).StatisticsController().HandleDispatchedEvt(e as StatisticsHitPlayerEvent, true); // var playerEntity = entity as PlayerEntity; // if (playerEntity != null) // { // var v = EventInfos.Instance.Allocate(e.EventType, true); // v.RewindTo(e); // playerEntity.remoteEvents.Events.AddEvent(v); // } }
public override Systems CreateUpdateSystems(IContexts contexts1) { var gameModule = new CompositeGameModule(); var contexts = contexts1 as Contexts; gameModule.AddModule(new ServerInitModule(contexts, this)); gameModule.AddModule(new SubResourceConfigurationInitModule(this)); var featrue = new ServerPrepareFeature("loadSubResourceConfig", gameModule, contexts.session.commonSession.AssetManager); return(featrue); }
public static void ObserveAll(IContexts contexts) { if (!Application.isPlaying || !Application.isEditor) { return; } foreach (var c in contexts.allContexts) { Observe(c); } }
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); }
/// <summary> /// Setup contexts to use visual debugging. /// </summary> public static void EnableVisualDebugging(this IContexts contexts) { // This moves the registration of visual debugging outside the Context so that games // using both Unity projects and external systems at the same time (such as WPF) // can optionally exclude debugging support and operate on the same project. // (external projects need to exclude unity specific code because it throws exceptions // whenever it accesses the C++ side of unity engine). for (int i = 0; i < contexts.allContexts.Length; i++) { SetupVisualDebugging(contexts.allContexts[i]); } }
/// <summary> /// </summary> /// <param name="contexts"></param> /// <param name="entity"></param> /// <param name="e"></param> public override void DoEventClient(IContexts contexts, IEntity entity, IEvent e) { FireEvent evt = e as FireEvent; if (evt != null) { var effectCfg = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(evt.weaponId) .S_EffectConfig as DefaultWeaponEffectConfig; if (effectCfg == null) { return; } Contexts ctx = contexts as Contexts; PlayerEntity player = ctx.player.GetEntityWithEntityKey(evt.owner); if (evt.fireEffectType != FireEvent.FireEffectType.EnjectOnly) { var muzzleTrans = player.characterBoneInterface.CharacterBone.GetLocation(SpecialLocation.MuzzleEffectPosition, CharacterView.ThirdPerson); if (muzzleTrans) { ClientEffectFactory.CreateMuzzleSparkEffct(muzzleTrans.position, evt.pitch, evt.yaw, effectCfg.Spark, muzzleTrans); } } if (evt.fireEffectType != FireEvent.FireEffectType.MuzzleOnly) { var ejectTrans = player.characterBoneInterface.CharacterBone.GetLocation(SpecialLocation.EjectionLocation, CharacterView.ThirdPerson); if (ejectTrans) { ClientEffectFactory.CreateBulletDrop(ejectTrans.position, evt.yaw, evt.pitch, effectCfg.BulletDrop, evt.weaponId, AudioGrp_FootMatType.Concrete); } } // var weaponGo = (entity as PlayerEntity).appearanceInterface.Appearance.GetWeaponP1InHand(); // GameAudioMedia.PlayWeaponFireAudio(evt.fireWeaponId, evt.audioFirePos, (AudioGrp_ShotMode)evt.audioFireMode); } // GameAudioMedium.ProcessWeaponAudio(playerEntity,allContexts,(item)=>item.Fire); // if (playerEntity.appearanceInterface.Appearance.IsFirstPerson) // { // } // else // { //// GameAudioMedium.PerformOnGunFire(); // } }
public override Systems CreateUpdateSystems(IContexts contexts) { Contexts _contexts = (Contexts)contexts; //SingletonManager.Get<MapConfigManager>().SetCurrentMap(_contexts.session.clientSessionObjects.MapId); _gameModule = CreateCompositeGameModule(_contexts); var systems = new Entitas.Systems(); systems.Add(new ClientPreLoginFeature( "PreLoginState", _gameModule, _contexts.session.commonSession )); return(systems); }