public void ExecuteUserCmd(IPlayerUserCmdGetter getter, IUserCmd cmd) { PlayerEntity playerEntity = (PlayerEntity)getter.OwnerEntity; CheckPlayerLifeState(playerEntity); if (cmd.PredicatedOnce) { return; } var stateManager = playerEntity.stateInterface.State; var animatorClipManager = playerEntity.animatorClip.ClipManager; playerEntity.stateInterVar.Reset(); _inputCreator.Reset(); if (Input.GetKeyDown(KeyCode.Alpha8)) { stateManager.InterruptSwitchWeapon(); } // cmd到FsmInput _inputCreator.CreateCommands(cmd, new FilterState { Posture = stateManager.GetCurrentPostureState() }, playerEntity, _contexts); PostureInterruptAction(playerEntity, cmd); // jump to prone or crouch disable JumpTipTest(playerEntity, cmd); var commandsContainer = _inputCreator.CommandsContainer; // 记录状态更新前动画状态,以第三人称为准 // 人物的移动在状态更新之后 _animMonitor.MonitorBeforeFsmUpdate(commandsContainer, playerEntity.thirdPersonAnimator.UnityAnimator, playerEntity.playerMove.IsGround); //_logger.InfoFormat("land:{2}:IsGround:{0},IsExceedSlopeLimit:{1}", playerEntity.playerMove.IsGround, // playerEntity.stateInterface.State.IsExceedSlopeLimit(),playerEntity.playerMove.IsGround && !playerEntity.stateInterface.State.IsExceedSlopeLimit() ); // AnimationMonitor会产生Freefall并对Freefall进行处理,所以要在AnimationMonitor.MonitorBeforeFsmUpdate的后面 AnimationTest(playerEntity, commandsContainer); UpdateStateResponseToInput(cmd, stateManager, commandsContainer, playerEntity); SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.Animator); // 播放动画 if (!playerEntity.gamePlay.IsLifeState(EPlayerLifeState.Dead)) { playerEntity.thirdPersonAnimator.UnityAnimator.Update(cmd.FrameInterval * 0.001f); playerEntity.firstPersonAnimator.UnityAnimator.Update(cmd.FrameInterval * 0.001f); } SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.Animator); // 记录状态更新后动画状态,生成FsmInput _animMonitor.MonitorAfterFsmUpdate(commandsContainer, playerEntity.thirdPersonAnimator.UnityAnimator, playerEntity.firstPersonAnimator.UnityAnimator); UpdateWeaponAnimation(commandsContainer, playerEntity); UpdateStateResponseToAnimation(stateManager, commandsContainer, animatorClipManager, playerEntity); if (_fsmOutputs.NeedUpdateP1()) { playerEntity.firstPersonAnimator.UnityAnimator.Update(0f); } if (_fsmOutputs.NeedUpdateP3()) { playerEntity.thirdPersonAnimator.UnityAnimator.Update(0f); //_logger.InfoFormat("update p3!!!!!!!!"); } WriteNetworkAnimation(cmd, playerEntity); SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.StateCallBackInvoke); stateManager.TryAnimationBasedCallBack(commandsContainer); SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.StateCallBackInvoke); CollectAnimationCallBack(stateManager, playerEntity); //_logger.InfoFormat("seq:{0},{1}",cmd.Seq, playerEntity.stateInterVar.PrintCommandsCount()); //_logger.InfoFormat("net work component hash:{0},{3}, SnapshotId:{1}, seq:{2}", playerEntity.networkAnimator.GetHashCode(), cmd.SnapshotId, cmd.Seq, playerEntity.networkAnimator.ToString()); //_logger.InfoFormat("state component hash:{0}, SnapshotId:{1}, seq:{2}", playerEntity.state, cmd.SnapshotId, cmd.Seq); }
public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd) { if (cmd.PredicatedOnce) { return; } PlayerEntity playerEntity = (PlayerEntity)owner.OwnerEntity; if (playerEntity.gamePlay.IsLifeState(EPlayerLifeState.Dead) || playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Dead)) { // gamePlay有对应的处理,这里不需要 return; } RewindNetworkAnimator(cmd, playerEntity); var stateManager = playerEntity.stateInterface.State; var animatorClipManager = playerEntity.animatorClip.ClipManager; playerEntity.stateInterVar.Reset(); _inputCreator.Reset(); // cmd到FsmInput _inputCreator.CreateCommands(cmd, new FilterState { Posture = stateManager.GetCurrentPostureState() }, playerEntity); PostureInterruptAction(playerEntity, cmd); var commandsContainer = _inputCreator.CommandsContainer; // 记录状态更新前动画状态,以第三人称为准 // 人物的移动在状态更新之后 _animMonitor.MonitorBeforeFsmUpdate(commandsContainer, playerEntity.thirdPersonAnimator.UnityAnimator, playerEntity.playerMove.IsGround); // AnimationMonitor会产生Freefall并对Freefall进行处理,所以要在AnimationMonitor.MonitorBeforeFsmUpdate的后面 AnimationTest(playerEntity, commandsContainer); UpdateStateResponseToInput(cmd, stateManager, commandsContainer, playerEntity); SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.Animator); // 播放动画 playerEntity.thirdPersonAnimator.UnityAnimator.Update(cmd.FrameInterval * 0.001f); playerEntity.firstPersonAnimator.UnityAnimator.Update(cmd.FrameInterval * 0.001f); SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.Animator); // 记录状态更新后动画状态,生成FsmInput _animMonitor.MonitorAfterFsmUpdate(commandsContainer, playerEntity.thirdPersonAnimator.UnityAnimator, playerEntity.firstPersonAnimator.UnityAnimator); UpdateWeaponAnimation(commandsContainer, playerEntity); UpdateStateResponseToAnimation(stateManager, commandsContainer, animatorClipManager, playerEntity); WriteNetworkAnimation(cmd, playerEntity); SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.StateCallBackInvoke); stateManager.TryAnimationBasedCallBack(commandsContainer); SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.StateCallBackInvoke); CollectAnimationCallBack(stateManager, playerEntity); //_logger.InfoFormat("seq:{0},{1}",cmd.Seq, playerEntity.stateInterVar.PrintCommandsCount()); //_logger.InfoFormat("net work component hash:{0},{3}, SnapshotId:{1}, seq:{2}", playerEntity.networkAnimator.GetHashCode(), cmd.SnapshotId, cmd.Seq, playerEntity.networkAnimator.ToString()); //_logger.InfoFormat("state component hash:{0}, SnapshotId:{1}, seq:{2}", playerEntity.state, cmd.SnapshotId, cmd.Seq); }