Fix parenting issue, add more dialogue verbose logs

This commit is contained in:
Nick 2023-03-26 13:47:04 -04:00
parent 41eb8438eb
commit a81f1e986a
3 changed files with 17 additions and 4 deletions

View File

@ -170,6 +170,8 @@ namespace NewHorizons.Builder.Props
if (detail.removeComponents) if (detail.removeComponents)
{ {
NHLogger.LogVerbose($"Removing all components from [{prop.name}]");
// Just swap all the children to a new game object // Just swap all the children to a new game object
var newDetailGO = new GameObject(prop.name); var newDetailGO = new GameObject(prop.name);
newDetailGO.transform.position = prop.transform.position; newDetailGO.transform.position = prop.transform.position;
@ -185,7 +187,8 @@ namespace NewHorizons.Builder.Props
{ {
child.parent = newDetailGO.transform; child.parent = newDetailGO.transform;
} }
GameObject.Destroy(prop); // Have to destroy it right away, else parented props might get attached to the old one
GameObject.DestroyImmediate(prop);
prop = newDetailGO; prop = newDetailGO;
} }

View File

@ -16,9 +16,15 @@ namespace NewHorizons.Builder.Props
// Returns the character dialogue tree and remote dialogue trigger, if applicable. // Returns the character dialogue tree and remote dialogue trigger, if applicable.
public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, DialogueInfo info, IModBehaviour mod) public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, DialogueInfo info, IModBehaviour mod)
{ {
NHLogger.LogVerbose($"[DIALOGUE] Created a new character dialogue [{info.rename}] on [{info.parentPath}]");
// In stock I think they disable dialogue stuff with conditions // In stock I think they disable dialogue stuff with conditions
// Here we just don't make it at all // Here we just don't make it at all
if (info.blockAfterPersistentCondition != null && PlayerData.GetPersistentCondition(info.blockAfterPersistentCondition)) return (null, null); if (!string.IsNullOrEmpty(info.blockAfterPersistentCondition) && PlayerData.GetPersistentCondition(info.blockAfterPersistentCondition))
{
NHLogger.LogVerbose($"[DIALOGUE] Persistent condition [{info.blockAfterPersistentCondition}] was met for [{info.rename}], aborting");
return (null, null);
}
var dialogue = MakeConversationZone(go, sector, info, mod.ModHelper); var dialogue = MakeConversationZone(go, sector, info, mod.ModHelper);

View File

@ -106,11 +106,15 @@ namespace NewHorizons.Builder.Props
{ {
try try
{ {
DialogueBuilder.Make(go, sector, dialogueInfo, mod); var (dialogue, trigger) = DialogueBuilder.Make(go, sector, dialogueInfo, mod);
if (dialogue == null)
{
NHLogger.LogVerbose($"[DIALOGUE] Failed to create dialogue [{dialogueInfo.xmlFile}]");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
NHLogger.LogError($"Couldn't make dialogue [{dialogueInfo.xmlFile}] for [{go.name}]:\n{ex}"); NHLogger.LogError($"[DIALOGUE] Couldn't make dialogue [{dialogueInfo.xmlFile}] for [{go.name}]:\n{ex}");
} }
} }
} }