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); }
protected void AddTransition(FsmTransition transition, FsmInput[] keys) { foreach (var key in keys) { _quickAccessTransition.Add(key, transition); } _transitions.Add(transition); }
protected void AddTransition(Func <IFsmInputCommand, Action <FsmOutput>, FsmStateResponseType> transfer, Func <IFsmInputCommand, Action <FsmOutput>, FsmTransitionResponseType> interrupt, short target, Action <float, Action <FsmOutput> > update, int duration, FsmInput[] keys) { var transition = new FsmTransition(AvailableTransitionId(), transfer, interrupt, target, update, duration); AddTransition(transition, keys); }
public void SetStateSnapshot(FsmSnapshot snapshot) { ElapsedTime = snapshot.StateProgress; if (snapshot.TransitoinId != -1) { _activeTransition = _transitions[snapshot.TransitoinId]; _activeTransition.NormalizedTime = snapshot.TransitionProgress; } else { _activeTransition = null; } }
public virtual void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput) { _activeTransition = null; ElapsedTime = 0; }