Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DadsAdventureMapping v1.0.9
DadsAdventureMapping.dll
Decompiled 14 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("1.0.9.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.9.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DadsAdventureMapping { [BepInPlugin("com.dadisbored.dadsadventuremapping", "DadsAdventureMapping", "1.0.9")] [BepInProcess("valheim.exe")] public sealed class DadsAdventureMappingPlugin : BaseUnityPlugin { public const string Guid = "com.dadisbored.dadsadventuremapping"; public const string Name = "DadsAdventureMapping"; public const string Version = "1.0.9"; internal const float MarkerRange = 25f; internal static ConfigEntry<float> RevealMultiplier = null; private readonly Dictionary<PoiDefinition, ConfigEntry<bool>> _markers = new Dictionary<PoiDefinition, ConfigEntry<bool>>(); private readonly List<ZDO> _nearObjects = new List<ZDO>(); private readonly List<ZDO> _farObjects = new List<ZDO>(); private Collider[] _nearColliders = (Collider[])(object)new Collider[256]; private static readonly FieldInfo LocationHashesField = AccessTools.Field(typeof(ZoneSystem), "m_locationsByHash"); private static readonly FieldInfo PinsField = AccessTools.Field(typeof(Minimap), "m_pins"); private Harmony? _harmony; private float _nextScan; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown RevealMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Map Reveal", "Reveal Size Multiplier", 2f, new ConfigDescription("Map area revealed as the player moves, from 2x to 5x the normal radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 5f), Array.Empty<object>())); foreach (PoiDefinition definition in PoiCatalog.Definitions) { _markers.Add(definition, ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Auto Markers", definition.SettingName, definition.DefaultEnabled, "Mark " + definition.PinLabel + " after coming within 25 meters. Prefabs: " + string.Join(", ", definition.PrefabNames))); } _harmony = new Harmony("com.dadisbored.dadsadventuremapping"); _harmony.PatchAll(typeof(DadsAdventureMappingPlugin).Assembly); } private void Update() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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) if (Time.time < _nextScan) { return; } _nextScan = Time.time + 2f; Player localPlayer = Player.m_localPlayer; Minimap instance = Minimap.instance; ZoneSystem instance2 = ZoneSystem.instance; ZDOMan instance3 = ZDOMan.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || instance3 == null) { return; } Vector3 position = ((Component)localPlayer).transform.position; foreach (LocationInstance location in instance2.GetLocationList()) { if (location.m_location != null && PoiCatalog.TryGetLocation(location.m_location.m_prefabName, out PoiDefinition definition)) { TryMark(instance, position, location.m_position, definition); } } _nearObjects.Clear(); _farObjects.Clear(); instance3.FindSectorObjects(ZoneSystem.GetZone(position), SimulationDistance.OriginalDistance, _nearObjects, _farObjects); Dictionary<int, ZoneLocation> dictionary = (Dictionary<int, ZoneLocation>)LocationHashesField.GetValue(instance2); foreach (ZDO nearObject in _nearObjects) { if (nearObject == null || !nearObject.IsValid()) { continue; } Vector3 position2 = nearObject.GetPosition(); Vector3 val = position - position2; if (((Vector3)(ref val)).sqrMagnitude > 625f) { continue; } int prefab = nearObject.GetPrefab(); PoiDefinition definition3; if (prefab == PoiCatalog.LocationProxyHash) { int key = nearObject.GetInt(ZDOVars.s_location, 0); if (dictionary.TryGetValue(key, out var value) && PoiCatalog.TryGetLocation(value.m_prefabName, out PoiDefinition definition2)) { TryMark(instance, position, position2, definition2); } } else if (PoiCatalog.TryGetObject(prefab, out definition3)) { TryMark(instance, position, position2, definition3); } } int num; while (true) { num = Physics.OverlapSphereNonAlloc(position, 25f, _nearColliders); if (num < _nearColliders.Length) { break; } Array.Resize(ref _nearColliders, _nearColliders.Length * 2); } for (int i = 0; i < num; i++) { Collider val2 = _nearColliders[i]; if (!((Object)(object)val2 == (Object)null)) { TryMarkComponent(instance, position, (Component)(object)((Component)val2).GetComponentInParent<MineRock>()); TryMarkComponent(instance, position, (Component)(object)((Component)val2).GetComponentInParent<MineRock5>()); TryMarkComponent(instance, position, (Component)(object)((Component)val2).GetComponentInParent<Vegvisir>()); TryMarkComponent(instance, position, (Component)(object)((Component)val2).GetComponentInParent<Trader>()); } } Array.Clear(_nearColliders, 0, num); } private void TryMarkComponent(Minimap map, Vector3 player, Component component) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)component == (Object)null)) { Vector3 position = component.transform.position; Vector3 val = player - position; if (!(((Vector3)(ref val)).sqrMagnitude > 625f) && PoiCatalog.TryGetObject(StringExtensionMethods.GetStableHashCode(Utils.GetPrefabName(component.gameObject)), out PoiDefinition definition)) { TryMark(map, player, position, definition); } } } private void TryMark(Minimap map, Vector3 player, Vector3 target, PoiDefinition definition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) Vector3 val = player - target; if (((Vector3)(ref val)).sqrMagnitude > 625f || !_markers[definition].Value) { return; } foreach (PinData item in (List<PinData>)PinsField.GetValue(map)) { float num = item.m_pos.x - target.x; float num2 = item.m_pos.z - target.z; if (num * num + num2 * num2 < 16f) { if (definition.Key == "Flametal" && item.m_name == "Leviathan Lava") { item.m_name = definition.PinLabel; } return; } } PinType val2 = (PinType)((definition.Category == PoiCategory.ResourceVeins) ? 2 : 3); map.AddPin(target, val2, definition.PinLabel, true, false, Player.m_localPlayer.GetPlayerID(), default(PlatformUserID)); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Minimap), "Explore", new Type[] { typeof(Vector3), typeof(float) })] internal static class MovingExplorePatch { private static void Prefix(Vector3 __0, ref float __1) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Vector3 position = ((Component)localPlayer).transform.position; float num = position.x - __0.x; float num2 = position.z - __0.z; if (num * num + num2 * num2 <= 1f) { __1 *= Mathf.Clamp(DadsAdventureMappingPlugin.RevealMultiplier.Value, 2f, 5f); } } } } internal enum PoiCategory { Towers, Houses, ResourceVeins, Tombs, Dolmens, Crypts, Caves, Mines, HildirLocations, Morkhalla, Villages, TarPits, BossAltars, BossVegvisirs, Camps, Ruins, Fortresses, Farms, Merchants, Runestones, Wells, Shipwrecks, StoneCircles, Landmarks, Nests, Excavations, Spawners } internal sealed class PoiDefinition { internal readonly string Key; internal readonly string SettingName; internal readonly string PinLabel; internal readonly PoiCategory Category; internal readonly bool DefaultEnabled; internal readonly List<string> PrefabNames = new List<string>(); internal PoiDefinition(string key, PoiCategory category) { Key = key; Category = category; SettingName = PoiCatalog.DisplayName(key); PinLabel = PoiCatalog.PinLabel(key); DefaultEnabled = category == PoiCategory.Towers || category == PoiCategory.ResourceVeins || category == PoiCategory.Tombs || category == PoiCategory.Crypts || category == PoiCategory.Caves || category == PoiCategory.Mines || category == PoiCategory.Morkhalla; } } internal static class PoiCatalog { internal static readonly int LocationProxyHash; private static readonly Dictionary<string, PoiDefinition> Locations; private static readonly Dictionary<int, PoiDefinition> Objects; private static readonly Dictionary<string, PoiDefinition> Families; internal static readonly List<PoiDefinition> Definitions; static PoiCatalog() { LocationProxyHash = StringExtensionMethods.GetStableHashCode("LocationProxy"); Locations = new Dictionary<string, PoiDefinition>(StringComparer.OrdinalIgnoreCase); Objects = new Dictionary<int, PoiDefinition>(); Families = new Dictionary<string, PoiDefinition>(StringComparer.OrdinalIgnoreCase); Definitions = new List<PoiDefinition>(); AddLocations(PoiCategory.Towers, "StoneTower1 StoneTower2 StoneTower3 StoneTower4 StoneTowerRuins03 StoneTowerRuins04 StoneTowerRuins05 StoneTowerRuins07 StoneTowerRuins08 StoneTowerRuins09 StoneTowerRuins10 Mistlands_GuardTower1_new Mistlands_GuardTower1_ruined_new Mistlands_GuardTower1_ruined_new2 Mistlands_GuardTower2_new Mistlands_GuardTower3_new Mistlands_GuardTower3_ruined_new Mistlands_Lighthouse1_new CharredTowerRuins1 CharredTowerRuins1_dvergr CharredTowerRuins2 CharredTowerRuins3"); AddLocations(PoiCategory.Houses, "WoodHouse1 WoodHouse2 WoodHouse3 WoodHouse4 WoodHouse5 WoodHouse6 WoodHouse7 WoodHouse8 WoodHouse9 WoodHouse10 WoodHouse11 WoodHouse12 WoodHouse13 StoneHouse1 StoneHouse2 StoneHouse3 StoneHouse4 StoneHouse5 StoneHouse1_heath StoneHouse2_heath StoneHouse5_heath SwampHut1 SwampHut2 SwampHut3 SwampHut4 SwampHut5 AbandonedLogCabin02 AbandonedLogCabin03 AbandonedLogCabin04"); AddLocations(PoiCategory.Tombs, "Grave1 MountainGrave01"); AddLocations(PoiCategory.Dolmens, "Dolmen01 Dolmen02 Dolmen03"); AddLocations(PoiCategory.Tombs, "Crypt2 Crypt3 Crypt4"); AddLocations(PoiCategory.Crypts, "SunkenCrypt1 SunkenCrypt2 SunkenCrypt3 SunkenCrypt4"); AddLocations(PoiCategory.Caves, "TrollCave TrollCave02 MountainCave01 MountainCave02 MorgenHole1 MorgenHole2 MorgenHole3"); AddLocations(PoiCategory.HildirLocations, "Hildir_cave Hildir_crypt Hildir_plainsfortress"); AddLocations(PoiCategory.Mines, "Mistlands_DvergrTownEntrance1 Mistlands_DvergrTownEntrance2"); AddLocations(PoiCategory.Morkhalla, "MorkBorg"); AddLocations(PoiCategory.Villages, "WoodVillage1"); AddLocations(PoiCategory.TarPits, "TarPit1 TarPit2 TarPit3"); AddLocations(PoiCategory.BossAltars, "Eikthyrnir GDKing Bonemass Dragonqueen GoblinKing FaderLocation Mistlands_DvergrBossEntrance1"); AddLocations(PoiCategory.Camps, "Greydwarf_camp1 Greydwarf_camp2 Greydwarf_camp3 GoblinCamp1 GoblinCamp2"); AddLocations(PoiCategory.Ruins, "SwampRuin1 SwampRuin2 Ruin1 Ruin2 Ruin3 CharredRuins1 CharredRuins2 CharredRuins3 CharredRuins4 AshlandRuins"); AddLocations(PoiCategory.Fortresses, "Castle Fort1 CharredFortress FortressRuins"); AddLocations(PoiCategory.Farms, "WoodFarm1"); AddLocations(PoiCategory.Merchants, "Vendor_BlackForest Hildir_camp"); AddLocations(PoiCategory.Runestones, "Runestone_Greydwarfs Runestone_Draugr Runestone_Meadows Runestone_Boars Runestone_Swamps Runestone_Mountains Runestone_BlackForest Runestone_Plains Runestone_Mistlands Runestone_Ashlands DrakeLorestone"); AddLocations(PoiCategory.Wells, "SwampWell1 MountainWell1"); AddLocations(PoiCategory.Shipwrecks, "ShipWreck01 ShipWreck02 ShipWreck03 ShipWreck04"); AddLocations(PoiCategory.StoneCircles, "StoneCircle StoneHenge1 StoneHenge2 StoneHenge3 StoneHenge4 StoneHenge5 StoneHenge6 ShipSetting01"); AddLocations(PoiCategory.Landmarks, "StartTemple Waymarker01 Waymarker02 PlaceofMystery1 PlaceofMystery2 PlaceofMystery3 Mistlands_Harbour1 Mistlands_Viaduct1 Mistlands_Viaduct2 Mistlands_RockSpire1 Mistlands_Giant1 Mistlands_Giant2 Mistlands_RoadPost1 Mistlands_StatueGroup1 Mistlands_Statue1 Mistlands_Statue2 Mistlands_Swords1 Mistlands_Swords2 Mistlands_Swords3 SulfurArch"); AddLocations(PoiCategory.ResourceVeins, "LeviathanLava"); AddLocations(PoiCategory.Nests, "DrakeNest01 VoltureNest"); AddLocations(PoiCategory.Excavations, "Mistlands_Excavation1 Mistlands_Excavation2 Mistlands_Excavation3"); AddLocations(PoiCategory.Spawners, "FireHole InfestedTree01 CharredStone_Spawner"); AddObjects(PoiCategory.ResourceVeins, "MineRock_Copper MineRock_Tin MineRock_Iron MineRock_Obsidian MineRock_Meteorite MineRock_Stone rock4_copper silvervein mudpile mudpile2 FlametalRockstand LeviathanLava"); AddObjects(PoiCategory.BossVegvisirs, "Vegvisir_Bonemass Vegvisir_DNBoss Vegvisir_DragonQueen Vegvisir_Eikthyr Vegvisir_Fader Vegvisir_GDKing Vegvisir_GoblinKing Vegvisir_SeekerQueen Vegvisir_placeofmystery Vegvisir_placeofmystery_2 Vegvisir_placeofmystery_3"); AddObjects(PoiCategory.Merchants, "Haldor Hildir BogWitch BogWitch_Hut"); } private static void AddLocations(PoiCategory category, string names) { string[] array = names.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { PoiDefinition definition = GetDefinition(text, category); Locations.Add(text, definition); definition.PrefabNames.Add(text); } } private static void AddObjects(PoiCategory category, string names) { string[] array = names.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { PoiDefinition definition = GetDefinition(text, category); Objects.Add(StringExtensionMethods.GetStableHashCode(text), definition); definition.PrefabNames.Add(text); } } private static PoiDefinition GetDefinition(string name, PoiCategory category) { string text = FamilyKey(name, category); if (!Families.TryGetValue(text, out PoiDefinition value)) { value = new PoiDefinition(text, category); Families.Add(text, value); Definitions.Add(value); } else if (value.Category != category) { throw new InvalidOperationException("POI family has conflicting categories: " + text); } return value; } private static string FamilyKey(string name, PoiCategory category) { switch (category) { case PoiCategory.Towers: return "Tower"; case PoiCategory.Houses: return "House"; case PoiCategory.Tombs: return "Tomb"; case PoiCategory.Crypts: return "Crypt"; case PoiCategory.Caves: return "Cave"; case PoiCategory.Mines: return "Mine"; case PoiCategory.Morkhalla: return "Morkhalla"; case PoiCategory.HildirLocations: return "Hildir Locations"; case PoiCategory.BossVegvisirs: return "Vegvisir"; case PoiCategory.Villages: return "Village"; case PoiCategory.TarPits: return "Tar Pit"; case PoiCategory.BossAltars: return "Boss Site"; case PoiCategory.Camps: return "Camp"; case PoiCategory.Ruins: return "Ruin"; case PoiCategory.Fortresses: return "Fortress"; case PoiCategory.Farms: return "Farm"; case PoiCategory.Runestones: return "Runestone"; case PoiCategory.Wells: return "Well"; case PoiCategory.Shipwrecks: return "Shipwreck"; case PoiCategory.StoneCircles: return "Stone Circle"; case PoiCategory.Nests: return "Nest"; case PoiCategory.Excavations: return "Excavation"; case PoiCategory.Spawners: return "Spawner"; case PoiCategory.Merchants: switch (name) { case "Vendor_BlackForest": case "Haldor": return "Haldor"; case "Hildir_camp": case "Hildir": return "Hildir"; default: return "Bog Witch"; } case PoiCategory.ResourceVeins: switch (name) { case "rock4_copper": case "MineRock_Copper": return "Copper"; case "MineRock_Tin": return "Tin"; case "MineRock_Iron": case "mudpile": case "mudpile2": return "Iron"; case "silvervein": return "Silver"; case "FlametalRockstand": case "LeviathanLava": return "Flametal"; default: return name.Replace("MineRock_", string.Empty); } default: return Regex.Replace(name, "[0-9]+", string.Empty).TrimEnd(new char[1] { '_' }); } } internal static bool TryGetLocation(string name, out PoiDefinition definition) { return Locations.TryGetValue(name ?? string.Empty, out definition); } internal static bool TryGetObject(int prefabHash, out PoiDefinition definition) { return Objects.TryGetValue(prefabHash, out definition); } private static string Readable(string key) { return Regex.Replace(key.Replace('_', ' '), "([a-z])([A-Z])", "$1 $2"); } internal static string DisplayName(string key) { return key switch { "GDKing" => "Elder Altar", "Eikthyrnir" => "Eikthyr Altar", "Dragonqueen" => "Moder Altar", "GoblinKing" => "Yagluth Altar", "Mistlands_DvergrBossEntrance" => "Queen Entrance", _ => Readable(key), }; } internal static string PinLabel(string key) { return DisplayName(key); } } }