Fix dialogue reuse thing not including dialogue added by other mods

This commit is contained in:
Nick 2024-04-30 18:00:07 -04:00
parent 037d3e02f5
commit 5392a1f3b5
2 changed files with 29 additions and 5 deletions

View File

@ -130,8 +130,6 @@ namespace NewHorizons.Builder.Props
var characterName = existingDialogueTree.SelectSingleNode("NameField").InnerText;
AddTranslation(additionalDialogueDoc.GetChildNode("DialogueTree"), characterName);
DoDialogueOptionsListReplacement(existingDialogueTree);
var newTextAsset = new TextAsset(existingDialogueDoc.OuterXml)
{
name = existingDialogue._xmlCharacterDialogueAsset.name
@ -139,9 +137,32 @@ namespace NewHorizons.Builder.Props
existingDialogue.SetTextXml(newTextAsset);
FixDialogueNextFrame(existingDialogue);
return existingDialogue;
}
private static void FixDialogueNextFrame(CharacterDialogueTree characterDialogueTree)
{
Delay.FireOnNextUpdate(() =>
{
var rawText = characterDialogueTree._xmlCharacterDialogueAsset.text;
var doc = new XmlDocument();
doc.LoadXml(rawText);
var dialogueTree = doc.DocumentElement.SelectSingleNode("//DialogueTree");
DoDialogueOptionsListReplacement(dialogueTree);
var newTextAsset = new TextAsset(doc.OuterXml)
{
name = characterDialogueTree._xmlCharacterDialogueAsset.name
};
characterDialogueTree.SetTextXml(newTextAsset);
});
}
/// <summary>
/// Always call this after adding translations, else it won't update them properly
/// </summary>
@ -253,7 +274,7 @@ namespace NewHorizons.Builder.Props
dialogueDoc.LoadXml(xml);
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
AddTranslation(xmlNode);
DoDialogueOptionsListReplacement(xmlNode);
xml = xmlNode.OuterXml;
var text = new TextAsset(xml)
@ -282,6 +303,8 @@ namespace NewHorizons.Builder.Props
conversationZone.SetActive(true);
FixDialogueNextFrame(dialogueTree);
return dialogueTree;
}
@ -499,12 +522,13 @@ namespace NewHorizons.Builder.Props
dialogueDoc.LoadXml(text);
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
AddTranslation(xmlNode, null);
DoDialogueOptionsListReplacement(xmlNode);
var newTextAsset = new TextAsset(dialogueDoc.OuterXml)
{
name = dialogue._xmlCharacterDialogueAsset.name
};
dialogue.SetTextXml(newTextAsset);
FixDialogueNextFrame(dialogue);
}
}
}

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.20.1",
"version": "1.20.2",
"owmlVersion": "2.10.3",
"dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "PacificEngine.OW_CommonResources" ],