public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { if (!cmd.IsDrawWeapon && !cmd.IsForceUnmountWeapon) { return; } var player = owner.OwnerEntity as PlayerEntity; if (cmd.IsForceUnmountWeapon) { player.playerAction.Logic.ForceUnmountWeapon(); return; } if (null != cmd.FilteredInput && !cmd.FilteredInput.IsInput(XmlConfig.EPlayerInput.IsDrawWeapon)) { return; } else { if (null == cmd.FilteredInput) { Logger.Error("FilteredInput in cmd should never be null !"); } } bool changeWeaponSucess = true; var curSlot = player.GetBagLogicImp().GetCurrentWeaponSlot(); if (curSlot == EWeaponSlotType.None) { var lastSlot = player.GetBagLogicImp().PopLastWeaponSlot(); if (lastSlot != EWeaponSlotType.None) { //player.soundManager.Value.PlayOnce(XmlConfig.EPlayerSoundType.ChangeWeapon); player.playerAction.Logic.DrawWeapon(lastSlot); } else { changeWeaponSucess = false; if (Logger.IsInfoEnabled) { Logger.Info("last weapon slot is none"); } } } else { // player.soundManager.Value.PlayOnce(XmlConfig.EPlayerSoundType.ChangeWeapon); player.playerAction.Logic.UnmountWeapon(); } if (changeWeaponSucess) { player.weaponLogic.State.OnSwitchWeapon(); } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity playerEntity = (PlayerEntity)owner.OwnerEntity; if (playerEntity.hasWeaponLogic) { PrepareAttackState(playerEntity); var comp = playerEntity.weaponLogic; comp.Weapon.Update(comp.State, cmd); } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = (PlayerEntity)owner.OwnerEntity; if (player.IsOnVehicle() || player.gamePlay.IsLifeState(EPlayerLifeState.Dead)) { return; } WaterTest(player); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null == player) { Logger.Error("owner entity is not player entity "); return; } player.appearanceInterface.Appearance.UpdateAvatar(); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null != player && (player.gamePlay.IsLifeState(EPlayerLifeState.Dead) || player.gamePlay.IsLastLifeState(EPlayerLifeState.Dead))) { return; } SyncSightComponent(player); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = owner.OwnerEntity as PlayerEntity; if (player.gamePlay.IsLifeState(EPlayerLifeState.Dead)) { return; } ShowPlayerStateTip(player); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (player == null) { return; } CommonUpdate(player, cmd); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { if (cmd.BagIndex > 0) { var player = owner.OwnerEntity as PlayerEntity; if (player.WeaponController().CanSwitchWeaponBag) { player.WeaponController().SwitchBag(); } // var bags = player.playerInfo.WeaponBags; } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = (PlayerEntity)owner.OwnerEntity; if (player.gamePlay.IsLifeState(EPlayerLifeState.Dead)) { // gamePlay有对应的处理,这里不需要 return; } UpdateTransform(player); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null != player && (player.gamePlay.IsLifeState(EPlayerLifeState.Dead) || player.gamePlay.IsLastLifeState(EPlayerLifeState.Dead))) { return; } SightUpdate(player, cmd.FrameInterval); BoneUpdate(player); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = (PlayerEntity)owner.OwnerEntity; if (!player.hasStatisticsData) { return; } StatisticsData statisticsData = player.statisticsData.Statistics; if (player.time.ClientTime - statisticsData.LastSamplingTime < 1000) { return; } _startPos.Set(statisticsData.LastPosition.x, statisticsData.LastPosition.z); _endPos.Set(player.position.Value.x, player.position.Value.z); float moveDis = Vector2.Distance(_startPos, _endPos); //总移动距离 statisticsData.TotalMoveDistance += moveDis; //载具移动距离 if (player.IsOnVehicle()) { statisticsData.VehicleMoveDistance += moveDis; } statisticsData.LastPosition = player.position.Value; //游泳时间 if (player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Swim || player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Dive) { if (statisticsData.LastIsSwimState) { statisticsData.SwimTime += player.time.ClientTime - statisticsData.LastSwimTime; } statisticsData.LastIsSwimState = true; statisticsData.LastSwimTime = player.time.ClientTime; } else { statisticsData.LastIsSwimState = false; } //治疗量(模式中获取) statisticsData.CureVolume = 0; //加速时间(模式中获取) statisticsData.AccSpeedTime = 0; //全副武装(模式中获取) statisticsData.IsFullArmed = false; //最后统计时间 statisticsData.LastSamplingTime = player.time.ClientTime; }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null == player) { Logger.Error("player entity is null"); return; } IGrenadeCacheHandler handler = player.WeaponController().GrenadeHandler; handler.Rewind(); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null == player) { return; } if (cmd.IsHoldBreath && player.IsAiming()) { if (null == player) { Logger.Error("owner entity is not player entity "); return; } if (!player.hasAppearanceInterface) { Logger.Error("player has no appearance interface "); return; } if (!player.oxygenEnergyInterface.Oxygen.InShiftState) { player.oxygenEnergyInterface.Oxygen.ShiftVeryTime = player.time.ClientTime; } player.oxygenEnergyInterface.Oxygen.InShiftState = true; } else { if (!player.hasAppearanceInterface) { Logger.Error("player has no appearance interface "); return; } if (player.oxygenEnergyInterface.Oxygen.InShiftState) { player.oxygenEnergyInterface.Oxygen.ShiftVeryTime = player.time.ClientTime; } player.oxygenEnergyInterface.Oxygen.InShiftState = false; } if (player.oxygenEnergyInterface.Oxygen.InShiftState) { player.appearanceInterface.FirstPersonAppearance.SightShift.SetHoldBreath(true); } else { player.appearanceInterface.FirstPersonAppearance.SightShift.SetHoldBreath(false); } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = (PlayerEntity)owner.OwnerEntity; if (player.playerMove.IsGround && !player.playerMove.FirstOnGround) { player.playerMove.FirstOnGround = true; } else if (player.playerMove.FirstOnGround && !player.playerMove.LastIsCollided && player.playerMove.IsCollided) { float damage = 0; //水平伤害 Vector2 inVel = new Vector2(player.playerMove.LastVelocity.x, player.playerMove.LastVelocity.z); Vector2 outVel = new Vector2(0, 0);//(player.playerMove.Velocity.x, player.playerMove.Velocity.z); float xzSpeed = (inVel - outVel).magnitude; float hurtSpeedHorizontal = SpeedHorizontal; if (player.playerMove.SpeedAffect > 0 && !player.IsOnVehicle())//有加速buff且不在载具内 { hurtSpeedHorizontal *= player.playerMove.SpeedAffect + 1; } if (xzSpeed >= hurtSpeedHorizontal) { damage += (xzSpeed * 3.6f - 30) * 2; } //垂直伤害 float ySpeed = -player.playerMove.LastVelocity.y; float hurtSpeedVertical = SpeedVertical; if (player.playerMove.JumpAffect > 0 && !player.IsOnVehicle()) { hurtSpeedVertical *= player.playerMove.JumpAffect + 1; } if (ySpeed >= hurtSpeedVertical) { //damage += (ySpeed - hurtSpeedVertical) * 14; 伤害取二者大值而非相加 damage = Mathf.Max(damage, (ySpeed - hurtSpeedVertical) * 14); } if (damage > 0 && SharedConfig.HaveFallDamage) { VehicleDamageUtility.DoPlayerDamage(_contexts, null, player, damage, EUIDeadType.Fall); } } player.playerMove.LastIsCollided = player.playerMove.IsCollided; player.playerMove.LastVelocity = player.playerMove.Velocity; }
/// <summary> /// 槽位切换&模式切换 /// </summary> /// <param name="owner"></param> /// <param name="cmd"></param> public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { if (cmd.FilteredInput.IsInput(XmlConfig.EPlayerInput.IsSwitchWeapon) && cmd.CurWeapon != (int)EWeaponSlotType.None) { var newSlot = owner.OwnerEntityKey.ModeController().GetSlotByIndex(cmd.CurWeapon); owner.OwnerEntityKey.WeaponController().SwitchIn(newSlot); return; } if (cmd.FilteredInput.IsInput(XmlConfig.EPlayerInput.IsSwitchFireMode)) { owner.OwnerEntityKey.WeaponController().SwitchFireMode(); return; } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { if (cmd.BagIndex > 0) { var player = owner.OwnerEntity as PlayerEntity; if (!player.modeLogic.ModeLogic.IsBagSwithEnabled(player)) { return; } var bags = player.playerInfo.WeaponBags; var realBagIndex = cmd.BagIndex - 1; player.modeLogic.ModeLogic.ResetWeaponWithBagIndex(realBagIndex, player); } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = (PlayerEntity)owner.OwnerEntity; if (player.gamePlay.IsLifeState(EPlayerLifeState.Dead)) { return; } if (!player.hasPlayerMove || !player.hasStateInterface || !player.hasOrientation) { return; } var state = player.stateInterface.State; var orientationPitch = player.orientation.Pitch; if (state.GetNextPostureState() == PostureInConfig.Dive) { float upDownValue = player.playerMove.UpDownValue; if (cmd.IsSpaceDown || cmd.IsCDown) { upDownValue = _controller.UpdateValue(cmd.FrameInterval * 0.001f, cmd.IsSpaceDown, cmd.IsCDown, player.playerMove.UpDownValue); } else if ((state.IsForth || state.IsBack) && !cmd.IsSpaceDown && !cmd.IsCDown) { upDownValue = _controller.UpdateToTarget(cmd.FrameInterval * 0.001f, Mathf.Clamp((state.IsForth ? -1.0f : -1.0f) * orientationPitch / SingletonManager.Get <CameraConfigManager>().Config .PoseConfigs[(int)ECameraPoseMode.Stand].PitchLimit.Max * state.VerticalValue , -1, 1), upDownValue); } else { upDownValue = _controller.UpdateValue(cmd.FrameInterval * 0.001f, cmd.IsSpaceDown, cmd.IsCDown, player.playerMove.UpDownValue); } state.SetDiveUpDownValue(upDownValue); player.playerMove.UpDownValue = upDownValue; } else { player.playerMove.UpDownValue = 0; } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = (PlayerEntity)owner.OwnerEntity; //服务器通过tcp指令修改客户端位置 CorrectPositionByServer(cmd, player); CheckPlayerLifeState(player); var updateComponent = player.moveUpdate; updateComponent.LastPosition = player.position.Value.ShiftedToFixedVector3(); updateComponent.Reset(); if (!CanPlayerMove(player)) { return; } player.playerMove.ClearState(); // swimhandler和divehandler未解耦,handler内部函数声明为static,解耦后可以不使用switch MoveType moveType = GetPlayerMoveType(player); switch (moveType) { case MoveType.Land: LandHandler.Move(_contexts, player, cmd.FrameInterval * 0.001f); break; case MoveType.Swim: SwimHandler.Move(_contexts, player, cmd.FrameInterval * 0.001f); break; case MoveType.Dive: DiveHandler.Move(_contexts, player, cmd.FrameInterval * 0.001f); break; case MoveType.Fly: FlyHandler.Move(player, cmd, cmd.FrameInterval * 0.001f); break; default: break; } SyncPlayerMove(player, moveType); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = (PlayerEntity)owner.OwnerEntity; var clientData = player.playerMoveByAnimUpdate; if (player.gamePlay.IsLifeState(EPlayerLifeState.Dead) || !clientData.NeedUpdate) { return; } player.RootGo().transform.position = player.position.Value = clientData.Position; player.orientation.ModelPitch = clientData.ModelPitch; player.orientation.ModelYaw = clientData.ModelYaw; }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity playerEntity = owner.OwnerEntity as PlayerEntity; if (!playerEntity.hasCameraStateNew) { return; } if (!playerEntity.hasCameraStateOutputNew) { return; } CopyClientOutputToComponent(playerEntity.cameraStateUpload, playerEntity.cameraFinalOutputNew); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { PlayerEntity player = owner.OwnerEntity as PlayerEntity; if (null == player) { Logger.Error("Owner is not player"); return; } if (player.triggerEvent.NeedUnmountWeapon) { player.WeaponController().ForceUnArmHeldWeapon(); } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = (PlayerEntity)owner.OwnerEntity; if (player.IsOnVehicle()) { player.position.AlwaysEqual = true; player.orientation.AlwaysEqual = true; } else { player.position.AlwaysEqual = false; player.orientation.AlwaysEqual = false; } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; player.uploadEvents.Events.ReInit(); foreach (var serials in player.uploadEvents.StoreEvents.Events) { foreach (var evt in serials.Value) { player.uploadEvents.Events.AddEvent(evt); } } player.uploadEvents.StoreEvents.ReInit(); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd userCmd) { if (userCmd.Seq != owner.LastCmdSeq + 1) { _logger.ErrorFormat("{2} lost user cmd last {0}, cur {1}", owner.LastCmdSeq, userCmd.Seq, owner.OwnerEntityKey); } if (_logger.IsDebugEnabled) { _logger.DebugFormat("processing user cmd {0}", userCmd); } userCmd.FilteredInput = owner.Filter(userCmd); }
public void CreateTasks(List <IUserCmdOwner> users) { int count = users.Count; int threadIdx = 0; for (int i = 0; i < MaxUserNum; i++) { if (_taskDictionary[i].Count > 0) { _taskDictionary[i].Clear(); } Interlocked.Exchange(ref _taskRunCounts[i], 0); } int taskCount = 0; IsStart = false; _userCount = count; for (var i = 0; i < count; i++) { IUserCmdOwner owner = users[i]; var queue = _taskDictionary[i]; foreach (var userCmd in owner.UserCmdList) { foreach (var taskInfo in _taskInfos) { taskCount++; queue.Enqueue(new CmdTask(i, owner, userCmd, taskInfo, threadIdx)); } } threadIdx++; threadIdx = threadIdx % _threadCount; } _logger.DebugFormat("CreateTasks count:{0}", taskCount); if (taskCount > 0) { _mainThread.StartInternal(); for (var i = 0; i < _threadCount; i++) { _slaveThreads[i].StartInternal(); } IsStart = true; } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = (PlayerEntity)owner.OwnerEntity; CheckPlayerLifeState(player); InterruptAutoRun(player, cmd); if (cmd.IsSwitchAutoRun) { player.playerMove.IsAutoRun = !player.playerMove.IsAutoRun; if (player.playerMove.IsAutoRun) { PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, player.gamePlay); } } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { //Logger.InfoFormat("seq:{0}, delata yaw:{2}, client return judge:{1}", cmd.Seq, (!cmd.NeedStepPredication && !SharedConfig.IsServer), cmd.DeltaYaw); if (!cmd.NeedStepPredication && !SharedConfig.IsServer) { return; } var player = owner.OwnerEntity as PlayerEntity; if (player == null) { return; } CommonUpdate(player, cmd); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { //if(SharedConfig.IsServer) //{ if (cmd.BagIndex > 0) { var player = owner.OwnerEntity as PlayerEntity; player.WeaponController().SwitchBag(cmd.BagIndex - 1); //if (player.WeaponController().CanSwitchWeaponBag) // { // player.WeaponController().SwitchBag(player); // } // var bags = player.playerInfo.WeaponBags; } // } }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var player = owner.OwnerEntity as PlayerEntity; if (null == player) { Logger.Error("player entity is null"); return; } if (!player.hasGrenadeInventoryHolder) { Logger.Error("palyer has no GrenadeInventoryHolder"); return; } player.grenadeInventoryHolder.Inventory.Rewind(); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { var controller = GameModuleManagement.Get <PlayerWeaponController>(owner.OwnerEntityKey.EntityId); var weaponId = controller.HeldWeaponAgent.ConfigId; if (weaponId < 1) { return; } var weaponLogic = _weaponLogicManager.GetWeaponLogic(weaponId); if (null != weaponLogic) { weaponLogic.Update(controller, cmd); } }