示例#1
0
        public void Update()
        {
            foreach (var edge in Edges) {
                if (currentState != null && edge.Condition(currentState)) {
                    TransitionTo(edge.State);
                    if (edge.Callback != null) {
                        edge.Callback(edge.State);
                    }
                }
            }

            if (nextState != null && currentState != null) {
                if (currentState.OnExit == null || currentState.OnExit(currentState)) {
                    currentState = null;
                }
            }
            else if (nextState != null && currentState == null) {
                if (nextState.OnEnter == null || nextState.OnEnter(nextState)) {
                    currentState = nextState;
                    nextState = null;
                }
            }
            else if (currentState != null) {
                if (currentState.OnUpdate(currentState)) {
                    exitNextTick = true;
                }
            }
        }
示例#2
0
 public void TransitionTo(PicoFSM.State next)
 {
     if (next != null && next != nextState)
     {
         nextState = next;
     }
 }
示例#3
0
 public void TransitionTo(PicoFSM.State next)
 {
     if (next != null && next != nextState) {
         nextState = next;
     }
 }
示例#4
0
 public Machine TransitionToWhenThen(PicoFSM.State state, Func <PicoFSM.State, bool> condition, Action <PicoFSM.State> callback)
 {
     Edges.Add(new Edge(state, condition, callback));
     return(this);
 }
示例#5
0
 public Machine TransitionToWhen(PicoFSM.State state, Func <PicoFSM.State, bool> condition)
 {
     Edges.Add(new Edge(state, condition, null));
     return(this);
 }