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 VargheimPins v0.1.5
VargheimPins.dll
Decompiled 6 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [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 VargheimPins { [BepInPlugin("digi.vargheim.pins", "VargheimPins", "0.1.5")] public class Plugin : BaseUnityPlugin { public const string Guid = "digi.vargheim.pins"; public const string Version = "0.1.5"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> PickerOn; internal static ConfigEntry<bool> PrefillName; internal static ConfigEntry<bool> HoverNames; internal static ConfigEntry<bool> DeOverlap; internal static ConfigEntry<bool> AutoPins; internal static ConfigEntry<bool> HoverTint; internal static ConfigEntry<bool> PlayerColors; internal static ConfigEntry<string> PlayerPalette; internal static ConfigEntry<string> InkHex; internal static ConfigEntry<string> LabelIcons; internal static ConfigEntry<string> AutoTypes; internal static ConfigEntry<float> PickerScale; internal static ConfigEntry<float> PickerX; internal static ConfigEntry<float> PickerY; internal static ConfigEntry<float> NamesZoom; internal static ConfigEntry<float> HoverRadius; internal static ConfigEntry<float> AutoRange; internal static ConfigEntry<float> PinScale; internal static ConfigEntry<int> PickerColumns; internal static Color Ink = new Color(0.17f, 0.11f, 0.06f); internal static readonly Color Paper = new Color(0.89f, 0.85f, 0.75f); internal static readonly Color Gold = new Color(0.8f, 0.67f, 0.39f); internal static readonly (string key, string label, PinType baseType)[] Types = new(string, string, PinType)[24] { ("copper", "Copper", (PinType)2), ("tin", "Tin", (PinType)2), ("silver", "Silver", (PinType)2), ("stone", "Stone", (PinType)2), ("berries", "Raspberries", (PinType)3), ("blueberries", "Blueberries", (PinType)3), ("mushrooms", "Mushrooms", (PinType)3), ("thistle", "Thistle", (PinType)3), ("wreck", "Shipwreck", (PinType)1), ("burial", "Burial chamber", (PinType)0), ("cave", "Cave", (PinType)0), ("trollcave", "Troll cave", (PinType)0), ("crypt", "Sunken crypt", (PinType)0), ("frostcave", "Frost cave", (PinType)0), ("mine", "Infested mine", (PinType)0), ("tarpit", "Tar pit", (PinType)0), ("portal", "Portal", (PinType)6), ("base", "Base", (PinType)1), ("landing", "Boat landing", (PinType)1), ("poi", "Point of interest", (PinType)3), ("danger", "Danger", (PinType)1), ("bear", "Bear", (PinType)1), ("fish", "Fish", (PinType)3), ("seamonster", "Sea monster", (PinType)1) }; internal static readonly Dictionary<string, Sprite> S = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); private void Awake() { //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Pins", "Enabled", true, "Vargheim pins on. Off = vanilla pins and icon bar (needs a relaunch to go back)."); InkHex = ((BaseUnityPlugin)this).Config.Bind<string>("Pins", "Ink", "#f4eedd", "Colour of the pin glyphs on the map (hex). Paper white by default; #2b1d10 for dark ink."); PinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Pins", "PinScale", 0.95f, "Size of our glyph pins relative to vanilla pins."); LabelIcons = ((BaseUnityPlugin)this).Config.Bind<string>("Pins", "LabelIcons", "Burial chambers=burial, Burial chamber=burial, Sunken crypt=crypt, Troll cave=trollcave, Frost cave=frostcave, Infested mine=mine, Dungeon=cave, Tar pit=tarpit, Trader=poi, Point of interest=poi, POI=poi, Shipwreck=wreck, Wreck=wreck, Boss altar=danger, Portal=portal, Base=base, Copper=copper, Tin=tin, Silver=silver, Bear=bear, Fish=fish, Fishing=fish, Sea monster=seamonster, Serpent=seamonster", "Pins whose name is one of these labels get the glyph: Label=key, ... Covers Landmark Sense pins and pins typed by hand. Keys: " + string.Join(" ", KeyList())); PickerOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Picker", "Enabled", true, "Show the glyph picker on the big map (left of the vanilla icon column)."); PickerColumns = ((BaseUnityPlugin)this).Config.Bind<int>("Picker", "Columns", 4, "Columns in the picker grid."); PickerX = ((BaseUnityPlugin)this).Config.Bind<float>("Picker", "OffsetX", 0f, "Nudge the picker grid right (+) / left (-) in pixels."); PickerY = ((BaseUnityPlugin)this).Config.Bind<float>("Picker", "OffsetY", 0f, "Nudge the picker grid up (+) / down (-) in pixels."); PickerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Picker", "Scale", 0.62f, "Picker cell size relative to the vanilla icon buttons (0.4-1)."); ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[4] { (ConfigEntryBase)PickerColumns, (ConfigEntryBase)PickerScale, (ConfigEntryBase)PickerX, (ConfigEntryBase)PickerY }; foreach (ConfigEntryBase e in array) { e.ConfigFile.SettingChanged += delegate(object o, SettingChangedEventArgs a) { if (a.ChangedSetting == e) { Picker.Reset(); } }; } PrefillName = ((BaseUnityPlugin)this).Config.Bind<bool>("Picker", "PrefillName", true, "Pre-fill the pin name box with the glyph's label (clear it for a nameless pin)."); NamesZoom = ((BaseUnityPlugin)this).Config.Bind<float>("Names", "ShowZoom", 0f, "Zoom level below which pin names are drawn on the big map (smaller = zoomed in further). 0 = the game's own value (logged at map start)."); HoverNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "Hover", true, "Show a pin's name while the mouse is over it, whatever the zoom."); HoverRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Names", "HoverRadius", 18f, "Mouse distance (screen pixels at 1080p) that counts as over a pin."); HoverTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "HoverTint", true, "Tint the hovered glyph gold."); DeOverlap = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "DeOverlap", true, "Hide pin names that would draw over another name (hovered and checked pins win)."); PlayerColors = ((BaseUnityPlugin)this).Config.Bind<bool>("Players", "Colors", true, "Give every other player's map marker and name its own colour (stable per name, the same on every client)."); PlayerPalette = ((BaseUnityPlugin)this).Config.Bind<string>("Players", "Palette", "#4fc3f7, #81c784, #ffd54f, #ff8a65, #ba68c8, #4db6ac, #f06292, #aed581, #ffb74d, #7986cb", "Colours handed out to players (hex, comma separated)."); AutoPins = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "Enabled", false, "Pin dungeons, caves, pits and the trader automatically when you walk up to them."); AutoRange = ((BaseUnityPlugin)this).Config.Bind<float>("AutoPins", "Range", 40f, "Distance (m) at which an auto-pin is placed."); AutoTypes = ((BaseUnityPlugin)this).Config.Bind<string>("AutoPins", "Types", "trollcave=trollcave, sunkencrypt=crypt, crypt=burial, mountaincave=frostcave, dvergrtownentrance=mine, tarpit=tarpit, vendor=poi, hildir=poi, mistlands_guardtower=danger, goblincamp=danger", "Location prefab name (substring, lower case) = pin key, first match wins; order matters (sunkencrypt before crypt)."); Color ink = default(Color); if (ColorUtility.TryParseHtmlString(InkHex.Value, ref ink)) { Ink = ink; } if (!Enabled.Value) { Log.LogInfo((object)"VargheimPins off (Pins.Enabled = false)."); return; } LoadSprites(); if (S.Count == 0) { Log.LogWarning((object)"VargheimPins: no pin_*.png found beside the DLL; mod disabled for this session."); return; } Pins.Load(); Harmony val = new Harmony("digi.vargheim.pins"); val.PatchAll(typeof(Patches)); Compat.Exploration(val); Log.LogInfo((object)("VargheimPins 0.1.5 loaded (" + (S.Count - (S.ContainsKey("glow") ? 1 : 0)) + " glyphs).")); } private void Update() { if (Enabled.Value && S.Count > 0) { Auto.Tick(); } } internal static IEnumerable<string> KeyList() { (string key, string label, PinType baseType)[] types = Types; for (int i = 0; i < types.Length; i++) { (string, string, PinType) tuple = types[i]; yield return tuple.Item1; } } internal static bool IsKey(string k) { (string, string, PinType)[] types = Types; for (int i = 0; i < types.Length; i++) { if (string.Equals(types[i].Item1, k, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static string LabelOf(string k) { (string, string, PinType)[] types = Types; for (int i = 0; i < types.Length; i++) { (string, string, PinType) tuple = types[i]; if (string.Equals(tuple.Item1, k, StringComparison.OrdinalIgnoreCase)) { return tuple.Item2; } } return k; } internal static PinType BaseOf(string k) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) (string, string, PinType)[] types = Types; for (int i = 0; i < types.Length; i++) { (string, string, PinType) tuple = types[i]; if (string.Equals(tuple.Item1, k, StringComparison.OrdinalIgnoreCase)) { return tuple.Item3; } } return (PinType)3; } private void LoadSprites() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00cf: Expected O, but got Unknown //IL_0100: 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) string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string[] array = new string[2] { directoryName, Path.Combine(directoryName, "assets") }; foreach (string item in new List<string>(KeyList()) { "glow" }) { string text = null; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = Path.Combine(array2[i], "pin_" + item + ".png"); if (File.Exists(text2)) { text = text2; break; } } if (text == null) { Log.LogWarning((object)("missing glyph pin_" + item + ".png")); continue; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; ImageConversion.LoadImage(val, File.ReadAllBytes(text)); S[item] = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } } } internal static class Pins { private const string DataKey = "vargheim.pins2"; internal static readonly ConditionalWeakTable<PinData, string> Applied = new ConditionalWeakTable<PinData, string>(); private static readonly Dictionary<string, string> s_labels = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); internal static string Pending; internal static bool Placing; internal static bool Restored; internal static void Load() { s_labels.Clear(); string[] array = (Plugin.LabelIcons.Value ?? "").Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { string text2 = text.Substring(0, num).Trim(); string text3 = text.Substring(num + 1).Trim(); if (text2.Length > 0 && Plugin.IsKey(text3)) { s_labels[text2] = text3; } } } Plugin.LabelIcons.SettingChanged += delegate { Load(); }; } internal static string LabelKey(string name) { if (string.IsNullOrEmpty(name)) { return null; } if (s_labels.TryGetValue(name.Trim(), out var value)) { return value; } int num = name.IndexOf(':'); if (num > 0 && s_labels.TryGetValue(name.Substring(num + 1).Trim().TrimEnd('?'), out value)) { return value; } return null; } internal static void Apply(PinData pin, string key) { if (pin != null && key != null && Plugin.S.TryGetValue(key, out var value)) { pin.m_icon = value; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = value; } if (Applied.TryGetValue(pin, out var _)) { Applied.Remove(pin); } Applied.Add(pin, key); } } internal 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); } internal 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.pins2", 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; } internal 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++ >= 2000) { break; } stringBuilder.Append(item.Key).Append(',').Append(item.Value) .Append(';'); } p.m_customData["vargheim.pins2"] = stringBuilder.ToString(); } internal static void Remember(Vector3 pos, string key) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Dictionary<string, string> dictionary = Saved(localPlayer); dictionary[PosKey(pos)] = key; Store(localPlayer, dictionary); } internal static void Restore(List<PinData> pins) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || pins == null) { return; } Restored = true; Dictionary<string, string> dictionary = Saved(localPlayer); int num = 0; foreach (PinData pin in pins) { if (pin != null && pin.m_ownerID == 0L && !Applied.TryGetValue(pin, out var _)) { if (!dictionary.TryGetValue(PosKey(pin.m_pos), out var value2)) { value2 = LabelKey(pin.m_name); } if (value2 != null) { Apply(pin, value2); num++; } } } Plugin.Log.LogInfo((object)("VargheimPins: restored glyphs on " + num + " pins (" + dictionary.Count + " saved, " + pins.Count + " on the map).")); } } internal static class Picker { private static Minimap s_builtFor; private static readonly List<GameObject> s_buttons = new List<GameObject>(); private static readonly List<Image> s_rings = new List<Image>(); private static RectTransform s_panel; internal static bool SelfSelect; private static int s_selected = -1; internal unsafe static void Ensure(Minimap map) { //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_0153: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0263: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051d: 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_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0588: 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_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: 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_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Unknown result type (might be due to invalid IL or missing references) //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_096a: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0772: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_078e: 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_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Expected O, but got Unknown //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Expected O, but got Unknown if (!Plugin.PickerOn.Value || (Object)(object)map == (Object)null || (Object)(object)s_builtFor == (Object)(object)map) { 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_rings.Clear(); if ((Object)(object)s_panel != (Object)null) { Object.Destroy((Object)(object)((Component)s_panel).gameObject); } 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); if ((Object)(object)val == (Object)null) { return; } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, -40f); if ((Object)(object)selectedIcon2 != (Object)null && ((Component)selectedIcon2).transform.parent is RectTransform) { Vector2 val3 = ((RectTransform)((Component)selectedIcon2).transform.parent).anchoredPosition - val.anchoredPosition; if (((Vector2)(ref val3)).sqrMagnitude >= 1f) { val2 = val3; } } float magnitude = ((Vector2)(ref val2)).magnitude; Vector2 val4 = val2 / magnitude; Vector2 anchoredPosition = val.anchoredPosition; int num = 0; Image[] array = (Image[])(object)new Image[8] { map.m_selectedIcon0, map.m_selectedIcon1, map.m_selectedIcon2, map.m_selectedIcon3, map.m_selectedIcon4, map.m_selectedIconDeath, map.m_selectedIconBoss, map.m_selectedIconPing }; 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 - anchoredPosition, val4) < 0f) { anchoredPosition = val6.anchoredPosition; } } } Vector2 val7 = anchoredPosition; array = (Image[])(object)new Image[5] { map.m_selectedIcon0, map.m_selectedIcon1, map.m_selectedIcon2, map.m_selectedIcon3, map.m_selectedIcon4 }; foreach (Image val8 in array) { RectTransform val9 = (RectTransform)(((Object)(object)val8 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val9 != (Object)null && (Object)(object)((Transform)val9).parent == (Object)(object)parent2 && Vector2.Dot(val9.anchoredPosition - val7, val4) > 0f) { val7 = val9.anchoredPosition; } } bool flag = Mathf.Abs(val2.y) >= Mathf.Abs(val2.x); float num2 = Mathf.Clamp(Plugin.PickerScale.Value, 0.4f, 1f); float num3 = magnitude * num2; float num4 = 6f; int num5 = Mathf.Max(1, Plugin.PickerColumns.Value); int num6 = Plugin.Types.Length; int num7 = (num6 + num5 - 1) / num5; Vector2 val10 = default(Vector2); ((Vector2)(ref val10))..ctor(1f, 0f); Vector2 val11 = default(Vector2); ((Vector2)(ref val11))..ctor(0f, 1f); Vector2 val13 = default(Vector2); if (flag) { bool num8 = val.anchoredPosition.x >= 0f || val.anchorMin.x > 0.5f; Vector2 val12 = val7 - val4 * (magnitude * 0.5f); float num9 = magnitude * 0.75f; float num10 = (num8 ? (anchoredPosition.x - magnitude * 0.5f - num9 - num3 * 0.5f) : (anchoredPosition.x + magnitude * 0.5f + num9 + ((float)num5 - 0.5f) * num3)); ((Vector2)(ref val13))..ctor(num10, val12.y + num4 + num3 * 0.5f); } else { Vector2 val14 = anchoredPosition + val11 * (magnitude * 0.5f); ((Vector2)(ref val13))..ctor(anchoredPosition.x - magnitude * 0.5f + ((float)num5 - 0.5f) * num3, val14.y + num4 + num3 * 0.5f); } val13 += new Vector2(Plugin.PickerX.Value, Plugin.PickerY.Value); Vector2 val15 = val13 - val10 * (num3 * (float)(num5 - 1)) + val11 * (num3 * (float)(num7 - 1)); GameObject val16 = new GameObject("VargheimPinsPanel", new Type[2] { typeof(RectTransform), typeof(Image) }); val16.transform.SetParent(parent2, false); val16.transform.SetAsFirstSibling(); s_panel = val16.GetComponent<RectTransform>(); s_panel.anchorMin = val.anchorMin; s_panel.anchorMax = val.anchorMax; s_panel.pivot = val.pivot; s_panel.anchoredPosition = (val15 + val13) * 0.5f; s_panel.sizeDelta = new Vector2(num3 * (float)num5 + 8f, num3 * (float)num7 + 8f); Image component = val16.GetComponent<Image>(); ((Graphic)component).color = new Color(0.05f, 0.06f, 0.08f, 0.78f); ((Graphic)component).raycastTarget = false; Plugin.S.TryGetValue("glow", out var value); Vector2 anchorMin; for (int j = 0; j < num6; j++) { (string, string, PinType) tuple = Plugin.Types[j]; if (!Plugin.S.TryGetValue(tuple.Item1, out var value2)) { continue; } GameObject val17 = Object.Instantiate<GameObject>(((Component)parent).gameObject, parent2); ((Object)val17).name = "VargheimPins_" + tuple.Item1; Transform transform = val17.transform; RectTransform val18 = (RectTransform)(object)((transform is RectTransform) ? transform : null); int num11 = j % num5; int num12 = j / num5; val18.anchoredPosition = val15 + val10 * (num3 * (float)num11) - val11 * (num3 * (float)num12); val18.sizeDelta = val.sizeDelta * num2; for (int num13 = ((Transform)val18).childCount - 1; num13 >= 0; num13--) { Object.Destroy((Object)(object)((Component)((Transform)val18).GetChild(num13)).gameObject); } Image val19 = null; if ((Object)(object)value != (Object)null) { GameObject val20 = new GameObject("glow", new Type[2] { typeof(RectTransform), typeof(Image) }); RectTransform component2 = val20.GetComponent<RectTransform>(); ((Transform)component2).SetParent((Transform)(object)val18, false); ((Transform)component2).SetAsFirstSibling(); anchorMin = (component2.anchorMax = new Vector2(0.5f, 0.5f)); component2.anchorMin = anchorMin; component2.anchoredPosition = Vector2.zero; component2.sizeDelta = val18.sizeDelta * 1.9f; val19 = val20.GetComponent<Image>(); val19.sprite = value; ((Graphic)val19).color = Plugin.Gold; ((Graphic)val19).raycastTarget = false; ((Behaviour)val19).enabled = false; } Image component3 = val17.GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { component3.sprite = value2; ((Graphic)component3).color = Plugin.Paper; component3.type = (Type)0; component3.preserveAspect = true; } Button component4 = val17.GetComponent<Button>(); if ((Object)(object)component4 != (Object)null) { component4.onClick = new ButtonClickedEvent(); var (pick, _, _) = tuple; ((UnityEvent)component4.onClick).AddListener((UnityAction)delegate { Pick(map, pick); }); } UITooltip component5 = val17.GetComponent<UITooltip>(); if ((Object)(object)component5 != (Object)null) { component5.m_text = tuple.Item2; } s_buttons.Add(val17); s_rings.Add(val19); } s_builtFor = map; ManualLogSource log = Plugin.Log; string[] obj = new string[19] { "VargheimPins picker: ", s_buttons.Count.ToString(), " glyphs, ", num5.ToString(), "x", num7.ToString(), ", cell ", num3.ToString(), ", ", flag ? "column" : "row", " bar '", ((Object)parent2).name, "' first ", null, null, null, null, null, null }; anchorMin = anchoredPosition; obj[13] = ((object)(*(Vector2*)(&anchorMin))/*cast due to .constrained prefix*/).ToString(); obj[14] = " last "; anchorMin = val7; obj[15] = ((object)(*(Vector2*)(&anchorMin))/*cast due to .constrained prefix*/).ToString(); obj[16] = " (vanilla "; obj[17] = num.ToString(); obj[18] = ")"; log.LogInfo((object)string.Concat(obj)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("VargheimPins picker: " + ex)); s_builtFor = map; } } internal static void Tick() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (s_selected >= 0 && s_selected < s_rings.Count && !((Object)(object)s_rings[s_selected] == (Object)null)) { ((Graphic)s_rings[s_selected]).color = new Color(Plugin.Gold.r, Plugin.Gold.g, Plugin.Gold.b, 0.55f + 0.35f * Mathf.PingPong(Time.unscaledTime * 1.6f, 1f)); } } private static void Pick(Minimap map, string key) { //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) Pins.Pending = key; SelfSelect = true; try { Traverse.Create((object)map).Method("SelectIcon", new object[1] { Plugin.BaseOf(key) }).GetValue(); } finally { SelfSelect = false; } Dictionary<PinType, Image> value = Traverse.Create((object)map).Field("m_selectedIcons").GetValue<Dictionary<PinType, Image>>(); if (value != null && value.TryGetValue(Plugin.BaseOf(key), out var value2) && (Object)(object)value2 != (Object)null) { ((Behaviour)value2).enabled = false; } Highlight(key); } internal static void Highlight(string key) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) s_selected = -1; for (int i = 0; i < s_buttons.Count; i++) { bool flag = key != null && (Object)(object)s_buttons[i] != (Object)null && ((Object)s_buttons[i]).name == "VargheimPins_" + key; if (flag) { s_selected = i; } if ((Object)(object)s_rings[i] != (Object)null) { ((Behaviour)s_rings[i]).enabled = flag; } Image val = (((Object)(object)s_buttons[i] != (Object)null) ? s_buttons[i].GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { ((Graphic)val).color = (flag ? Color.white : Plugin.Paper); } } } internal static void Reset() { s_builtFor = null; s_buttons.Clear(); s_rings.Clear(); s_panel = null; s_selected = -1; } } internal static class Names { private static readonly List<Rect> s_taken = new List<Rect>(64); internal static PinData Hovered; private static Camera s_cam; private static bool s_camLooked; private static readonly Vector3[] s_corners = (Vector3[])(object)new Vector3[4]; private static Camera Cam(Component any) { //IL_0037: 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) if (s_camLooked) { return s_cam; } s_camLooked = true; Canvas val = (((Object)(object)any != (Object)null) ? any.GetComponentInParent<Canvas>() : null); if ((Object)(object)val != (Object)null) { val = val.rootCanvas; s_cam = (((int)val.renderMode == 0) ? null : val.worldCamera); } Plugin.Log.LogInfo((object)("VargheimPins: GUI canvas " + (((Object)(object)val != (Object)null) ? ((object)val.renderMode/*cast due to .constrained prefix*/).ToString() : "?") + ", camera " + (((Object)(object)s_cam != (Object)null) ? ((Object)s_cam).name : "none"))); return s_cam; } internal static void ResetCam() { s_camLooked = false; s_cam = null; } internal static void Tick(Minimap map) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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) //IL_00c2: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: 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_024e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)map == (Object)null || (int)map.m_mode != 2) { Hovered = null; return; } List<PinData> value = Traverse.Create((object)map).Field("m_pins").GetValue<List<PinData>>(); if (value == null) { return; } Camera val = Cam((Component)(object)map.m_pinRootLarge); Hovered = null; if (Plugin.HoverNames.Value) { Vector2 val2 = Vector2.op_Implicit(Input.mousePosition); float num = Plugin.HoverRadius.Value * ((float)Screen.height / 1080f); num *= num; for (int i = 0; i < value.Count; i++) { PinData val3 = value[i]; if (val3 != null && !((Object)(object)val3.m_uiElement == (Object)null) && ((Component)val3.m_uiElement).gameObject.activeInHierarchy) { Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val, ((Transform)val3.m_uiElement).position) - val2; float sqrMagnitude = ((Vector2)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; Hovered = val3; } } } } s_taken.Clear(); if (Hovered != null && Hovered.m_NamePinData != null && (Object)(object)Hovered.m_NamePinData.PinNameGameObject != (Object)null && !string.IsNullOrEmpty(Hovered.m_name)) { Hovered.m_NamePinData.PinNameGameObject.SetActive(true); s_taken.Add(ScreenRect(Hovered.m_NamePinData.PinNameRectTransform, val)); } if (!Plugin.DeOverlap.Value) { return; } for (int j = 0; j < 2; j++) { for (int k = 0; k < value.Count; k++) { PinData val5 = value[k]; if (val5 == null || val5 == Hovered || val5.m_NamePinData == null || (Object)(object)val5.m_NamePinData.PinNameGameObject == (Object)null || j == 0 != val5.m_checked) { continue; } GameObject pinNameGameObject = val5.m_NamePinData.PinNameGameObject; if (!pinNameGameObject.activeSelf) { continue; } Rect val6 = ScreenRect(val5.m_NamePinData.PinNameRectTransform, val); bool flag = false; for (int l = 0; l < s_taken.Count; l++) { Rect val7 = s_taken[l]; if (((Rect)(ref val7)).Overlaps(val6)) { flag = true; break; } } if (flag) { pinNameGameObject.SetActive(false); } else { s_taken.Add(val6); } } } } private static Rect ScreenRect(RectTransform rt, Camera cam) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00ae: 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) if ((Object)(object)rt == (Object)null) { return new Rect(-9999f, -9999f, 0f, 0f); } rt.GetWorldCorners(s_corners); Vector2 val = RectTransformUtility.WorldToScreenPoint(cam, s_corners[0]); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(cam, s_corners[2]); return Rect.MinMaxRect(Mathf.Min(val.x, val2.x) - 2f, Mathf.Min(val.y, val2.y) - 1f, Mathf.Max(val.x, val2.x) + 2f, Mathf.Max(val.y, val2.y) + 1f); } } internal static class Players { private static List<Color> s_palette; private static string s_src; private static readonly Dictionary<string, Color> s_cache = new Dictionary<string, Color>(StringComparer.Ordinal); internal static Color Of(string name) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (s_palette == null || s_src != Plugin.PlayerPalette.Value) { s_palette = new List<Color>(); s_src = Plugin.PlayerPalette.Value; s_cache.Clear(); string[] array = s_src.Split(new char[3] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); Color item = default(Color); for (int i = 0; i < array.Length; i++) { if (ColorUtility.TryParseHtmlString(array[i].Trim(), ref item)) { s_palette.Add(item); } } if (s_palette.Count == 0) { s_palette.Add(Color.white); } } if (s_cache.TryGetValue(name ?? "", out var value)) { return value; } int num = StringExtensionMethods.GetStableHashCode(name ?? ""); if (num < 0) { num = -num; } value = s_palette[num % s_palette.Count]; s_cache[name ?? ""] = value; return value; } internal static void Tick(Minimap map) { //IL_004a: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.PlayerColors.Value) { return; } List<PinData> value = Traverse.Create((object)map).Field("m_playerPins").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)) { Color color = Of(val.m_name); ((Graphic)val.m_iconElement).color = color; if (val.m_NamePinData != null && (Object)(object)val.m_NamePinData.PinNameText != (Object)null) { ((Graphic)val.m_NamePinData.PinNameText).color = color; } } } } } internal static class Auto { private static float s_next; private static readonly FieldRef<List<Location>> s_all = AccessTools.StaticFieldRefAccess<List<Location>>(AccessTools.Field(typeof(Location), "s_allLocations")); private static List<(string sub, string key)> s_map; private static string s_mapSrc; internal static void Tick() { //IL_0177: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0292: 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_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.AutoPins.Value || Time.time < s_next) { return; } s_next = Time.time + 2f; Player localPlayer = Player.m_localPlayer; Minimap instance = Minimap.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null) { return; } try { if (s_map == null || s_mapSrc != Plugin.AutoTypes.Value) { s_map = new List<(string, string)>(); s_mapSrc = Plugin.AutoTypes.Value; string[] array = s_mapSrc.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { string text2 = text.Substring(0, num).Trim().ToLowerInvariant(); string text3 = text.Substring(num + 1).Trim(); if (text2.Length > 0 && Plugin.IsKey(text3)) { s_map.Add((text2, text3)); } } } } List<Location> list = s_all.Invoke(); if (list == null) { return; } List<PinData> value = Traverse.Create((object)instance).Field("m_pins").GetValue<List<PinData>>(); float value2 = Plugin.AutoRange.Value; foreach (Location item in list) { if ((Object)(object)item == (Object)null) { continue; } Vector3 position = ((Component)item).transform.position; if (Vector3.Distance(position, ((Component)localPlayer).transform.position) > value2) { continue; } string text4 = ((Object)((Component)item).gameObject).name; int num2 = text4.IndexOf("(Clone)", StringComparison.Ordinal); if (num2 >= 0) { text4 = text4.Substring(0, num2); } text4 = text4.ToLowerInvariant(); string text5 = null; foreach (var item2 in s_map) { if (text4.Contains(item2.sub)) { text5 = item2.key; break; } } if (text5 == null) { continue; } bool flag = false; if (value != null) { foreach (PinData item3 in value) { if (item3 != null && Vector3.Distance(item3.m_pos, position) < 25f) { flag = true; break; } } } if (!flag) { string text6 = Plugin.LabelOf(text5); PinData val = instance.AddPin(position, Plugin.BaseOf(text5), text6, true, false, 0L, default(PlatformUserID)); if (val != null) { Pins.Apply(val, text5); Pins.Remember(position, text5); } if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, text6 + " marked on your map", 0, (Sprite)null, false, true); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("VargheimPins auto: " + ex.Message)); } } } internal static class Compat { internal static void Exploration(Harmony h) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown try { Type type = AccessTools.TypeByName("VargheimExploration.Pins"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "EnsureBar", (Type[])null, (Type[])null); if (methodInfo != null) { h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Compat), "SkipBar", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Plugin.Log.LogInfo((object)"VargheimPins: VargheimExploration present; its extra icon columns are off, Landmark Sense pins use our glyphs."); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("VargheimPins compat: " + ex.Message)); } } private static bool SkipBar() { return !Plugin.PickerOn.Value; } } [HarmonyAfter(new string[] { "digi.vargheim.exploration", "org.bepinex.plugins.groups" })] internal static class Patches { [HarmonyPatch(typeof(Minimap), "Start")] [HarmonyPostfix] private static void Start(Minimap __instance) { Picker.Reset(); Names.ResetCam(); Pins.Restored = false; Plugin.Log.LogInfo((object)("VargheimPins: game ShowNamesZoom = " + __instance.m_showNamesZoom + ((Plugin.NamesZoom.Value > 0f) ? (" -> " + Plugin.NamesZoom.Value) : " (kept)"))); if (Plugin.NamesZoom.Value > 0f) { __instance.m_showNamesZoom = Plugin.NamesZoom.Value; } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] [HarmonyPostfix] private static void 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) { Picker.Ensure(__instance); } } [HarmonyPatch(typeof(Minimap), "SelectIcon")] [HarmonyPostfix] private static void SelectIcon() { if (!Picker.SelfSelect) { Pins.Pending = null; Picker.Highlight(null); } } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] [HarmonyPrefix] private static void NameInputPre() { Pins.Placing = true; } [HarmonyPatch(typeof(Minimap), "ShowPinNameInput")] [HarmonyPostfix] private static void NameInputPost(Minimap __instance) { Pins.Placing = false; try { if (Pins.Pending != null && Plugin.PrefillName.Value && (Object)(object)__instance.m_nameInput != (Object)null) { ((TMP_InputField)__instance.m_nameInput).text = Plugin.LabelOf(Pins.Pending); ((TMP_InputField)__instance.m_nameInput).caretPosition = ((TMP_InputField)__instance.m_nameInput).text.Length; } } catch { } } [HarmonyPatch(typeof(Minimap), "AddPin")] [HarmonyPostfix] private static void AddPin(PinData __result, Vector3 pos, string name, bool save, long ownerID) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (__result == null) { return; } try { if (Pins.Placing && Pins.Pending != null) { Pins.Apply(__result, Pins.Pending); Pins.Remember(pos, Pins.Pending); } else if (save && ownerID == 0L) { if (!Pins.Saved(Player.m_localPlayer).TryGetValue(Pins.PosKey(pos), out var value)) { value = Pins.LabelKey(name); } if (value != null) { Pins.Apply(__result, value); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("VargheimPins pin: " + ex.Message)); } } [HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })] [HarmonyPrefix] private static void RemovePin(PinData pin) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) try { if (pin != null && Pins.Applied.TryGetValue(pin, out var _)) { Player localPlayer = Player.m_localPlayer; Dictionary<string, string> dictionary = Pins.Saved(localPlayer); if (dictionary.Remove(Pins.PosKey(pin.m_pos))) { Pins.Store(localPlayer, dictionary); } } } catch { } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] [HarmonyPostfix] private static void UpdatePins(Minimap __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) try { List<PinData> value = Traverse.Create((object)__instance).Field("m_pins").GetValue<List<PinData>>(); if (value == null) { return; } if (!Pins.Restored) { Pins.Restore(value); } bool flag = (int)__instance.m_mode == 2; float num = (flag ? __instance.m_pinSizeLarge : __instance.m_pinSizeSmall) * Plugin.PinScale.Value; for (int i = 0; i < value.Count; i++) { PinData val = value[i]; if (val != null && !((Object)(object)val.m_iconElement == (Object)null) && Pins.Applied.TryGetValue(val, out var value2) && Plugin.S.TryGetValue(value2, out var value3)) { if ((Object)(object)val.m_icon != (Object)(object)value3) { val.m_icon = value3; } if ((Object)(object)val.m_iconElement.sprite != (Object)(object)value3) { val.m_iconElement.sprite = value3; } if (val.m_ownerID == 0L) { ((Graphic)val.m_iconElement).color = ((Plugin.HoverTint.Value && val == Names.Hovered) ? Plugin.Gold : Plugin.Ink); } if ((Object)(object)val.m_uiElement != (Object)null && !val.m_doubleSize) { val.m_uiElement.SetSizeWithCurrentAnchors((Axis)0, num); val.m_uiElement.SetSizeWithCurrentAnchors((Axis)1, num); } } } Names.Tick(__instance); Players.Tick(__instance); if (flag) { Picker.Tick(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("VargheimPins update: " + ex.Message)); } } } }