namespace Harmony.Dialog { // Removes the custom IsBusy bool, which pauses custom NPCs in their activities, allowing the player to talk to them. [HarmonyPatch(typeof(XUiC_DialogWindowGroup))] [HarmonyPatch("OnClose")] public class OnClose { public static bool Prefix(XUiC_DialogWindowGroup __instance) { //if (!__instance.xui.playerUI.entityPlayer.Buffs.HasCustomVar("CurrentNPC")) return true; int entityID = RebirthVariables.talkingToNPC; // (int)__instance.xui.playerUI.entityPlayer.Buffs.GetCustomVar("CurrentNPC"); global::EntityAliveV2 myEntity = __instance.xui.playerUI.entityPlayer.world.GetEntity(entityID) as global::EntityAliveV2; if (myEntity == null) { return true; } myEntity.Buffs.RemoveBuff("buffTalkingTo"); myEntity.Buffs.SetCustomVar("CurrentPlayer", 0f); myEntity.emodel.avatarController.UpdateBool("IsBusy", false); return true; } } // Removes the custom IsBusy bool, which pauses custom NPCs in their activities, allowing the player to talk to them. [HarmonyPatch(typeof(XUiC_DialogWindowGroup))] [HarmonyPatch("OnOpen")] public class OnOpen { public static bool Prefix(XUiC_DialogWindowGroup __instance) { //if (!__instance.xui.playerUI.entityPlayer.Buffs.HasCustomVar("CurrentNPC")) return true; int entityID = RebirthVariables.talkingToNPC; // (int)__instance.xui.playerUI.entityPlayer.Buffs.GetCustomVar("CurrentNPC"); global::EntityAliveV2 myEntity = __instance.xui.playerUI.entityPlayer.world.GetEntity(entityID) as global::EntityAliveV2; if (myEntity == null) { return true; } myEntity.Buffs.AddBuff("buffTalkingTo"); myEntity.emodel.avatarController.UpdateBool("IsBusy", true); myEntity.RotateTo(__instance.xui.playerUI.entityPlayer, 360f, 360f); myEntity.SetLookPosition(__instance.xui.playerUI.entityPlayer.getHeadPosition()); return true; } } [HarmonyPatch(typeof(XUiC_LootWindowGroup))] [HarmonyPatch("OnClose")] public class XUiC_LootWindowGroupOnClose { public static bool Prefix(XUiC_DialogWindowGroup __instance) { if (!__instance.xui.playerUI.entityPlayer.Buffs.HasCustomVar("CurrentNPC")) return true; int entityID = (int)__instance.xui.playerUI.entityPlayer.Buffs.GetCustomVar("CurrentNPC"); global::EntityAliveV2 myEntity = __instance.xui.playerUI.entityPlayer.world.GetEntity(entityID) as global::EntityAliveV2; if (myEntity == null) return true; myEntity.UpdateWeapon(); if (!SingletonMonoBehaviour.Instance.IsServer) { //myEntity.SendSyncData(); } return true; } } }