From b8966741718f1baa94a2d27adaa18107eb4a21ac Mon Sep 17 00:00:00 2001 From: Interkarma Date: Thu, 19 Oct 2023 08:52:11 +1000 Subject: [PATCH] Fix localized quest messages not restored on load Localized quest messages were not reimported when loading a game. This did not matter if quest was recently compiled as localizations were already memory resident. But once game was closed and restarted, localizations are lost. These are supposed to be available for entire lifetime of quest. Added a step to restore localized quest messages on load. --- .../UnityConsole/Console/Scripts/DefaultCommands.cs | 1 + Assets/Scripts/Game/Questing/Quest.cs | 3 +++ Assets/Scripts/Game/Questing/QuestMachine.cs | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/Assets/Game/Addons/UnityConsole/Console/Scripts/DefaultCommands.cs b/Assets/Game/Addons/UnityConsole/Console/Scripts/DefaultCommands.cs index 7b651dff8e..12f6b2b6c1 100644 --- a/Assets/Game/Addons/UnityConsole/Console/Scripts/DefaultCommands.cs +++ b/Assets/Game/Addons/UnityConsole/Console/Scripts/DefaultCommands.cs @@ -2274,6 +2274,7 @@ public static string Execute(params string[] args) if (quest != null) { QuestMachine.Instance.StartQuest(quest); + QuestMachine.Instance.RestoreLocalizedQuestMessages(quest.QuestName); return "Started quest '" + quest.DisplayName + "'"; } else diff --git a/Assets/Scripts/Game/Questing/Quest.cs b/Assets/Scripts/Game/Questing/Quest.cs index 1d12f2f7b9..ee532a3c6e 100644 --- a/Assets/Scripts/Game/Questing/Quest.cs +++ b/Assets/Scripts/Game/Questing/Quest.cs @@ -1007,6 +1007,9 @@ public void RestoreSaveData(QuestSaveData_v1 data) messages.Add(message.ID, message); } + // Restore localized messages + QuestMachine.Instance.RestoreLocalizedQuestMessages(questName); + // Restore resources resources.Clear(); foreach(QuestResource.ResourceSaveData_v1 resourceData in data.resources) diff --git a/Assets/Scripts/Game/Questing/QuestMachine.cs b/Assets/Scripts/Game/Questing/QuestMachine.cs index 04d34f1437..171dc5207b 100644 --- a/Assets/Scripts/Game/Questing/QuestMachine.cs +++ b/Assets/Scripts/Game/Questing/QuestMachine.cs @@ -686,6 +686,15 @@ public Quest ParseQuest(string questName, string[] questSource, int factionId = } } + /// + /// Localized quest messages need to be restored when game is loaded. + /// + /// Name of quest to restore localized messages. + public bool RestoreLocalizedQuestMessages(string questName) + { + return ParseLocalizedQuestText(questName); + } + /// /// Parse and start a quest from quest name. ///