diff --git a/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs b/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs index cdbf8ad..2727aef 100644 --- a/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs +++ b/TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs @@ -19,11 +19,12 @@ namespace TNodeCore.Components{ /// /// Map of node id to runtime node /// - + [NonSerialized] public readonly Dictionary RuntimeNodes = new Dictionary(); /// /// The graph tool the current runtime graph is using /// + [NonSerialized] private GraphTool _graphTool; /// /// Inner graph tool to help with graph operations @@ -35,6 +36,8 @@ namespace TNodeCore.Components{ /// [NonSerialized] public readonly List TopologicalOrder = new List(); + + public RuntimeGraph Parent; /// /// Entry nodes of the graph. These are the nodes that has no input. @@ -100,8 +103,7 @@ namespace TNodeCore.Components{ return; } runtimeNode.NodeData.Process(); - - + Parent.StartCoroutine(runtimeNode.NodeData.AfterProcess()); } /// /// Max depth of dependency traversal,in case of some special situation. the dependency level bigger than this number will be considered as a loop. @@ -133,8 +135,9 @@ namespace TNodeCore.Components{ /// List of nodes you need to traversal to build graph tool /// Map stores the mapping of node data id to runtime node - public GraphTool(List list, Dictionary graphNodes){ + public GraphTool(List list, Dictionary graphNodes,RuntimeGraph graph){ RuntimeNodes = graphNodes; + Parent = graph; if (list == null) return; Queue queue = new Queue(); Dictionary inDegreeCounterForTopologicalSort = new Dictionary(); @@ -195,7 +198,7 @@ namespace TNodeCore.Components{ } Debug.Log("hi"); var nodeList = RuntimeNodes.Values; - _graphTool = new GraphTool(nodeList.ToList(),RuntimeNodes); + _graphTool = new GraphTool(nodeList.ToList(),RuntimeNodes,this); var sceneNodes = RuntimeNodes.Values.Where(x => x.NodeData is SceneNodeData).Select(x => x.NodeData as SceneNodeData); foreach (var sceneNode in sceneNodes){ if (sceneNode != null) sceneNode.BlackboardData = runtimeBlackboardData; diff --git a/TNode/TNodeCore/Runtime/Models/NodeData.cs b/TNode/TNodeCore/Runtime/Models/NodeData.cs index 5701a69..08d9501 100644 --- a/TNode/TNodeCore/Runtime/Models/NodeData.cs +++ b/TNode/TNodeCore/Runtime/Models/NodeData.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using TNodeCore.Attribute; using UnityEngine; @@ -25,6 +26,10 @@ namespace TNodeCore.Models{ public virtual void Process(){ } + public virtual IEnumerator AfterProcess(){ + yield return null; + } + #if UNITY_EDITOR [HideInInspector] public bool isTest; diff --git a/TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs b/TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs index d00cfb9..9a12f9c 100644 --- a/TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs +++ b/TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs @@ -121,11 +121,9 @@ namespace TNodeCore.RuntimeCache{ //Check if the type is implementing IPortTypeConversion if(type.BaseType is{IsGenericType: true} && type.BaseType.GetGenericTypeDefinition()==typeof(PortTypeConversion<,>)){ //if it is, add it to the cache - Debug.Log("find conversion"); CacheRuntimePortTypeConversion(type); } else{ - Debug.Log(type); } } @@ -142,8 +140,6 @@ namespace TNodeCore.RuntimeCache{ var type1 = type.BaseType.GetGenericArguments()[0]; var type2 = type.BaseType.GetGenericArguments()[1]; - Debug.Log(type1); - Debug.Log(type2); var specificType = typeof(PortConverterHelper<,>).MakeGenericType(type1, type2); var instance = Activator.CreateInstance(specificType, type) as IPortConverterHelper; if (instance == null){ diff --git a/TNode/TNodeCore/Runtime/RuntimeNode.cs b/TNode/TNodeCore/Runtime/RuntimeNode.cs index 5a6bd1b..4003369 100644 --- a/TNode/TNodeCore/Runtime/RuntimeNode.cs +++ b/TNode/TNodeCore/Runtime/RuntimeNode.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Reflection; using Codice.Client.Common.TreeGrouper; @@ -29,11 +30,6 @@ namespace TNodeCore.Runtime{ _portAccessors[portName].SetValue(this.NodeData,value); } - - - - - } public object GetOutput(string portName){ @@ -42,7 +38,7 @@ namespace TNodeCore.Runtime{ private readonly Dictionary _portAccessors; - + public Action Process; public RuntimeNode(NodeData nodeData){ NodeData = nodeData; @@ -51,6 +47,8 @@ namespace TNodeCore.Runtime{ var info = nodeData.GetType().GetProperties(); _portAccessors = RuntimeCache.RuntimeCache.Instance.CachedPropertyAccessors[_type]; + + } public List GetInputNodesId(){ List dependencies = new List();