QuestStateListeners does not update when loading Dialogue Database

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Fitbie
Posts: 46
Joined: Tue Dec 07, 2021 6:30 pm

QuestStateListeners does not update when loading Dialogue Database

Post by Fitbie »

Hey, Tony!
In my project I use QuestStateListener and QuestStateDispatcher (actually derived components from them, but it doesn't matter)

I also use saving and loading the Dialogue Database via PersistentDataManager.ApplySaveData/GetSaveData and passing to a third party API to store string representation of database.

However, I noticed: after loading the database, listeners are not notified that the quest has loaded from, for example, the default unnasigned state to the active state. Moreover - having tried the traditional approach with the SaveSystem component - the listeners did not get the update either. The db itself, quests state and track status are loaded completely fine.

I know that in my custom dispatcher I can subscribe to OnSaveDataApplied, but I would like to ask:
1) maybe I'm missing something or doing something wrong?
2) maybe in the load method I can call some kind of global update of the dialogue database so that quest listeners and other systems, if any, can be notified of the change in the state of the database?
Thanks!
Fitbie
Posts: 46
Joined: Tue Dec 07, 2021 6:30 pm

Re: QuestStateListeners does not update when loading Dialogue Database

Post by Fitbie »

UPD: I double-checked the Dispatcher code, and it causes all listeners to update when SaveSystem.OnSaveDataApplied.
However, neither when using PersistentDataManager, nor when adding a SaveSystem and calling LoadFromSlot()/ApplySavedGameData() - the OnSaveDataApplied event is not raised, which means the listeners are not updated.
Why does this happening? And additional question - can this event be reaised without SaveSystem, just PersistentDataManagerstatic methods?
Thanks!
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: QuestStateListeners does not update when loading Dialogue Database

Post by Tony Li »

Hi,

Not calling OnQuestStateChange() again is intentional. Imagine for example that you have an OnQuestStateChange() method that gives the player experience points whenever a quest state is changed to success. You'd want this method to run when the player actually completes the quest at runtime. But you don't want it to run again when reloading a saved game.

In version 2.2.53, I'll make QuestStateDispatcher.UpdateListeners() public so you can call it after using PersistentDataManager.ApplySavedGameData().
Post Reply