Merge pull request #30 from taoria/working-in-process

Working in process
main
taoria 3 years ago committed by GitHub
commit bec7b8540d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs
  2. 5
      TNode/TNodeCore/Runtime/Models/NodeData.cs
  3. 4
      TNode/TNodeCore/Runtime/RuntimeCache/RuntimeCache.cs
  4. 10
      TNode/TNodeCore/Runtime/RuntimeNode.cs

@ -19,11 +19,12 @@ namespace TNodeCore.Components{
/// <summary>
/// Map of node id to runtime node
/// </summary>
[NonSerialized]
public readonly Dictionary<string, RuntimeNode> RuntimeNodes = new Dictionary<string, RuntimeNode>();
///<summary>
/// The graph tool the current runtime graph is using
/// </summary>
[NonSerialized]
private GraphTool _graphTool;
/// <summary>
/// Inner graph tool to help with graph operations
@ -36,6 +37,8 @@ namespace TNodeCore.Components{
[NonSerialized]
public readonly List<RuntimeNode> TopologicalOrder = new List<RuntimeNode>();
public RuntimeGraph Parent;
/// <summary>
/// Entry nodes of the graph. These are the nodes that has no input.
/// </summary>
@ -100,8 +103,7 @@ namespace TNodeCore.Components{
return;
}
runtimeNode.NodeData.Process();
Parent.StartCoroutine(runtimeNode.NodeData.AfterProcess());
}
/// <summary>
/// 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{
/// <param name="list">List of nodes you need to traversal to build graph tool</param>
/// <param name="graphNodes">Map stores the mapping of node data id to runtime node</param>
public GraphTool(List<RuntimeNode> list, Dictionary<string, RuntimeNode> graphNodes){
public GraphTool(List<RuntimeNode> list, Dictionary<string, RuntimeNode> graphNodes,RuntimeGraph graph){
RuntimeNodes = graphNodes;
Parent = graph;
if (list == null) return;
Queue<RuntimeNode> queue = new Queue<RuntimeNode>();
Dictionary<string,int> inDegreeCounterForTopologicalSort = new Dictionary<string, int>();
@ -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;

@ -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;

@ -121,11 +121,9 @@ namespace TNodeCore.RuntimeCache{
//Check if the type is implementing IPortTypeConversion<T1,T2>
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){

@ -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<string, IModelPropertyAccessor> _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<string> GetInputNodesId(){
List<string> dependencies = new List<string>();

Loading…
Cancel
Save