Beispiel #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;
                }
            }
        }
Beispiel #2
0
 public void TransitionTo(PicoFSM.State next)
 {
     if (next != null && next != nextState)
     {
         nextState = next;
     }
 }
Beispiel #3
0
 public void TransitionTo(PicoFSM.State next)
 {
     if (next != null && next != nextState) {
         nextState = next;
     }
 }
Beispiel #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);
 }
Beispiel #5
0
 public Machine TransitionToWhen(PicoFSM.State state, Func <PicoFSM.State, bool> condition)
 {
     Edges.Add(new Edge(state, condition, null));
     return(this);
 }