// UTILITY protected static void DebugNodes(Yarn.Dialogue dialogue) { List <string> startNodes = dialogue.allNodes.ToList(); string debugLog = "Start Nodes\n"; foreach (string node in startNodes) { debugLog += '\t' + node + '\n'; IEnumerable <string> tags = dialogue.GetTagsForNode(node); foreach (var tag in tags) { debugLog += "\t\t" + tag + '\n'; } } DebugLog.Log(debugLog); }
/// <summary> /// Select a dialog tree based on the start nodes of the dialog database. /// /// You can also search the tags of the node by using `dialog.GetTagsFromNode(nodeName)` /// </summary> /// <param name="history">History of previous and current interactions</param> /// <param name="intention">Strategy intention of the interaction</param> /// <param name="startNodes">List of nodes to select from.</param> /// <returns>Dialog tree that contains information on which start node to begin from.</returns> protected virtual YarnDialogTree SelectDialogYarn(History history, Intention intention, List <string> startNodes) { var potencialNodes = new List <string>(); // Filter by name foreach (string node in startNodes) { var tags = Dialogue.GetTagsForNode(node); var tagsList = tags.ToList(); // TODO Remove to use Moodle if (tagsList.Contains("online")) { continue; } foreach (var tag in tagsList) { if (intention.Name.ToLower().Contains(tag.ToLower())) { // a node can be inserted several times, the more tags that match with the name the more it is inserted. potencialNodes.Add(node); } } } if (potencialNodes.Count == 0) { return(null); } // Shuffle list potencialNodes = potencialNodes.OrderBy(a => Guid.NewGuid()).ToList(); // pick first string n = potencialNodes[0]; return(new YarnDialogTree(Dialogue, n)); }