diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 54eab78a..7f4d2d58 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -68,8 +68,6 @@ namespace NewHorizons.Builder.Props private static CharacterDialogueTree AddToExistingDialogue(DialogueInfo info, string xml) { - AddTranslation(xml); - var existingDialogue = SearchUtilities.Find(info.pathToExistingDialogue)?.GetComponent(); if (existingDialogue == null) @@ -125,6 +123,9 @@ namespace NewHorizons.Builder.Props existingDialogue.SetTextXml(newTextAsset); + var characterName = existingDialogueTree.SelectSingleNode("NameField").InnerText; + AddTranslation(xml, characterName); + return existingDialogue; } @@ -374,14 +375,20 @@ namespace NewHorizons.Builder.Props } } - private static void AddTranslation(string xml) + private static void AddTranslation(string xml, string characterName = null) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); var xmlNode = xmlDocument.SelectSingleNode("DialogueTree"); var xmlNodeList = xmlNode.SelectNodes("DialogueNode"); - string characterName = xmlNode.SelectSingleNode("NameField").InnerText; - TranslationHandler.AddDialogue(characterName); + + // When adding dialogue to existing stuff, we have to pass in the character name + // Otherwise we translate it if its from a new dialogue object + if (characterName == null) + { + characterName = xmlNode.SelectSingleNode("NameField").InnerText; + TranslationHandler.AddDialogue(characterName); + } foreach (object obj in xmlNodeList) {