Exemple #1
0
            public void Reset()
            {
                _graph    = null;
                _nextNode = new NodeFrame();

#if UNITY_EDITOR
                _callstack.Clear();
#endif
            }
Exemple #2
0
 private IEnumerator ProcessFrame(NodeFrame frame)
 {
     if (IsImmediate(frame.Node))
     {
         RunEnumerator(frame.Node, frame.Node.Run(this, _rootStore, frame.Iteration));
     }
     else
     {
         yield return(frame.Node.Run(this, _rootStore, frame.Iteration));
     }
 }
Exemple #3
0
        private NodeFrame SetupFrame(NodeFrame node)
        {
            if (node.Node == null)
            {
                // the current frame should never continue if there is no next

                if (_callstack.Count > 0)
                {
                    _callstack.Pop();
                }

                // check if there is a sequence or loop node in the call stack to iterate

                while (_callstack.Count > 0)
                {
                    var frame = _callstack.Pop();

                    if (frame.Type != NodeType.Normal)
                    {
                        return new NodeFrame {
                                   Type = frame.Type, Iteration = frame.Iteration + 1, Node = frame.Node, Source = frame.Source, This = frame.This
                        }
                    }
                    ;
                }
            }
            else if (IsNodeInStack(node.Node))
            {
                // the node is already in the call stack, so retreat to the existing entry rather than adding a new one
                // and re-use its original variables - any loop or sequence nodes on the way are bypassed which is
                // probably the intended behavior

                while (_callstack.Count > 0)
                {
                    var frame = _callstack.Pop();

                    if (frame.Node == node.Node)
                    {
                        return new NodeFrame {
                                   Type = frame.Type, Iteration = frame.Iteration + 1, Node = frame.Node, Source = frame.Source, This = frame.This
                        }
                    }
                    ;
                }
            }

            return(node);
        }
Exemple #4
0
        private IEnumerator ProcessFrame(NodeFrame frame)
        {
            if (frame.Node.IsBreakpoint && IsDebugBreakEnabled)
            {
                DebugState = PlaybackState.Paused;
                OnBreakpointHit?.Invoke(this, frame.Node);
            }

            if (DebugState == PlaybackState.Paused && IsDebugLoggingEnabled)
            {
                Debug.LogFormat(this, "(Frame {0}) Instruction Graph {1}: pausing at node '{2}'", Time.frameCount, name, frame.Node.Name);
            }

            while (DebugState == PlaybackState.Paused)
            {
                yield return(null);
            }

            if (DebugState == PlaybackState.Stopped)
            {
                yield break;
            }

            if (IsDebugLoggingEnabled)
            {
                if (frame.Iteration > 0)
                {
                    Debug.LogFormat(this, "(Frame {0}) Instruction Graph {1}: running iteration {2} of node '{3}' ", Time.frameCount, name, frame.Iteration + 1, frame.Node.Name);
                }
                else
                {
                    Debug.LogFormat(this, "(Frame {0}) Instruction Graph {1}: following '{2}' to node '{3}'", Time.frameCount, name, frame.Source, frame.Node.Name);
                }
            }

            yield return(frame.Node.Run(this, _rootStore, frame.Iteration));

            if (DebugState == PlaybackState.Step)
            {
                DebugState = PlaybackState.Paused;
            }
        }
 private IEnumerator ProcessFrame(NodeFrame frame)
 {
     yield return(frame.Node.Run(this, _rootStore, frame.Iteration));
 }