From fb0d9e30f6448c92ed0cba4ddad04f206c5df37f Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 18 Jan 2023 00:12:58 -0500 Subject: [PATCH] Get rid of enter conditions, just one prereq, clean up patch --- NewHorizons/Builder/Props/DialogueBuilder.cs | 6 ++++-- NewHorizons/External/Modules/PropModule.cs | 9 ++------- .../Patches/RemoteDialogueTriggerPatches.cs | 15 +++++++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index fc958d9c..b4d77f10 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -80,8 +80,10 @@ namespace NewHorizons.Builder.Props priority = 1, dialogue = dialogue, prereqConditionType = RemoteDialogueTrigger.MultiConditionType.AND, - prereqConditions = info.remoteTriggerPrereqConditions ?? new string[]{ }, - onTriggerEnterConditions = info.remoteTriggerOnEnterConditions ?? new string[]{ } + // Base game never uses more than one condition anyone so we'll keep it simple + prereqConditions = string.IsNullOrEmpty(info.remoteTriggerPrereqCondition) ? new string[]{ } : new string[] { info.remoteTriggerPrereqCondition }, + // Just set your enter conditions in XML instead of complicating it with this + onTriggerEnterConditions = new string[]{ } } }; remoteDialogueTrigger._activatedDialogues = new bool[1]; diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 17d1846e..683244c8 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -509,14 +509,9 @@ namespace NewHorizons.External.Modules public float remoteTriggerRadius; /// - /// If setting up a remote trigger volume, these conditions must be met for it to trigger + /// If setting up a remote trigger volume, this conditions must be met for it to trigger. Note: This is a dialogue condition, not a persistent condition. /// - public string[] remoteTriggerPrereqConditions; - - /// - /// If setting up a remote trigger volume, but I have no idea what this does at all - /// - public string[] remoteTriggerOnEnterConditions; + public string remoteTriggerPrereqCondition; /// /// Relative path to the xml file defining the dialogue. diff --git a/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs b/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs index fb7acb9f..18ac648c 100644 --- a/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs +++ b/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs @@ -14,18 +14,25 @@ namespace NewHorizons.Patches [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))] public static void OnTriggerEnter(RemoteDialogueTrigger __instance) { - _wasLastDialogueInactive = __instance._activeRemoteDialogue.gameObject.activeInHierarchy; - __instance._activeRemoteDialogue.gameObject.SetActive(true); + if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null) + { + _wasLastDialogueInactive = __instance._activeRemoteDialogue.gameObject.activeInHierarchy; + __instance._activeRemoteDialogue.gameObject.SetActive(true); + } } [HarmonyPrefix] [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))] public static void OnEndConversation(RemoteDialogueTrigger __instance) { - if (_wasLastDialogueInactive) + if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null) { - __instance._activeRemoteDialogue.gameObject.SetActive(false); + if (_wasLastDialogueInactive) + { + __instance._activeRemoteDialogue.gameObject.SetActive(false); + } } + _wasLastDialogueInactive = false; } }