using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Newtonsoft.Json; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MMOHeim SimpleQuest")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MMOHeim SimpleQuest")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("526f6350-8ad0-4fd8-8066-5806b070f058")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SimpleQuest; [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] public static class ItemCollectionPatch { private static void Postfix(Inventory __instance, ItemData item, bool __result) { if (!__result || item == null || (Object)(object)item.m_dropPrefab == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || __instance != ((Humanoid)Player.m_localPlayer).GetInventory()) { return; } if ((Object)(object)SimpleQuestPro.Instance != (Object)null) { string name = ((Object)item.m_dropPrefab).name; foreach (QuestConfig item2 in SimpleQuestPro.Instance.serverQuests.Quests.Where((QuestConfig q) => string.IsNullOrEmpty(q.PreReqID) || SimpleQuestPro.Instance.completedQuests.Contains(q.PreReqID)).ToList()) { if (!SimpleQuestPro.Instance.completedQuests.Contains(item2.ID)) { QuestRequirement questRequirement = item2.Reqs?.FirstOrDefault((QuestRequirement r) => r.Prefab.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)); if (questRequirement != null) { int itemCount = QuestUtils.GetItemCount(name); string itemName = QuestUtils.GetItemName(name); ((Character)Player.m_localPlayer).Message((MessageType)1, $"{itemName}: {itemCount} / {questRequirement.Amount}", 0, (Sprite)null); } } } if (SimpleQuestPro.Instance.IsWindowActive()) { QuestUI.UpdateUI(); } } QuestUI.UpdateHUD(); } } [HarmonyPatch] public static class PlantWatcher { [HarmonyPatch(typeof(Player), "ConsumeResources")] [HarmonyPrefix] private static void Prefix(Requirement[] requirements, int itemQuality) { if (requirements == null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } foreach (Requirement val in requirements) { if (val == null || (Object)(object)val.m_resItem == (Object)null) { continue; } string name = ((Object)val.m_resItem).name; string questName = ""; if (name.Contains("CarrotSeeds")) { questName = "Carrot"; } else if (name.Contains("TurnipSeeds")) { questName = "Turnip"; } else if (name.Contains("OnionSeeds")) { questName = "Onion"; } else if (name.Contains("Seed")) { questName = name.Replace("Seeds", "").Replace("Seed", ""); } if (string.IsNullOrEmpty(questName)) { continue; } if ((Object)(object)SimpleQuestPro.Instance != (Object)null) { foreach (QuestConfig visibleQuest in QuestUtils.GetVisibleQuests()) { if (SimpleQuestPro.Instance.completedQuests.Contains(visibleQuest.ID)) { continue; } QuestRequirement questRequirement = visibleQuest.KillReqs?.FirstOrDefault((QuestRequirement k) => string.Equals(k.Prefab.Trim(), questName, StringComparison.OrdinalIgnoreCase)); if (questRequirement != null) { if (!SimpleQuestPro.playerKills.ContainsKey(questName)) { SimpleQuestPro.playerKills[questName] = 0; } SimpleQuestPro.playerKills[questName]++; int num = SimpleQuestPro.playerKills[questName]; string itemName = QuestUtils.GetItemName(questName); ((Character)Player.m_localPlayer).Message((MessageType)1, $"{itemName}: {num} / {questRequirement.Amount}", 0, (Sprite)null); } } if (SimpleQuestPro.Instance.IsWindowActive()) { QuestUI.UpdateUI(); } } QuestUI.UpdateHUD(); } } } public class QuestConfig { public string ID; public string Title; public string Goal; public string Rarity; public string RewardItem; public string PreReqID; public int RewardAmount; public int ExpReward; public List Reqs; public List KillReqs; public List RewardItems; } public class QuestList { public List Quests = new List(); } public class QuestRequirement { public string Prefab; public int Amount; } public static class QuestUI { private class TrackerDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private RectTransform rectTransform; private Canvas canvas; private bool canDrag; public void OnBeginDrag(PointerEventData eventData) { canDrag = IsTrackerDragAllowed() && (Object)(object)hudPanel != (Object)null && hudPanel.activeSelf; if (canDrag) { rectTransform = hudPanel.GetComponent(); canvas = (((Object)(object)rectTransform != (Object)null) ? ((Component)rectTransform).GetComponentInParent() : null); } } public void OnDrag(PointerEventData eventData) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!IsTrackerDragAllowed()) { canDrag = false; } else if (canDrag && !((Object)(object)rectTransform == (Object)null)) { float num = (((Object)(object)canvas != (Object)null && canvas.scaleFactor > 0f) ? canvas.scaleFactor : 1f); RectTransform obj = rectTransform; obj.anchoredPosition += eventData.delta / num; ClampRectToScreen(rectTransform); } } public void OnEndDrag(PointerEventData eventData) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (canDrag && (Object)(object)rectTransform != (Object)null && (Object)(object)SimpleQuestPro.Instance != (Object)null) { ClampRectToScreen(rectTransform); SimpleQuestPro.Instance.SaveTrackerPosition(ToSavedTopLeft(rectTransform)); } canDrag = false; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__10_0; public static UnityAction <>9__10_1; public static UnityAction <>9__10_2; public static UnityAction <>9__10_3; public static Func, int> <>9__11_2; public static Func <>9__11_0; public static Func, int> <>9__12_2; internal void b__10_0() { List visibleQuests = QuestUtils.GetVisibleQuests(); if (visibleQuests.Count > 0) { QuestConfig questConfig = visibleQuests[currentIndex]; if (SimpleQuestPro.trackedQuests.Contains(questConfig.ID)) { SimpleQuestPro.trackedQuests.Remove(questConfig.ID); } else { SimpleQuestPro.trackedQuests.Add(questConfig.ID); } UpdateUI(); UpdateHUD(); QuestUtils.PlaySfx("sfx_gui_mouse_over"); } } internal void b__10_1() { int count = QuestUtils.GetVisibleQuests().Count; if (count > 0) { currentIndex = (currentIndex - 1 + count) % count; currentIconIndex = 0; UpdateUI(); QuestUtils.PlaySfx("sfx_book_page"); } } internal void b__10_2() { int count = QuestUtils.GetVisibleQuests().Count; if (count > 0) { currentIndex = (currentIndex + 1) % count; currentIconIndex = 0; UpdateUI(); QuestUtils.PlaySfx("sfx_book_page"); } } internal void b__10_3() { showHistoryMode = !showHistoryMode; currentIndex = 0; UpdateUI(); QuestUtils.PlaySfx("sfx_book_page"); } internal int b__11_2(KeyValuePair x) { return x.Value; } internal string b__11_0(QuestRequirement x) { return $"{QuestUtils.GetItemName(x.Prefab)} x{x.Amount}"; } internal int b__12_2(KeyValuePair x) { return x.Value; } } public static GameObject window; public static GameObject hudPanel; public static Text infoText; public static Text pageText; public static Text btnText; public static Text titleText; public static Text historyBtnText; public static Text hudText; public static Text trackBtnText; public static GameObject btnFinish; public static GameObject btnHistory; public static GameObject btnTrack; public static Image rewardIcon; public static int currentIndex; public static int currentIconIndex; public static float iconTimer; public static bool showHistoryMode; private static bool hudAttachedToMinimap; private static Image hudBackground; private static CanvasGroup hudCanvasGroup; private static readonly Color hudGhostColor = new Color(0.22f, 0.16f, 0.1f, 0f); private static Transform ResolveMainUiRoot() { if ((Object)(object)GUIManager.CustomGUIFront != (Object)null) { return GUIManager.CustomGUIFront.transform; } if ((Object)(object)Hud.instance != (Object)null) { return ((Component)Hud.instance).transform; } return null; } private static void DestroySafe(GameObject go) { if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } } public static void CleanupUI() { DestroySafe(window); DestroySafe(hudPanel); window = null; hudPanel = null; infoText = null; pageText = null; btnText = null; titleText = null; historyBtnText = null; hudText = null; trackBtnText = null; btnFinish = null; btnHistory = null; btnTrack = null; rewardIcon = null; hudBackground = null; hudCanvasGroup = null; hudAttachedToMinimap = false; } private static string L(string key, string fallback) { string text = "$" + key; string text2 = ((Localization.instance != null) ? Localization.instance.Localize(text) : text); if (!(text2 == text) && !string.IsNullOrEmpty(text2)) { return text2; } return fallback; } private static bool IsTrackerDragAllowed() { if ((Object)(object)Menu.instance != (Object)null) { return Menu.IsVisible(); } return false; } public static void SetTrackerInteractionEnabled(bool enabled) { if ((Object)(object)hudBackground != (Object)null) { ((Graphic)hudBackground).raycastTarget = enabled; } if ((Object)(object)hudCanvasGroup != (Object)null) { hudCanvasGroup.blocksRaycasts = enabled; hudCanvasGroup.interactable = enabled; } } private static Vector2 ToSavedTopLeft(RectTransform rectTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Vector2 anchoredPosition = rectTransform.anchoredPosition; Rect rect = rectTransform.rect; return anchoredPosition - new Vector2(((Rect)(ref rect)).width, 0f); } private static Vector2 FromSavedTopLeft(RectTransform rectTransform, Vector2 savedTopLeft) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Rect rect = rectTransform.rect; return savedTopLeft + new Vector2(((Rect)(ref rect)).width, 0f); } private static void ClampRectToScreen(RectTransform rectTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rectTransform == (Object)null)) { Vector3[] array = (Vector3[])(object)new Vector3[4]; rectTransform.GetWorldCorners(array); Vector3 zero = Vector3.zero; if (array[0].x < 0f) { zero.x += 0f - array[0].x; } if (array[2].x > (float)Screen.width) { zero.x -= array[2].x - (float)Screen.width; } if (array[0].y < 0f) { zero.y += 0f - array[0].y; } if (array[2].y > (float)Screen.height) { zero.y -= array[2].y - (float)Screen.height; } if (zero != Vector3.zero) { ((Transform)rectTransform).position = ((Transform)rectTransform).position + zero; } } } private static void TryAttachHudToMinimap() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hudPanel == (Object)null) { return; } RectTransform component = hudPanel.GetComponent(); if ((Object)(object)component == (Object)null) { return; } Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_smallRoot == (Object)null) { Transform val = ResolveMainUiRoot(); if ((Object)(object)val != (Object)null) { ((Transform)component).SetParent(val, false); hudAttachedToMinimap = false; Debug.Log((object)"[MMOHeim SimpleQuest] Minimap root missing. Tracker parented to fallback UI root."); } else { Debug.LogWarning((object)"[MMOHeim SimpleQuest] Could not attach tracker: both minimap and fallback UI root are unavailable."); } hudAttachedToMinimap = false; } else { ((Transform)component).SetParent(instance.m_smallRoot.transform, false); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 1f); component.sizeDelta = new Vector2(360f, 120f); LayoutRebuilder.ForceRebuildLayoutImmediate(component); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(-380f, -20f); Vector2 savedTopLeft = (((Object)(object)SimpleQuestPro.Instance != (Object)null) ? SimpleQuestPro.Instance.GetSavedTrackerPosition(val2) : val2); component.anchoredPosition = FromSavedTopLeft(component, savedTopLeft); ClampRectToScreen(component); hudAttachedToMinimap = true; Debug.Log((object)"[MMOHeim SimpleQuest] Tracker parented to Minimap.smallRoot."); } } public static void CreateUI() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Expected O, but got Unknown //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Expected O, but got Unknown //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Expected O, but got Unknown //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Expected O, but got Unknown //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Expected O, but got Unknown //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)window != (Object)null && (Object)(object)hudPanel != (Object)null) { return; } CleanupUI(); if (GUIManager.Instance == null) { Debug.LogWarning((object)"[MMOHeim SimpleQuest] CreateUI aborted: GUIManager.Instance is null."); return; } Transform val = ResolveMainUiRoot(); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"[MMOHeim SimpleQuest] CreateUI aborted: no valid UI root (CustomGUIFront/Hud) is available."); return; } try { window = GUIManager.Instance.CreateWoodpanel(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 600f, 550f, true); Image component = window.GetComponent(); if ((Object)(object)component != (Object)null) { ((Graphic)component).color = new Color(0.6f, 0.6f, 0.6f, 1f); } titleText = GUIManager.Instance.CreateText("", window.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -20f), GUIManager.Instance.AveriaSerifBold, 18, new Color(1f, 0.84f, 0f, 1f), false, Color.clear, 400f, 30f, false).GetComponent(); titleText.alignment = (TextAnchor)4; pageText = GUIManager.Instance.CreateText("", window.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -40f), GUIManager.Instance.AveriaSerifBold, 14, Color.white, false, Color.clear, 200f, 30f, false).GetComponent(); pageText.alignment = (TextAnchor)4; infoText = GUIManager.Instance.CreateText("", window.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 60f), GUIManager.Instance.AveriaSerifBold, 17, Color.white, false, Color.clear, 500f, 350f, false).GetComponent(); infoText.alignment = (TextAnchor)4; GameObject val2 = new GameObject("RewardIcon", new Type[1] { typeof(Image) }); val2.transform.SetParent(window.transform, false); rewardIcon = val2.GetComponent(); RectTransform component2 = val2.GetComponent(); component2.anchoredPosition = new Vector2(0f, -145f); component2.sizeDelta = new Vector2(64f, 64f); val2.SetActive(false); btnTrack = GUIManager.Instance.CreateButton(L("sq_track", "TRACK"), window.transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-100f, 45f), 130f, 30f); trackBtnText = btnTrack.GetComponentInChildren(); ButtonClickedEvent onClick = btnTrack.GetComponent