using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("DungeonFinder")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DungeonFinder")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f28048ab-6a92-4efe-be3c-86f41e711226")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace DungeonFinder; [BepInPlugin("com.Horhpeus.dungeonfinder", "Dungeon Finder", "1.0.1")] public class DungeonFinderPlugin : BaseUnityPlugin { public const string PluginGUID = "com.Horhpeus.dungeonfinder"; public const string PluginName = "Dungeon Finder"; public const string PluginVersion = "1.0.1"; private Harmony _harmony; internal static ManualLogSource Log; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; DungeonFinderConfig.Log = Log; _harmony = new Harmony("com.Horhpeus.dungeonfinder"); _harmony.PatchAll(); Log.LogInfo((object)"Dungeon Finder loaded"); DungeonFinderConfig.Init(((BaseUnityPlugin)this).Config); DungeonFinderConfig.InitLocationLabels(); DungeonFinderConfig.InitLocationSets(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(ZoneSystem), "SpawnLocation")] public static class ZoneSystem_SpawnLocation_Patch { private static void Postfix(ZoneLocation location, GameObject __result) { if (!((Object)(object)__result == (Object)null)) { string prefabName = location.m_prefabName; if (DungeonFinderConfig.locationNamesToScan.Contains(prefabName)) { AddTrigger(__result, prefabName); } } } private static void AddTrigger(GameObject obj, string name) { SphereCollider val = obj.AddComponent(); ((Collider)val).isTrigger = true; val.radius = DungeonFinderConfig.SearchDistance.Value; DungeonTrigger dungeonTrigger = obj.AddComponent(); dungeonTrigger.locationName = name; } } public class DungeonTrigger : MonoBehaviour { public string locationName; private bool triggered; private void OnTriggerEnter(Collider other) { if (!triggered && (Object)(object)((Component)other).GetComponent() != (Object)null) { triggered = true; DungeonFinderPlugin.Log.LogInfo((object)("Player entered: " + locationName)); AddMinimapIcon(); } } private void AddMinimapIcon() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Minimap.instance == (Object)null) && !IsIconAlreadyPlaced(((Component)this).transform.position)) { string text = (DungeonFinderConfig.locationNameToLabel.ContainsKey(locationName) ? DungeonFinderConfig.locationNameToLabel[locationName] : "Dungeon"); Minimap.instance.AddPin(((Component)this).transform.position, (PinType)2, text, true, false, 0L, default(PlatformUserID)); } } private bool IsIconAlreadyPlaced(Vector3 position) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return false; } List pins = GetPins(); return pins.Any((PinData pin) => Vector3.Distance(pin.m_pos, position) < 1f); } public static List GetPins() { FieldInfo field = typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return null; } return (List)field.GetValue(Minimap.instance); } } public class DungeonFinderConfig { internal static ManualLogSource Log; public static HashSet locationNamesToScan = new HashSet(); public static Dictionary locationNameToLabel = new Dictionary(); public static ConfigEntry EnableDungeonFinder { get; private set; } public static ConfigEntry SearchDistance { get; private set; } public static ConfigEntry SearchForCrypts { get; private set; } public static ConfigEntry SearchForTroll { get; private set; } public static ConfigEntry SearchForSunkenCrypt { get; private set; } public static ConfigEntry SearchForMountainCave { get; private set; } public static ConfigEntry SearchForInfestedMine { get; private set; } public static ConfigEntry SearchForMorgenHole { get; private set; } public static ConfigEntry SearchForHildirDungeons { get; private set; } public static ConfigEntry SearchForPlaceOfMystery { get; private set; } public static ConfigEntry CryptLabelName { get; private set; } public static ConfigEntry TrollLabelName { get; private set; } public static ConfigEntry SunkenCryptLabelName { get; private set; } public static ConfigEntry MountainCaveLabelName { get; private set; } public static ConfigEntry InfestedMineLabelName { get; private set; } public static ConfigEntry MorgenHoleLabelName { get; private set; } public static ConfigEntry HildirDungeonsLabelName { get; private set; } public static ConfigEntry PlaceOfMysteryLabelName { get; private set; } public static void Init(ConfigFile config) { EnableDungeonFinder = config.Bind("General", "EnableDungeonFinder", true, "Enable or disable the dungeon Finder feature."); SearchDistance = config.Bind("General", "SearchDistance", 75f, "The search diameter for locations around the player."); SearchForCrypts = config.Bind("General", "Crypts", true, "Enable search for crypt locations."); SearchForTroll = config.Bind("General", "Troll", true, "Enable search for troll locations."); SearchForSunkenCrypt = config.Bind("General", "SunkenCrypt", true, "Enable search for sunken crypt locations."); SearchForMountainCave = config.Bind("General", "MountainCave", true, "Enable search for mountain cave locations."); SearchForInfestedMine = config.Bind("General", "InfestedMine", true, "Enable search for infested mine locations."); SearchForMorgenHole = config.Bind("General", "MorgenHole", true, "Enable search for morgen hole locations."); SearchForHildirDungeons = config.Bind("General", "HildirDungeons", false, "Enable search for hildir dungeons locations."); SearchForPlaceOfMystery = config.Bind("General", "PlaceOfMystery", false, "Enable search for place of mystery locations."); CryptLabelName = config.Bind("Labels", "CryptLabelName", "Crypt", "Label for crypt locations on the minimap."); TrollLabelName = config.Bind("Labels", "TrollLabelName", "Troll Cave", "Label for troll locations on the minimap."); SunkenCryptLabelName = config.Bind("Labels", "SunkenCryptLabelName", "Sunken Crypt", "Label for sunken crypt locations on the minimap."); MountainCaveLabelName = config.Bind("Labels", "MountainCaveLabelName", "Mountain Cave", "Label for mountain cave locations on the minimap."); InfestedMineLabelName = config.Bind("Labels", "InfestedMineLabelName", "Infested Mine", "Label for infested mine locations on the minimap."); MorgenHoleLabelName = config.Bind("Labels", "MorgenHoleLabelName", "Morgen Hole", "Label for morgen hole locations on the minimap."); HildirDungeonsLabelName = config.Bind("Labels", "HildirDungeonsLabelName", "Hildir Dungeon", "Label for hildir dungeon locations on the minimap."); PlaceOfMysteryLabelName = config.Bind("Labels", "PlaceOfMysteryLabelName", "Place of Mystery", "Label for place of mystery locations on the minimap."); } public static void InitLocationLabels() { locationNameToLabel["Crypt2"] = CryptLabelName.Value; locationNameToLabel["Crypt3"] = CryptLabelName.Value; locationNameToLabel["Crypt4"] = CryptLabelName.Value; locationNameToLabel["TrollCave02"] = TrollLabelName.Value; locationNameToLabel["SunkenCrypt4"] = SunkenCryptLabelName.Value; locationNameToLabel["MountainCave02"] = MountainCaveLabelName.Value; locationNameToLabel["Mistlands_DvergrBossEntrance1"] = InfestedMineLabelName.Value; locationNameToLabel["Mistlands_DvergrTownEntrance1"] = InfestedMineLabelName.Value; locationNameToLabel["Mistlands_DvergrTownEntrance2"] = InfestedMineLabelName.Value; locationNameToLabel["MorgenHole1"] = MorgenHoleLabelName.Value; locationNameToLabel["MorgenHole2"] = MorgenHoleLabelName.Value; locationNameToLabel["MorgenHole3"] = MorgenHoleLabelName.Value; locationNameToLabel["Hildir_cave"] = HildirDungeonsLabelName.Value; locationNameToLabel["Hildir_crypt"] = HildirDungeonsLabelName.Value; locationNameToLabel["Hildir_plainsfortress"] = HildirDungeonsLabelName.Value; locationNameToLabel["PlaceofMystery3"] = PlaceOfMysteryLabelName.Value; } public static void InitLocationSets() { if (SearchForCrypts != null && SearchForCrypts.Value) { locationNamesToScan.Add("Crypt2"); locationNamesToScan.Add("Crypt3"); locationNamesToScan.Add("Crypt4"); } if (SearchForTroll != null && SearchForTroll.Value) { locationNamesToScan.Add("TrollCave02"); } if (SearchForSunkenCrypt != null && SearchForSunkenCrypt.Value) { locationNamesToScan.Add("SunkenCrypt4"); } if (SearchForMountainCave != null && SearchForMountainCave.Value) { locationNamesToScan.Add("MountainCave02"); } if (SearchForInfestedMine != null && SearchForInfestedMine.Value) { locationNamesToScan.Add("Mistlands_DvergrBossEntrance1"); locationNamesToScan.Add("Mistlands_DvergrTownEntrance1"); locationNamesToScan.Add("Mistlands_DvergrTownEntrance2"); } if (SearchForMorgenHole != null && SearchForMorgenHole.Value) { locationNamesToScan.Add("MorgenHole1"); locationNamesToScan.Add("MorgenHole2"); locationNamesToScan.Add("MorgenHole3"); } if (SearchForHildirDungeons != null && SearchForHildirDungeons.Value) { locationNamesToScan.Add("Hildir_cave"); locationNamesToScan.Add("Hildir_crypt"); locationNamesToScan.Add("Hildir_plainsfortress"); } if (SearchForPlaceOfMystery != null && SearchForPlaceOfMystery.Value) { locationNamesToScan.Add("PlaceofMystery3"); } } }