End conversation on attach (#367)

## Bug fixes
- Fix a vanilla bug where being in a conversation and then getting
attached to something traps you in dialogue.
This commit is contained in:
Nick 2022-09-09 19:56:19 -04:00 committed by GitHub
commit 82f5f34800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,21 @@
using HarmonyLib;
namespace NewHorizons.Patches;
[HarmonyPatch]
internal class CharacterDialogueTreePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))]
private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", (_) => __instance.EndConversation());
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))]
private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.RemoveListener("AttachPlayerToPoint", (_) => __instance.EndConversation());
}
}