[HOWTO] How To: "Conversation Ended" Quest Condition
Posted: Sun Nov 29, 2020 5:43 pm
This post contains a custom Quest Machine condition that becomes true when a Dialogue System conversation ends. You can use it if a quest needs to wait until a conversation is over. For example, you could add it as a condition to the "End Conversation" node in the quest below:
ConversationEndQuestCondition.cs
ConversationEndQuestCondition.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
namespace PixelCrushers.QuestMachine
{
/// <summary>
/// Condition that becomes true when the active conversation ends.
/// </summary>
public class ConversationEndQuestCondition : QuestCondition
{
public override string GetEditorName()
{
return "Dialogue System Conversation Has Ended";
}
public override void StartChecking(System.Action trueAction)
{
base.StartChecking(trueAction);
DialogueManager.instance.conversationEnded += OnConversationEnded;
}
public override void StopChecking()
{
base.StopChecking();
DialogueManager.instance.conversationEnded -= OnConversationEnded;
}
private void OnConversationEnded(Transform actor)
{
SetTrue();
}
}
}