private int FindActorIdFromArticyDialogue(ArticyData.Dialogue articyDialogue, int index) { Actor actor = null; if (index < articyDialogue.references.Count) { actor = FindActorByArticyId(articyDialogue.references[index]); } return((actor != null) ? actor.id : 0); }
/// <summary> /// Creates a new Dialogue System conversation from an articy dialogue. This also adds the /// conversation's mandatory first dialogue entry, "START". /// </summary> /// <returns> /// The new conversation. /// </returns> /// <param name='articyDialogue'> /// Articy dialogue. /// </param> private Conversation CreateNewConversation(ArticyData.Dialogue articyDialogue) { if (articyDialogue != null) { conversationID++; Conversation conversation = template.CreateConversation(conversationID, articyDialogue.displayName.DefaultText); Field.SetValue(conversation.fields, ArticyIdFieldTitle, articyDialogue.id, FieldType.Text); Field.SetValue(conversation.fields, "Description", articyDialogue.text.DefaultText, FieldType.Text); conversation.ActorID = FindActorIdFromArticyDialogue(articyDialogue, 0); conversation.ConversantID = FindActorIdFromArticyDialogue(articyDialogue, 1); DialogueEntry startEntry = template.CreateDialogueEntry(StartEntryID, conversationID, "START"); Field.SetValue(startEntry.fields, ArticyIdFieldTitle, articyDialogue.id, FieldType.Text); ConvertPins(startEntry, articyDialogue.pins); startEntry.outgoingLinks = new List <Link>(); Field.SetValue(startEntry.fields, "Sequence", "None()", FieldType.Text); conversation.dialogueEntries.Add(startEntry); database.conversations.Add(conversation); return(conversation); } else { return(null); } }