Hello, again ,
I am trying to create a custom quest timer. After a lot of research the only solution that I was able to work with was AddLuaObserver(). As a general idea, I found it very difficult to trigger custom events depending on the ongoing dialogue line (subtitle). And I don't mind using the lua observer but I just don't think it would be a good ideea to have a lot of subscribers that need to check something every Update() and also having to keep track of the subscriptions (in case a lot of action is happening in one scene).
I would like to have a system where there is a Quest class that has attributes like OnFailed(), OnStart(), OnSuccess(), a variable isTimed and the QuestTimer class (which handles counting and displaying the timer)
A reference in the DialogueManager of the quest timer and every time a quest starts the DialogueManager should also start the timer (if the isTimed attribute of the quest is true).
So my question is is there a smarter alternative to do this? I would gladly try to implement what I've mentioned above but I'm afraid that future updates will not be compatible anymore (since I am editing the DialogueManager class)
Thanks
Custom timer & triggering events at dialogue lines
Re: Custom timer & triggering events at dialogue lines
Hi,
To get events when quest states change, you can use a Dialogue System Events component or hook into QuestLog.SetQuestStateOverride or write a script with an OnQuestStateChange method. Example:
To get events when quest states change, you can use a Dialogue System Events component or hook into QuestLog.SetQuestStateOverride or write a script with an OnQuestStateChange method. Example:
Code: Select all
void OnQuestStateChange(string quest)
{
switch (QuestLog.GetQuestState(quest))
{
case QuestState.Active:
Invoke("UpdateTimer", 1, 1); // Start timer
break;
case QuestState.Success:
case QuestState.Failure:
case QuestState.Abandoned:
CancelInvoke(); // Stop timer
break;
}
void UpdateTimer()
{
// Maybe update a Dialogue System variable or quest field with the time.
DialogueManager.SendUpdateTracker();
}
}