/// <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));
 }