using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using QuestFramework; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0d02688ca05f415d9319b5e85b2635fd3fbeffc8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HuginQuestFramework; [BepInPlugin("aedenthorn.HuginQuestFramework", "Hugin Quest Framework", "0.4.2")] public class BepInExPlugin : BaseUnityPlugin { public enum QuestType { Fetch, Kill, Build } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Patch { public static void Postfix(StoreGui __instance) { if (modEnabled.Value) { GetQuests(); lastCheckTime = ZNet.instance.GetTimeSeconds(); } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class Character_RPC_Damage_Patch { public static void Postfix(Character __instance, HitData hit) { if (modEnabled.Value && !(__instance.GetHealth() > 0f) && !((Object)(object)hit.GetAttacker() != (Object)(object)Player.m_localPlayer)) { AdvanceKillQuests(__instance); } } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] public static class Player_PlacePiece_Patch { public static void Postfix(Piece piece, bool __result) { if (modEnabled.Value && __result) { AdvanceBuildQuests(piece); } } } [HarmonyPatch(typeof(Inventory), "Changed")] public static class Inventory_Changed_Patch { public static void Postfix(Inventory __instance) { if (modEnabled.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { AdjustFetchQuests(); } } } [HarmonyPatch(typeof(Menu), "IsVisible")] public static class Menu_IsVisible_Patch { public static bool Prefix(Menu __instance, ref bool __result) { if (modEnabled.Value) { Transform questDialogueTransform = BepInExPlugin.questDialogueTransform; if (questDialogueTransform != null && ((Component)questDialogueTransform).gameObject.activeSelf) { __result = true; return false; } } return true; } } [HarmonyPatch(typeof(Raven), "Say")] public static class Raven_Say_Patch { public static void Prefix(ref string topic, ref string text, bool showName, bool longTimeout, bool large) { if (!(!modEnabled.Value || showName || longTimeout || large)) { if (finishedQuest != null) { topic = haveRewardDialogue.Value; text = ""; } else if (nextQuest != null) { topic = haveQuestDialogue.Value; text = ""; } } } } [HarmonyPatch(typeof(Raven), "FlyAway")] public static class Raven_FlyAway_Patch { public static bool Prefix() { return !modEnabled.Value || (Object)(object)questDialogueTransform == (Object)null || !((Component)questDialogueTransform).gameObject.activeSelf; } } [HarmonyPatch(typeof(Raven), "GetBestText")] public static class Raven_GetBestText_Patch { public static bool Prefix(Raven __instance, ref RavenText __result) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if (!modEnabled.Value || __instance.m_isMunin || (Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (finishedQuest == null) { foreach (QuestData value in QuestFrameworkAPI.GetCurrentQuests().Values) { if (value.ID.StartsWith(typeof(BepInExPlugin).Namespace) && value.currentStage == "StageTwo") { finishedQuest = value; break; } } } if (finishedQuest != null || nextQuest != null) { __result = new RavenText(); return false; } return true; } } [HarmonyPatch(typeof(Raven), "Talk")] public static class Raven_Talk_Patch { public static bool Prefix(Raven __instance, ref RavenText ___m_currentText, ref bool ___m_hasTalked) { //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Expected O, but got Unknown //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Expected O, but got Unknown //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || ___m_currentText == null || (Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (finishedQuest == null) { foreach (QuestData value in QuestFrameworkAPI.GetCurrentQuests().Values) { if (value.ID.StartsWith(typeof(BepInExPlugin).Namespace) && value.currentStage == "StageTwo") { Dbgl("Setting finished quest to " + value.ID); finishedQuest = value; break; } } } if (finishedQuest != null) { if (finishedQuest.currentStage == "StageTwo") { FulfillQuest(finishedQuest); AccessTools.Method(typeof(Raven), "Say", (Type[])null, (Type[])null).Invoke(__instance, new object[5] { currentText.m_topic, "", false, true, true }); ___m_hasTalked = true; return false; } Dbgl("Finished quest isn't finished"); finishedQuest = null; } if (nextQuest != null) { if ((Object)(object)questDialogueTransform == (Object)null) { Dbgl("Creating Quest Accept Window"); questDialogueTransform = Object.Instantiate(Menu.instance.m_logoutDialog, Menu.instance.m_logoutDialog.parent.parent); ((Object)((Component)questDialogueTransform).gameObject).name = "QuestAcceptWindow"; RectTransform component = ((Component)questDialogueTransform.Find("dialog")).GetComponent(); component.anchoredPosition -= new Vector2(0f, 200f); Transform val = questDialogueTransform.Find("dialog/Button_yes"); ((Object)val).name = "Button_Decline"; RectTransform component2 = ((Component)val).GetComponent(); component2.anchoredPosition -= new Vector2(0f, 32f); ((Component)val).GetComponentInChildren().text = declineButtonText.Value; ((Component)val).GetComponent