Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 protected void AddTransition(FsmTransition transition, FsmInput[] keys)
 {
     foreach (var key in keys)
     {
         _quickAccessTransition.Add(key, transition);
     }
     _transitions.Add(transition);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public void SetStateSnapshot(FsmSnapshot snapshot)
 {
     ElapsedTime = snapshot.StateProgress;
     if (snapshot.TransitoinId != -1)
     {
         _activeTransition = _transitions[snapshot.TransitoinId];
         _activeTransition.NormalizedTime = snapshot.TransitionProgress;
     }
     else
     {
         _activeTransition = null;
     }
 }
Exemplo n.º 5
0
 public virtual void DoBeforeEntering(IFsmInputCommand command, Action <FsmOutput> addOutput)
 {
     _activeTransition = null;
     ElapsedTime       = 0;
 }