Please disclose if your mod was created primarily 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 ZenMap v1.4.6
plugins/ZenMap.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using GUIFramework; using HarmonyLib; using JetBrains.Annotations; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using Zen; using Zen.Interop; using Zen.Lib; using Zen.Lib.Config; using Zen.Lib.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ZenMap")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ZenMap")] [assembly: AssemblyCopyright("Copyright \ufffd 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 ZenMap { internal static class ColorExt { public static uint ToUInt(this Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Color32.op_Implicit(color).ToUInt(); } public static uint ToUInt(this Color32 color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return (uint)((color.r << 24) | (color.g << 16) | (color.b << 8) | color.a); } public static Color ToColor(this uint rgba) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return Color32.op_Implicit(new Color32((byte)(rgba >> 24), (byte)(rgba >> 16), (byte)(rgba >> 8), (byte)rgba)); } } internal static class DataKey { public const int CurrentVersion = 1; public const string MapID = "ZenMap_id"; public const string Seed = "ZenMap_seed"; public const string Label = "ZenMap_label"; public const string Position = "ZenMap_position"; public const string Radius = "ZenMap_radius"; public const string Pins = "ZenMap_pins"; public const string Timestamp = "ZenMap_timestamp"; public const string Version = "ZenMap_version"; public const string LastUsedMapID = "ZenMap_LastUsedMapID"; } [HarmonyPatch] internal static class InventoryCheck { private static bool _isFound; public static bool HaveMap { get; private set; } internal static void Init() { HaveMap = InventoryExt.ContainsItemByPrefab(((Humanoid)Player.m_localPlayer).GetInventory(), "ZenMap"); _isFound = false; } private static bool IsValid(Inventory inv) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return inv == ((Humanoid)Player.m_localPlayer).GetInventory(); } return false; } private static void Reset(Inventory inv) { if (IsValid(inv)) { _isFound = false; } } private static void CheckIfHadMap(Inventory inv) { if (IsValid(inv) && Object.op_Implicit((Object)(object)Minimap.instance) && Minimap.instance.m_visibleIconTypes == MapPinType.VisibleTypes.CompassWithMap && !_isFound) { RequirePinUpdate(); } } private static void CheckMapItem(Inventory inv, ItemData item) { if (IsValid(inv) && !_isFound) { HaveMap = ItemDataExt.GetPrefabName(item) == "ZenMap"; if (HaveMap) { _isFound = true; RequirePinUpdate(); } } } private static void RequirePinUpdate() { if (Object.op_Implicit((Object)(object)Minimap.instance)) { Minimap.instance.m_pinUpdateRequired = true; } } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "OnSpawned")] private static void Player_OnSpawned() { Init(); } [HarmonyTranspiler] [HarmonyPatch(typeof(Inventory), "UpdateTotalWeight")] private static IEnumerable<CodeInstruction> Inventory_UpdateTotalWeight_Transpiler(IEnumerable<CodeInstruction> codes) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ItemData), "GetWeight", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(Inventory), "m_totalWeight"), (string)null) }; Action<Inventory> action = Reset; CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)action.Method) }; Action<Inventory, ItemData> action2 = CheckMapItem; CodeInstruction[] array3 = (CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)action2.Method) }; Action<Inventory> action3 = CheckIfHadMap; CodeInstruction[] array4 = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)action3.Method) }; return new CodeMatcher(codes, (ILGenerator)null).Start().Insert(array2).MatchEndForward(array) .ThrowIfInvalid("Unable to match IL") .Advance(1) .Insert(array3) .End() .Insert(array4) .InstructionEnumeration(); } } [HarmonyPatch] internal static class MapClouds { private static Texture2D? _cloudsCache; private static readonly Texture2D NoClouds; private static bool _isVisible; private static readonly int CloudTexID; static MapClouds() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) _isVisible = true; CloudTexID = Shader.PropertyToID("_CloudTex"); NoClouds = new Texture2D(1, 1); NoClouds.SetPixel(0, 0, Color.clear); NoClouds.Apply(); } public static void ResetState() { if (Object.op_Implicit((Object)(object)Minimap.instance) && Object.op_Implicit((Object)(object)_cloudsCache)) { Minimap.instance.m_mapLargeShader.SetTexture(CloudTexID, (Texture)(object)_cloudsCache); } _isVisible = true; _cloudsCache = null; } internal static void Shutdown() { if (Object.op_Implicit((Object)(object)_cloudsCache) && Object.op_Implicit((Object)(object)Minimap.instance)) { Minimap.instance.m_mapLargeShader.SetTexture(CloudTexID, (Texture)(object)_cloudsCache); } } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "Start")] private static void Minimap_Start() { ResetState(); } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "UpdateMap")] private static void Minimap_UpdateMap(Minimap __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.m_mode != 2) { return; } Material mapLargeShader = __instance.m_mapLargeShader; if (!Object.op_Implicit((Object)(object)_cloudsCache)) { _cloudsCache = (Texture2D)mapLargeShader.GetTexture(CloudTexID); } if ((Configs.HideMapItemClouds.Value && MapLocation.IsMapItem()) || (Configs.HideMapTableClouds.Value && MapLocation.IsMapTable())) { if (_isVisible) { mapLargeShader.SetTexture(CloudTexID, (Texture)(object)NoClouds); _isVisible = false; } return; } bool flag = ZInput.GetKey(Configs.HideMapCloudsKey.Value, true) || ZInput.GetButton("JoyRStick"); if (flag == _isVisible) { _isVisible = !flag; mapLargeShader.SetTexture(CloudTexID, (Texture)(_isVisible ? ((object)_cloudsCache) : ((object)NoClouds))); } } } [HarmonyPatch] internal static class MapFog { private static Texture2D? _fogAll; private static Texture2D? _fogNone; private static bool[] _exploreAll = Array.Empty<bool>(); private static bool IsInitialized { get { if (Object.op_Implicit((Object)(object)_fogAll) && Object.op_Implicit((Object)(object)_fogNone)) { return _exploreAll.Length != 0; } return false; } } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "Start")] [HarmonyPriority(200)] private static void Minimap_Start(Minimap __instance) { Init(); } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "ExploreAll")] private static void Minimap_ExploreAll(ref bool __runOriginal) { if (IsInitialized) { __runOriginal = false; FastExploreAll(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "Reset")] private static void Minimap_Reset(ref bool __runOriginal) { if (IsInitialized) { __runOriginal = false; FastReset(); Minimap.instance.m_sharedMapHint.gameObject.SetActive(false); } } private static void InitFog(this Texture2D texture, Color32 color) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[((Texture)texture).width * ((Texture)texture).height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } texture.SetPixels32(array); texture.Apply(); } internal static void Init() { //IL_0038: 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_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) Logging<Plugin>.Info((object)"Initialize the fog cache", 0); _fogAll = Create(Minimap.instance.m_fogTexture); _fogNone = Create(Minimap.instance.m_fogTexture); _fogAll.InitFog(Color32.op_Implicit(Color.white)); _fogNone.InitFog(Color32.op_Implicit(Color.clear)); _exploreAll = Enumerable.Repeat(element: true, Minimap.instance.m_explored.Length).ToArray(); static Texture2D Create(Texture2D tex) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new Texture2D(((Texture)tex).width, ((Texture)tex).height, tex.format, ((Texture)tex).mipmapCount, false, true); } } private static void FastExploreAll() { if (!IsInitialized) { throw new Exception("Not initialized"); } Logging<Plugin>.Info((object)"Set the fog texture to no fog", 0); Graphics.CopyTexture((Texture)(object)_fogNone, (Texture)(object)Minimap.instance.m_fogTexture); Minimap.instance.m_fogTexture.Apply(); Logging<Plugin>.Info((object)"Set the explored area to all", 0); _exploreAll.CopyTo(Minimap.instance.m_explored, 0); } private static void FastReset() { if (!IsInitialized) { throw new Exception("Not initialized"); } Logging<Plugin>.Info((object)"Set the fog texture to all fog", 0); Graphics.CopyTexture((Texture)(object)_fogAll, (Texture)(object)Minimap.instance.m_fogTexture); Minimap.instance.m_fogTexture.Apply(); Logging<Plugin>.Info((object)"Reset the explored area to none", 0); int length = Minimap.instance.m_explored.Length; Array.Clear(Minimap.instance.m_explored, 0, length); Array.Clear(Minimap.instance.m_exploredOthers, 0, length); } } [HarmonyPatch] internal static class MapItem { public const string PrefabName = "ZenMap"; private const int VariantCount = 10; private static Guid LastUsedMapID { get { if (!Player.m_localPlayer.m_customData.TryGetValue("ZenMap_LastUsedMapID", out var value)) { return Guid.Empty; } return Guid.Parse(value); } set { Player.m_localPlayer.m_customData["ZenMap_LastUsedMapID"] = value.ToString("N"); } } internal static Action? AddCraftingItem() { //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_004d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) Sprite[] array = (Sprite[])(object)new Sprite[10]; for (int i = 0; i < array.Length; i++) { array[i] = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, $"ItemIcons.map_item{i:00}.png"); } CustomItem val = new CustomItem("ZenMap", "ArmorRagsChest", new ItemConfig { Name = "$map_item", Description = "$map_item_description", CraftingStation = CraftingStations.None, MinStationLevel = 0, Requirements = Array.Empty<RequirementConfig>(), Icons = array, Amount = 1, Weight = 0.1f, StackSize = 1 }); CustomItemExt.ApplyTextureToPrefab(val, array[0].texture, 0.5f, Vector2.one * 2f, Vector2.zero, "map", true, (Color?)null); ItemManager.Instance.AddItem(val); return null; } public static void ShowLastUsed() { Logging<Plugin>.Info((object)$"Last used map: {LastUsedMapID}", 0); Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); Guid guid2; ItemData val = ((IEnumerable<ItemData>)inventory.GetAllItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData item) => item.TryGetMapID(out guid2) && guid2 == LastUsedMapID)) ?? inventory.GetItem("ZenMap", -1, true); if (val == null) { MapMissing(); return; } val.TryGetMapID(out var guid); Logging<Plugin>.Info((object)$"Showing map: {guid}", 0); LastUsedMapID = guid; MapLocation mapLocation = MapLocation.ReadFrom(val); if (mapLocation == null) { MapMissing(); } else { mapLocation.Show(); } static void MapMissing() { Logging<Plugin>.Info((object)"Map not found", 0); ((Character)Player.m_localPlayer).Message((MessageType)2, "$map_error_missing", 0, (Sprite)null); } } public static int GetNextVariant() { Dictionary<string, string> customData = Player.m_localPlayer.m_customData; string value; int num = (customData.TryGetValue("ZenMap_MapItemNextVariant", out value) ? int.Parse(value) : 0); customData["ZenMap_MapItemNextVariant"] = ((num + 1) % 10).ToString(); return num; } public static bool IsMapItem(this ItemData? item) { return ((item != null) ? ItemDataExt.GetPrefabName(item) : null) == "ZenMap"; } public static bool IsNear(this ItemData? item, Vector3 position, float maxDistance, out string mapItemLabel) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) mapItemLabel = string.Empty; if (item == null) { return false; } MapLocation mapLocation = MapLocation.ReadFrom(item); if (mapLocation == null) { return false; } mapItemLabel = mapLocation.Label; bool flag = MathExt.DistanceToXZ(mapLocation.Position, position) < maxDistance; Logging<Plugin>.Info((object)$"Is near origin table? {flag}", 0); return flag; } public static bool IsValidSeed(this ItemData item) { if (!item.m_customData.TryGetValue("ZenMap_seed", out var value)) { return false; } return int.Parse(value) == WorldGenerator.instance.GetSeed(); } private static bool TryGetMapID(this ItemData mapItem, out Guid guid) { guid = Guid.Empty; if (!mapItem.IsMapItem()) { return false; } if (mapItem.m_customData.TryGetValue("ZenMap_id", out var value)) { guid = Guid.Parse(value); } return guid != Guid.Empty; } internal static void CreateMapID(this ItemData mapItem) { if (!mapItem.IsMapItem()) { throw new ArgumentException("Item is not a MapItem"); } mapItem.m_customData["ZenMap_id"] = Guid.NewGuid().ToString("D"); } [HarmonyPrefix] [HarmonyPatch(typeof(Humanoid), "UseItem")] [HarmonyPriority(100)] private static void Humanoid_UseItem(Humanoid __instance, Inventory? inventory, ItemData? item, bool fromInventoryGui, ref bool __runOriginal) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || item == null || !item.IsMapItem() || !fromInventoryGui) { return; } if (inventory == null) { inventory = __instance.m_inventory; } if (!inventory.ContainsItem(item)) { return; } __runOriginal = false; if (!item.IsValidSeed()) { ((Character)__instance).Message((MessageType)2, "$map_error_alien", 0, (Sprite)null); return; } if (inventory == __instance.GetInventory() && item.TryGetMapID(out var guid)) { LastUsedMapID = guid; } MapLocation.ReadFrom(item)?.Show(); } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGrid), "CreateItemTooltip")] private static void InventoryGrid_CreateItemTooltip(InventoryGrid __instance, ItemData item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 HintType activeType = KeyHint.ActiveType; if (activeType - 4 <= 1) { KeyHint.SetLabel("Split", item.IsMapItem() ? StringExt.Localize("$hud_rename") : StringExt.Localize("$inventory_splitstack")); } } [HarmonyPrefix] [HarmonyPatch(typeof(UITooltip), "HideTooltip")] private static void UITooltip_HideTooltip(UITooltip __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 HintType activeType = KeyHint.ActiveType; if (activeType - 4 <= 1) { KeyHint.SetLabel("Split", StringExt.Localize("$inventory_splitstack")); } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(int) })] private static void ItemDrop_ItemData_GetTooltip(ItemData __instance, ref string __result) { if (!__instance.IsMapItem()) { return; } __instance.m_customData.TryGetValue("ZenMap_label", out var value); string text = "$map_item_description"; string text2 = string.Empty; if (!Utility.IsNullOrWhiteSpace(value)) { text2 += $"\n\n<color={UIColor.ValheimBeige}>{value}</color>"; } if (Configs.CalendarShow.Value) { string text3 = MapLocation.ReadFrom(__instance)?.GetCalendarString(); if (text3 != null) { if (Utility.IsNullOrWhiteSpace(value)) { text2 += "\n"; } text2 += $"\n<color={UIColor.ValheimBeige}>{text3}</color>"; } } if (!__instance.IsValidSeed()) { text2 += $"\n\n<color={UIColor.Red}>$map_error_alien</color>"; } __result = __result.Replace("$map_item_description", text + text2); ItemDataExt.SetTooltipExtra(__instance, text2); } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "OnSelectedItem")] private static void InventoryGui_OnSelectedItem(InventoryGui __instance, ItemData item, Modifier mod, ref bool __runOriginal) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 ItemData item2 = item; if (item2.IsMapItem() && (int)mod == 1) { __runOriginal = false; MapLocation map = MapLocation.ReadFrom(item2, ignoreSeed: true); map?.PromptLabel(delegate { map.WriteTo(item2); }); } } } internal class MapLocation { private static MapLocation? _active; public readonly Vector3 Position; public readonly float Radius; public readonly float Percent; public readonly int WorldSeed; private double _timestamp; private string? _pinsBase64; private List<MapLocationPins.PinInfo>? _pins; public static bool InUse => _active != null; public static MapLocation Active => _active ?? throw new InvalidOperationException("No active map location"); public string Label { get; private set; } public MapLocation(string label, Vector3 position, float radius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Label = label; Position = position; if (!(radius > 0f)) { throw new ArgumentOutOfRangeException("radius", "must be positive"); } Radius = radius; Percent = Mathf.Clamp(Radius / (float)Configs.MapTableFullRadius.Value, 0f, 1f); WorldSeed = WorldGenerator.instance.GetSeed(); } private MapLocation(string label, Vector3 position, float radius, int worldSeed) : this(label, position, radius) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) WorldSeed = worldSeed; } public static bool IsMapTable() { if (InUse) { return !IsMapItem(); } return false; } public static bool IsMapItem() { List<MapLocationPins.PinInfo> pins; return IsMapItem(out pins); } public static bool IsMapItem(out List<MapLocationPins.PinInfo> pins) { pins = _active?._pins; return pins != null; } public void WriteTo(ItemData target) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Logging<Plugin>.Info((object)"Write map location to item", 0); target.CreateMapID(); Dictionary<string, string> customData = target.m_customData; int worldSeed = WorldSeed; customData["ZenMap_seed"] = worldSeed.ToString(); target.m_customData["ZenMap_position"] = JsonUtility.ToJson((object)Position); Dictionary<string, string> customData2 = target.m_customData; float radius = Radius; customData2["ZenMap_radius"] = radius.ToString("F"); target.m_customData["ZenMap_label"] = Label; target.m_customData["ZenMap_pins"] = _pinsBase64 ?? MapLocationPins.SerializePins(Position, Radius); target.m_customData["ZenMap_timestamp"] = BitConverter.DoubleToInt64Bits((_timestamp != 0.0) ? _timestamp : ZNet.instance.GetTimeSeconds()).ToString(); target.m_customData["ZenMap_version"] = 1.ToString(); } public static MapLocation? ReadFrom(ItemData source, bool ignoreSeed = false) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!ignoreSeed && !source.IsValidSeed()) { Logging<Plugin>.Info((object)"Map item world seed does not match current world seed.", 0); return null; } Logging<Plugin>.Info((object)"Read map data from the item", 0); Dictionary<string, string> customData = source.m_customData; if (customData.TryGetValue("ZenMap_position", out var value) && customData.TryGetValue("ZenMap_radius", out var value2) && customData.TryGetValue("ZenMap_label", out var value3) && customData.TryGetValue("ZenMap_seed", out var value4)) { string value5; MapLocation obj = new MapLocation(value3, JsonUtility.FromJson<Vector3>(value), float.Parse(value2), int.Parse(value4)) { _pinsBase64 = (customData.TryGetValue("ZenMap_pins", out value5) ? value5 : null) }; obj._pins = MapLocationPins.DeserializePins(obj._pinsBase64); obj._timestamp = (customData.TryGetValue("ZenMap_timestamp", out var value6) ? BitConverter.Int64BitsToDouble(long.Parse(value6)) : 0.0); return obj; } Logging<Plugin>.Warning((object)"Map item data missing or invalid location data. Was this map item instanced manually by admin?", 0); return null; } public void Show() { //IL_0022: 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) _active = this; Minimap.instance.Reset(); if (IsMapItem()) { MapLocationPins.ResetPinMarkers(); } Minimap.instance.Explore(Position, Radius); Minimap.instance.m_largeZoom = Mathf.Max(Map.Zoom.Min, Map.Zoom.Max * (Percent + 0.2f)); bool noMap = Game.m_noMap; Game.m_noMap = false; Minimap.instance.ShowPointOnMap(Position); Game.m_noMap = noMap; PlaySoundFX(); } public static void Close() { if (InUse) { MapLocationPins.ResetPinMarkers(); PlaySoundFX(); _active = null; } } private static void PlaySoundFX() { ((Humanoid)Player.m_localPlayer).TriggerEquipEffect((ItemData)null); } public void PromptLabel(Action onSuccess) { Action onSuccess2 = onSuccess; TextPrompt.Show("$map_item_prompt", Label, (Action<string>)delegate(string input) { Label = StringExt.ToProperCase(StringExtensionMethods.RemoveRichTextTags(Regex.Replace(input, "\\$", string.Empty, RegexOptions.Multiline)).Trim(), false); Logging<Plugin>.Info((object)("Set text (sanitized): '" + Label + "'"), 0); onSuccess2(); }, 50); } public int GetCalendarYear(double defaultSeconds = -1.0) { double num = ((_timestamp > 0.0) ? _timestamp : defaultSeconds); if (num < 0.0) { return 0; } int num2 = EnvMan.instance.GetDay(num) + Configs.CalendarInitDays.Value; int value = Configs.CalendarDaysPerYear.Value; return num2 / value + 1; } public string? GetCalendarString(double defaultSeconds = -1.0) { int calendarYear = GetCalendarYear(defaultSeconds); if (calendarYear != 0) { return StringExt.Localize("$msg_calendar", new string[1] { calendarYear.ToString("N0", CultureInfo.CurrentCulture) }); } return null; } } internal static class MapParchment { public const string PrefabName = "ZenMapParchment"; internal static Action AddCraftingItem() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Logging<Plugin>.Info((object)"Add crafting item: ZenMapParchment", 0); Sprite val = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, "ItemIcons.parchment.png"); ItemConfig val2 = new ItemConfig(); val2.Name = "$map_item_parchment"; val2.Description = "$map_item_parchment_description"; val2.CraftingStation = Configs.ParchmentCraftingStation.Value; val2.MinStationLevel = Configs.ParchmentCraftingStationLevel.Value; val2.Requirements = Configs.ParchmentResources.Value.ToRequirementConfigs(':'); val2.Icons = (Sprite[])(object)new Sprite[1] { val }; val2.Amount = 1; val2.Weight = 0.1f; val2.StackSize = 10; CustomItem item = new CustomItem("ZenMapParchment", "ArmorRagsChest", val2); CustomItemExt.ApplyTextureToPrefab(item, val.texture, 0.5f, Vector2.one, Vector2.zero, "", true, (Color?)null); ItemManager.Instance.AddItem(item); return ConfigSync; void ConfigSync() { Recipe recipe = item.Recipe.Recipe; recipe.m_craftingStation = PrefabManagerExt.GetCraftingStation(PrefabManager.Instance, Configs.ParchmentCraftingStation.Value); recipe.m_minStationLevel = Configs.ParchmentCraftingStationLevel.Value; recipe.m_resources = (Configs.MapItemEnabled.Value ? Configs.ParchmentResources.Value.ToRequirements(':') : Array.Empty<Requirement>()); } } public static bool IsMapParchment(this ItemData? item) { return ((item != null) ? ItemDataExt.GetPrefabName(item) : null) == "ZenMapParchment"; } } [HarmonyPatch] internal static class MapLocationPins { public class PinInfo { public Guid Guid; public PinType Type; public bool Checked; public Color Color; } private static readonly List<PinData> ValidPins = new List<PinData>(); private const int SerializeVersion = 1; public static void Shutdown() { ResetPinMarkers(); } public static void ResetPinMarkers() { foreach (PinData validPin in ValidPins) { Minimap instance = Minimap.instance; if (instance != null) { instance.DestroyPinMarker(validPin); } MapTrack.RemoveFromCache(validPin); } ValidPins.Clear(); if (Object.op_Implicit((Object)(object)Minimap.instance)) { CollectionExtensions.Do<PinData>((IEnumerable<PinData>)Minimap.instance.m_pins, (Action<PinData>)Minimap.instance.DestroyPinMarker); Minimap.instance.m_pinUpdateRequired = true; } } public static string SerializePins(Vector3 origin, float range) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected I4, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) List<PinData> list = (from pin in Minimap.instance.m_pins where VectorExtensions.DistanceTo(origin, pin.m_pos) < range where Configs.PinShowMapItem.IsAllowed(pin.GetPrefabHash()) select pin).ToList(); ZPackage val = new ZPackage(); val.Write(1); val.Write(list.Count); foreach (PinData item in list) { Guid guid = item.GetGuid(); if (guid == Guid.Empty) { throw new Exception("Guid can not be empty"); } val.Write(guid.ToByteArray()); val.Write((int)item.m_type); val.Write(item.m_checked); val.Write(Color.white.ToUInt()); } string @base = val.GetBase64(); Logging<Plugin>.Info((object)$"Serialized pins: {list.Count}, bytes: {val.Size()}, base64 size: {@base.Length}", 0); return @base; } public static List<PinInfo> DeserializePins(string? base64) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (base64 == null) { return new List<PinInfo>(); } ZPackage val = new ZPackage(base64); int num = val.ReadInt(); if (num != 1) { Logging<Plugin>.Error((object)$"Map version mismatch. Expected {1}, got {num}", (ushort)0); return new List<PinInfo>(); } List<PinInfo> list = new List<PinInfo>(); int num2 = val.ReadInt(); for (int i = 0; i < num2; i++) { PinInfo pinInfo = new PinInfo { Guid = new Guid(val.ReadByteArray()), Type = (PinType)val.ReadInt(), Checked = val.ReadBool(), Color = val.ReadUInt().ToColor() }; Logging<Plugin>.Info((object)$"Deserialized pin: {pinInfo.Guid}, type: {pinInfo.Type}", 0); list.Add(pinInfo); } Logging<Plugin>.Info((object)$"Deserialized pins: {list.Count}", 0); return list; } private static List<PinData> MergeLocationPins() { if (!MapLocation.IsMapItem(out List<PinInfo> pins)) { return Minimap.instance.m_pins; } if (ValidPins.Count > 0) { return ValidPins; } foreach (PinData pin in Minimap.instance.m_pins) { if (!IsHiddenOnMapItem(pin) && !pin.IsTracked()) { ValidPins.Add(CopyPin(pin)); } } foreach (PinInfo item2 in pins) { if (MapTrack.TryGetZDO(item2.Guid, out ZDO zdo)) { PinData item = CreateTempPin(zdo, item2); ValidPins.Add(item); } } return ValidPins; } private static bool IsHiddenOnMapItem(PinData pin) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected I4, but got Unknown bool flag = pin.m_shouldDelete; if (!flag) { PinType type = pin.m_type; bool flag2; switch (type - 5) { case 0: case 2: case 4: case 6: case 7: case 8: flag2 = true; break; default: flag2 = false; break; } flag = flag2; } return flag; } private static PinData CreateTempPin(ZDO zdo, PinInfo pinInfo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_004b: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown PinData val = new PinData { m_name = MapTrack.CreateTrackingLabel(zdo.GetLabel(), pinInfo.Guid), m_pos = zdo.GetPosition(), m_type = pinInfo.Type, m_icon = Minimap.instance.GetSprite(pinInfo.Type) }; val.m_NamePinData = new PinNameData(val); Logging<Plugin>.Info((object)("Pin Created: " + val.m_name), 0); return val; } private static PinData CopyPin(PinData pin) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) //IL_0040: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) //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_007a: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00a5: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00ab: Expected O, but got Unknown Logging<Plugin>.Info((object)$"Copy pin: {pin.m_name} {pin.m_pos}", 0); PinData val = new PinData { m_name = pin.m_name, m_pos = pin.m_pos, m_type = pin.m_type, m_icon = pin.m_icon, m_checked = pin.m_checked, m_ownerID = pin.m_ownerID, m_author = pin.m_author, m_doubleSize = pin.m_doubleSize, m_worldSize = pin.m_worldSize, m_animate = pin.m_animate }; val.m_NamePinData = new PinNameData(val); return val; } [HarmonyTranspiler] [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static IEnumerable<CodeInstruction> Minimap_UpdatePins_MergePins(IEnumerable<CodeInstruction> codes) { FieldInfo pinsField = AccessTools.Field(typeof(Minimap), "m_pins"); Func<List<PinData>> intercept = MergeLocationPins; return Transpilers.Manipulator(codes, (Func<CodeInstruction, bool>)((CodeInstruction code) => CodeInstructionExtensions.Is(code, OpCodes.Ldfld, (MemberInfo)pinsField)), (Action<CodeInstruction>)delegate(CodeInstruction code) { code.opcode = OpCodes.Call; code.operand = intercept.Method; }); } [HarmonyTranspiler] [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static IEnumerable<CodeInstruction> Minimap_UpdatePins_ColorPins(IEnumerable<CodeInstruction> codes, ILGenerator gen) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PinData), "m_iconElement"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Graphic), "color"), (string)null) }; Func<PinData, Color, Color> func = AdjustPinColor; CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)6), new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)9), new CodeInstruction(OpCodes.Call, (object)func.Method), new CodeInstruction(OpCodes.Stloc_S, (object)(byte)9) }; return new CodeMatcher(codes, gen).MatchStartForward(array).ThrowIfInvalid("Unable to match IL").Insert(array2) .InstructionEnumeration(); } private static Color AdjustPinColor(PinData pin, Color defaultColor) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (!Configs.PinColorEnabled.Value) { return defaultColor; } PinType type = pin.m_type; if ((int)type != 4) { if ((int)type == 9) { return Configs.PinColorBoss.Value; } if (pin.GetPrefabHash() == MapTrack.Pin.Sign) { return Configs.PinColorPrivate.Value; } if (MapTrack.Pin.Mounts.Contains(pin.GetPrefabHash())) { return Configs.PinColorPrivate.Value; } if (pin.IsTracked()) { return Configs.PinColorShared.Value; } return Configs.PinColorSpecial.Value; } return Configs.PinColorDeath.Value; } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "OnSpawned")] private static void Player_OnSpawned() { ResetPinMarkers(); } } [HarmonyPatch] internal static class MapPinSelect { private static VariantDialog _dialog = null; private static Action<PinType>? _onSelect; private static ItemData? _mapPinsIconData; private static readonly string[] PinDisplayOrder = new string[41] { "pickaxe", "axe", "sword", "bow", "anvil", "armor", "chest", "stackedbars", "potion", "cauldron", "tree", "berries", "berries2", "carrot", "turnip", "onion", "mushroom", "fish", "bee", "flower", "bread", "grain", "pig", "chicken", "wolf", "castle", "castle2", "tent", "bridge", "cave", "crystal", "magic_circle", "magic_eye", "magic_book", "swirl", "monster", "monster_trex", "dragon", "dragon2", "kraken", "question" }; private static readonly PinType[] PinnableTypes = ((IEnumerable<PinType>)(object)new PinType[1] { (PinType)3 }).Union(PinDisplayOrder.Select(MapPinIcon.GetPinTypeFromResourceName)).ToArray(); public static bool IsOpen { get { if (Object.op_Implicit((Object)(object)_dialog)) { return ((Component)_dialog).gameObject.activeSelf; } return false; } } public static void Init() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00af: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) _dialog = Object.Instantiate<VariantDialog>(InventoryGui.instance.m_variantDialog, Hud.instance.m_rootObject.transform); ((Component)_dialog).gameObject.SetActive(false); ((Object)_dialog).name = "ZenMap_PinSelect"; _dialog.m_selected = OnSelected; ((Graphic)((Component)_dialog.m_elementPrefab.transform.Find("Button")).GetComponent<Image>()).material = Materials.IconCleanTransparency; _mapPinsIconData = CreateMapPinsIconData(); RectTransform val = (RectTransform)_dialog.m_listRoot.parent; Vector2 anchoredPosition = val.anchoredPosition; anchoredPosition.y = -590f; val.anchoredPosition = anchoredPosition; val.sizeDelta = new Vector2(448f, 515f); } private static ItemData CreateMapPinsIconData() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown ItemData obj = ZNetScene.instance.GetPrefab("ZenMapPin").GetComponent<ItemDrop>().m_itemData.Clone(); obj.m_shared = new SharedData { m_icons = ((IEnumerable<PinType>)PinnableTypes).Select((Func<PinType, Sprite>)Minimap.instance.GetSprite).ToArray(), m_variants = PinnableTypes.Length }; return obj; } private static GameObject CreateButton(Transform parent, string text, Action? onClick = null, Vector2 size = default(Vector2)) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Action onClick2 = onClick; GameObject val = Object.Instantiate<GameObject>(((Component)Resources.FindObjectsOfTypeAll<Settings>()[0].m_backButton).gameObject, parent, false); ((Object)val).name = "ZenMap_RemovePinBtn"; GuiButton component = val.GetComponent<GuiButton>(); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component).navigation = navigation; ((UnityEventBase)((Button)component).onClick).RemoveAllListeners(); ((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(ClickHandler)); ((Component)val.transform.Find("Label")).GetComponent<TMP_Text>().text = text; RectTransform val2 = (RectTransform)val.transform; val2.anchoredPosition = Vector2.one * 0.5f; val2.pivot = Vector2.one * 0.5f; if (size != default(Vector2)) { val2.sizeDelta = size; } Localization.instance.Localize(val.transform); return val; void ClickHandler() { onClick2?.Invoke(); } } public static void Choose(Action<PinType> onSelect) { if (!IsOpen) { _onSelect = onSelect; _dialog.Setup(_mapPinsIconData); } } public static void CheckForInput() { if (IsOpen) { if (ZInput.GetKeyDown((KeyCode)27, true)) { Close(); } if (ZInput.GetButtonDown("JoyButtonB")) { Close(); } } } private static void Close() { _dialog.OnClose(); } public static void Shutdown() { if (Object.op_Implicit((Object)(object)_dialog)) { Object.Destroy((Object)(object)((Component)_dialog).gameObject); } } private static void OnSelected(int index) { Logging<Plugin>.Info((object)$"Selected index: {index}", 0); _onSelect?.Invoke(PinnableTypes[index]); Close(); } [HarmonyPrefix] [HarmonyPatch(typeof(VariantDialog), "OnClose")] private static void VariantDialog_OnClose(VariantDialog __instance) { if (!((Object)(object)__instance != (Object)(object)_dialog)) { _onSelect = null; PlayerController.SetTakeInputDelay(0.5f); } } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "IsVisible")] private static void InventoryGui_IsVisible(ref bool __result, ref bool __runOriginal) { __runOriginal = !IsOpen; __result = IsOpen; } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "Show")] private static void InventoryGui_Show() { if (IsOpen) { Close(); } } } [HarmonyPatch] internal static class MapUI { private const float IconPadding = 15f; private const float IconScale = 0.65f; private static readonly (string Name, PinType PinType, PinOption options)[] PinGroups = new(string, PinType, PinOption)[8] { ("Sign", (PinType)3, PinOption.Sign), ("Town", (PinType)1, PinOption.MapTable), ("Bonfire", (PinType)0, PinOption.Bonfire), ("Vehicle", (PinType)260, PinOption.Cart | PinOption.WarMachine), ("Ship", (PinType)258, PinOption.LargeShip | PinOption.SmallBoat), ("Portal", (PinType)6, PinOption.Portal), ("TombStone", (PinType)4, PinOption.Tombstone), ("BossAlter", (PinType)9, PinOption.None) }; private static RectTransform _iconPanel = null; private static RectTransform _iconPanel2 = null; private static RectTransform _keyHints = null; private static RectTransform _sharedPanel = null; private static RectTransform _publicPanel = null; private static Image _playerMarker = null; private static void DisableOriginalIcons() { Disable(Minimap.instance.m_selectedIcon0); Disable(Minimap.instance.m_selectedIcon1); Disable(Minimap.instance.m_selectedIcon2); Disable(Minimap.instance.m_selectedIcon3); Disable(Minimap.instance.m_selectedIcon4); Disable(Minimap.instance.m_selectedIconBoss); Disable(Minimap.instance.m_selectedIconDeath); static void Disable(Image img) { ((Component)((Component)img).transform.parent).gameObject.SetActive(false); } } public static void Show(bool isVisible) { //IL_0035: 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_0060: 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) //IL_006b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ((Component)_iconPanel).gameObject.SetActive(isVisible); ((Component)_iconPanel2).gameObject.SetActive(false); ((Component)_keyHints).gameObject.SetActive(isVisible); if (_sharedPanel.anchoredPosition.y > _publicPanel.anchoredPosition.y) { RectTransform sharedPanel = _sharedPanel; RectTransform publicPanel = _publicPanel; Vector2 anchoredPosition = _publicPanel.anchoredPosition; Vector2 anchoredPosition2 = _sharedPanel.anchoredPosition; sharedPanel.anchoredPosition = anchoredPosition; publicPanel.anchoredPosition = anchoredPosition2; sharedPanel = _sharedPanel; RectTransform publicPanel2 = _publicPanel; anchoredPosition2 = _publicPanel.pivot; anchoredPosition = _sharedPanel.pivot; sharedPanel.pivot = anchoredPosition2; publicPanel2.pivot = anchoredPosition; } ((Component)_sharedPanel).gameObject.SetActive(isVisible || !Map.IsNoMapKey); ((Component)_publicPanel).gameObject.SetActive(isVisible); ((Behaviour)_playerMarker).enabled = !Configs.HidePlayerArrow.Value || isVisible; } internal static void Init() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Transform transform = Minimap.instance.m_largeRoot.transform; _iconPanel = (RectTransform)transform.Find("IconPanel"); _iconPanel2 = (RectTransform)transform.Find("IconPanel2"); _keyHints = (RectTransform)transform.Find("KeyHints"); _sharedPanel = (RectTransform)transform.Find("SharedPanel"); _publicPanel = (RectTransform)transform.Find("PublicPanel"); _playerMarker = ((Component)Minimap.instance.m_largeMarker).GetComponent<Image>(); } internal static void Shutdown() { } private static void InitNavIcons() { //IL_000f: 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_0041: 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_0073: 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) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_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_0157: Unknown result type (might be due to invalid IL or missing references) _iconPanel.anchoredPosition = new Vector2(-39f, -100f); _iconPanel.anchorMax = new Vector2(1f, 1f); _iconPanel.anchorMin = new Vector2(1f, 0f); _iconPanel.pivot = new Vector2(0.5f, 0.5f); _iconPanel.sizeDelta = new Vector2(100f, -110f); ((Transform)_iconPanel).localScale = Vector3.one * 0.65f; ((Transform)_iconPanel).Find("iconhints").localScale = Vector3.one / 0.65f; GameObject gameObject = ((Component)((Component)Minimap.instance.m_selectedIcon1).transform.parent).gameObject; Minimap.instance.m_selectedIcons.Clear(); foreach (var item3 in IEnumerableExt.WithIndex<(string, PinType, PinOption)>((IEnumerable<(string, PinType, PinOption)>)PinGroups)) { (string, PinType, PinOption) item = item3.Item1; int item2 = item3.Item2; GameObject val = Object.Instantiate<GameObject>(gameObject, (Transform)(object)_iconPanel); Image component = val.GetComponent<Image>(); component.sprite = Minimap.instance.GetSprite(item.Item2); if (MapPinType.IsTrackedPin(item.Item2)) { Color color = Color.white * 0.8f; ((Graphic)component).color = color; } Transform transform = val.transform; Vector3 localPosition = transform.localPosition; Vector3 val2 = Vector3.down * (float)item2; Rect rect = ((Graphic)component).rectTransform.rect; transform.localPosition = localPosition + val2 * (((Rect)(ref rect)).height + 15f); ((Object)val).name = item.Item1; val.SetActive(true); SetupEventHandlers(val, item2); Minimap.instance.m_selectedIcons.Add(item.Item2, ((Component)val.transform.Find("Selected")).GetComponent<Image>()); } } private static void SetupEventHandlers(GameObject obj, int index) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown Button component = obj.GetComponent<Button>(); ((Behaviour)component).enabled = true; component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { OnSelectPinGroup(index); }); MouseClick component2 = obj.GetComponent<MouseClick>(); ((Behaviour)component2).enabled = false; component2.m_leftClick = (UnityEvent)new ButtonClickedEvent(); component2.m_rightClick = (UnityEvent)new ButtonClickedEvent(); component2.m_middleClick = (UnityEvent)new ButtonClickedEvent(); } private static void OnSelectPinGroup(int index) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Logging<Plugin>.Info((object)$"Selected pin group index: {index}", 0); PinType item = PinGroups[index].PinType; Minimap.instance.ToggleIconFilter(item); } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "Start")] private static void Minimap_Start() { Init(); } } [HarmonyPatch] internal static class NetPlayerPosition { [HarmonyPatch] private static class AlwaysShowPlayerPosition { [UsedImplicitly] private static IEnumerable<MethodInfo> TargetMethods() { return new <>z__ReadOnlyArray<MethodInfo>(new MethodInfo[3] { AccessTools.DeclaredMethod(typeof(ZNet), "UpdatePlayerList", (Type[])null, (Type[])null), AccessTools.DeclaredMethod(typeof(ZNet), "SendPlayerList", (Type[])null, (Type[])null), AccessTools.DeclaredMethod(typeof(ZNet), "RPC_PlayerList", (Type[])null, (Type[])null) }); } [UsedImplicitly] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codes) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.DeclaredField(typeof(PlayerInfo), "m_publicPosition"), (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null) }; return new CodeMatcher(codes, (ILGenerator)null).MatchStartForward(array).ThrowIfInvalid("Unable to match IL").Repeat((Action<CodeMatcher>)Change, (Action<string>)null) .InstructionEnumeration(); static void Change(CodeMatcher cm) { cm.Advance(-1); cm.SetAndAdvance(OpCodes.Nop, (object)null); cm.SetAndAdvance(OpCodes.Nop, (object)null); cm.SetAndAdvance(OpCodes.Nop, (object)null); } } } [HarmonyPrefix] [HarmonyPatch(typeof(ZNet), "SendServerSyncPlayerData")] private static void ZNet_SendServerSyncPlayerData(ZNet __instance) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Character)Player.m_localPlayer).InGodMode()) { if (Configs.PinPvPStealth.Value) { __instance.SetPublicReferencePosition(!((Character)Player.m_localPlayer).IsPVPEnabled()); } else { __instance.SetPublicReferencePosition(true); } } } } [HarmonyPatch] internal static class PinBoss { public enum RevealMode { Never, NearOnly, Anywhere } private const float NearDistance = 20f; [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "DiscoverLocation")] private static void Minimap_DiscoverLocation(PinType type, Vector3 pos, ref bool __runOriginal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((int)type != 9 || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } if (((Character)Player.m_localPlayer).InGodMode()) { Logging<Plugin>.Info((object)"God mode is enabled, use vanilla behavior", 0); return; } Logging<Plugin>.Info((object)$"Boss pin reveal mode: {Configs.PinBossReveal.Value}", 0); switch (Configs.PinBossReveal.Value) { case RevealMode.Never: __runOriginal = false; break; case RevealMode.NearOnly: if (MathExt.DistanceTo((MonoBehaviour)(object)Player.m_localPlayer, pos) > 20f) { __runOriginal = false; } break; default: throw new ArgumentOutOfRangeException(); case RevealMode.Anywhere: break; } Logging<Plugin>.Info((object)(__runOriginal ? $"Revealing pin {MathExt.XZY(pos)}" : "Suppressing pin"), 0); } } internal static class MapPin { public const string PrefabName = "ZenMapPin"; public static readonly Sprite Icon = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, "ItemIcons.pin_nail2.png"); internal static Action AddCraftingItem() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) Logging<Plugin>.Info((object)"Add crafting item: ZenMapPin", 0); ItemConfig val = new ItemConfig(); val.Name = "$map_item_pin"; val.Description = "$map_item_pin_description"; val.CraftingStation = Configs.MapPinCraftingStation.Value; val.MinStationLevel = Configs.MapPinCraftingStationLevel.Value; val.Requirements = Configs.MapPinItemResources.Value.ToRequirementConfigs(':'); val.Icons = (Sprite[])(object)new Sprite[1] { Icon }; val.Amount = 1; val.Weight = 0.1f; val.StackSize = Configs.MapPinStackSize.Value; CustomItem mapPinItem = new CustomItem("ZenMapPin", "Club", val); CustomItemExt.ApplyTextureToPrefab(mapPinItem, Icon.texture, 0.35f, Vector2.one * 2f, Vector2.zero, "", true, (Color?)null); ItemManager.Instance.AddItem(mapPinItem); return ConfigSync; void ConfigSync() { Recipe recipe = mapPinItem.Recipe.Recipe; recipe.m_craftingStation = PrefabManagerExt.GetCraftingStation(PrefabManager.Instance, Configs.MapPinCraftingStation.Value); recipe.m_minStationLevel = Configs.MapPinCraftingStationLevel.Value; recipe.m_resources = Configs.MapPinItemResources.Value.ToRequirements(':'); recipe.m_item.m_itemData.m_shared.m_maxStackSize = Configs.MapPinStackSize.Value; } } public static bool IsMapPin(this ItemData? item) { return ((item != null) ? ItemDataExt.GetPrefabName(item) : null) == "ZenMapPin"; } } [HarmonyPatch] internal static class PinDeath { public static bool AllowAdd; [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "AddPin")] private static void Minimap_AddPin(PinType type, ref bool __runOriginal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 __runOriginal = (int)type != 4 || AllowAdd; } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "LoadMapData")] private static void Minimap_LoadMapData(Minimap __instance) { __instance.m_pins.RemoveAll((PinData pin) => (int)pin.m_type == 4); } } [HarmonyPatch] internal static class MapPinType { internal static class VisibleTypes { public static readonly bool[] Everything = Init(state: true); public static readonly bool[] CompassNoMap = Init(state: false); public static readonly bool[] CompassWithMap = Init(state: false); public static readonly bool[] MapTable = Init(state: false); public static readonly bool[] MapItem = Init(state: false); public static readonly bool[] Nothing = Init(state: false); private static bool[] Init(bool state) { return Enumerable.Repeat(state, 384).ToArray(); } } private const int ReservedTypes = 128; private const PinType ReservedStart = 256; private const PinType ReservedEnd = 384; internal const PinType UserPin = 288; public const PinType Raft = 256; public const PinType Karve = 257; public const PinType VikingShip = 258; public const PinType VikingShipAshlands = 259; public const PinType Cart = 260; public const PinType Catapult = 261; public const PinType BatteringRam = 262; public const PinType Mount = 263; public const PinType None = 8; public const PinType Campfire = 0; public const PinType House = 1; public const PinType Hammer = 2; public const PinType Dot = 3; public const PinType Portal = 6; public const PinType Death = 4; public const PinType Boss = 9; public const PinType Bed = 5; public const PinType Player = 10; public static bool IsSignPin(PinType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)type >= 288) { if ((int)type < 384) { goto IL_0016; } } else if ((int)type == 3) { goto IL_0016; } return false; IL_0016: return true; } public static bool IsTrackedPin(PinType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)type < 256 || (int)type >= 384) { return IsSignPin(type); } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "Start")] private static void Minimap_Start(Minimap __instance) { Minimap.instance.m_visibleIconTypes = VisibleTypes.Nothing; } } [HarmonyPatch] internal static class MapPinIcon { internal static readonly Dictionary<int, PinType> NamedPinTypes; internal static readonly Dictionary<PinType, string> PinTypeToResource; private static readonly Dictionary<string, Sprite> SpriteCache; static MapPinIcon() { NamedPinTypes = new Dictionary<int, PinType> { [MapTrack.Pin.Raft] = (PinType)256, [MapTrack.Pin.Karve] = (PinType)257, [MapTrack.Pin.Longship] = (PinType)258, [MapTrack.Pin.Drakkar] = (PinType)259, [MapTrack.Pin.Cart] = (PinType)260, [MapTrack.Pin.Catapult] = (PinType)261, [MapTrack.Pin.BatteringRam] = (PinType)262, [MapTrack.Pin.Tombstone] = (PinType)4, [MapTrack.Pin.Bonfire] = (PinType)0, [MapTrack.Pin.MapTable] = (PinType)1, [MapTrack.Pin.PortalWood] = (PinType)6, [MapTrack.Pin.PortalStone] = (PinType)6 }; PinTypeToResource = new Dictionary<PinType, string> { [(PinType)3] = "flag", [(PinType)256] = "vehicle_ship_raft", [(PinType)257] = "vehicle_ship_karve", [(PinType)258] = "vehicle_ship_longboat", [(PinType)259] = "vehicle_ship_drakkar", [(PinType)260] = "vehicle_cart", [(PinType)261] = "vehicle_catapult", [(PinType)262] = "vehicle_batteringram", [(PinType)263] = "horse", [(PinType)288] = "anvil", [(PinType)289] = "cauldron", [(PinType)290] = "pickaxe", [(PinType)291] = "armor", [(PinType)292] = "axe", [(PinType)293] = "sword", [(PinType)294] = "potion", [(PinType)295] = "bow", [(PinType)296] = "stackedbars", [(PinType)297] = "chest", [(PinType)298] = "tree", [(PinType)299] = "berries", [(PinType)300] = "berries2", [(PinType)301] = "carrot", [(PinType)302] = "turnip", [(PinType)303] = "onion", [(PinType)304] = "mushroom", [(PinType)305] = "fish", [(PinType)306] = "bee", [(PinType)307] = "flower", [(PinType)308] = "bread", [(PinType)309] = "grain", [(PinType)310] = "pig", [(PinType)311] = "chicken", [(PinType)312] = "wolf", [(PinType)313] = "castle", [(PinType)314] = "castle2", [(PinType)315] = "tent", [(PinType)316] = "bridge", [(PinType)317] = "cave", [(PinType)318] = "crystal", [(PinType)319] = "magic_circle", [(PinType)320] = "magic_eye", [(PinType)321] = "magic_book", [(PinType)322] = "swirl", [(PinType)323] = "monster", [(PinType)324] = "monster_trex", [(PinType)325] = "dragon", [(PinType)326] = "dragon2", [(PinType)327] = "kraken", [(PinType)328] = "question" }; SpriteCache = new Dictionary<string, Sprite>(); Logging<Plugin>.Info((object)"Init sprite cache", 0); SpriteCache.Clear(); foreach (string item in PinTypeToResource.Values.Distinct()) { SpriteCache.Add(item, LoadSprite(item)); } } private static Sprite LoadSprite(string name) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) try { if (name.StartsWith("#")) { PinType val = (PinType)int.Parse(name.Substring(1)); return Minimap.instance.GetSprite(val); } if (name.StartsWith("$")) { string text = name.Substring(1); GameObject prefab = ZNetScene.instance.GetPrefab(text); if (Object.op_Implicit((Object)(object)prefab)) { return prefab.GetComponent<Piece>().m_icon; } prefab = ObjectDB.instance.GetItemPrefab(text); if (Object.op_Implicit((Object)(object)prefab)) { return ItemDataExt.GetIcon(prefab.GetComponent<ItemDrop>()); } throw new NullReferenceException("Prefab not found: " + name); } return AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, "MapPins." + name + ".png"); } catch (Exception innerException) { throw new Exception("Failed to load sprite: " + name, innerException); } } private static PinType GetPrefabPinType(int prefabHash) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!NamedPinTypes.TryGetValue(prefabHash, out var value)) { return (PinType)3; } return value; } internal static PinType GetPinTypeFromResourceName(string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) string name2 = name; return PinTypeToResource.First<KeyValuePair<PinType, string>>((KeyValuePair<PinType, string> kvp) => kvp.Value == name2).Key; } internal static PinType GetPinType(this ZDO zdo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return GetPrefabPinType(zdo.GetPrefab()); } private static Sprite? GetCustomIcon(PinType pinType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!PinTypeToResource.TryGetValue(pinType, out string value)) { return null; } return SpriteCache[value]; } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "GetSprite")] private static void Minimap_GetSprite(PinType type, ref Sprite? __result, ref bool __runOriginal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Sprite customIcon = GetCustomIcon(type); if (Object.op_Implicit((Object)(object)customIcon)) { __result = customIcon; __runOriginal = false; } } } [HarmonyPatch] internal static class MapTrack { public static class Pin { public static readonly int Sign = StringExtensionMethods.GetStableHashCode("sign"); public static readonly int Tombstone = StringExtensionMethods.GetStableHashCode("Player_tombstone"); public static readonly int MapTable = StringExtensionMethods.GetStableHashCode("piece_cartographytable"); public static readonly int Bonfire = StringExtensionMethods.GetStableHashCode("bonfire"); public static readonly int Raft = StringExtensionMethods.GetStableHashCode("Raft"); public static readonly int Karve = StringExtensionMethods.GetStableHashCode("Karve"); public static readonly int Longship = StringExtensionMethods.GetStableHashCode("VikingShip"); public static readonly int Drakkar = StringExtensionMethods.GetStableHashCode("VikingShip_Ashlands"); public static readonly int Cart = StringExtensionMethods.GetStableHashCode("Cart"); public static readonly int Catapult = StringExtensionMethods.GetStableHashCode("Catapult"); public static readonly int BatteringRam = StringExtensionMethods.GetStableHashCode("BatteringRam"); public static readonly int PortalWood = StringExtensionMethods.GetStableHashCode("portal_wood"); public static readonly int PortalStone = StringExtensionMethods.GetStableHashCode("portal_stone"); public static readonly HashSet<int> Mounts = new HashSet<int>(); } internal static readonly Dictionary<int, PinOption> PinToOption = new Dictionary<int, PinOption> { { Pin.Sign, PinOption.Sign }, { Pin.Raft, PinOption.SmallBoat }, { Pin.Karve, PinOption.SmallBoat }, { Pin.Longship, PinOption.LargeShip }, { Pin.Drakkar, PinOption.LargeShip }, { Pin.Cart, PinOption.Cart }, { Pin.Catapult, PinOption.WarMachine }, { Pin.BatteringRam, PinOption.WarMachine }, { Pin.Tombstone, PinOption.Tombstone }, { Pin.MapTable, PinOption.MapTable }, { Pin.Bonfire, PinOption.Bonfire }, { Pin.PortalWood, PinOption.Portal }, { Pin.PortalStone, PinOption.Portal } }; private const string GuidPrefix = "GUID|"; private static readonly int ZDOVarGUID = StringExtensionMethods.GetStableHashCode("GUID|"); private static readonly Dictionary<Guid, ZDOID> GuidIndexZDOID = new Dictionary<Guid, ZDOID>(); private static readonly Dictionary<Guid, PinData> GuidIndexPin = new Dictionary<Guid, PinData>(); private static readonly Dictionary<PinData, Guid> PinToGuidCache = new Dictionary<PinData, Guid>(); private static bool _isIndexReady; private const string DataDelimiter = "\0#"; private static readonly int DataSize; internal static void Init() { Configs.UpdatePinOptions(); ZRoutedRpc.instance.Register<ZDOID>("RPC_StopTracking", (Action<long, ZDOID>)RPC_StopTracking); _isIndexReady = false; Logging<Plugin>.Info((object)"Waiting before rebuilding index...", 0); Timing.Delay((MonoBehaviour)(object)ZenMod<Plugin>.Instance, 3f, (Action)delegate { RebuildIndex(); SetupAutoPins(); _isIndexReady = true; }); } internal static void Shutdown() { _isIndexReady = false; ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { ZRoutedRpcExt.Unregister(instance, "RPC_StopTracking"); } } public static PinOption GetPinOption(int prefabHash) { if (!PinToOption.TryGetValue(prefabHash, out var value)) { return PinOption.None; } return value; } private static void SetupAutoPins() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) Logging<Plugin>.Debug((object)"Refreshing AutoPins", 0); ZDOID[] array = GuidIndexZDOID.Values.ToArray(); foreach (ZDOID val in array) { ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO == null) { Logging<Plugin>.Warning((object)$"ZDO is null for ZDOID: {val} - skipping.", 0); } else { AutoPinIfReq(zDO); } } } [HarmonyTranspiler] [HarmonyPatch(typeof(Minimap), "AddPin")] private static IEnumerable<CodeInstruction> Minimap_AddPin(IEnumerable<CodeInstruction> codes) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Minimap), "ToggleIconFilter", (Type[])null, (Type[])null), (string)null) }; return new CodeMatcher(codes, (ILGenerator)null).MatchStartForward(array).ThrowIfInvalid("Unable to match IL").SetAndAdvance(OpCodes.Nop, (object)null) .SetAndAdvance(OpCodes.Nop, (object)null) .SetAndAdvance(OpCodes.Nop, (object)null) .InstructionEnumeration(); } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static void Minimap_UpdatePins(Minimap __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 bool flag = (int)__instance.m_mode != 2; Minimap instance = Minimap.instance; bool[] visibleIconTypes = (((Character)Player.m_localPlayer).InGodMode() ? MapPinType.VisibleTypes.Everything : (MapLocation.IsMapItem() ? MapPinType.VisibleTypes.MapItem : (MapLocation.IsMapTable() ? MapPinType.VisibleTypes.MapTable : ((!flag) ? MapPinType.VisibleTypes.Nothing : (InventoryCheck.HaveMap ? MapPinType.VisibleTypes.CompassWithMap : MapPinType.VisibleTypes.CompassNoMap))))); instance.m_visibleIconTypes = visibleIconTypes; } [HarmonyPrefix] [HarmonyPatch(typeof(Minimap), "UpdateDynamicPins")] private static void Minimap_UpdateDynamicPins(float dt) { if (_isIndexReady) { UpdatePins(dt); } } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "AddPin")] private static void Minimap_AddPin(PinData? __result) { if (__result != null) { UpdateIndex(__result); } } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })] private static void Minimap_RemovePin(PinData? pin) { if (pin != null) { GuidIndexPin.Remove(pin.GetGuid()); RemoveFromCache(pin); } } [HarmonyPrefix] [HarmonyPatch(typeof(ZDOMan), "CreateSyncList")] private static void ZDOMan_CreateSyncList(ZDOMan __instance) { if (!ZNet.IsSinglePlayer && ZNet.instance.IsServer()) { CollectionExtensions.Do<ZDOID>((IEnumerable<ZDOID>)GuidIndexZDOID.Values, (Action<ZDOID>)__instance.ForceSendZDO); } } [HarmonyPrefix] [HarmonyPatch(typeof(ZDOMan), "HandleDestroyedZDO")] private static void ZDOMan_HandleDestroyedZDO(ZDOID uid) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!Game.instance.IsShuttingDown()) { RemoveIndexAndPin(uid, out ZDO _); } } [HarmonyPostfix] [HarmonyPatch(typeof(ZDOMan), "FilterZDO")] private static void ZDOMan_FilterZDO(ZDO? zdo) { if (zdo != null) { UpdateIndex(zdo); } } [HarmonyPostfix] [HarmonyPatch(typeof(ZDOMan), "GetZDO")] private static void ZDOMan_GetZDO(ZDO? __result) { if (__result != null) { UpdateIndex(__result); } } [HarmonyTranspiler] [HarmonyPatch(typeof(ZDOMan), "RPC_ZDOData")] private static IEnumerable<CodeInstruction> ZDOMan_RPC_ZDOData(IEnumerable<CodeInstruction> codes) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZDO), "Deserialize", (Type[])null, (Type[])null); Action<ZDO, ZPackage> action = DeserializeIntercept; return Transpilers.MethodReplacer(codes, (MethodBase)methodInfo, (MethodBase)action.Method); static void DeserializeIntercept(ZDO zdo, ZPackage pkg) { zdo.Deserialize(pkg); UpdateIndex(zdo); AutoPinIfReq(zdo); } } [HarmonyPostfix] [HarmonyPatch(typeof(ZNetView), "Awake")] private static void ZNetView_Awake(ZNetView __instance) { if (__instance.IsValid()) { AutoPinIfReq(__instance.GetZDO()); } } public static int GetPrefabHash(this PinData pin) { if (!pin.TryGetZDO(out ZDO zdo)) { return 0; } return zdo.GetPrefab(); } private static bool IsAutoPinPrefab(ZDO zdo) { if (zdo.GetPrefab() != Pin.Sign && !Pin.Mounts.Contains(zdo.GetPrefab())) { return PinToOption.ContainsKey(zdo.GetPrefab()); } return false; } private static void AutoPinIfReq(ZDO zdo) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (IsAutoPinPrefab(zdo)) { if (ZNet.instance.IsDedicated()) { TrackZDO(zdo); } else if (zdo.FindPin() == null) { Logging<Plugin>.Info((object)$"Adding autopin for ZDO: {ZdoExt.GetPrefabName(zdo)} {zdo.m_uid}", 0); AddPin(zdo, save: false, (PinType)8); } } } private static void RebuildIndex() { Logging<Plugin>.Info((object)"Rebuilding Guid to ZDO index", 0); GuidIndexZDOID.Clear(); foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { UpdateIndex(value); if (ZNet.instance.IsServer() && IsAutoPinPrefab(value)) { TrackZDO(value); } } Logging<Plugin>.Info((object)"Rebuilding Guid to PinData index", 0); GuidIndexPin.Clear(); PinToGuidCache.Clear(); foreach (PinData pin in Minimap.instance.m_pins) { UpdateIndex(pin); VerifyMountPins(pin); } } private static void VerifyMountPins(PinData pin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_003b: 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) if ((int)pin.m_type != 263 && Pin.Mounts.Contains(pin.GetPrefabHash())) { Logging<Plugin>.Message((object)("Restoring mount pin type for " + pin.GetLabel()), 0); pin.m_type = (PinType)263; pin.m_icon = Minimap.instance.GetSprite(pin.m_type); } } private static Guid UpdateIndex(PinData pin) { Guid guid = pin.GetGuid(); if (guid != Guid.Empty) { GuidIndexPin[guid] = pin; } return guid; } private static Guid UpdateIndex(ZDO zdo) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Guid guid = zdo.GetGuid(); if (guid != Guid.Empty) { GuidIndexZDOID[guid] = zdo.m_uid; } return guid; } private static ZDOID LookupZDOID(Guid guid) { //IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references) if (guid == Guid.Empty) { return ZDOID.None; } if (!GuidIndexZDOID.TryGetValue(guid, out var value)) { return ZDOID.None; } return value; } private static Guid GetGuid(this ZDO? zdo) { byte[] array = ((zdo != null) ? zdo.GetByteArray(ZDOVarGUID, (byte[])null) : null); if (array == null || array.Length != 16) { return Guid.Empty; } return new Guid(array); } public static string CreateTrackingLabel(string label, Guid guid) { if (label.Contains("\0#")) { throw new ArgumentException("label already contains guid, double guid encoding is not safe"); } return label + "\0#" + guid.ToString("N"); } private static string RemoveTrackingFromLabel(string label) { int num = label.IndexOf("\0#", StringComparison.Ordinal); if (num >= 0) { return label.Substring(0, num); } return label; } public static bool IsTracked(this PinData pin) { return pin.GetGuid() != Guid.Empty; } public static Guid GetGuid(this PinData pin) { if (PinToGuidCache.TryGetValue(pin, out var value)) { return value; } if (Utility.IsNullOrWhiteSpace(pin.m_name) || pin.m_name.Length < DataSize + "\0#".Length) { return Guid.Empty; } int num = pin.m_name.IndexOf("\0#"[0]); if (num < 0 || num >= pin.m_name.Length - 1 || pin.m_name[num + 1] != "\0#"[1]) { return Guid.Empty; } value = Guid.ParseExact(pin.m_name.Substring(num + "\0#".Length, DataSize), "N"); Logging<Plugin>.Info((object)$"Caching Pin: {value}", 0); PinToGuidCache.Add(pin, value); return value; } public static string GetLabel(this PinData pin) { return RemoveTrackingFromLabel(pin.m_name); } public static PinData? FindPin(this ZDO zdo) { return FindPin(zdo.GetGuid()); } private static PinData? FindPin(Guid guid) { if (!GuidIndexPin.TryGetValue(guid, out PinData value)) { return null; } return value; } public static void RemovePin(PinData pin) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Logging<Plugin>.Info((object)$"Remove Pin: {pin.m_name} {MathExt.XZY(pin.m_pos)}", 0); Minimap.instance.RemovePin(pin); } internal static void RemoveFromCache(PinData pin) { PinToGuidCache.Remove(pin); } private static void RPC_StopTracking(long sender, ZDOID zid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (RemoveIndexAndPin(zid, out ZDO removedZDO) && removedZDO.IsOwner()) { Logging<Plugin>.Info((object)$"Zero out Guid for ZDO: {zid}", 0); removedZDO.Set(ZDOVarGUID, Array.Empty<byte>()); } } public static void StopTracking(ZDO zdo) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!zdo.HasOwner()) { zdo.SetOwner(ZDOMan.GetSessionID()); } ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_StopTracking", new object[1] { zdo.m_uid }); } private static bool RemoveIndexAndPin(ZDOID zid, out ZDO removedZDO) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) removedZDO = ZDOMan.instance.GetZDO(zid); Guid guid = removedZDO.GetGuid(); if (guid != Guid.Empty) { Logging<Plugin>.Info((object)$"ZDOID: {zid} remove Guid: {guid}", 0); GuidIndexZDOID.Remove(guid); } if (Object.op_Implicit((Object)(object)Minimap.instance)) { PinData val = FindPin(guid); if (val != null) { RemovePin(val); } } return removedZDO != null; } private static Guid TrackZDO(ZDO zdo) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) Guid guid = zdo.GetGuid(); if (guid != Guid.Empty) { return guid; } ZNetView val = ZNetScene.instance.FindInstance(zdo); if (Object.op_Implicit((Object)(object)val)) { val.ClaimOwnership(); } guid = Guid.NewGuid(); Logging<Plugin>.Info((object)$"Create new Guid: {guid} for zdo {zdo.m_uid}", 0); zdo.Set(ZDOVarGUID, guid.ToByteArray()); UpdateIndex(zdo); return guid; } public static bool TryGetZDO(Guid guid, out ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ZDOID val = LookupZDOID(guid); zdo = ZDOMan.instance.GetZDO(val); return zdo != null; } private static bool TryGetZDO(this PinData pin, out ZDO zdo) { return TryGetZDO(pin.GetGuid(), out zdo); } private static bool IsSharedPin(PinData pin) { if (pin.m_ownerID != Player.m_localPlayer.GetPlayerID()) { return pin.m_ownerID != 0; } return false; } private static void UpdatePins(float dt) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Invalid comparison between Unknown and I4 //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Invalid comparison between Unknown and I4 if (Game.instance.IsShuttingDown()) { return; } List<PinData> pins = Minimap.instance.m_pins; Player localPlayer = Player.m_localPlayer; ZNetView attached = null; Ship controlled = PlayerExt.GetControlled<Ship>(localPlayer); if (Object.op_Implicit((Object)(object)controlled)) { attached = controlled.m_nview; } if (!Object.op_Implicit((Object)(object)attached)) { Sadle controlled2 = PlayerExt.GetControlled<Sadle>(localPlayer); if (Object.op_Implicit((Object)(object)controlled2)) { attached = controlled2.m_nview; } } if (!Object.op_Implicit((Object)(object)attached) && ((Character)localPlayer).IsAttachedToShip() && Object.op_Implicit((Object)(object)localPlayer.m_attachPoint)) { attached = ((Component)localPlayer.m_attachPoint).GetComponentInParent<ZNetView>(); } int num = pins.Count - 1; PinData pin; while (num >= 0) { pin = pins[num]; ZDO zdo; if (IsSharedPin(pin)) { Logging<Plugin>.Debug((object)"Shared pin found, ignoring", 0); } else if (!pin.TryGetZDO(out zdo)) { if (pin.GetGuid() != Guid.Empty) { RemovePin(pin); } } else { Vector3 position = zdo.GetPosition(); pin.m_pos = Vector3.MoveTowards(pin.m_pos, position, 200f * dt); if (!MathExt.Approximately(pin.m_pos, position)) { Minimap.instance.m_pinUpdateRequired = true; } MapMode mode = Minimap.instance.m_mode; if ((int)mode > 1) { if ((int)mode != 2) { throw new ArgumentOutOfRangeException("m_mode"); } bool num2 = PlayerExt.IsShipCaptain(localPlayer) && (!Configs.HideShipBanana.Value || ((Character)Player.m_localPlayer).InGodMode()); ShowShipBanana(num2); ShowAttachedPin(!num2); pin.SetLabel(zdo.GetLabel()); } else { ShowAttachedPin(isVisible: false); } } num--; void ShowAttachedPin(bool isVisible) { bool flag = Object.op_Implicit((Object)(object)attached) && zdo == attached.GetZDO(); ShowPin(isVisible || !flag); } } void ShowPin(bool isVisible) { RectTransform uiElement = pin.m_uiElement; if (uiElement != null) { ((Component)uiElement).gameObject.SetActive(isVisible); } } static void ShowShipBanana(bool isVisible) { ((Component)Minimap.instance.m_largeShipMarker).gameObject.SetActive(isVisible); } } public static bool AddPin(ZDO zdo, bool save, PinType type = 8) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0038: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) if (ZNet.instance.IsDedicated()) { throw new Exception("AddPin() should not be called on dedicated servers"); } PinData val = zdo.FindPin(); if (val != null) { Logging<Plugin>.Debug((object)$"Pin already exists: {val.GetGuid()} {val.m_name} {val.m_pos}", 0); return false; } string label = zdo.GetLabel(); Vector3 position = zdo.GetPosition(); Guid guid = TrackZDO(zdo); string text = CreateTrackingLabel(label, guid); Logging<Plugin>.Info((object)("Tracking Label: " + text), 0); if ((int)type == 8) { type = zdo.GetPinType(); } PinDeath.AllowAdd = true; PinData val2 = Minimap.instance.AddPin(position, type, text, save, false, 0L, default(PlatformUserID)); PinDeath.AllowAdd = false; if (val2 == null) { return false; } Logging<Plugin>.Info((object)$"Add pin type: {val2.m_type} {guid} {ZdoExt.GetPrefabName(zdo)} ({MathExt.XZY(position)}) ", 0); return true; } private static void SetLabel(this PinData pin, string label) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!Utility.IsNullOrWhiteSpace(label)) { pin.m_name = CreateTrackingLabel(label, pin.GetGuid()); if (pin.m_NamePinData == null) { pin.m_NamePinData = new PinNameData(pin); } if (Object.op_Implicit((Object)(object)pin.m_NamePinData.PinNameText)) { pin.m_NamePinData.PinNameText.text = pin.GetLabel(); } } } internal static string GetLabel(this ZDO zdo) { GameObject prefab = ZNetScene.instance.GetPrefab(zdo.GetPrefab()); Sign val = default(Sign); string text = default(string); if (prefab.TryGetComponent<Sign>(ref val) && zdo.GetString(ZDOVars.s_text, ref text)) { if (!(text != val.m_defaultText)) { return string.Empty; } return text; } Tameable val2 = default(Tameable); if (prefab.T