Code: Select all
actor = new Actor(npcActorTemplate)
{
Name = characterData.FullName,
id = DialogueManager.MasterDatabase.actors.Count
};
var database = CreateInstance<DialogueDatabase>();
database.actors.Add(actor);
DialogueManager.AddDatabase(database);
When the game is saved and reloaded the save data is restored to the lua system properly. However, the actor data is lost when the actor is later added to the database using DialogueManager.AddDatabase during generation. As far as I can tell this is due to AddToTable called from AddChatMapperVariables because it is replacing the actor's fields table with the fields on the actor being added (empty/template).
I'm adding the actors to the database with AddDatabase so their lua data isn't lost in the future when Quest Engine calls AddDatabase to add generated dialogue for actors.
Is there any way to ensure the lua data is preserved when we generate the actor? I thought about getting the Actor table when OnApplyPersistentData is called but I couldn't figure out how to convert the actors in the Actor table to database actors.
Any direction on the best way to go about this is highly appreciated!