/// <summary>
 /// Stops the current conversation immediately, and sends an OnConversationEnd message to 
 /// the actor and conversant. Your scripts can listen for OnConversationEnd to do anything
 /// necessary at the end of a conversation, such as resuming other gameplay or re-enabling
 /// player control.
 /// </summary>
 public void StopConversation()
 {
     if (conversationController != null) {
         conversationController.Close();
         conversationController = null;
     }
 }
 /// <summary>
 /// Preloads the resources used by the Dialogue System to avoid delays caused by lazy loading.
 /// </summary>
 public void PreloadResources()
 {
     PreloadMasterDatabase();
     PreloadDialogueUI();
     var originalDebugLevel = DialogueDebug.Level;
     try {
         DialogueDebug.Level = DialogueDebug.DebugLevel.None;
         PlaySequence("None()");
         if (databaseManager.MasterDatabase == null || databaseManager.MasterDatabase.conversations == null ||
             databaseManager.MasterDatabase.conversations.Count < 1) return;
         ConversationModel model = new ConversationModel(databaseManager.MasterDatabase, databaseManager.MasterDatabase.conversations[0].Title, null, null, AllowLuaExceptions, IsDialogueEntryValid);
         ConversationView view = this.gameObject.AddComponent<ConversationView>();
         view.Initialize(DialogueUI, GetNewSequencer(), displaySettings, OnDialogueEntrySpoken);
         view.SetPCPortrait(model.GetPCTexture(), model.GetPCName());
         conversationController = new ConversationController(model, view, displaySettings.inputSettings.alwaysForceResponseMenu, OnEndConversation);
         conversationController.Close();
     } finally {
         DialogueDebug.Level = originalDebugLevel;
     }
 }
 /// <summary>
 /// Starts a conversation, which also broadcasts an OnConversationStart message to the 
 /// actor and conversant. Your scripts can listen for OnConversationStart to do anything
 /// necessary at the beginning of a conversation, such as pausing other gameplay or 
 /// temporarily disabling player control. See the Feature Demo scene, which uses the
 /// SetEnabledOnDialogueEvent component to disable player control during conversations.
 /// </summary>
 /// <param name='title'>
 /// The title of the conversation to look up in the master database.
 /// </param>
 /// <param name='actor'>
 /// The transform of the actor (primary participant). The sequencer uses this to direct 
 /// camera angles and perform other actions. In PC-NPC conversations, the actor is usually
 /// the PC.
 /// </param>
 /// <param name='conversant'>
 /// The transform of the conversant (the other participant). The sequencer uses this to 
 /// direct camera angles and perform other actions. In PC-NPC conversations, the conversant
 /// is usually the NPC.
 /// </param>
 /// <param name='initialDialogueEntryID'> 
 /// The initial dialogue entry ID, or -1 to start from the beginning.
 /// </param>
 /// <example>
 /// Example:
 /// <code>StartConversation("Shopkeeper Conversation", player, shopkeeper, 8);</code>
 /// </example>
 public void StartConversation(string title, Transform actor, Transform conversant, int initialDialogueEntryID)
 {
     if (!IsConversationActive) {
         if (DialogueUI != null) {
             if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Starting conversation '{1}', actor={2}, conversant={3}.", new System.Object[] { DialogueDebug.Prefix, title, actor, conversant }));
             if (WarnIfActorAndConversantSame && (actor != null) && (actor == conversant)) {
                 if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Actor and conversant are the same GameObject.", new System.Object[] { DialogueDebug.Prefix }));
             }
             CheckDebugLevel();
             CurrentActor = actor;
             CurrentConversant = conversant;
             LastConversationStarted = title;
             SetConversationUI(conversant);
             ConversationModel model = new ConversationModel(databaseManager.MasterDatabase, title, actor, conversant, AllowLuaExceptions, IsDialogueEntryValid, initialDialogueEntryID);
             if (!model.HasValidEntry) return;
             ConversationView view = this.gameObject.AddComponent<ConversationView>();
             view.Initialize(DialogueUI, GetNewSequencer(), displaySettings, OnDialogueEntrySpoken);
             view.SetPCPortrait(model.GetPCTexture(), model.GetPCName());
             conversationController = new ConversationController(model, view, displaySettings.inputSettings.alwaysForceResponseMenu, OnEndConversation);
             var target = (actor != null) ? actor : this.transform;
             if (actor != this.transform) gameObject.BroadcastMessage("OnConversationStart", target, SendMessageOptions.DontRequireReceiver);
         } else {
             if (DialogueDebug.LogErrors) Debug.LogError(string.Format("{0}: No Dialogue UI is assigned. Can't start conversation '{1}'.", new System.Object[] { DialogueDebug.Prefix, title }));
         }
     } else {
             if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Another conversation is already active. Not starting '{1}'.", new System.Object[] { DialogueDebug.Prefix, title }));
     }
 }
 /// <summary>
 /// Handles the end conversation event.
 /// </summary>
 public void OnEndConversation()
 {
     if (conversationController != null) {
         //---Was: Transform actor = ((conversationController.ActorInfo != null) && (conversationController.ActorInfo.transform != null)) ? conversationController.ActorInfo.transform : this.transform;
         var target = ((conversationController.ActorInfo != null) && (conversationController.ActorInfo.transform != null)) ? conversationController.ActorInfo.transform : this.transform;
         gameObject.BroadcastMessage("OnConversationEnd", target, SendMessageOptions.DontRequireReceiver);
         conversationController = null;
     }
     RestoreOriginalUI();
     luaWatchers.NotifyObservers(LuaWatchFrequency.EndOfConversation);
     CheckAlerts();
     CurrentActor = null;
     CurrentConversant = null;
 }