/// <summary>
        /// The constructor will only ever be called in editor.
        /// </summary>
        public NodeGraph()
        {
            NodeCollection = new NodeCollection();
            ANode entryNode = NodeCollection.CreateNode(typeof(EntryNode), Vector2.zero);

            NodeCollection.SetEntryNode(entryNode.Id);
            BlackboardProperties = new BlackboardProperties();
        }
示例#2
0
        public ANode CreateNode(Type type, Vector2 pos)
        {
            ANode node = Activator.CreateInstance(type) as ANode;

            node.Position = pos;
            AddNode(node);
            return(node);
        }
示例#3
0
        public void RemoveNode(string nodeId)
        {
            //TODO: MAKE THIS MORE EFFICIENT
            ANode node = m_nodes.Find(x => x.Id == nodeId);

            if (node != null)
            {
                m_nodes.Remove(node);
            }
        }
示例#4
0
        private void TraverseEdge(OutportEdge edge)
        {
            if (!m_currentNode.ContainsOutport(edge))
            {
                Debug.LogError("Ahhhh! Trying to traverse edge from non-current node.");
                return;
            }

            m_currentNode?.OnNodeExit(graphControls);

            if (edge == null)
            {
                StopGraph();
                return;
            }

            m_currentNode = m_nodeCollection.GetNodeById(edge.ConnectedNodeId);
            m_currentNode?.OnNodeEnter(graphControls);
        }
示例#5
0
 public void AddNode(ANode node)
 {
     //TODO: SORT BY GUID
     m_nodes.Add(node);
 }
示例#6
0
 public int GetNodeIndex(ANode node)
 {
     return(m_nodes.FindIndex(x => x == node));
 }
示例#7
0
 public void StartGraph()
 {
     OnGraphStart?.Invoke();
     m_currentNode = m_nodeCollection.GetEntryNode();
     m_currentNode?.OnNodeEnter(graphControls);
 }
示例#8
0
 /// <summary>
 /// Call this method from any of a node's methods to traverse a particular edge and enter another node.
 /// </summary>
 /// <param name="index"> The index of the edge (aka outport) we want to traverse. </param>
 /// <param name="node"> The current node. </param>
 public void TraverseEdge(int index, ANode node)
 {
     m_onTraverseEdge?.Invoke(node.GetOutportEdge(index));
 }