Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MapHeim v0.3.2
plugins/MapHeim.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MapHeim")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5c976bfab5d765f1652acc6965a3bf64d7834904")] [assembly: AssemblyProduct("MapHeim")] [assembly: AssemblyTitle("MapHeim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MapHeim { internal static class AutoPins { private enum Category { Runestone, Dungeon, Structure } private static float _nextScan; private static readonly Dictionary<int, string> DepositNames = new Dictionary<int, string>(); private static Category Classify(string prefab) { string text = prefab.ToLowerInvariant(); if (text.Contains("runestone") || text.Contains("vegvisir")) { return Category.Runestone; } if (text.Contains("crypt") || text.Contains("cave") || text.Contains("dungeon") || text.Contains("burialchamber") || text.Contains("grave") || (text.Contains("forge") && text.Contains("cave"))) { return Category.Dungeon; } return Category.Structure; } private static string PrettyName(string prefab) { return Regex.Replace(Regex.Replace(prefab, "[0-9_]+$", ""), "(?<=[a-z])(?=[A-Z])", " ").Replace('_', ' ').Trim(); } public static void Tick(Player player, Minimap map) { //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) if (MapHeimPlugin.AutoPinsEnabled.Value && !(Time.time < _nextScan)) { _nextScan = Time.time + 2f; Vector3 position = ((Component)player).transform.position; ScanLocations(position, map); ScanDeposits(position, map); } } private static void ScanLocations(Vector3 origin, Minimap map) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return; } float value = MapHeimPlugin.LocationRadius.Value; float num = value * value; foreach (LocationInstance value2 in instance.m_locationInstances.Values) { if (!value2.m_placed) { continue; } Vector3 val = value2.m_position - origin; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > num)) { string prefabName = value2.m_location.m_prefabName; Category category = Classify(prefabName); if ((category != Category.Runestone || MapHeimPlugin.PinRunestones.Value) && (category != Category.Dungeon || MapHeimPlugin.PinDungeons.Value) && (category != Category.Structure || MapHeimPlugin.PinStructures.Value)) { PinType type = (PinType)(category switch { Category.Dungeon => 6, Category.Runestone => 3, _ => 1, }); Add(map, value2.m_position, type, PrettyName(prefabName), 30f); } } } } private static void ScanDeposits(Vector3 origin, Minimap map) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_009c: Unknown result type (might be due to invalid IL or missing references) if (!MapHeimPlugin.PinOre.Value || ZDOMan.instance == null) { return; } float value = MapHeimPlugin.DepositRadius.Value; float num = value * value; string[] keywords = MapHeimPlugin.OreKeywords.Value.ToLowerInvariant().Split(','); foreach (ZDO value2 in ZDOMan.instance.m_objectsByID.Values) { Vector3 position = value2.GetPosition(); float num2 = position.x - origin.x; float num3 = position.z - origin.z; if (!(num2 * num2 + num3 * num3 > num)) { string text = DepositName(value2.GetPrefab(), keywords); if (text != null) { Add(map, position, (PinType)2, text, 12f); } } } } private static string DepositName(int prefabHash, string[] keywords) { if (DepositNames.TryGetValue(prefabHash, out var value)) { return value; } string text = null; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabHash) : null); if ((Object)(object)val != (Object)null && ((Object)(object)val.GetComponent<MineRock5>() != (Object)null || (Object)(object)val.GetComponent<MineRock>() != (Object)null || (Object)(object)val.GetComponent<Destructible>() != (Object)null)) { string text2 = ((Object)val).name.ToLowerInvariant(); for (int i = 0; i < keywords.Length; i++) { string text3 = keywords[i].Trim(); if (text3.Length > 0 && text2.Contains(text3)) { text = char.ToUpperInvariant(text3[0]) + text3.Substring(1) + " deposit"; break; } } } DepositNames[prefabHash] = text; return text; } private static void Add(Minimap map, Vector3 position, PinType type, string name, float spacing) { //IL_0017: 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_001d: 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) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) foreach (PinData pin in map.m_pins) { Vector3 val = pin.m_pos - position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < spacing * spacing && (pin.m_type == type || pin.m_name == name)) { return; } } map.AddPin(position, type, name, true, false, 0L, default(PlatformUserID)); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "Map: " + name, 0, (Sprite)null, false); } } } [HarmonyPatch(typeof(MineRock5), "Damage")] internal static class HitDepositPatch { private static void Postfix(MineRock5 __instance, HitData hit) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (MapHeimPlugin.AutoPinsEnabled.Value && MapHeimPlugin.PinOre.Value && !((Object)(object)Minimap.instance == (Object)null) && hit != null && !((Object)(object)hit.GetAttacker() != (Object)(object)Player.m_localPlayer)) { AutoPinsHit.Pin(((Component)__instance).gameObject, ((Component)__instance).transform.position); } } } internal static class AutoPinsHit { public static void Pin(GameObject go, Vector3 position) { //IL_0069: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) string text = Utils.GetPrefabName(go).ToLowerInvariant(); string[] array = MapHeimPlugin.OreKeywords.Value.ToLowerInvariant().Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0 || !text.Contains(text2)) { continue; } foreach (PinData pin in Minimap.instance.m_pins) { Vector3 val = pin.m_pos - position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 144f && (int)pin.m_type == 2) { return; } } Minimap.instance.AddPin(position, (PinType)2, char.ToUpperInvariant(text2[0]) + text2.Substring(1) + " deposit", true, false, 0L, default(PlatformUserID)); break; } } } internal static class DungeonMap { private const float CellSize = 0.5f; private const int Pixels = 128; private const float PictureMeters = 64f; private const byte Floor = 1; private const byte Wall = 2; private static readonly Dictionary<long, byte> Cells = new Dictionary<long, byte>(); private static readonly Color32 Unknown = new Color32((byte)14, (byte)11, (byte)9, (byte)235); private static readonly Color32 FloorColor = new Color32((byte)98, (byte)82, (byte)60, byte.MaxValue); private static readonly Color32 WallColor = new Color32((byte)232, (byte)214, (byte)168, byte.MaxValue); private static RawImage _image; private static Texture2D _texture; private static Color32[] _buffer; private static float _nextScan; private static float _nextDraw; private static int _mask; public static bool Showing { get; private set; } public static float MetersAcross => Mathf.Max(8f, MapHeimPlugin.ShownMeters.Value / MapZoom.Level); private static long Key(int x, int z) { return ((long)x << 32) ^ (uint)z; } private static bool InDungeon(Player player) { return ((Character)player).InInterior(); } public static void Hide() { Showing = false; if ((Object)(object)_image != (Object)null) { ((Component)_image).gameObject.SetActive(false); } } public static void Tick(Player player, Minimap map) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (!MapHeimPlugin.DungeonEnabled.Value || !InDungeon(player) || (Object)(object)map.m_mapImageSmall == (Object)null) { if (Showing) { RestoreMap(map); } return; } if (_mask == 0) { _mask = LayerMask.GetMask(new string[4] { "Default", "static_solid", "Default_small", "piece" }); } EnsureImage(map); if (Time.time >= _nextScan) { _nextScan = Time.time + 0.1f; Scan(player); } if (Time.time >= _nextDraw) { _nextDraw = Time.time + 0.15f; Draw(((Component)player).transform.position); } Showing = true; ((Component)_image).gameObject.SetActive(true); ((Behaviour)map.m_mapImageSmall).enabled = false; float num = Mathf.Clamp(MetersAcross / 64f, 0.05f, 1f); Vector3 position = ((Component)player).transform.position; Vector2 val = CellCentre(position); Vector2 val2 = new Vector2(position.x - val.x, position.z - val.y) / 64f; _image.uvRect = new Rect(0.5f + val2.x - num / 2f, 0.5f + val2.y - num / 2f, num, num); } private static void RestoreMap(Minimap map) { Showing = false; if ((Object)(object)_image != (Object)null) { ((Component)_image).gameObject.SetActive(false); } if ((Object)(object)map.m_mapImageSmall != (Object)null) { ((Behaviour)map.m_mapImageSmall).enabled = true; } } private static Vector2 CellCentre(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) return new Vector2((Mathf.Floor(position.x / 0.5f) + 0.5f) * 0.5f, (Mathf.Floor(position.z / 0.5f) + 0.5f) * 0.5f); } private static void EnsureImage(Minimap map) { //IL_0081: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00aa: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_image != (Object)null) || !((Object)(object)((Component)_image).transform.parent == (Object)(object)((Component)map.m_mapImageSmall).transform.parent)) { if ((Object)(object)_image != (Object)null) { Object.Destroy((Object)(object)((Component)_image).gameObject); } RectTransform rectTransform = ((Graphic)map.m_mapImageSmall).rectTransform; GameObject val = new GameObject("MapHeimDungeon", new Type[2] { typeof(RectTransform), typeof(RawImage) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(((Transform)rectTransform).parent, false); val2.anchorMin = rectTransform.anchorMin; val2.anchorMax = rectTransform.anchorMax; val2.pivot = rectTransform.pivot; val2.anchoredPosition = rectTransform.anchoredPosition; val2.sizeDelta = rectTransform.sizeDelta; ((Transform)val2).SetSiblingIndex(((Transform)rectTransform).GetSiblingIndex() + 1); if ((Object)(object)_texture == (Object)null) { _texture = new Texture2D(128, 128, (TextureFormat)4, false) { name = "MapHeimDungeon", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; Texture2D texture = _texture; ((Object)texture).hideFlags = (HideFlags)(((Object)texture).hideFlags | 0x20); _buffer = (Color32[])(object)new Color32[16384]; } _image = val.GetComponent<RawImage>(); _image.texture = (Texture)(object)_texture; ((Graphic)_image).raycastTarget = false; } } private static void Scan(Player player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001a: 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) //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0081: 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_00bd: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Vector3 origin = ((Component)player).transform.position + Vector3.up * 1.1f; Vector3 val = ((Character)player).GetLookDir(); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)player).transform.forward; } ((Vector3)(ref val)).Normalize(); float reach = MapHeimPlugin.ViewFeet.Value * 0.3048f; for (int i = 0; i < 16; i++) { Cast(origin, Quaternion.Euler(0f, (float)i * 22.5f, 0f) * Vector3.forward, 1.6f); } for (int j = 0; j < 31; j++) { float num = Mathf.Lerp(-65f, 65f, (float)j / 30f); Cast(origin, Quaternion.Euler(0f, num, 0f) * val, reach); } } private static void Cast(Vector3 origin, Vector3 direction, float reach) { //IL_0004: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0073: 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) float num = reach; bool flag = false; RaycastHit val = default(RaycastHit); if (Physics.Raycast(origin, direction, ref val, reach, _mask, (QueryTriggerInteraction)1)) { num = ((RaycastHit)(ref val)).distance; flag = true; } for (float num2 = 0f; num2 < num - 0.05f; num2 += 0.4f) { Vector3 val2 = origin + direction * num2; Mark(val2.x, val2.z, 1); } if (flag) { Vector3 val3 = origin + direction * (num + 0.1f); Mark(val3.x, val3.z, 2); } } private static void Mark(float x, float z, byte kind) { long key = Key(Mathf.FloorToInt(x / 0.5f), Mathf.FloorToInt(z / 0.5f)); if (!Cells.TryGetValue(key, out var value) || value < kind) { Cells[key] = kind; } } private static void Draw(Vector3 position) { //IL_0000: 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_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_0069: 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) int num = Mathf.FloorToInt(position.x / 0.5f) - 64; int num2 = Mathf.FloorToInt(position.z / 0.5f) - 64; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { Cells.TryGetValue(Key(num + j, num2 + i), out var value); _buffer[i * 128 + j] = (Color32)(value switch { 1 => FloorColor, 2 => WallColor, _ => Unknown, }); } } _texture.SetPixelData<Color32>(_buffer, 0, 0); _texture.Apply(false, false); } } internal static class Gps { private const float WindowSeconds = 20f; private static readonly List<(float time, Vector3 position)> Samples = new List<(float, Vector3)>(); private static bool _active; private static Vector3 _target; private static string _name = ""; private static float _nextSample; private static GUIStyle _style; private static Texture2D _arrow; public static bool Active => _active; public static void Clear() { _active = false; } public static void Set(Vector3 position, string name) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _active = true; _target = position; _name = (string.IsNullOrWhiteSpace(name) ? "Marker" : name); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "GPS set: " + _name, 0, (Sprite)null, false); } } public static void Tick(Player player, Minimap map) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b9: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (time >= _nextSample) { _nextSample = time + 0.5f; Samples.Add((time, ((Component)player).transform.position)); while (Samples.Count > 0 && time - Samples[0].time > 20f) { Samples.RemoveAt(0); } } if (Minimap.IsOpen() && Input.GetKeyDown(MapHeimPlugin.GpsKey.Value)) { PinData closestPin = map.GetClosestPin(map.ScreenToWorldPoint(ZInput.pointerPosition), map.PinInteractRadius, true); if (closestPin != null) { if (_active) { Vector3 val = closestPin.m_pos - _target; if (((Vector3)(ref val)).sqrMagnitude < 4f) { _active = false; ((Character)player).Message((MessageType)1, "GPS off", 0, (Sprite)null, false); goto IL_010e; } } Set(closestPin.m_pos, closestPin.m_name); } else if (_active) { _active = false; ((Character)player).Message((MessageType)1, "GPS off", 0, (Sprite)null, false); } } goto IL_010e; IL_010e: if (_active && Distance(((Component)player).transform.position) < MapHeimPlugin.GpsArriveMeters.Value) { _active = false; ((Character)player).Message((MessageType)2, "Arrived: " + _name, 0, (Sprite)null, false); } } private static float Distance(Vector3 from) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _target - from; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private static float Speed() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (Samples.Count < 2) { return 0f; } float num = 0f; for (int i = 1; i < Samples.Count; i++) { Vector3 val = Samples[i].position - Samples[i - 1].position; val.y = 0f; num += ((Vector3)(ref val)).magnitude; } float num2 = Samples[Samples.Count - 1].time - Samples[0].time; if (!(num2 > 1f)) { return 0f; } return num / num2; } public static void Draw() { //IL_00a9: 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_0073: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0174: 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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (_active && !((Object)(object)localPlayer == (Object)null) && MapHeimPlugin.GpsEnabled.Value && !((Object)(object)Hud.instance == (Object)null) && Hud.instance.m_rootObject.activeSelf) { float num = Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 2.5f); if (_style == null) { _style = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, fontStyle = (FontStyle)1, richText = true }; } _style.fontSize = Mathf.RoundToInt(20f * num); float num2 = Distance(((Component)localPlayer).transform.position); float num3 = Speed(); string text = ((num3 > 0.4f) ? Format(num2 / num3) : "--"); string text2 = ((num2 >= 1000f) ? $"{num2 / 1000f:0.0} km" : $"{Mathf.RoundToInt(num2)} m"); Vector3 val = _target - ((Component)localPlayer).transform.position; float num4 = Mathf.Atan2(val.x, val.z) * 57.29578f; Transform val2 = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : null); float num5 = (((Object)(object)val2 != (Object)null) ? val2.eulerAngles.y : ((Component)localPlayer).transform.eulerAngles.y); float num6 = num4 - num5; float num7 = 46f * num; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor((float)Screen.width / 2f - 230f * num, 12f * num, num7, num7); Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(num6, ((Rect)(ref val3)).center); GUI.color = new Color(1f, 0.85f, 0.3f); GUI.DrawTexture(val3, (Texture)(object)Arrow()); GUI.color = Color.white; GUI.matrix = matrix; GUI.Label(new Rect(((Rect)(ref val3)).xMax + 10f * num, ((Rect)(ref val3)).y, 420f * num, num7), "<color=#ffd966>" + _name + "</color> " + text2 + " ETA " + text, _style); } } private static string Format(float seconds) { int num = Mathf.RoundToInt(Mathf.Min(seconds, 359999f)); if (num < 3600) { return $"{num / 60}:{num % 60:00}"; } return $"{num / 3600}:{num % 3600 / 60:00}:{num % 60:00}"; } private static Texture2D Arrow() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_arrow != (Object)null) { return _arrow; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f; float num2 = ((float)i + 0.5f) / 64f; float num3 = Mathf.Lerp(0f, 0.34f, 1f - Mathf.Clamp01((num2 - 0.12f) / 0.8f)); bool flag = num2 > 0.12f && num2 < 0.92f && Mathf.Abs(num - 0.5f) < num3 && (!(num2 < 0.34f) || !(Mathf.Abs(num - 0.5f) < (0.34f - num2) * 0.6f)); array[i * 64 + j] = (flag ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); } } _arrow = new Texture2D(64, 64, (TextureFormat)4, false) { name = "MapHeimArrow", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; _arrow.SetPixelData<Color32>(array, 0, 0); _arrow.Apply(false, true); Texture2D arrow = _arrow; ((Object)arrow).hideFlags = (HideFlags)(((Object)arrow).hideFlags | 0x20); return _arrow; } } [BepInPlugin("mbaya.MapHeim", "MapHeim", "0.3.2")] public class MapHeimPlugin : BaseUnityPlugin { public const string Guid = "mbaya.MapHeim"; public const string Name = "MapHeim"; public const string Version = "0.3.2"; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> ZoomInKey; internal static ConfigEntry<KeyCode> ZoomOutKey; internal static ConfigEntry<bool> ScrollZoom; internal static ConfigEntry<float> Zoom; internal static ConfigEntry<bool> TrailEnabled; internal static ConfigEntry<float> TrailSeconds; internal static ConfigEntry<Color> TrailColor; internal static ConfigEntry<float> TrailWidth; internal static ConfigEntry<bool> DungeonEnabled; internal static ConfigEntry<float> ViewFeet; internal static ConfigEntry<float> ShownMeters; internal static ConfigEntry<bool> GpsEnabled; internal static ConfigEntry<KeyCode> GpsKey; internal static ConfigEntry<float> GpsArriveMeters; internal static ConfigEntry<bool> AutoPinsEnabled; internal static ConfigEntry<bool> PinRunestones; internal static ConfigEntry<bool> PinDungeons; internal static ConfigEntry<bool> PinStructures; internal static ConfigEntry<bool> PinOre; internal static ConfigEntry<float> LocationRadius; internal static ConfigEntry<float> DepositRadius; internal static ConfigEntry<string> OreKeywords; private Harmony _harmony; private void Awake() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Expected O, but got Unknown //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ZoomInKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Zoom", "ZoomInKey", (KeyCode)93, "Zooms the minimap in."); ZoomOutKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Zoom", "ZoomOutKey", (KeyCode)91, "Zooms the minimap out."); ScrollZoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Zoom", "CtrlScrollZoom", true, "Hold Ctrl and use the mouse wheel to zoom the minimap."); Zoom = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "Zoom", 1f, new ConfigDescription("The minimap's zoom, 1 = the game's own. Bigger shows less, closer up. (Set by the keys; saved.)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 6f), Array.Empty<object>())); TrailEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Trail", "ShowTrail", true, "Show a trail of dots behind you on the minimap, where you've just been."); TrailSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Trail", "Seconds", 90f, new ConfigDescription("How long the trail lasts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); TrailColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Trail", "Color", new Color(1f, 0.82f, 0.25f), "The trail's colour (the oldest dots fade away)."); TrailWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Trail", "Width", 2f, new ConfigDescription("How thick the trail line is, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 8f), Array.Empty<object>())); DungeonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Dungeon", "DungeonMap", true, "Inside a dungeon, the minimap draws a plan of the walls you've seen instead of the world map."); ViewFeet = ((BaseUnityPlugin)this).Config.Bind<float>("Dungeon", "ViewFeet", 10f, new ConfigDescription("How far ahead of you the dungeon map reveals, in feet.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 40f), Array.Empty<object>())); ShownMeters = ((BaseUnityPlugin)this).Config.Bind<float>("Dungeon", "ShownMeters", 40f, new ConfigDescription("How many metres across the dungeon map shows at zoom 1.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 64f), Array.Empty<object>())); GpsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("GPS", "ShowGps", true, "Show the GPS readout (name, distance, arrow and arrival time) for the pin you've chosen."); GpsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("GPS", "GpsKey", (KeyCode)103, "On the big map, hover a pin and press this to make it the GPS target (press it again to clear it)."); GpsArriveMeters = ((BaseUnityPlugin)this).Config.Bind<float>("GPS", "ArriveMeters", 8f, new ConfigDescription("The GPS switches off when you're this close.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f), Array.Empty<object>())); AutoPinsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "Enabled", true, "Put things on the map as you find them."); PinRunestones = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "Runestones", true, "Rune stones and Vegvisirs, when you get close."); PinDungeons = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "Dungeons", true, "Dungeon entrances (crypts, caves and the like), when you get close."); PinStructures = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "Structures", true, "Other large structures (ruins, camps, towers...), when you get close."); PinOre = ((BaseUnityPlugin)this).Config.Bind<bool>("AutoPins", "OreDeposits", true, "Ore deposits, when you hit one or stand close to it."); LocationRadius = ((BaseUnityPlugin)this).Config.Bind<float>("AutoPins", "LocationRadius", 40f, new ConfigDescription("How close you must get to a rune stone, dungeon or structure, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 150f), Array.Empty<object>())); DepositRadius = ((BaseUnityPlugin)this).Config.Bind<float>("AutoPins", "DepositRadius", 6f, new ConfigDescription("How close you must get to an ore deposit, in metres (hitting one always counts).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), Array.Empty<object>())); OreKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("AutoPins", "OreKeywords", "copper,tin,silver,obsidian,meteorite", "Deposits whose name contains one of these are pinned (comma separated)."); _harmony = new Harmony("mbaya.MapHeim"); SafePatch.All(_harmony, typeof(MapHeimPlugin).Assembly, Log); Log.LogInfo((object)"MapHeim 0.3.2 loaded"); } private void Update() { TableRepair.Tick(); Player localPlayer = Player.m_localPlayer; Minimap instance = Minimap.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null) { Trail.Clear(); DungeonMap.Hide(); return; } MapZoom.Tick(instance); DungeonMap.Tick(localPlayer, instance); Trail.Tick(localPlayer, instance); Gps.Tick(localPlayer, instance); AutoPins.Tick(localPlayer, instance); } private void OnGUI() { Gps.Draw(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class MapZoom { private const float Step = 1.25f; private static float? _vanilla; public static float Level => Mathf.Clamp(MapHeimPlugin.Zoom.Value, 0.4f, 6f); public static void Tick(Minimap map) { //IL_002d: 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_0076: Unknown result type (might be due to invalid IL or missing references) if (!_vanilla.HasValue) { _vanilla = map.m_smallZoom; } if (CanZoom()) { int num = 0; if (Input.GetKeyDown(MapHeimPlugin.ZoomInKey.Value)) { num++; } if (Input.GetKeyDown(MapHeimPlugin.ZoomOutKey.Value)) { num--; } if (MapHeimPlugin.ScrollZoom.Value && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305))) { float y = Input.mouseScrollDelta.y; if (y > 0f) { num++; } else if (y < 0f) { num--; } } if (num != 0) { MapHeimPlugin.Zoom.Value = Mathf.Clamp(Level * Mathf.Pow(1.25f, (float)num), 0.4f, 6f); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, $"Map zoom {Level:0.##}x", 0, (Sprite)null, false); } } } if (!Minimap.IsOpen()) { map.m_smallZoom = _vanilla.Value / Level; } } private static bool CanZoom() { if (Minimap.IsOpen() || Console.IsVisible() || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())) { return false; } if (!((Object)(object)Menu.instance != (Object)null) || !Menu.IsVisible()) { return !TextInput.IsVisible(); } return false; } } internal static class SafePatch { public static void All(Harmony harmony, Assembly assembly, ManualLogSource log) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { try { harmony.PatchAll(type); } catch (Exception ex) { log.LogError((object)("Couldn't apply the patch " + type.Name + "; the rest are fine. " + ex.Message)); } } } } } internal static class TableRepair { private const int TooBig = 409600; private static readonly int TablePrefab = StringExtensionMethods.GetStableHashCode("piece_cartographytable"); private static float _next; public static void Tick() { //IL_00cc: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || ZDOMan.instance == null || (Object)(object)ZNetScene.instance == (Object)null) { _next = 0f; return; } if (_next == 0f) { _next = Time.time + 20f; } if (Time.time < _next) { return; } _next = Time.time + 300f; int num = 0; foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { if (value != null && value.GetPrefab() == TablePrefab) { byte[] byteArray = value.GetByteArray(ZDOVars.s_data, (byte[])null); if (byteArray != null && byteArray.Length >= 409600) { Vector3 position = value.GetPosition(); MapHeimPlugin.Log.LogWarning((object)$"A cartographer's table at ({position.x:0}, {position.y:0}, {position.z:0}) held {byteArray.Length / 1024} KB of map data, too much to send to players. Emptying it."); value.SetOwner(ZDOMan.GetSessionID()); value.Set(ZDOVars.s_data, new byte[0]); ZDOMan.instance.ForceSendZDO(value.m_uid); num++; } } } if (num > 0) { MapHeimPlugin.Log.LogInfo((object)$"Emptied {num} oversized cartographer's table(s)."); } } } internal static class Trail { private struct Point { public Vector3 Position; public float Time; } private class Layer { public RectTransform Parent; public RectTransform Holder; public readonly List<Image> Segments = new List<Image>(); public void Attach(RectTransform parent) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Parent == (Object)(object)parent && (Object)(object)Holder != (Object)null) { return; } foreach (Image segment in Segments) { if ((Object)(object)segment != (Object)null) { Object.Destroy((Object)(object)((Component)segment).gameObject); } } Segments.Clear(); if ((Object)(object)Holder != (Object)null) { Object.Destroy((Object)(object)((Component)Holder).gameObject); } Parent = parent; GameObject val = new GameObject("MapHeimTrail", new Type[1] { typeof(RectTransform) }); Holder = (RectTransform)val.transform; ((Transform)Holder).SetParent((Transform)(object)parent, false); RectTransform holder = Holder; RectTransform holder2 = Holder; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); holder2.anchorMax = val2; holder.anchorMin = val2; Holder.sizeDelta = Vector2.zero; } public void Hide() { foreach (Image segment in Segments) { if ((Object)(object)segment != (Object)null && ((Component)segment).gameObject.activeSelf) { ((Component)segment).gameObject.SetActive(false); } } } public void Draw(List<Vector2> points, List<float> alphas, float width, Color color) { //IL_0077: 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_0081: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_012f: 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) int num = Mathf.Max(0, points.Count - 1); while (Segments.Count < num) { Segments.Add(MakeSegment()); } for (int i = 0; i < Segments.Count; i++) { Image val = Segments[i]; if ((Object)(object)val == (Object)null) { continue; } if (i >= num) { if (((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); } continue; } Vector2 val2 = points[i]; Vector2 val3 = points[i + 1]; Vector2 val4 = val3 - val2; float magnitude = ((Vector2)(ref val4)).magnitude; if (magnitude < 0.01f) { ((Component)val).gameObject.SetActive(false); continue; } ((Component)val).gameObject.SetActive(true); RectTransform rectTransform = ((Graphic)val).rectTransform; rectTransform.anchoredPosition = (val2 + val3) / 2f; rectTransform.sizeDelta = new Vector2(magnitude + 0.6f, width); ((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val4.y, val4.x) * 57.29578f); ((Graphic)val).color = new Color(color.r, color.g, color.b, Mathf.Clamp01(alphas[i + 1])); } } private Image MakeSegment() { //IL_0025: 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) GameObject val = new GameObject("Segment", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent((Transform)(object)Holder, false); Image component = val.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; return component; } } private const float SampleSeconds = 0.5f; private const float MinMove = 0.75f; private static readonly List<Point> Points = new List<Point>(); private static readonly Layer Small = new Layer(); private static readonly Layer Large = new Layer(); private static readonly List<Vector2> Local = new List<Vector2>(); private static readonly List<float> Alpha = new List<float>(); private static float _nextSample; public static void Clear() { Points.Clear(); Small.Hide(); Large.Hide(); } public static void Tick(Player player, Minimap map) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0088: 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_0060: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if (!MapHeimPlugin.TrailEnabled.Value) { Clear(); return; } float time = Time.time; if (time >= _nextSample) { _nextSample = time + 0.5f; Vector3 position = ((Component)player).transform.position; if (Points.Count != 0) { Vector3 val = Points[Points.Count - 1].Position - position; if (!(((Vector3)(ref val)).sqrMagnitude > 0.5625f)) { goto IL_009c; } } Points.Add(new Point { Position = position, Time = time }); } goto IL_009c; IL_009c: float value = MapHeimPlugin.TrailSeconds.Value; while (Points.Count > 0 && time - Points[0].Time > value) { Points.RemoveAt(0); } float value2 = MapHeimPlugin.TrailWidth.Value; Color value3 = MapHeimPlugin.TrailColor.Value; if (Minimap.IsOpen() && (Object)(object)map.m_mapImageLarge != (Object)null) { Small.Hide(); Large.Attach(((Graphic)map.m_mapImageLarge).rectTransform); DrawLarge(map, time, value, value2, value3); } else if ((Object)(object)map.m_mapImageSmall != (Object)null) { Large.Hide(); Small.Attach(((Graphic)map.m_mapImageSmall).rectTransform); DrawSmall(map, player, time, value, value2, value3); } } private static void Fill(float now, float lifetime) { Alpha.Clear(); foreach (Point point in Points) { Alpha.Add(Mathf.Clamp01(1f - (now - point.Time) / lifetime) * 0.9f); } } private static void DrawSmall(Minimap map, Player player, float now, float lifetime, float width, Color color) { //IL_0017: 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_003b: 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_005b: 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_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_0086: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) RectTransform parent = Small.Parent; Rect val; float num; if (!DungeonMap.Showing) { val = map.m_mapImageSmall.uvRect; num = ((Rect)(ref val)).width * (float)map.m_textureSize * map.m_pixelSize; } else { num = DungeonMap.MetersAcross; } float num2 = num; val = parent.rect; float num3 = ((Rect)(ref val)).width / Mathf.Max(0.01f, num2); Vector3 position = ((Component)player).transform.position; Local.Clear(); foreach (Point point in Points) { Vector3 val2 = (point.Position - position) * num3; Local.Add(new Vector2(val2.x, val2.z)); } Fill(now, lifetime); Small.Draw(Local, Alpha, width, color); } private static void DrawLarge(Minimap map, float now, float lifetime, float width, Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0036: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) RectTransform parent = Large.Parent; Vector2 val = RectTransformUtility.WorldToScreenPoint((Camera)null, ((Transform)parent).position); Vector3 val2 = map.ScreenToWorldPoint(new Vector3(val.x, val.y, 0f)); Vector3 val3 = map.ScreenToWorldPoint(new Vector3(val.x + 100f, val.y, 0f)); Vector3 val4 = map.ScreenToWorldPoint(new Vector3(val.x, val.y + 100f, 0f)); float num = (val3.x - val2.x) / 100f; float num2 = (val4.z - val2.z) / 100f; if (Mathf.Abs(num) < 1E-05f || Mathf.Abs(num2) < 1E-05f) { Large.Hide(); return; } Local.Clear(); Vector2 val5 = default(Vector2); Vector2 item = default(Vector2); foreach (Point point in Points) { ((Vector2)(ref val5))..ctor(val.x + (point.Position.x - val2.x) / num, val.y + (point.Position.z - val2.z) / num2); RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, val5, (Camera)null, ref item); Local.Add(item); } Fill(now, lifetime); Large.Draw(Local, Alpha, width, color); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }