public virtual FsmStateResponseType TransferTest(IFsmInputCommand command, Action <FsmOutput> addOutput) { var ret = FsmStateResponseType.Pass; if (_simpleTransferCondition != null) { if (_simpleTransferCondition(command, addOutput)) { ret = FsmStateResponseType.Transfer; } } if (_responsiveTransferCondition != null) { ret = _responsiveTransferCondition(command, addOutput); } if (ret != FsmStateResponseType.Pass) { if (_durationCoefficientId != null) { Duration = (int)(_baseDuration * _infoProvider.GetDurationCoefficient(_durationCoefficientId)); } else { Duration = _baseDuration; } } return(ret); }
public virtual FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { FsmStateResponseType response = FsmStateResponseType.Pass; if (_activeTransition != null) { var ret = _activeTransition.InterruptTest(command, addOutput); if (ret == FsmTransitionResponseType.ChangeRoad) { response = TryTransition(command, addOutput); } else if (ret == FsmTransitionResponseType.ForceEnd) { TransitionCallback(_activeTransition.To, command, StateId.ToString(), addOutput); response = FsmStateResponseType.Reenter; } else if (ret == FsmTransitionResponseType.ExternalEnd) { TransitionCallback(_activeTransition.To, command, StateId.ToString(), addOutput); } } else { response = TryTransition(command, addOutput); } return(response); }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); FsmOutput.Cache.SetValue(FsmOutputType.ChangeDiveSensitivity, InputSchemeConst.Dive); addOutput(FsmOutput.Cache); }
protected FsmStateResponseType TryTransition(IFsmInputCommand command, Action <FsmOutput> addOutput) { var ret = FsmStateResponseType.Pass; if (_quickAccessTransition.ContainsKey(command.Type)) { var transition = _quickAccessTransition[command.Type]; ret = transition.TransferTest(command, addOutput); if (ret == FsmStateResponseType.Transfer || ret == FsmStateResponseType.Reenter) { if (transition.Duration <= 0) { TransitionCallback(transition.To, command, StateId.ToString(), addOutput); } else { _activeTransition = transition; _activeTransition.Init(command); } if (ret == FsmStateResponseType.Transfer) { ret = FsmStateResponseType.Pass; } } } return(ret); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.ChangeGrenadeDistance)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.NearThrowHash, AnimatorParametersHash.Instance.NearThrowName, command.AdditioanlValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } else if (command.IsMatch(FsmInput.FinishGrenade)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.ForceFinishThrowHash, AnimatorParametersHash.Instance.ForceFinishThrowName, AnimatorParametersHash.Instance.ForceFinishThrowDisable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.StartThrowHash, AnimatorParametersHash.Instance.StartThrowName, AnimatorParametersHash.Instance.StartThrowDisable, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); command.Handled = true; } else if (command.IsMatch(FsmInput.ThrowEndProgressP3)) { LerpUpperBodyLayerWeight(command, addOutput, SingletonManager.Get <CharacterStateConfigManager>().LongLayerWeightTransitionTime); } return(base.HandleInput(command, addOutput)); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.MeleeAttackProgressP3)) { LerpUpperBodyLayerWeight(command, addOutput, SingletonManager.Get <CharacterStateConfigManager>().MeleeLayerWeightTransitionTime); } if (command.IsMatch(FsmInput.LightMeleeAttackOne)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.MeleeStateHash, AnimatorParametersHash.Instance.MeleeAttackName, AnimatorParametersHash.Instance.LightMeleeOne, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); TurnOnUpperBodyOverlay(addOutput); } else if (command.IsMatch(FsmInput.LightMeleeAttackTwo)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.MeleeStateHash, AnimatorParametersHash.Instance.MeleeAttackName, AnimatorParametersHash.Instance.LightMeleeTwo, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); TurnOnUpperBodyOverlay(addOutput); } return(base.HandleInput(command, addOutput)); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.SpecialReloadTrigger)) { --_reloadCount; } if (_reloadCount <= 0 || command.IsMatch(FsmInput.BreakSpecialReload)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.ForceSpecialReloadEndHash, AnimatorParametersHash.Instance.ForceSpecialReloadEndName, AnimatorParametersHash.Instance.ForceSpecialReloadEndDisableValue, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.SpecialReloadHash, AnimatorParametersHash.Instance.SpecialReloadName, AnimatorParametersHash.Instance.SpecialReloadDisableValue, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); // 不单独区分FsmInput.BreakSpecialReload command.Handled = true; _reloadCount = int.MaxValue; } return(base.HandleInput(command, addOutput)); }
public virtual FsmTransitionResponseType InterruptTest(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (_interruptCondition != null) { return(_interruptCondition(command, addOutput)); } return(FsmTransitionResponseType.NoResponse); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.MeleeAttackProgressP3)) { LerpUpperBodyLayerWeight(command, addOutput, SingletonManager.Get <CharacterStateConfigManager>().LongLayerWeightTransitionTime); } return(base.HandleInput(command, addOutput)); }
public override void Init(IFsmInputCommand command) { base.Init(command); if (InitValue != 0) { NormalizedTime = 1 - InitValue; } }
public override void Init(IFsmInputCommand command) { base.Init(command); if (InitValue > 0) { NormalizedTime = 1 - command.AdditioanlValue; Logger.InfoFormat("Init normalizeTime:{0}", NormalizedTime); } }
private void Filter(IFsmInputCommand command) { FsmInput mappedType; if (SimpleMap.TryGetValue(command.Type, out mappedType)) { command.Type = mappedType; } }
public override FsmTransitionResponseType InterruptTest(IFsmInputCommand command, Action <FsmOutput> addOutput) { var ret = base.InterruptTest(command, addOutput); if (ret == FsmTransitionResponseType.ForceEnd) { command.AdditioanlValue = NormalizedTime; } return(ret); }
public static bool SimpleCommandHandler(IFsmInputCommand command, FsmInput type) { var ret = command.IsMatch(type); if (ret) { command.Handled = true; } return(ret); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.BigJump) && !isBigJump) { isBigJump = true; //FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerJumpHeight, _characterInfo.GetBigJumpHeight()); //addOutput(FsmOutput.Cache); } return(base.HandleInput(command, addOutput)); }
protected override void SetCurrentState(int id, IFsmInputCommand command, string msg, Action <FsmOutput> addOutput) { base.SetCurrentState(id, command, msg, addOutput); if (PostureStateId.JumpStart == (PostureStateId)CurrentState.StateId) { _jumpStart = true; } }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.FireHoldHash, AnimatorParametersHash.Instance.FireHoldName, AnimatorParametersHash.Instance.FireHoldEnableValue, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); }
private void MoveJumpTest(PlayerEntity playerEntity, IAdaptiveContainer <IFsmInputCommand> commandsContainer) { var state = playerEntity.stateInterface.State.GetNextPostureState(); var moveState = playerEntity.stateInterface.State.GetNextMovementState(); if (!((state == PostureInConfig.Land || state == PostureInConfig.Stand) && (moveState == MovementInConfig.Sprint || moveState == MovementInConfig.Run))) { return; } IFsmInputCommand jumpCommand = null; bool forthExist = false; bool leftExist = false; bool rightExist = false; for (int i = 0; i < commandsContainer.Length; i++) { var v = commandsContainer[i]; if (v.Type == FsmInput.Jump) { jumpCommand = v; } else if (v.Type == FsmInput.Forth) { forthExist = true; } else if (v.Type == FsmInput.Left) { leftExist = true; } else if (v.Type == FsmInput.Right) { rightExist = true; } } if (jumpCommand != null && forthExist && CheckJumpSpeed(playerEntity)) { jumpCommand.AdditioanlValue = AnimatorParametersHash.Instance.JumpStateMove; if (leftExist) { jumpCommand.AlternativeAdditionalValue = AnimatorParametersHash.Instance.MoveJumpStateLF; } else if (rightExist) { jumpCommand.AlternativeAdditionalValue = AnimatorParametersHash.Instance.MoveJumpStateRF; } else { jumpCommand.AlternativeAdditionalValue = AnimatorParametersHash.Instance.MoveJumpStateNormal; } } }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.Crouch) && !isBigJump) { isBigJump = true; FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerJumpHeight, SingletonManager.Get <CharacterStateConfigManager>().CharacterControllerJumpHeight); addOutput(FsmOutput.Cache); } return(base.HandleInput(command, addOutput)); }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); _reloadCount = (int)command.AdditioanlValue; // handled here is better than DoBeforeLeaving, consider reset FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.ForceSpecialReloadEndHash, AnimatorParametersHash.Instance.ForceSpecialReloadEndName, AnimatorParametersHash.Instance.ForceSpecialReloadEndDisableValue, CharacterView.FirstPerson | CharacterView.ThirdPerson, false); addOutput(FsmOutput.Cache); }
private bool Filter(IFsmInputCommand command) { FsmInput mappedType; if (SimpleMap.TryGetValue(command.Type, out mappedType)) { //Logger.InfoFormat("convert from:{0} to:{1}", command.Type, mappedType); command.Type = mappedType; return(true); } return(false); }
public static void LerpUpperBodyLayerWeight(IFsmInputCommand command, Action <FsmOutput> addOutput, float threshold) { float timeRemain = command.AlternativeAdditionalValue * (1 - command.AdditioanlValue); if (timeRemain <= threshold) { FsmOutput.Cache.SetLayerWeight(AnimatorParametersHash.Instance.UpperBodyLayer, Mathf.Lerp(AnimatorParametersHash.Instance.UpperBodyEnableValue, AnimatorParametersHash.Instance.UpperBodyDisableValue, (threshold - timeRemain) / threshold), CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); } }
private void SetCommandParam(IFsmInputCommand command, FsmInput type, float additionalValue = float.NaN, float alterAdditionalValue = float.NaN) { command.Type = type; if (!float.IsNaN(additionalValue)) { command.AdditioanlValue = additionalValue; } if (!float.IsNaN(alterAdditionalValue)) { command.AlternativeAdditionalValue = alterAdditionalValue; } }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); FsmOutput.Cache.SetValue(FsmOutputType.FirstPersonHeight, _height); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.FirstPersonForwardOffset, _forward); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerHeight, _controllerHeight.Invoke()); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerRadius, _controllerRadius.Invoke()); addOutput(FsmOutput.Cache); switch (_stateId) { case PostureStateId.Prone: { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.PostureHash, AnimatorParametersHash.Instance.PostureName, AnimatorParametersHash.Instance.ProneValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); break; } case PostureStateId.Crouch: { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.PostureHash, AnimatorParametersHash.Instance.PostureName, AnimatorParametersHash.Instance.CrouchValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); break; } case PostureStateId.Stand: { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.PostureHash, AnimatorParametersHash.Instance.PostureName, AnimatorParametersHash.Instance.StandValue, CharacterView.FirstPerson | CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); break; } } }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { if (command.IsMatch(FsmInput.LadderSpeed)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.LadderSpeedHash, AnimatorParametersHash.Instance.LadderSpeedName, command.AdditioanlValue, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } return(base.HandleInput(command, addOutput)); }
protected virtual void SetCurrentState(int id, IFsmInputCommand command, string msg, Action <FsmOutput> addOutput) { if (_states.ContainsKey(id)) { _currentState.DoBeforeLeaving(addOutput); _currentState = _states[id]; Logger.DebugFormat("{0}: Source: {1} Target: {2}", _name, msg, id); _currentState.DoBeforeEntering(command, addOutput); _currentStateChanged = true; } else { Logger.ErrorFormat("target state not exists: {0} in {1}", id, _name); } }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); FsmOutput.Cache.SetValue(FsmOutputType.FirstPersonHeight, _height); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.FirstPersonForwardOffset, _forward); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerHeight, _controllerHeight); addOutput(FsmOutput.Cache); FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerRadius, _controllerRadius); addOutput(FsmOutput.Cache); }
public override FsmStateResponseType HandleInput(IFsmInputCommand command, Action <FsmOutput> addOutput) { float seatId = command.AdditioanlValue % 10; if (command.IsMatch(FsmInput.DriveStart)) { FsmOutput.Cache.SetValue(AnimatorParametersHash.Instance.VehiclesAnimStateHash, AnimatorParametersHash.Instance.VehiclesAnimStateName, seatId, CharacterView.ThirdPerson); addOutput(FsmOutput.Cache); command.Handled = true; } return(base.HandleInput(command, addOutput)); }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { FsmOutput.Cache.SetValue(FsmOutputType.CharacterControllerJumpHeight, SingletonManager.Get <CharacterStateConfigManager>().GetCharacterControllerCapsule(PostureInConfig.Stand).Height); addOutput(FsmOutput.Cache); base.DoBeforeEntering(command, addOutput); }
public override void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { base.DoBeforeEntering(command, addOutput); }