public NodeMenuItem[] NodeContextMenuItems(Node node, NodeMachineModel model) { FunctionNode funcNode = node as FunctionNode; return(new NodeMenuItem[] { new NodeMenuItem("Edit name", () => { if (!funcNode.editingName) { funcNode.editingName = true; } else { FunctionNode func = model.GetFunction(funcNode.name); if (func != null && func != funcNode) { EditorUtility.DisplayDialog("Function exists!", "A function with that name already exists.", "OK"); return; } funcNode.editingName = false; model.UpdateFunctionCache(); } }, funcNode.editingName, false), new NodeMenuItem("Hide function group", () => { foreach (Node hide in funcNode.GetFunctionGroup()) { hide.visible = false; } }, false, false), new NodeMenuItem("Reveal function group", () => { foreach (Node hide in funcNode.GetFunctionGroup()) { hide.visible = true; } }, false, false), new NodeMenuItem("Remove function group", () => { if (EditorUtility.DisplayDialog("Remove function group", "Are you sure you want to remove all nodes in this function?", "Yes", "No")) { foreach (Node remove in funcNode.GetFunctionGroup()) { model.RemoveNode(remove); } } }, false, false) }); }
public override void OnRunStart(Machine machine, NodeFollower context) { if (followers == null) { followers = new Dictionary <NodeFollower, NodeFollower>(); } if (!followers.ContainsKey(context)) { FunctionNode funcNode = machine._model.GetFunction(function); if (funcNode != null) { followers.Add(context, new NodeFollower(machine, funcNode, context, continuous)); } else { Debug.LogError("Attempted to run non-existent function " + function + "!"); } } }
public override void OnEncountered(Node prevNode, Machine machine, NodeFollower context) { if (followers == null) { followers = new Dictionary <NodeFollower, NodeFollower>(); } if (!followers.ContainsKey(context)) { FunctionNode funcNode = machine._model.GetFunction(function); if (funcNode != null) { followers.Add(context, new NodeFollower(machine, funcNode, context, true)); } else { Debug.LogError("Attempted to run non-existent function " + function + "!"); } } if (followers[context].Active) { machine.UpdateCurrents(followers[context].Checkin()); } }
public override Node[] NextNodes() { FunctionNode funcNode = model.GetFunction(function); return(new Node[] { funcNode }); }