public void SaveGraph() { if (CurrentGraph == null || CurrentGraphNodes == null) { return; } foreach (KeyValuePair <System.Guid, NodeDescription> node in CurrentGraphNodes) { node.Value.PreSave(); } VScriptEngine.SaveOpenGraphs(); }
static void Main(string[] args) { VSLogger.std_print = Print; VSLogger.debug_print = Print; VSLogger.error_print = Print; VScriptEngine.input_function = delegate() { return(Encoding.ASCII.GetBytes("Test")); }; VScriptEngine.engine_directory = "../../VScript/"; VScriptEngine.Init(); Graph graph = VScriptEngine.NewGraph("Temp"); //Graph graph = VScriptEngine.OpenGraph("Infinite Loop"); /* * graph.Clear(); * graph.AddNode(0, 1); * * GraphNode const_msg = graph.AddNode(0, 2); * const_msg.meta_data.Put("value", "\"Hard coded msg\""); * * GraphNode true_node = graph.AddNode(1, 5); * GraphNode false_node = graph.AddNode(1, 6); * GraphNode print_true = graph.AddNode(1, 3); * GraphNode print_false = graph.AddNode(1, 3); * GraphNode print_msg = graph.AddNode(1, 3); * * graph.AddConnection(true_node, "end", print_true, "message"); * graph.AddConnection(false_node, "end", print_false, "message"); * graph.AddConnection(const_msg, "end", print_msg, "message"); * * * graph.AddConnection(graph.start_node, "end", print_true, "begin"); * graph.AddConnection(print_true, "end", print_false, "begin"); * graph.AddConnection(print_false, "end", print_msg, "begin"); */ //graph.AddConnection(if_then, "true", print_true, "begin"); //graph.AddConnection(if_then, "false", print_false, "begin"); VScriptEngine.CompileAndRun(graph); VSLogger.Log("Done"); Console.ReadLine(); }
void Start() { if (main != null) { return; } else { main = this; } GraphSheild.SetActive(true); VSLogger.stamp_time = false; VSLogger.std_print = StdPrint; VSLogger.debug_print = DebugPrint; VSLogger.error_print = ErrorPrint; VScriptEngine.engine_directory = "VScript/"; VScriptEngine.input_function = ConsoleInput.ReadInput; VScriptEngine.Init(); }
public void OpenGraph(string name) { if (CurrentGraph != null) { CloseGraph(); } if (CurrentGraphNodes == null) { CurrentGraphNodes = new Dictionary <System.Guid, NodeDescription>(); } CurrentGraph = VScriptEngine.OpenGraph(name); if (CurrentGraph == null) { return; } Vector2 desired_position = new Vector2(); //Create all the nodes foreach (KeyValuePair <System.Guid, GraphNode> pair in CurrentGraph.nodes) { NodeDescription new_node = Instantiate(NodeObject); new_node.SetReferenceNode(pair.Value); CurrentGraphNodes.Add(pair.Key, new_node); //If start node if (pair.Value.module_id == 0 && pair.Value.node_id == 1) { desired_position = new_node.transform.position; } } GraphSheild.SetActive(false); Camera.main.transform.position = new Vector3(desired_position.x, desired_position.y - 2.0f, -8.26f); }
public void ExecuteGraph() { if (CurrentGraph == null) { return; } if (ExecutionThread != null) { ExecutionThread.Abort(); ExecutionThread = null; } ConsoleInput.ClearInput(); ExecutionThread = new Thread(new ThreadStart( delegate() { VScriptEngine.CompileAndRun(CurrentGraph); } )); ExecutionThread.Start(); }
public void CloseGraph() { if (CurrentGraph == null || CurrentGraphNodes == null) { return; } VScriptEngine.CloseGraph(CurrentGraph.display_name, false); foreach (KeyValuePair <System.Guid, NodeDescription> node in CurrentGraphNodes) { Destroy(node.Value.gameObject); } CurrentGraphNodes.Clear(); if (ExecutionThread != null) { ExecutionThread.Abort(); ExecutionThread = null; } GraphSheild.SetActive(true); CurrentGraph = null; }
public void NewGraph(string name) { Graph graph = VScriptEngine.NewGraph(name); OpenGraph(name); }