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 VargheimExploration v1.0.7
VargheimExploration.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using VargheimProfessions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 VargheimExploration { [BepInPlugin("digi.vargheim.exploration", "VargheimExploration", "1.0.7")] [BepInDependency("digi.vargheim.professions", "0.4.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(ZNet), "Awake")] [HarmonyPostfix] private static void ZNetAwake() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<Vector3, int>("VP_Pathfind", (Action<long, Vector3, int>)Server_Pathfind); ZRoutedRpc.instance.Register<bool, Vector3, string>("VP_PathfindResult", (Action<long, bool, Vector3, string>)Client_PathfindResult); ZRoutedRpc.instance.Register<Vector3, int>("VP_Pathfind2", (Action<long, Vector3, int>)Server_Pathfind2); ZRoutedRpc.instance.Register<ZPackage>("VP_PathfindResult2", (Action<long, ZPackage>)Client_PathfindResult2); } } [HarmonyPatch(typeof(SEMan), "ModifyRunStaminaDrain")] [HarmonyPostfix] private static void RunDrain(SEMan __instance, ref float drain) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)Traverse.Create((object)__instance).Field("m_character").GetValue<Character>() != (Object)(object)localPlayer) && Api.HasPerk("Exploration", TrailLevel.Value) && ((int)localPlayer.GetCurrentBiome() == 2 || WorldGenerator.InForest(((Component)localPlayer).transform.position))) { drain *= 1f - TrailStamina.Value; } } catch { } } } public const string Guid = "digi.vargheim.exploration"; public const string Version = "1.0.7"; private const string Prof = "Exploration"; internal static ConfigEntry<int> LandmarkLevel; internal static ConfigEntry<int> WeatherLevel; internal static ConfigEntry<int> TrailLevel; internal static ConfigEntry<int> GroupLevel; internal static ConfigEntry<int> PathLevel; internal static ConfigEntry<float> LandmarkRange; internal static ConfigEntry<float> WeatherWarn; internal static ConfigEntry<float> TrailStamina; internal static ConfigEntry<float> TrailSwim; internal static ConfigEntry<float> GroupRange; internal static ConfigEntry<float> PathMinDistance; internal static ConfigEntry<float> PathFuzz; internal static ConfigEntry<string> PathTargets; internal static Plugin Instance; private float _nextLandmark; private float _nextWeather; private float _nextGroup; private static readonly FieldRef<List<Location>> s_locations = AccessTools.StaticFieldRefAccess<List<Location>>(AccessTools.Field(typeof(Location), "s_allLocations")); private static MethodInfo s_explore; private static MethodInfo s_similar; private static MethodInfo s_windOctave; private static MethodInfo s_selectEnv; private static MethodInfo s_getBiome; private static float? s_baseSwim; private static string s_warned = ""; private const int PathCandidates = 8; private static MethodInfo s_isExplored; private static readonly FieldRef<Minimap, List<PinData>> s_pins = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins"); private void Awake() { //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) Instance = this; LandmarkLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "LandmarkSenseLevel", 25, "Landmark sense level."); LandmarkRange = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "LandmarkSenseRange", 150f, "Landmark sense: dungeons and points of interest within this range are pinned."); WeatherLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "WeatherEyeLevel", 35, "Weather eye level."); WeatherWarn = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "WeatherEyeWarningSeconds", 60f, "Weather eye: how many seconds of warning before a storm or a wind change."); TrailLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "TrailblazerLevel", 60, "Trailblazer level."); TrailStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "TrailblazerStaminaReduction", 0.25f, "Trailblazer: less run stamina drain in forests and swamps."); TrailSwim = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "TrailblazerSwimBonus", 0.2f, "Trailblazer: faster swimming."); GroupLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "GroupCartographerLevel", 75, "Group cartographer level."); GroupRange = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "GroupCartographerRange", 50f, "Group cartographer: group members within this range see what you uncover."); PathLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "PathfinderLevel", 100, "Pathfinder level."); PathMinDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "PathfinderMinDistance", 300f, "Pathfinder ignores places closer than this (they'd be found anyway)."); PathFuzz = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "PathfinderAreaSize", 150f, "Pathfinder marks an area this big, not the exact spot."); PathTargets = ((BaseUnityPlugin)this).Config.Bind<string>("Perks", "PathfinderTargets", "Eikthyrnir,GDKing,Bonemass,Dragonqueen,GoblinKing,Mistlands_DvergrBossEntrance,FaderLocation,Crypt,SunkenCrypt,TrollCave,MountainCave,Mistlands_DvergrTownEntrance,CharredFortress,MorgenHole", "Location prefab names (or parts of names) Pathfinder points to."); Api.RegisterLadder("Exploration", "VargheimExploration 1.0.7", "Smoothbrain Exploration: bigger map reveal, faster movement and a bigger wishbone radius with level. Everyone at 20 can read and write the map table.", (Perk[])(object)new Perk[6] { new Perk(LandmarkLevel.Value, "Landmark sense", "Dungeons, camps and boss altars within ~" + LandmarkRange.Value + " m are pinned on your map."), new Perk(WeatherLevel.Value, "Weather eye", "A warning about a minute before a storm starts or the wind turns."), new Perk(50, "Treasure", "25% chance of double treasure (Smoothbrain Exploration)."), new Perk(TrailLevel.Value, "Trailblazer", Mathf.RoundToInt(TrailStamina.Value * 100f) + "% less stamina running in forests and swamps, " + Mathf.RoundToInt(TrailSwim.Value * 100f) + "% faster swimming."), new Perk(GroupLevel.Value, "Group cartographer", "Group members within " + GroupRange.Value + " m also reveal the map around you."), new Perk(PathLevel.Value, "Pathfinder", "Once per in-game day: points toward an undiscovered boss altar or dungeon in your biome (button below).") }); Content.AddAction("Exploration", PathLevel.Value, "Pathfinder (once per day)", (Func<string>)Pathfind); Pins.Bind(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("digi.vargheim.exploration"); val.PatchAll(typeof(Patches)); val.PatchAll(typeof(Pins)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VargheimExploration 1.0.7 loaded."); } private void Update() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)Minimap.instance == (Object)null) { return; } try { if (Time.time > _nextLandmark) { _nextLandmark = Time.time + 3f; if (Api.HasPerk("Exploration", LandmarkLevel.Value)) { Landmarks(localPlayer); } Swim(localPlayer); } if (Time.time > _nextWeather) { _nextWeather = Time.time + 5f; if (Api.HasPerk("Exploration", WeatherLevel.Value)) { Weather(); } } if (Time.time > _nextGroup) { _nextGroup = Time.time + 2f; GroupReveal(localPlayer); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)ex.Message); } } private static string Label(string prefab) { string text = prefab.ToLowerInvariant(); if (text.Contains("eikthyrnir") || text.Contains("gdking") || text.Contains("bonemass") || text.Contains("dragonqueen") || text.Contains("goblinking") || text.Contains("bossentrance") || text.Contains("fader")) { return "Boss altar"; } if (text.Contains("sunkencrypt")) { return "Sunken crypt"; } if (text.Contains("crypt")) { return "Burial chambers"; } if (text.Contains("trollcave")) { return "Troll cave"; } if (text.Contains("mountaincave")) { return "Frost cave"; } if (text.Contains("dvergrtownentrance")) { return "Infested mine"; } if (text.Contains("goblincamp")) { return "Fuling camp"; } if (text.Contains("woodvillage") || text.Contains("woodfarm")) { return "Draugr village"; } if (text.Contains("charredfortress")) { return "Fortress"; } if (text.Contains("morgenhole")) { return "Morgen hole"; } return null; } private static string PrefabName(GameObject go) { string name = ((Object)go).name; int num = name.IndexOf("(Clone)", StringComparison.Ordinal); return ((num >= 0) ? name.Substring(0, num) : name).Trim(); } private static void Landmarks(Player p) { //IL_005e: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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) List<Location> list = s_locations.Invoke(); if (list == null) { return; } if (s_similar == null) { s_similar = AccessTools.Method(typeof(Minimap), "HaveSimilarPin", (Type[])null, (Type[])null); } foreach (Location item in list) { if ((Object)(object)item == (Object)null || Vector3.Distance(((Component)item).transform.position, ((Component)p).transform.position) > LandmarkRange.Value) { continue; } string text = Label(PrefabName(((Component)item).gameObject)); if (text == null && (item.m_hasInterior || (Object)(object)item.m_generator != (Object)null)) { text = "Dungeon"; } if (text == null) { continue; } Vector3 position = ((Component)item).transform.position; bool flag = false; foreach (PinData item2 in Traverse.Create((object)Minimap.instance).Field("m_pins").GetValue<List<PinData>>()) { if (item2 != null && Vector3.Distance(item2.m_pos, position) < 25f) { flag = true; break; } } if (!flag) { Minimap.instance.AddPin(position, (PinType)3, text, true, false, 0L, default(PlatformUserID)); Api.Note("Landmark sense: " + text + " marked on your map."); } } } private static void Weather() { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null || (Object)(object)ZNet.instance == (Object)null || instance.m_environmentDuration <= 0) { return; } long num = (long)ZNet.instance.GetTimeSeconds(); long num2 = num / instance.m_environmentDuration; long num3 = (num2 + 1) * instance.m_environmentDuration - num; EnvSetup currentEnvironment = instance.GetCurrentEnvironment(); if ((float)num3 <= WeatherWarn.Value) { EnvSetup val = PredictEnv(instance, num2 + 1); string text = "env" + (num2 + 1); if (val != null && currentEnvironment != null && val.m_name != currentEnvironment.m_name && Stormy(val) && !Stormy(currentEnvironment) && s_warned != text) { s_warned = text; Api.Message("Weather eye: a storm is coming in about " + Mathf.Max(10, (int)num3) + " seconds."); } } if (Wind(instance, num, out var angle, out var _) && Wind(instance, num + (long)WeatherWarn.Value, out var angle2, out var _)) { float num4 = Mathf.Abs(Mathf.DeltaAngle(angle * 57.29578f, angle2 * 57.29578f)); string text2 = "wind" + num / 120; if (num4 >= 60f && s_warned != text2 && !s_warned.StartsWith("wind" + (num / 120 - 1), StringComparison.Ordinal)) { s_warned = text2; Vector3 dir = default(Vector3); ((Vector3)(ref dir))..ctor(Mathf.Sin(angle2), 0f, Mathf.Cos(angle2)); Api.Message("Weather eye: the wind will turn soon - it will blow toward the " + Compass(dir) + "."); } } } private static bool Stormy(EnvSetup e) { if (e.m_name != null) { if (e.m_name.IndexOf("storm", StringComparison.OrdinalIgnoreCase) < 0 && e.m_name.IndexOf("Rain", StringComparison.Ordinal) < 0) { return e.m_name.IndexOf("Snow", StringComparison.Ordinal) >= 0; } return true; } return false; } private static EnvSetup PredictEnv(EnvMan em, long period) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown if (s_selectEnv == null) { s_selectEnv = AccessTools.Method(typeof(EnvMan), "SelectWeightedEnvironment", (Type[])null, (Type[])null); s_getBiome = AccessTools.Method(typeof(EnvMan), "GetBiome", (Type[])null, (Type[])null); } object obj = s_getBiome.Invoke(em, null); List<EnvEntry> list = (List<EnvEntry>)AccessTools.Method(typeof(EnvMan), "GetAvailableEnvironments", (Type[])null, (Type[])null).Invoke(em, new object[1] { obj }); if (list == null || list.Count == 0) { return null; } State state = Random.state; try { Random.InitState((int)period); return (EnvSetup)s_selectEnv.Invoke(em, new object[1] { list }); } finally { Random.state = state; } } private static bool Wind(EnvMan em, long time, out float angle, out float intensity) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) angle = 0f; intensity = 0.5f; if (s_windOctave == null) { s_windOctave = AccessTools.Method(typeof(EnvMan), "AddWindOctave", (Type[])null, (Type[])null); } if (s_windOctave == null) { return false; } State state = Random.state; try { object[] array = new object[4] { time, 1, angle, intensity }; int[] array2 = new int[4] { 1, 2, 4, 8 }; foreach (int num in array2) { array[1] = num; s_windOctave.Invoke(em, array); } angle = (float)array[2]; intensity = (float)array[3]; return true; } finally { Random.state = state; } } private static string Compass(Vector3 dir) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) string[] obj = new string[8] { "north", "north-east", "east", "south-east", "south", "south-west", "west", "north-west" }; float num = Mathf.Atan2(dir.x, dir.z) * 57.29578f; if (num < 0f) { num += 360f; } return obj[Mathf.RoundToInt(num / 45f) % 8]; } private static void Swim(Player p) { if (!s_baseSwim.HasValue) { s_baseSwim = ((Character)p).m_swimSpeed; } float num = (Api.HasPerk("Exploration", TrailLevel.Value) ? (s_baseSwim.Value * (1f + TrailSwim.Value)) : s_baseSwim.Value); if (Math.Abs(((Character)p).m_swimSpeed - num) > 0.001f) { ((Character)p).m_swimSpeed = num; } } private static void GroupReveal(Player p) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)p).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && component.IsOwner()) { float num = (Api.HasPerk("Exploration", GroupLevel.Value) ? Minimap.instance.m_exploreRadius : 0f); if (Math.Abs(component.GetZDO().GetFloat("vp_cart_r", 0f) - num) > 0.5f) { component.GetZDO().Set("vp_cart_r", num); } } foreach (Player item in Api.GroupMembersNear(((Component)p).transform.position, GroupRange.Value)) { ZNetView component2 = ((Component)item).GetComponent<ZNetView>(); float num2 = (((Object)(object)component2 != (Object)null && component2.IsValid()) ? component2.GetZDO().GetFloat("vp_cart_r", 0f) : 0f); if (!(num2 <= 0f)) { if (s_explore == null) { s_explore = AccessTools.Method(typeof(Minimap), "Explore", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); } s_explore.Invoke(Minimap.instance, new object[2] { ((Component)item).transform.position, num2 }); } } } private static string Pathfind() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected I4, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ZRoutedRpc.instance == null) { return null; } if (Content.UsedToday("pathfinder")) { return "Pathfinder can be used again tomorrow."; } ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetServerPeer() : null); if (val == null) { return "Pathfinder only works on a server."; } ZRoutedRpc.instance.InvokeRoutedRPC(val.m_uid, "VP_Pathfind2", new object[2] { ((Component)localPlayer).transform.position, (int)localPlayer.GetCurrentBiome() }); return "You study the land..."; } private static List<KeyValuePair<Vector3, string>> Candidates(Vector3 pos, int biome, int max) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_00b2: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) List<KeyValuePair<float, KeyValuePair<Vector3, string>>> list = new List<KeyValuePair<float, KeyValuePair<Vector3, string>>>(); string[] array = PathTargets.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (LocationInstance value in ZoneSystem.instance.m_locationInstances.Values) { if (value.m_location == null || (value.m_location.m_biome & biome) == 0) { continue; } string text = value.m_location.m_prefabName ?? ""; bool flag = false; string[] array2 = array; foreach (string text2 in array2) { if (text.IndexOf(text2.Trim(), StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; break; } } float num = Vector3.Distance(value.m_position, pos); if (flag && num >= PathMinDistance.Value) { list.Add(new KeyValuePair<float, KeyValuePair<Vector3, string>>(num, new KeyValuePair<Vector3, string>(value.m_position, Label(text) ?? "Dungeon"))); } } list.Sort((KeyValuePair<float, KeyValuePair<Vector3, string>> a, KeyValuePair<float, KeyValuePair<Vector3, string>> b) => a.Key.CompareTo(b.Key)); List<KeyValuePair<Vector3, string>> list2 = new List<KeyValuePair<Vector3, string>>(); for (int num2 = 0; num2 < list.Count && num2 < max; num2++) { list2.Add(list[num2].Value); } return list2; } private static void Server_Pathfind2(long sender, Vector3 pos, int biome) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZoneSystem.instance == (Object)null) { return; } ZPackage val = new ZPackage(); List<KeyValuePair<Vector3, string>> list = Candidates(pos, biome, 8); val.Write(list.Count); foreach (KeyValuePair<Vector3, string> item in list) { val.Write(item.Key); val.Write(item.Value); } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "VP_PathfindResult2", new object[1] { val }); } private static bool AlreadyKnown(Vector3 where) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e5: 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) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { return false; } try { if (s_isExplored == null) { s_isExplored = AccessTools.Method(typeof(Minimap), "IsExplored", new Type[1] { typeof(Vector3) }, (Type[])null); } if (s_isExplored != null && (bool)s_isExplored.Invoke(instance, new object[1] { where })) { return true; } List<PinData> list = s_pins.Invoke(instance); if (list != null) { float num = PathFuzz.Value * 0.5f + 10f; foreach (PinData item in list) { if (item != null) { float num2 = Vector2.Distance(new Vector2(item.m_pos.x, item.m_pos.z), new Vector2(where.x, where.z)); bool flag = item.m_name != null && item.m_name.StartsWith("Pathfinder:", StringComparison.Ordinal); if (num2 <= 50f || (flag && num2 <= num)) { return true; } } } } } catch { } return false; } private static void Client_PathfindResult2(long sender, ZPackage pkg) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || pkg == null) { return; } try { int num = pkg.ReadInt(); bool flag = num > 0; for (int i = 0; i < num; i++) { Vector3 val = pkg.ReadVector3(); string what = pkg.ReadString(); if (!AlreadyKnown(val)) { Client_PathfindResult(sender, ok: true, val, what); return; } } Api.Message(flag ? "Pathfinder: you already know every place nearby. Try again further afield." : "Pathfinder: nothing left to find in this land."); } catch (Exception ex) { Debug.LogWarning((object)("VargheimExploration: " + ex.Message)); } } private static void Server_Pathfind(long sender, Vector3 pos, int biome) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZoneSystem.instance == (Object)null) { return; } string[] array = PathTargets.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); float num = float.MaxValue; Vector3 val = Vector3.zero; string text = ""; foreach (LocationInstance value in ZoneSystem.instance.m_locationInstances.Values) { if (value.m_location == null || (value.m_location.m_biome & biome) == 0) { continue; } string text2 = value.m_location.m_prefabName ?? ""; bool flag = false; string[] array2 = array; foreach (string text3 in array2) { if (text2.IndexOf(text3.Trim(), StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; break; } } if (flag) { float num2 = Vector3.Distance(value.m_position, pos); if (num2 >= PathMinDistance.Value && num2 < num) { num = num2; val = value.m_position; text = Label(text2) ?? "Dungeon"; } } } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "VP_PathfindResult", new object[3] { num < float.MaxValue, val, text }); } private static void Client_PathfindResult(long sender, bool ok, Vector3 where, string what) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_00e6: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if (!ok) { Api.Message("Pathfinder: nothing left to find in this land."); return; } Content.MarkUsedToday("pathfinder"); Vector2 val = Random.insideUnitCircle * (PathFuzz.Value * 0.5f); Vector3 val2 = where + new Vector3(val.x, 0f, val.y); Vector3 dir = where - ((Component)localPlayer).transform.position; dir.y = 0f; float num = ((Vector3)(ref dir)).magnitude / 1000f; if ((Object)(object)Minimap.instance != (Object)null) { Minimap.instance.AddPin(val2, (PinType)3, "Pathfinder: " + what + "?", true, false, 0L, default(PlatformUserID)); } Api.Message("Pathfinder: a " + what.ToLowerInvariant() + " lies to the " + Compass(dir) + ", about " + num.ToString("0.0") + " km. Marked on your map."); } } [HarmonyPatch] internal static class Pins { private sealed class Icon { public string Key; public string Prefix; public string Sprite; public Color Tint = Color.white; public PinType Base = (PinType)2; public Sprite Cached; } internal static ConfigEntry<string> LandmarkIcons; internal static ConfigEntry<string> PlayerIcons; internal static ConfigEntry<bool> IconBar; internal static ConfigEntry<float> IconScale; private const string DataKey = "vargheim.pins"; private static readonly Dictionary<string, Icon> s_landmarks = new Dictionary<string, Icon>(StringComparer.OrdinalIgnoreCase); private static readonly List<Icon> s_player = new List<Icon>(); private static readonly ConditionalWeakTable<PinData, Icon> s_applied = new ConditionalWeakTable<PinData, Icon>(); private static readonly List<GameObject> s_buttons = new List<GameObject>(); private static readonly List<GameObject> s_highlights = new List<GameObject>(); private static Icon s_pending; private static bool s_placing; private static bool s_selfSelect; private static Minimap s_builtFor; internal static void Bind(ConfigFile cfg) { LandmarkIcons = cfg.Bind<string>("Pins", "Landmarks", "Boss altar=Boss:#ffd166, Sunken crypt=TrophyDraugr:#9bd37a, Burial chambers=TrophySkeleton:#c9c9c9, Troll cave=TrophyFrostTroll:#7fb8ff, Frost cave=TrophyUlv:#bfe9ff, Infested mine=TrophySeeker:#d6a8ff, Fuling camp=TrophyGoblin:#ffb070, Dungeon=Icon3:#ffffff, Pathfinder=Icon4:#ffd166", "Icon and colour for Landmark Sense / Pathfinder pins: Label=Icon:#colour, ... Labels are the pin names Landmark Sense writes; 'Pathfinder' covers Pathfinder pins."); PlayerIcons = cfg.Bind<string>("Pins", "PlayerIcons", "Ore=skill.Pickaxes:#ffd27f:Icon2, Wood=skill.WoodCutting:#9be37a:Icon2, Danger=skill.Swords:#ff6b6b:Icon1, Dungeon=skill.Sneak:#c9c9c9:Icon1, Trader=Coins:#ffd700:Icon0, Fishing=skill.Fishing:#7fd0ff:Icon3, Dock=skill.Swim:#a0c8ff:Icon3, Camp=se.Rested:#ffcc80:Icon0, Farm=Carrot:#9be37a:Icon2, Honey=Honey:#ffcc33:Icon2, Hunt=skill.Bows:#e0b080:Icon1, Water=se.Wet:#80c0ff:Icon3", "Extra pin icons on the map's icon bar: Name=Icon:#colour:BaseType[:default pin name], ... Icon is a vanilla pin type (Icon0-Icon4, Boss...), an item prefab (Carrot), or one of the game's white symbol icons: skill.<Skill> (Pickaxes, WoodCutting, Swords, Bows, Fishing, Swim, Sneak, Run, Ride...), loc.<location> (Vendor_BlackForest, Eikthyrnir, GDKing, Bonemass...), se.<status effect> (Wet, Rested, Cold, Burning, Poison...). BaseType is the vanilla pin type the pin counts as for the map filters. The default pin name (emoji allowed) is pre-filled when you place the pin; leave it out to pre-fill the Name."); IconBar = cfg.Bind<bool>("Pins", "IconBar", true, "Add the PlayerIcons to the map's icon bar (client side)."); IconScale = cfg.Bind<float>("Pins", "IconScale", 0.6f, "Size of the extra icons relative to the vanilla ones (0.3-1). The extra grid starts level with the top of the vanilla bar and uses as many rows as the vanilla bar at this size, so smaller icons leave the bottom of the screen free."); Load(); LandmarkIcons.SettingChanged += delegate { Load(); }; PlayerIcons.SettingChanged += delegate { Load(); s_builtFor = null; }; } private static void Load() { s_landmarks.Clear(); s_player.Clear(); foreach (string item in Split(LandmarkIcons.Value)) { int num = item.IndexOf('='); if (num > 0) { Icon icon = Parse(item.Substring(0, num).Trim(), item.Substring(num + 1)); if (icon != null) { s_landmarks[icon.Key] = icon; } } } foreach (string item2 in Split(PlayerIcons.Value)) { int num2 = item2.IndexOf('='); if (num2 > 0) { Icon icon2 = Parse(item2.Substring(0, num2).Trim(), item2.Substring(num2 + 1)); if (icon2 != null && icon2.Key.Length > 0) { s_player.Add(icon2); } } } } private static IEnumerable<string> Split(string s) { return (s ?? string.Empty).Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); } private static Icon Parse(string key, string value) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_006e: Unknown result type (might be due to invalid IL or missing references) string[] array = value.Trim().Split(':'); if (array.Length == 0 || array[0].Trim().Length == 0) { return null; } Icon icon = new Icon { Key = key, Sprite = array[0].Trim(), Prefix = key }; Color tint = default(Color); for (int i = 1; i < array.Length; i++) { string text = array[i].Trim(); if (text.StartsWith("#", StringComparison.Ordinal) && ColorUtility.TryParseHtmlString(text, ref tint)) { icon.Tint = tint; continue; } bool flag = false; try { icon.Base = (PinType)Enum.Parse(typeof(PinType), text, ignoreCase: true); flag = true; } catch { } if (!flag) { icon.Prefix = string.Join(":", array, i, array.Length - i).Trim(); break; } } return icon; } private static Sprite SpriteOf(Icon ic) { //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ic.Cached != (Object)null) { return ic.Cached; } try { int num = ic.Sprite.IndexOf('.'); if (num > 0) { string text = ic.Sprite.Substring(0, num).ToLowerInvariant(); string text2 = ic.Sprite.Substring(num + 1); if (text == "skill") { SkillType val = (SkillType)Enum.Parse(typeof(SkillType), text2, ignoreCase: true); Player localPlayer = Player.m_localPlayer; Skills val2 = (((Object)(object)localPlayer != (Object)null) ? ((Character)localPlayer).GetSkills() : null); if ((Object)(object)val2 != (Object)null && val2.m_skills != null) { foreach (SkillDef skill in val2.m_skills) { if (skill != null && skill.m_skill == val) { ic.Cached = skill.m_icon; break; } } } return ic.Cached; } if (text == "loc" && (Object)(object)Minimap.instance != (Object)null && Minimap.instance.m_locationIcons != null) { foreach (LocationSpriteData locationIcon in Minimap.instance.m_locationIcons) { if (string.Equals(locationIcon.m_name, text2, StringComparison.OrdinalIgnoreCase)) { ic.Cached = locationIcon.m_icon; break; } } return ic.Cached; } if (text == "se" && (Object)(object)ObjectDB.instance != (Object)null) { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(text2)); ic.Cached = (((Object)(object)statusEffect != (Object)null) ? statusEffect.m_icon : null); return ic.Cached; } } bool flag = false; PinType val3; try { val3 = (PinType)Enum.Parse(typeof(PinType), ic.Sprite, ignoreCase: true); flag = true; } catch { val3 = (PinType)3; } if (flag && (Object)(object)Minimap.instance != (Object)null) { ic.Cached = Traverse.Create((object)Minimap.instance).Method("GetSprite", new object[1] { val3 }).GetValue<Sprite>(); } else if ((Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(ic.Sprite); ItemDrop val4 = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val4 != (Object)null && val4.m_itemData != null && val4.m_itemData.m_shared != null && val4.m_itemData.m_shared.m_icons != null && val4.m_itemData.m_shared.m_icons.Length != 0) { ic.Cached = val4.m_itemData.m_shared.m_icons[0]; } } } catch (Exception ex) { Debug.LogWarning((object)("VargheimExploration pin icon '" + ic.Sprite + "': " + ex.Message)); } return ic.Cached; } private static void Apply(PinData pin, Icon ic) { if (pin == null || ic == null) { return; } Sprite val = SpriteOf(ic); if ((Object)(object)val != (Object)null) { pin.m_icon = val; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val; } } if (s_applied.TryGetValue(pin, out var _)) { s_applied.Remove(pin); } s_applied.Add(pin, ic); } internal static void ApplyLandmark(PinData pin, string label) { Icon icon = LandmarkIcon(label); if (icon != null) { Apply(pin, icon); } } private static Icon LandmarkIcon(string name) { if (string.IsNullOrEmpty(name)) { return null; } Icon value; if (name.StartsWith("Pathfinder:", StringComparison.OrdinalIgnoreCase)) { if (!s_landmarks.TryGetValue("Pathfinder", out value)) { return null; } return value; } if (!s_landmarks.TryGetValue(name, out value)) { return null; } return value; } private static Dictionary<string, string> Saved(Player p) { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); if ((Object)(object)p != (Object)null && p.m_customData != null && p.m_customData.TryGetValue("vargheim.pins", out var value)) { string[] array = value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { int num = text.LastIndexOf(','); if (num > 0) { dictionary[text.Substring(0, num)] = text.Substring(num + 1); } } } return dictionary; } private static void Store(Player p, Dictionary<string, string> d) { if ((Object)(object)p == (Object)null || p.m_customData == null) { return; } StringBuilder stringBuilder = new StringBuilder(); int num = 0; foreach (KeyValuePair<string, string> item in d) { if (num++ >= 1000) { break; } stringBuilder.Append(item.Key).Append(',').Append(item.Value) .Append(';'); } p.m_customData["vargheim.pins"] = stringBuilder.ToString(); } private static string PosKey(Vector3 pos) { //IL_0000: 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) return Mathf.RoundToInt(pos.x).ToString(CultureInfo.InvariantCulture) + "," + Mathf.RoundToInt(pos.z).ToString(CultureInfo.InvariantCulture); } private static Icon PlayerIcon(string key) { foreach (Icon item in s_player) { if (string.Equals(item.Key, key, StringComparison.OrdinalIgnoreCase)) { return item; } } return null; } internal unsafe static void EnsureBar(Minimap map) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: 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_0385: 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_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Expected O, but got Unknown //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Expected O, but got Unknown //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Expected O, but got Unknown //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) if (!IconBar.Value || (Object)(object)map == (Object)null || (Object)(object)s_builtFor == (Object)(object)map || s_player.Count == 0) { return; } try { foreach (GameObject s_button in s_buttons) { if ((Object)(object)s_button != (Object)null) { Object.Destroy((Object)(object)s_button); } } s_buttons.Clear(); s_highlights.Clear(); Image selectedIcon = map.m_selectedIcon0; Image selectedIcon2 = map.m_selectedIcon1; if ((Object)(object)selectedIcon == (Object)null || (Object)(object)((Component)selectedIcon).transform.parent == (Object)null) { return; } Transform parent = ((Component)selectedIcon).transform.parent; Transform parent2 = parent.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(40f, 0f); Vector2 val3 = (((Object)(object)val != (Object)null) ? val.anchoredPosition : Vector2.zero); if ((Object)(object)selectedIcon2 != (Object)null && ((Component)selectedIcon2).transform.parent is RectTransform) { val2 = ((RectTransform)((Component)selectedIcon2).transform.parent).anchoredPosition - val3; if (((Vector2)(ref val2)).sqrMagnitude < 1f) { ((Vector2)(ref val2))..ctor(40f, 0f); } } int num = 0; Vector2 val4 = (((Object)(object)val != (Object)null) ? val.anchoredPosition : Vector2.zero); Image[] array = (Image[])(object)new Image[5] { map.m_selectedIcon0, map.m_selectedIcon1, map.m_selectedIcon2, map.m_selectedIcon3, map.m_selectedIcon4 }; foreach (Image val5 in array) { RectTransform val6 = (RectTransform)(((Object)(object)val5 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val6 != (Object)null && (Object)(object)((Transform)val6).parent == (Object)(object)parent2) { num++; if (Vector2.Dot(val6.anchoredPosition - val4, val2) < 0f) { val4 = val6.anchoredPosition; } } } if (num < 1) { num = 5; } Vector2 val7 = ((Mathf.Abs(val2.y) >= Mathf.Abs(val2.x)) ? new Vector2(0f - ((Vector2)(ref val2)).magnitude, 0f) : new Vector2(0f, 0f - ((Vector2)(ref val2)).magnitude)); if ((Object)(object)val != (Object)null && val.anchoredPosition.x < 0f && Mathf.Abs(val2.y) >= Mathf.Abs(val2.x)) { ((Vector2)(ref val7))..ctor(((Vector2)(ref val2)).magnitude, 0f); } int num2 = 0; int num3 = 0; bool flag = (Object)(object)((Component)parent2).GetComponent<LayoutGroup>() != (Object)null; float num4 = Mathf.Clamp(IconScale.Value, 0.3f, 1f); float magnitude = ((Vector2)(ref val2)).magnitude; float num5 = magnitude * num4; Vector2 val8 = val2 / magnitude; Vector2 val9 = val7 / ((Vector2)(ref val7)).magnitude; int num6 = num; int num7 = (s_player.Count + num6 - 1) / num6; Vector2 val10 = val4 - val8 * (magnitude * 0.5f) + val8 * (num5 * 0.5f) + val9 * (magnitude * 0.5f + num5 * 0.5f); if (!flag && (Object)(object)val != (Object)null && num7 > 0) { GameObject val11 = new GameObject("VargheimPinPanel", new Type[2] { typeof(RectTransform), typeof(Image) }); val11.transform.SetParent(parent2, false); val11.transform.SetAsFirstSibling(); RectTransform component = val11.GetComponent<RectTransform>(); component.anchorMin = val.anchorMin; component.anchorMax = val.anchorMax; component.pivot = val.pivot; Vector2 val12 = val10; Vector2 val13 = val10 + val8 * (num5 * (float)(num6 - 1)) + val9 * (num5 * (float)(num7 - 1)); Vector2 anchoredPosition = (val12 + val13) * 0.5f; component.anchoredPosition = anchoredPosition; component.sizeDelta = new Vector2(Mathf.Abs(val13.x - val12.x) + num5, Mathf.Abs(val13.y - val12.y) + num5); Image component2 = val11.GetComponent<Image>(); ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.55f); ((Graphic)component2).raycastTarget = false; s_buttons.Add(val11); s_highlights.Add(null); } for (int j = 0; j < s_player.Count; j++) { Icon icon = s_player[j]; Sprite val14 = SpriteOf(icon); if ((Object)(object)val14 == (Object)null) { num3++; continue; } GameObject val15 = Object.Instantiate<GameObject>(((Component)parent).gameObject, parent2); num2++; ((Object)val15).name = "VargheimPin_" + icon.Key; Transform transform = val15.transform; RectTransform val16 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val16 != (Object)null && !flag) { val16.anchoredPosition = val10 + val8 * (num5 * (float)(j % num6)) + val9 * (num5 * (float)(j / num6)); val16.sizeDelta = val.sizeDelta * num4; foreach (RectTransform item in (Transform)val16) { item.sizeDelta *= num4; } } Image component3 = val15.GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { component3.sprite = val14; ((Graphic)component3).color = icon.Tint; } GameObject val18 = null; Transform val19 = val15.transform.Find(((Object)selectedIcon).name); if ((Object)(object)val19 != (Object)null) { val18 = ((Component)val19).gameObject; val18.SetActive(false); Image component4 = val18.GetComponent<Image>(); if ((Object)(object)component4 != (Object)null) { ((Behaviour)component4).enabled = false; } } Button component5 = val15.GetComponent<Button>(); if ((Object)(object)component5 != (Object)null) { component5.onClick = new ButtonClickedEvent(); Icon pick = icon; ((UnityEvent)component5.onClick).AddListener((UnityAction)delegate { Pick(map, pick); }); } UITooltip component6 = val15.GetComponent<UITooltip>(); if ((Object)(object)component6 != (Object)null) { component6.m_text = icon.Key; } s_buttons.Add(val15); s_highlights.Add(val18); } string[] obj = new string[14] { "VargheimExploration pins: icon bar '", ((Object)parent2).name, "' layout=", flag.ToString(), " vanilla=", num.ToString(), " step=", null, null, null, null, null, null, null }; Vector2 val20 = val2; obj[7] = ((object)(*(Vector2*)(&val20))/*cast due to .constrained prefix*/).ToString(); obj[8] = " first="; val20 = val4; obj[9] = ((object)(*(Vector2*)(&val20))/*cast due to .constrained prefix*/).ToString(); obj[10] = " made="; obj[11] = num2.ToString(); obj[12] = " noSprite="; obj[13] = num3.ToString(); Debug.Log((object)string.Concat(obj)); s_builtFor = map; } catch (Exception ex) { Debug.LogWarning((object)("VargheimExploration pin icon bar: " + ex)); s_builtFor = map; } } private static void Pick(Minimap map, Icon ic) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) s_pending = ic; s_selfSelect = true; try { Traverse.Create((object)map).Method("SelectIcon", new object[1] { ic.Base }).GetValue(); } finally { s_selfSelect = false; } Dictionary<PinType, Image> value = Traverse.Create((object)map).Field("m_selectedIcons").GetValue<Dictionary<PinType, Image>>(); if (value != null && value.TryGetValue(ic.Base, out var value2) && (Object)(object)value2 != (Object)null) { ((Behaviour)value2).enabled = false; } Highlight(ic); } private static void Highlight(Icon ic) { for (int i = 0; i < s_buttons.Count && i < s_highlights.Count; i++) { GameObject val = s_highlights[i]; if (!((Object)(object)val == (Object)null)) { bool flag = ic != null && (Object)(object)s_buttons[i] != (Object)null && ((Object)s_buttons[i]).name == "VargheimPin_" + ic.Key; val.SetActive(flag); Image component = val.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = flag; } } } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] [HarmonyPostfix] private static void Minimap_SetMapMode(Minimap __instance, MapMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)mode == 2) { EnsureBar(__instance); } } [HarmonyPatch(typeof(Minimap), "SelectIcon")] [HarmonyPostfix] private static void Minimap_SelectIcon() { if (!s_selfSelect) { s_pending = null; Highlight(null); } } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] [HarmonyPrefix] private static void Minimap_ShowPinNameInput_Pre() { s_placing = true; } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] [HarmonyPostfix] private static void Minimap_ShowPinNameInput_Post(Minimap __instance) { s_placing = false; try { if (s_pending != null && !string.IsNullOrEmpty(s_pending.Prefix) && (Object)(object)__instance != (Object)null && (Object)(object)__instance.m_nameInput != (Object)null) { ((TMP_InputField)__instance.m_nameInput).text = s_pending.Prefix; ((TMP_InputField)__instance.m_nameInput).caretPosition = ((TMP_InputField)__instance.m_nameInput).text.Length; } } catch { } } [HarmonyPatch(typeof(Minimap), "AddPin")] [HarmonyPostfix] private static void Minimap_AddPin(PinData __result, Vector3 pos, string name, bool save, long ownerID) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (__result == null) { return; } try { if (s_placing && s_pending != null) { Apply(__result, s_pending); Player localPlayer = Player.m_localPlayer; Dictionary<string, string> dictionary = Saved(localPlayer); dictionary[PosKey(pos)] = s_pending.Key; Store(localPlayer, dictionary); } else if (save && ownerID == 0L) { Icon icon = LandmarkIcon(name); if (icon == null && Saved(Player.m_localPlayer).TryGetValue(PosKey(pos), out var value)) { icon = PlayerIcon(value); } if (icon != null) { Apply(__result, icon); } } } catch (Exception ex) { Debug.LogWarning((object)("VargheimExploration pin: " + ex.Message)); } } [HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })] [HarmonyPrefix] private static void Minimap_RemovePin(PinData pin) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) try { if (pin != null && s_applied.TryGetValue(pin, out var value) && PlayerIcon(value.Key) == value) { Player localPlayer = Player.m_localPlayer; Dictionary<string, string> dictionary = Saved(localPlayer); if (dictionary.Remove(PosKey(pin.m_pos))) { Store(localPlayer, dictionary); } } } catch { } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] [HarmonyPostfix] private static void Minimap_UpdatePins(Minimap __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) List<PinData> value = Traverse.Create((object)__instance).Field("m_pins").GetValue<List<PinData>>(); if (value == null) { return; } for (int i = 0; i < value.Count; i++) { PinData val = value[i]; if (val != null && (Object)(object)val.m_iconElement != (Object)null && s_applied.TryGetValue(val, out var value2)) { if (val.m_ownerID == 0L) { ((Graphic)val.m_iconElement).color = value2.Tint; } if ((Object)(object)val.m_icon != (Object)null && (Object)(object)val.m_iconElement.sprite != (Object)(object)val.m_icon) { val.m_iconElement.sprite = val.m_icon; } } } } } }