/// <summary> /// Reads the OutgoingLinks section. Again, Link is not a subclass of Asset, /// so we can't reuse the ReadAssets() method. /// </summary> /// <param name="database">Dialogue database.</param> private void ReadOutgoingLinks(DialogueDatabase database, bool add) { Debug.Log((add ? "Reading" : "Skipping") + " OutgoingLinks section"); GetNextSourceLine(); // Headings GetNextSourceLine(); // Types // Keep reading until we reach another asset type heading or end of file: int safeguard = 0; while (!(IsSourceAtEnd() || AssetTypeHeadings.Contains(GetFirstField(PeekNextSourceLine())))) { safeguard++; if (safeguard > MaxIterations) { break; } string[] values = GetValues(GetNextSourceLine()); if (add) { var link = new Link(Tools.StringToInt(values[0]), Tools.StringToInt(values[1]), Tools.StringToInt(values[2]), Tools.StringToInt(values[3])); link.priority = ConditionPriorityTools.StringToConditionPriority(values[4]); var entry = database.GetDialogueEntry(link.originConversationID, link.originDialogueID); if (entry == null) { throw new InvalidDataException(string.Format("Dialogue entry {0}.{1} referenced in link not found", link.originConversationID, link.originDialogueID)); } entry.outgoingLinks.Add(link); } } }
/// <summary> /// Initializes a new DialogueEntry copied from a Chat Mapper DialogEntry. /// </summary> /// <param name='chatMapperDialogEntry'> /// The Chat Mapper dialog entry to copy. /// </param> public DialogueEntry(ChatMapper.DialogEntry chatMapperDialogEntry) { if (chatMapperDialogEntry != null) { id = chatMapperDialogEntry.ID; fields = Field.CreateListFromChatMapperFields(chatMapperDialogEntry.Fields); //--- Removed in Chat Mapper 1.7: conversationID = chatMapperDialogEntry.ConversationID; isRoot = chatMapperDialogEntry.IsRoot; isGroup = chatMapperDialogEntry.IsGroup; if (isGroup) { Sequence = "None()"; } nodeColor = chatMapperDialogEntry.NodeColor; delaySimStatus = chatMapperDialogEntry.DelaySimStatus; falseConditionAction = chatMapperDialogEntry.FalseCondtionAction; conditionPriority = ConditionPriorityTools.StringToConditionPriority(chatMapperDialogEntry.ConditionPriority); foreach (var chatMapperLink in chatMapperDialogEntry.OutgoingLinks) { outgoingLinks.Add(new Link(chatMapperLink)); } conditionsString = chatMapperDialogEntry.ConditionsString; userScript = chatMapperDialogEntry.UserScript; } }
/// <summary> /// Reads the DialogueEntries section. DialogueEntry is not a subclass of Asset, /// so we can't reuse the ReadAssets() code above. /// </summary> /// <param name="database">Dialogue database.</param> private void ReadDialogueEntries(DialogueDatabase database, bool add) { Debug.Log((add ? "Reading" : "Skipping") + " DialogueEntries section"); // Read field names and types: string[] fieldNames = GetValues(GetNextSourceLine()); string[] fieldTypes = GetValues(GetNextSourceLine()); // Keep reading until we reach another asset type heading or end of file: int safeguard = 0; while (!(IsSourceAtEnd() || AssetTypeHeadings.Contains(GetFirstField(PeekNextSourceLine())))) { safeguard++; if (safeguard > MaxIterations) { break; } string[] values = GetValues(GetNextSourceLine()); if (add) { // Create the dialogue entry: DialogueEntry entry = new DialogueEntry(); entry.fields = new List <Field>(); // We can ignore value[0] (entrytag). entry.conversationID = Tools.StringToInt(values[1]); entry.id = Tools.StringToInt(values[2]); entry.ActorID = Tools.StringToInt(values[3]); entry.ConversantID = Tools.StringToInt(values[4]); entry.Title = values[5]; entry.DefaultMenuText = values[6]; entry.DefaultDialogueText = values[7]; entry.isGroup = Tools.StringToBool(values[8]); entry.falseConditionAction = values[9]; entry.conditionPriority = ConditionPriorityTools.StringToConditionPriority(values[10]); entry.conditionsString = values[11]; entry.userScript = values[12]; // Read the remaining values and assign them to the asset's fields: ReadAssetFields(fieldNames, fieldTypes, DialogueEntrySpecialValues, values, entry.fields); // Convert canvasRect field to entry position on node editor canvas: entry.UseCanvasRectField(); // Finally, add the asset: var conversation = database.GetConversation(entry.conversationID); if (conversation == null) { throw new InvalidDataException(string.Format("Conversation {0} referenced in entry {1} not found", entry.conversationID, entry.id)); } conversation.dialogueEntries.Add(entry); } } }