public void Execute() { // iterate nodes Debug.Log("Execute!"); if (entryPoint == null) { Debug.LogError($"<b>[{name}]</b> No EntryPoint node found", this); return; } ExecData data = new ExecData(); // Execute through the graph until we run out of nodes to execute ICanExec next = entryPoint; int sanityCheck = 0; while (next != null) { next = next.Execute(data); // Just in case :) sanityCheck++; if (sanityCheck > 2000) { Debug.LogError("Potential infinite loop detected. Stopping early.", this); break; } } }
public override ICanExec Execute(ExecData data) { int count = GetInputValue("Count", this.count); // Execution does not leave this node until the loop completes. // Not sure if I like this idea, but it's the simplest version. // This implies we repeat the code from ExecGraph.Execute though for (m_currentCount = 0; m_currentCount < count; m_currentCount++) { ICanExec next = GetNextExec(); while (next != null) { next = next.Execute(data); } } return(GetNextExec("Then")); }
public void Compile(CodeBuilder builder) { // For an EntryPoint with inputs from the host, they'd be added here. builder.AppendLine("public static void Run()"); builder.BeginScope(); ICanExec next = GetNextExec(); if (next is ICanCompile node) { node.Compile(builder); } else { builder.AppendLine($"// Not ICanCompile {(next as AbstractNode).name}"); } builder.EndScope(); }