/// <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(); }
public ANode CreateNode(Type type, Vector2 pos) { ANode node = Activator.CreateInstance(type) as ANode; node.Position = pos; AddNode(node); return(node); }
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); } }
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); }
public void AddNode(ANode node) { //TODO: SORT BY GUID m_nodes.Add(node); }
public int GetNodeIndex(ANode node) { return(m_nodes.FindIndex(x => x == node)); }
public void StartGraph() { OnGraphStart?.Invoke(); m_currentNode = m_nodeCollection.GetEntryNode(); m_currentNode?.OnNodeEnter(graphControls); }
/// <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)); }