/// <summary>
 /// "Follows" a dialogue entry and returns its full conversation state. This method updates
 /// the Lua environment (marking the entry as visited). If includeLinks is <c>true</c>,
 /// it evaluates all links from the dialogue entry and records valid links in the state.
 /// </summary>
 /// <returns>The state.</returns>
 /// <param name="entry">The dialogue entry to "follow."</param>
 /// <param name="includeLinks">If set to <c>true</c> records all links from the dialogue entry whose conditions are true.</param>
 /// <param name="stopAtFirstValid">If set to <c>true</c> ,stops including at the first valid link.</param>
 /// <param name="skipExecution">IF set to <c>true</c>, doesn't run the Lua Script or OnExecute event.</param>
 public ConversationState GetState(DialogueEntry entry, bool includeLinks, bool stopAtFirstValid = false, bool skipExecution = false)
 {
     if (entry != null)
     {
         DialogueManager.instance.SendMessage(DialogueSystemMessages.OnPrepareConversationLine, entry, SendMessageOptions.DontRequireReceiver);
         DialogueLua.MarkDialogueEntryDisplayed(entry);
         Lua.Run("thisID = " + entry.id);
         SetDialogTable(entry.conversationID);
         if (!skipExecution)
         {
             Lua.Run(entry.userScript, DialogueDebug.logInfo, m_allowLuaExceptions);
             entry.onExecute.Invoke();
         }
         CharacterInfo        actorInfo       = GetCharacterInfo(entry.ActorID);
         CharacterInfo        listenerInfo    = GetCharacterInfo(entry.ConversantID);
         List <CharacterInfo> entryActorsInfo = GetEntryActorsInfo(entry);
         if (!skipExecution)
         {
             var sceneEvent      = DialogueSystemSceneEvents.GetDialogueEntrySceneEvent(entry.sceneEventGuid);
             var eventGameObject = (actorInfo.transform != null) ? actorInfo.transform.gameObject : DialogueManager.instance.gameObject;
             if (sceneEvent != null)
             {
                 sceneEvent.onExecute.Invoke(eventGameObject);
             }
         }
         FormattedText formattedText = FormattedText.Parse(entry.subtitleText, m_database.emphasisSettings);
         CheckSequenceField(entry);
         string          entrytag     = m_database.GetEntrytag(entry.conversationID, entry.id, m_entrytagFormat);
         Subtitle        subtitle     = new Subtitle(actorInfo, listenerInfo, entryActorsInfo, formattedText, entry.currentSequence, entry.currentResponseMenuSequence, entry, entrytag);
         List <Response> npcResponses = new List <Response>();
         List <Response> pcResponses  = new List <Response>();
         if (includeLinks)
         {
             if (forceLinkEntry != null)
             {
                 AddForcedLink(npcResponses, pcResponses);
             }
             else
             {
                 EvaluateLinks(entry, npcResponses, pcResponses, new List <DialogueEntry>(), stopAtFirstValid);
             }
         }
         return(new ConversationState(subtitle, npcResponses.ToArray(), pcResponses.ToArray(), entry.isGroup));
     }
     else
     {
         return(null);
     }
 }
 private void Awake()
 {
     m_sceneInstance = this;
 }
 static void InitStaticVariables()
 {
     m_sceneInstance = null;
 }