Fix xml dialogue loading and changed parameter name

This commit is contained in:
Nick J. Connors 2022-02-04 14:57:27 -05:00
parent 0d915bcffc
commit 77131b9aca
5 changed files with 15 additions and 14 deletions

View File

@ -8,7 +8,7 @@
"position":{"x": -0.3071011, "y": 2.741472, "z": -4.005298}, "position":{"x": -0.3071011, "y": 2.741472, "z": -4.005298},
"radius":1, "radius":1,
"xmlFile":"AssetBundle/WarpDriveDialogue.xml", "xmlFile":"AssetBundle/WarpDriveDialogue.xml",
"remoteVolumePosition": {"x": -0.05656214, "y": 0.5362684, "z": 0.5467669} "remoteTriggerPosition": {"x": -0.05656214, "y": 0.5362684, "z": 0.5467669}
} }
] ]
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.External; using NewHorizons.External;
using OWML.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,10 +13,10 @@ namespace NewHorizons.Builder.Props
{ {
public static class DialogueBuilder public static class DialogueBuilder
{ {
public static void Make(GameObject go, Sector sector, PropModule.DialogueInfo info) public static void Make(GameObject go, Sector sector, PropModule.DialogueInfo info, IModHelper mod)
{ {
var dialogue = MakeConversationZone(go, sector, info); var dialogue = MakeConversationZone(go, sector, info, mod);
if (info.remoteVolumePosition != null) MakeRemoteDialogueTrigger(go, sector, info, dialogue); if (info.remoteTriggerPosition != null) MakeRemoteDialogueTrigger(go, sector, info, dialogue);
} }
public static void MakeRemoteDialogueTrigger(GameObject go, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) public static void MakeRemoteDialogueTrigger(GameObject go, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue)
@ -44,11 +45,11 @@ namespace NewHorizons.Builder.Props
boxCollider.size = Vector3.one * info.radius / 2f; boxCollider.size = Vector3.one * info.radius / 2f;
conversationTrigger.transform.parent = sector?.transform ?? go.transform; conversationTrigger.transform.parent = sector?.transform ?? go.transform;
conversationTrigger.transform.localPosition = info.remoteVolumePosition; conversationTrigger.transform.localPosition = info.remoteTriggerPosition;
conversationTrigger.SetActive(true); conversationTrigger.SetActive(true);
} }
public static CharacterDialogueTree MakeConversationZone(GameObject go, Sector sector, PropModule.DialogueInfo info) public static CharacterDialogueTree MakeConversationZone(GameObject go, Sector sector, PropModule.DialogueInfo info, IModHelper mod)
{ {
GameObject conversationZone = new GameObject("ConversationZone"); GameObject conversationZone = new GameObject("ConversationZone");
conversationZone.SetActive(false); conversationZone.SetActive(false);
@ -64,7 +65,7 @@ namespace NewHorizons.Builder.Props
var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>(); var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>();
var xml = System.IO.File.ReadAllText(Main.Instance.ModHelper.Manifest.ModFolderPath + info.xmlFile); var xml = System.IO.File.ReadAllText(mod.Manifest.ModFolderPath + info.xmlFile);
var text = new TextAsset(xml); var text = new TextAsset(xml);
dialogueTree.SetTextXml(text); dialogueTree.SetTextXml(text);

View File

@ -15,17 +15,17 @@ namespace NewHorizons.Builder.Props
{ {
public static class PropBuildManager public static class PropBuildManager
{ {
public static void Make(GameObject go, Sector sector, IPlanetConfig config, IModAssets assets, string uniqueModName) public static void Make(GameObject go, Sector sector, IPlanetConfig config, IModHelper mod, string uniqueModName)
{ {
if (config.Props.Scatter != null) if (config.Props.Scatter != null)
{ {
ScatterBuilder.Make(go, sector, config, assets, uniqueModName); ScatterBuilder.Make(go, sector, config, mod.Assets, uniqueModName);
} }
if(config.Props.Details != null) if(config.Props.Details != null)
{ {
foreach (var detail in config.Props.Details) foreach (var detail in config.Props.Details)
{ {
DetailBuilder.Make(go, sector, config, assets, uniqueModName, detail); DetailBuilder.Make(go, sector, config, mod.Assets, uniqueModName, detail);
} }
} }
if(config.Props.Geysers != null) if(config.Props.Geysers != null)
@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Props
{ {
foreach(var dialogueInfo in config.Props.Dialogue) foreach(var dialogueInfo in config.Props.Dialogue)
{ {
DialogueBuilder.Make(go, sector, dialogueInfo); DialogueBuilder.Make(go, sector, dialogueInfo, mod);
} }
} }
} }

View File

@ -62,9 +62,9 @@ namespace NewHorizons.External
public class DialogueInfo public class DialogueInfo
{ {
public MVector3 position; public MVector3 position;
public float radius; public float radius = 1f;
public string xmlFile; public string xmlFile;
public MVector3 remoteVolumePosition; public MVector3 remoteTriggerPosition;
public string persistentCondition; public string persistentCondition;
} }
} }

View File

@ -591,7 +591,7 @@ namespace NewHorizons
} }
if (body.Config.Props != null) if (body.Config.Props != null)
PropBuildManager.Make(go, sector, body.Config, body.Mod.Assets, body.Mod.Manifest.UniqueName); PropBuildManager.Make(go, sector, body.Config, body.Mod, body.Mod.Manifest.UniqueName);
if (body.Config.Signal != null) if (body.Config.Signal != null)
SignalBuilder.Make(go, sector, body.Config.Signal, body.Mod); SignalBuilder.Make(go, sector, body.Config.Signal, body.Mod);