public PostureLadderState(PostureStateId id) : base(id) { #region ladder to stand AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.ExitLadder) || command.IsMatch(FsmInput.InterruptLadder)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.PostureHash, AnimatorParametersHash.Instance.PostureName, AnimatorParametersHash.Instance.StandValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); return(true); } return(false); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Stand, null, 0, new[] { FsmInput.ExitLadder, FsmInput.InterruptLadder }); #endregion }
/// <summary> /// 现在站蹲趴不允许被打断了 /// </summary> /// <param name="id"></param> /// <param name="transfer"></param> /// <param name="interrupt"></param> /// <param name="target"></param> /// <param name="duration"></param> /// <param name="firstPersonFromValue"></param> /// <param name="firstPersonToValue"></param> /// <param name="thirdPersonFromValue"></param> /// <param name="thirdPersonToValue"></param> /// <param name="fromCharacterControllerConfig"></param> /// <param name="toCharacterControllerConfig"></param> /// <param name="updateP3"></param> internal PostureTransition(short id, Func <IFsmInputCommand, Action <FsmOutput>, bool> transfer, Func <IFsmInputCommand, Action <FsmOutput>, FsmTransitionResponseType> interrupt, PostureStateId target, int duration, float firstPersonFromValue, float firstPersonToValue, float firstPersonForwardOffsetFromValue, float firstPersonForwardOffsetToValue, float thirdPersonFromValue, float thirdPersonToValue, PostureInConfig fromCharacterControllerConfig, PostureInConfig toCharacterControllerConfig, bool updateP3 = true) : base(id, (short)target, duration) { _fromValueP1 = firstPersonFromValue; _toValueP1 = firstPersonToValue; _firstPersonForwardOffsetFromValue = firstPersonForwardOffsetFromValue; _firstPersonForwardOffsetToValue = firstPersonForwardOffsetToValue; _fromValueP3 = thirdPersonFromValue; _toValueP3 = thirdPersonToValue; _fromCharacterControllerConfig = GetFunc(fromCharacterControllerConfig); _toCharacterControllerConfig = GetFunc(toCharacterControllerConfig); _simpleTransferCondition = transfer; _interruptCondition = interrupt; _updateP3 = updateP3; }
public CustomPostureState(PostureStateId id, float height, float forward, float controllerHeight, float controllerRadius) : base(id) { _height = height; _forward = forward; _controllerHeight = controllerHeight; _controllerRadius = controllerRadius; }
public ProneTransitState(PostureStateId id) : base(id) { #region proneTransit to prone AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.ToProneTransitFinish) || command.IsMatch(FsmInput.Dying); if (command.IsMatch(FsmInput.ToProneTransitFinish)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.PostureHash, AnimatorParametersHash.Instance.PostureName, AnimatorParametersHash.Instance.ProneValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } return(ret); }, null, (int)PostureStateId.Prone, null, 0, new[] { FsmInput.ToProneTransitFinish, FsmInput.Dying }); #endregion }
internal static LeanInConfig GetLeanStateId(PostureStateId stateId) { LeanInConfig ret = LeanInConfig.NoPeek; switch (stateId) { case PostureStateId.NoPeek: ret = LeanInConfig.NoPeek; break; case PostureStateId.PeekLeft: ret = LeanInConfig.PeekLeft; break; case PostureStateId.PeekRight: ret = LeanInConfig.PeekRight; break; default: ret = LeanInConfig.NoPeek; Logger.ErrorFormat("can not convert PostureStateId type:{0} to MovementInConfig type", stateId); break; } return(ret); }
public ClimbState(PostureStateId id) : base(id) { #region climb to stand AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.GenericActionFinished)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.ClimbHash, AnimatorParametersHash.Instance.ClimbName, AnimatorParametersHash.Instance.ClimbDisableValue, CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); return(FsmStateResponseType.Reenter); } return(FsmStateResponseType.Pass); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Stand, null, 0, new[] { FsmInput.GenericActionFinished }); #endregion }
public FreefallState(PostureStateId id) : base(id) { InitSpecial(); InitCommon(); #region jumpstart to stand AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.MiddleEnterLadder) || command.IsMatch(FsmInput.EnterLadder)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.JumpStartHash, AnimatorParametersHash.Instance.JumpStartName, AnimatorParametersHash.Instance.JumpStartDisable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.FreeFallHash, AnimatorParametersHash.Instance.FreeFallName, AnimatorParametersHash.Instance.FreeFallDisable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); return(true); } return(false); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Ladder, null, 0, new[] { FsmInput.MiddleEnterLadder, FsmInput.EnterLadder }); #endregion }
public DyingTransitionState(PostureStateId id) : base(id) { AddTransition( (command, action) => FsmTransition.SimpleCommandHandler(command, FsmInput.DyingTransitionFinished), (command, action) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Dying, null, 0, new [] { FsmInput.DyingTransitionFinished } ); }
public LeanInConfig GetNextLeanState() { PostureStateId id = CurrentState.ActiveTransition == null ? (PostureStateId)CurrentState.StateId : (PostureStateId)CurrentState.ActiveTransition.To; return(StateIdAdapter.GetLeanStateId(id)); }
public PeekLeftState(PostureStateId id) : base(id) { #region PeekLeft to NoPeek AddTransition(new PeekLeftToNoPeekTransition(AvailableTransitionId(), (int)PostureStateId.NoPeek, AnimatorParametersHash.PeekTime), new[] { FsmInput.NoPeek, FsmInput.PeekRight }); #endregion }
private bool GetCurrentOrNextState(bool getCurrent, PostureStateId state) { if (getCurrent) { return(state == (PostureStateId)CurrentState.StateId); } if (CurrentState.ActiveTransition != null) { return(state == (PostureStateId)CurrentState.ActiveTransition.To); } return(false); }
//private static LoggerAdapter _logger = new LoggerAdapter(typeof(ClimbState)); public ClimbState(PostureStateId id) : base(id) { #region climb to stand AddTransition( (command, addOutput) => FsmTransition.SimpleCommandHandler(command, FsmInput.GenericActionFinished) || FsmTransition.SimpleCommandHandler(command, FsmInput.FinishedClimb), null, (int)PostureStateId.Stand, null, 0, new[] { FsmInput.GenericActionFinished, FsmInput.FinishedClimb }); AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.Freefall)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.FreeFallHash, AnimatorParametersHash.Instance.FreeFallName, AnimatorParametersHash.Instance.FreeFallEnable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.JumpStateHash, AnimatorParametersHash.Instance.JumpStateName, AnimatorParametersHash.Instance.JumpStateNormal, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.MoveJumpStateHash, AnimatorParametersHash.Instance.MoveJumpStateName, AnimatorParametersHash.Instance.MoveJumpStateNormal, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; return(true); } return(false); }, null, (int)PostureStateId.Freefall, null, 0, new[] { FsmInput.Freefall }); #endregion }
public JumpEndState(PostureStateId id) : base(id) { #region jumpend to jumpstart AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.Jump); if (ret) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.JumpStartHash, AnimatorParametersHash.Instance.JumpStartName, AnimatorParametersHash.Instance.JumpStartEnable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); SetJumpMoveState(command.AdditioanlValue, command.AlternativeAdditionalValue, addOutput); command.Handled = true; } return(ret); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.JumpStart, null, 0, new[] { FsmInput.Jump }); #endregion #region jumpend to stand AddTransition(new JumpEndToStandTransition(AvailableTransitionId(), (int)PostureStateId.Stand, AnimatorParametersHash.ImpossibleTransitionTime), new[] { FsmInput.Land, FsmInput.SlideEnd }); #endregion #region jumpend to dying AddTransitionFromJumpToDying(this); #endregion }
public CustomPostureState(PostureStateId id, float height, float forward) : base(id) { _stateId = id; _height = height; _forward = forward; if (PostureStateId.Prone == id) { _controllerHeight = () => _characterInfo.GetProneCapsule().Height; _controllerRadius = () => _characterInfo.GetProneCapsule().Radius; } else if (PostureStateId.Crouch == id) { _controllerHeight = () => _characterInfo.GetCrouchCapsule().Height; _controllerRadius = () => _characterInfo.GetCrouchCapsule().Radius; } else { _controllerHeight = () => _characterInfo.GetStandCapsule().Height; _controllerRadius = () => _characterInfo.GetStandCapsule().Radius; } }
public DyingState(PostureStateId id) : base(id) { #region dying to crouch AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.Revive); if (ret) { command.Handled = true; } return(ret); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Stand, null, 0, new[] { FsmInput.Revive }); #endregion }
public JumpStartState(PostureStateId id) : base(id) { #region jumpstart to jumpend AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.Land)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.JumpStartHash, AnimatorParametersHash.Instance.JumpStartName, AnimatorParametersHash.Instance.JumpStartDisable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); return(FsmStateResponseType.Reenter); } return(FsmStateResponseType.Pass); }, (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.JumpEnd, null, 0, new[] { FsmInput.Land }); #endregion #region jumpstart to freefall AddTransition( (command, addOutput) => FsmTransition.SimpleCommandHandler(command, FsmInput.Freefall), (command, addOutput) => FsmTransitionResponseType.NoResponse, (int)PostureStateId.Freefall, null, 0, new[] { FsmInput.Freefall }); #endregion #region jumpStart to dying AddTransitionFromJumpToDying(this); #endregion }
public SlideState(PostureStateId id) : base(id) { InitSpecial(); InitCommon(); }
public FreefallState(PostureStateId id) : base(id) { InitSpecial(); InitCommon(); }
public FreefallState(PostureStateId id) : base(id) { #region freefall to jumpend AddTransition( (command, addOutput) => { if (command.IsMatch(FsmInput.Land)) { return(FsmStateResponseType.Reenter); } return(FsmStateResponseType.Pass); }, null, (int)PostureStateId.JumpEnd, null, 0, new[] { FsmInput.Land }); #endregion #region freefall to swim AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.Swim); if (ret) { FsmOutput.Cache.SetLayerWeight(AnimatorParametersHash.Instance.SwimLayer, AnimatorParametersHash.Instance.SwimEnableValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.SwimStateHash, AnimatorParametersHash.Instance.SwimStateName, AnimatorParametersHash.Instance.SwimStateSwimValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } return(ret); }, null, (int)PostureStateId.Swim, null, 0, new[] { FsmInput.Swim }); #endregion #region freefall to dive AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.Dive); if (ret) { FsmOutput.Cache.SetLayerWeight(AnimatorParametersHash.Instance.SwimLayer, AnimatorParametersHash.Instance.SwimEnableValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.SwimStateHash, AnimatorParametersHash.Instance.SwimStateName, AnimatorParametersHash.Instance.SwimStateDiveValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } return(ret); }, null, (int)PostureStateId.Dive, null, 0, new[] { FsmInput.Dive }); #endregion #region freefall to dying AddTransition( (command, addOutput) => { var ret = command.IsMatch(FsmInput.Dying); if (ret) { command.Handled = true; FsmOutput.Cache.SetLayerWeight(AnimatorParametersHash.Instance.DyingLayer, AnimatorParametersHash.Instance.DyingEnableValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); } return(ret); }, null, (int)PostureStateId.Dying, null, 0, new[] { FsmInput.Dying }); #endregion }
internal static PostureInConfig GetPostureStateId(PostureStateId stateId) { PostureInConfig ret = PostureInConfig.Null; switch (stateId) { case PostureStateId.Stand: ret = PostureInConfig.Stand; break; case PostureStateId.Crouch: ret = PostureInConfig.Crouch; break; case PostureStateId.Prone: ret = PostureInConfig.Prone; break; case PostureStateId.Dying: ret = PostureInConfig.Dying; break; case PostureStateId.Dive: ret = PostureInConfig.Dive; break; // go through case PostureStateId.JumpStart: case PostureStateId.Freefall: ret = PostureInConfig.Jump; break; case PostureStateId.JumpEnd: ret = PostureInConfig.Land; break; case PostureStateId.Swim: ret = PostureInConfig.Swim; break; case PostureStateId.ProneTransit: ret = PostureInConfig.ProneTransit; break; case PostureStateId.ProneToCrouch: ret = PostureInConfig.ProneToCrouch; break; case PostureStateId.ProneToStand: ret = PostureInConfig.ProneToStand; break; case PostureStateId.Climb: ret = PostureInConfig.Climb; break; default: ret = PostureInConfig.Null; Logger.ErrorFormat("can not convert PostureStateId type:{0} to PostureInConfig type", stateId); break; } return(ret); }
public PostureState(PostureStateId id) : base((short)id) { }
public LeanInConfig GetCurrentLeanState() { PostureStateId id = (PostureStateId)CurrentState.StateId; return(StateIdAdapter.GetLeanStateId(id)); }
public DiveState(PostureStateId id) : base(id) { }