Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Tacos Minimap v1.0.1
TacosMinimap.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Phone.Map; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using TacosMinimap; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Mod), "Tacos Minimap", "1.0.0", "Taco", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("TacosMinimap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TacosMinimap")] [assembly: AssemblyTitle("TacosMinimap")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TacosMinimap { internal class MapCalibration { internal Texture Texture; internal Rect Uv; internal float X0; internal float X1; internal float Z0; internal float Z1; internal string Info; internal static MapCalibration TryMake(out string why) { //IL_00bb: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) why = null; MapPositionUtility util = Singleton<MapPositionUtility>.Instance; if ((Object)(object)util == (Object)null) { why = "no map position helper yet"; return null; } MapApp instance = PlayerSingleton<MapApp>.Instance; if ((Object)(object)instance == (Object)null) { why = "phone map not loaded yet"; return null; } Image backgroundImage = instance.BackgroundImage; RectTransform layer = instance.PoIContainer; if ((Object)(object)backgroundImage == (Object)null || (Object)(object)layer == (Object)null) { why = "phone map parts missing"; return null; } Sprite val = (((Object)(object)backgroundImage.sprite != (Object)null) ? backgroundImage.sprite : instance.MainMapSprite); if ((Object)(object)val == (Object)null || (Object)(object)val.texture == (Object)null) { why = "no map picture"; return null; } Vector2 anchor = new Vector2(0.5f, 0.5f); for (int i = 0; i < ((Transform)layer).childCount; i++) { RectTransform val2 = ((Il2CppObjectBase)((Transform)layer).GetChild(i)).TryCast<RectTransform>(); if ((Object)(object)val2 != (Object)null && val2.anchorMin == val2.anchorMax) { anchor = val2.anchorMin; break; } } RectTransform bgRt = ((Graphic)backgroundImage).rectTransform; Vector2 val3 = Norm(Vector3.zero); Vector2 val4 = (Norm(new Vector3(100f, 0f, 0f)) - val3) / 100f; Vector2 val5 = (Norm(new Vector3(0f, 0f, 100f)) - val3) / 100f; if (!Ok(val3) || !Ok(val4) || !Ok(val5) || Mathf.Abs(val4.x) < 1E-07f || Mathf.Abs(val5.y) < 1E-07f) { why = "phone map layout not ready"; return null; } MapCalibration mapCalibration = new MapCalibration { Texture = (Texture)(object)val.texture, X0 = (0f - val3.x) / val4.x, X1 = (1f - val3.x) / val4.x, Z0 = (0f - val3.y) / val5.y, Z1 = (1f - val3.y) / val5.y }; Rect textureRect = val.textureRect; float num = ((Texture)val.texture).width; float num2 = ((Texture)val.texture).height; mapCalibration.Uv = new Rect(((Rect)(ref textureRect)).x / num, ((Rect)(ref textureRect)).y / num2, ((Rect)(ref textureRect)).width / num, ((Rect)(ref textureRect)).height / num2); float num3 = (Mathf.Abs(val4.y) + Mathf.Abs(val5.x)) / (Mathf.Abs(val4.x) + Mathf.Abs(val5.y)); mapCalibration.Info = $"picture {((Texture)val.texture).width}x{((Texture)val.texture).height}, world X {mapCalibration.X0:0}..{mapCalibration.X1:0} m, Z {mapCalibration.Z0:0}..{mapCalibration.Z1:0} m, {Mathf.Abs(val4.x) * ((Rect)(ref textureRect)).width:0.00} px per m, turn {num3:0.000}, anchor {anchor}"; if (num3 > 0.02f) { mapCalibration.Info += " (WARNING: the map picture is turned; markers may be off)"; } return mapCalibration; Vector2 Norm(Vector3 world) { //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) //IL_000c: 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_0018: 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_005e: 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_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_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_008f: 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_00bb: Unknown result type (might be due to invalid IL or missing references) Vector2 mapPosition = util.GetMapPosition(world); Rect rect = layer.rect; Vector3 p = default(Vector3); ((Vector3)(ref p))..ctor(Mathf.Lerp(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).xMax, anchor.x) + mapPosition.x, Mathf.Lerp(((Rect)(ref rect)).yMin, ((Rect)(ref rect)).yMax, anchor.y) + mapPosition.y, 0f); Vector3 val6 = Between((Transform)(object)layer, (Transform)(object)bgRt, p); Rect rect2 = bgRt.rect; return new Vector2((val6.x - ((Rect)(ref rect2)).xMin) / ((Rect)(ref rect2)).width, (val6.y - ((Rect)(ref rect2)).yMin) / ((Rect)(ref rect2)).height); } } private static bool Ok(Vector2 v) { //IL_0000: 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) //IL_001a: 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) if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsInfinity(v.x)) { return !float.IsInfinity(v.y); } return false; } private static Vector3 Between(Transform from, Transform to, Vector3 p) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //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_0123: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0143: 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_0151: 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) //IL_016f: Unknown result type (might be due to invalid IL or missing references) HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); Transform val = from; while ((Object)(object)val != (Object)null) { hashSet.Add(((Il2CppObjectBase)val).Pointer); val = val.parent; } Transform val2 = null; Transform val3 = to; while ((Object)(object)val3 != (Object)null) { if (hashSet.Contains(((Il2CppObjectBase)val3).Pointer)) { val2 = val3; break; } val3 = val3.parent; } Transform val4 = from; while ((Object)(object)val4 != (Object)null && ((Object)(object)val2 == (Object)null || ((Il2CppObjectBase)val4).Pointer != ((Il2CppObjectBase)val2).Pointer)) { p = val4.localRotation * Vector3.Scale(p, val4.localScale) + val4.localPosition; val4 = val4.parent; } List<Transform> list = new List<Transform>(); Transform val5 = to; while ((Object)(object)val5 != (Object)null && ((Object)(object)val2 == (Object)null || ((Il2CppObjectBase)val5).Pointer != ((Il2CppObjectBase)val2).Pointer)) { list.Add(val5); val5 = val5.parent; } for (int num = list.Count - 1; num >= 0; num--) { Transform val6 = list[num]; p = Quaternion.Inverse(val6.localRotation) * (p - val6.localPosition); Vector3 localScale = val6.localScale; ((Vector3)(ref p))..ctor(p.x / localScale.x, p.y / localScale.y, p.z / localScale.z); } return p; } } internal class MiniMap { private enum Mode { Normal, Big, Hidden } private class Pin { public RectTransform Rt; public RectTransform Body; public RectTransform Arrow; public RectTransform DistRt; public TextMeshProUGUI Dist; public POI Poi; public NPC Npc; public bool Clamp; public bool Seen; public bool IsDealer; public Il2CppArrayBase<Image> Src; public Il2CppArrayBase<Image> Dst; public Image Dot; public int LastMeters = -1; } private const float IconSize = 22f; private const float CustomerSize = 15f; private const float DealerSize = 18f; private const float Edge = 13f; private Mode _mode; private GameObject _root; private RectTransform _frame; private RectTransform _view; private RectTransform _mapLayer; private RectTransform _mapRt; private RectTransform _pinLayer; private RectTransform _playerRt; private RectTransform _northRt; private RawImage _mapImg; private TMP_FontAsset _font; private bool _built; private bool _shown = true; private bool _stopped; private MapCalibration _cal; private float _nextCal; private float _nextRefresh; private float _meters = -1f; private float _selfTestAt = -1f; private float _nextCountLog; private string _lastCalWhy; private string _lastCounts; private int _errors; private readonly Dictionary<IntPtr, Pin> _pins = new Dictionary<IntPtr, Pin>(); internal void Tick() { //IL_002f: 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_00a7: Invalid comparison between Unknown and I4 if (_stopped) { return; } Player local = Player.Local; if ((Object)(object)local == (Object)null || (!_built && !Build())) { return; } if (Input.GetKeyDown(Mod.Key.Value) && !IsTyping()) { _mode = ((_mode == Mode.Normal) ? Mode.Big : ((_mode == Mode.Big) ? Mode.Hidden : Mode.Normal)); Mod.Log.Msg("Minimap: " + _mode); } bool flag = _mode != Mode.Hidden && HudShowing() && (!Mod.HideInMenus.Value || (int)Cursor.lockState == 1); if (flag != _shown) { _root.SetActive(flag); _shown = flag; } if (!flag) { return; } float unscaledTime = Time.unscaledTime; if (_cal == null && unscaledTime >= _nextCal) { _nextCal = unscaledTime + 2f; _cal = MapCalibration.TryMake(out var why); if (_cal != null) { UseCalibration(); Mod.Log.Msg("Map ready: " + _cal.Info); } else if (why != _lastCalWhy) { _lastCalWhy = why; Mod.Log.Msg("Waiting for the map: " + why); } } if (unscaledTime >= _nextRefresh) { _nextRefresh = unscaledTime + 1f; Refresh(local); } Draw(local); if (Mod.SelfTest.Value && _cal != null) { if (_selfTestAt < 0f) { _selfTestAt = unscaledTime + 8f; } else if (_selfTestAt > 0f && unscaledTime >= _selfTestAt) { _selfTestAt = 0f; SelfTestShot(local); } } } internal void Fail(Exception e) { _errors++; if (_errors <= 3) { Mod.Log.Warning("Minimap problem: " + e); } if (_errors >= 300) { _stopped = true; Mod.Log.Error("Minimap turned itself off after repeated problems (see above)."); Destroy(); } } internal void Destroy() { try { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } catch { } _root = null; _built = false; _pins.Clear(); } private static bool IsTyping() { try { return GameInput.IsTyping; } catch { return false; } } private static bool HudShowing() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.canvas == (Object)null) { return true; } if (((Behaviour)instance.canvas).enabled) { return ((Component)instance.canvas).gameObject.activeInHierarchy; } return false; } private bool Build() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_010e: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) HUD instance = Singleton<HUD>.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.canvas == (Object)null) { return false; } try { _font = (((Object)(object)instance.selectedItemLabel != (Object)null) ? ((TMP_Text)instance.selectedItemLabel).font : null); } catch { _font = null; } _root = new GameObject("TacosMinimap"); Canvas obj2 = _root.AddComponent<Canvas>(); obj2.renderMode = (RenderMode)0; Canvas val = (((Object)(object)instance.canvas.rootCanvas != (Object)null) ? instance.canvas.rootCanvas : instance.canvas); obj2.sortingOrder = val.sortingOrder; CanvasScaler val2 = _root.AddComponent<CanvasScaler>(); CanvasScaler component = ((Component)val).GetComponent<CanvasScaler>(); if ((Object)(object)component != (Object)null) { val2.uiScaleMode = component.uiScaleMode; val2.referenceResolution = component.referenceResolution; val2.screenMatchMode = component.screenMatchMode; val2.matchWidthOrHeight = component.matchWidthOrHeight; val2.scaleFactor = component.scaleFactor; } else { val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.matchWidthOrHeight = 0.5f; } _frame = NewRect("Frame", _root.transform); AddImage(Fill(NewRect("Back", (Transform)(object)_frame)), null, new Color(0.03f, 0.04f, 0.06f, 0.88f)); _view = Fill(NewRect("View", (Transform)(object)_frame)); ((Component)_view).gameObject.AddComponent<RectMask2D>(); _mapLayer = Center(NewRect("MapLayer", (Transform)(object)_view), Vector2.zero); _mapRt = Center(NewRect("Picture", (Transform)(object)_mapLayer), Vector2.zero); _mapImg = ((Component)_mapRt).gameObject.AddComponent<RawImage>(); ((Graphic)_mapImg).raycastTarget = false; ((Graphic)_mapImg).color = new Color(1f, 1f, 1f, 0f); _pinLayer = Center(NewRect("Pins", (Transform)(object)_view), Vector2.zero); _playerRt = Center(NewRect("You", (Transform)(object)_view), new Vector2(24f, 24f)); Shade((Graphic)(object)AddImage(_playerRt, Shapes.PlayerArrow, Color.white)); _northRt = Center(NewRect("North", (Transform)(object)_view), new Vector2(20f, 20f)); AddImage(_northRt, Shapes.Ring, Color.white); Text(_northRt, "N", 12f, Color.white); Color color = default(Color); ((Color)(ref color))..ctor(Shapes.Blue.r, Shapes.Blue.g, Shapes.Blue.b, 0.55f); Bar(_frame, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), Vector2.zero, color); Bar(_frame, new Vector2(0f, 0f), new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 2f), color); Bar(_frame, new Vector2(0f, 0f), new Vector2(0f, 1f), Vector2.zero, new Vector2(2f, 0f), color); Bar(_frame, new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-2f, 0f), Vector2.zero, color); Vector2[] array = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }; foreach (Vector2 val3 in array) { float num = ((val3.x == 0f) ? 1 : (-1)); float num2 = ((val3.y == 0f) ? 1 : (-1)); Corner(_frame, val3, new Vector2(22f * num, 4f * num2)); Corner(_frame, val3, new Vector2(4f * num, 22f * num2)); } Place(); _built = true; _shown = true; Mod.Log.Msg("Minimap built (" + Mod.Corner.Value + ", " + Mod.Size.Value + " px)."); return true; } private void Place() { //IL_0071: 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) //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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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) //IL_00e1: 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_0083: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a7: 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_0123: Unknown result type (might be due to invalid IL or missing references) float num = ((_mode == Mode.Big) ? Mod.BigSize.Value : Mod.Size.Value); Vector2 val = (Vector2)((Mod.Corner.Value ?? "").Trim().ToLowerInvariant() switch { "topleft" => new Vector2(0f, 1f), "topright" => new Vector2(1f, 1f), "bottomright" => new Vector2(1f, 0f), _ => new Vector2(0f, 0f), }); RectTransform frame = _frame; RectTransform frame2 = _frame; Vector2 val2 = (_frame.pivot = val); Vector2 anchorMin = (frame2.anchorMax = val2); frame.anchorMin = anchorMin; _frame.sizeDelta = new Vector2(num, num); _frame.anchoredPosition = new Vector2((val.x == 0f) ? 24f : (-24f), (val.y == 0f) ? 40f : (-40f)); } private void UseCalibration() { //IL_0022: 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) _mapImg.texture = _cal.Texture; _mapImg.uvRect = _cal.Uv; ((Graphic)_mapImg).color = Color.white; } private void Refresh(Player me) { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Invalid comparison between Unknown and I4 foreach (Pin value in _pins.Values) { value.Seen = false; } HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); List<Customer> unlockedCustomers = Customer.UnlockedCustomers; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; if (unlockedCustomers != null) { for (int i = 0; i < unlockedCustomers.Count; i++) { Customer obj = unlockedCustomers[i]; NPC npc = ((obj != null) ? obj.NPC : null); if (!((Object)(object)npc == (Object)null)) { Want(((Il2CppObjectBase)npc).Pointer, () => NpcPin(npc, dealer: false)).Seen = true; hashSet.Add(((Il2CppObjectBase)npc).Pointer); num++; } } } List<Dealer> allPlayerDealers = Dealer.AllPlayerDealers; if (allPlayerDealers != null) { for (int num5 = 0; num5 < allPlayerDealers.Count; num5++) { Dealer d = allPlayerDealers[num5]; if (!((Object)(object)d == (Object)null) && d.IsRecruited) { Want(((Il2CppObjectBase)d).Pointer, () => NpcPin((NPC)(object)d, dealer: true)).Seen = true; hashSet.Add(((Il2CppObjectBase)d).Pointer); num2++; } } } HashSet<IntPtr> hashSet2 = new HashSet<IntPtr>(); List<Quest> activeQuests = Quest.ActiveQuests; if (activeQuests != null) { for (int num6 = 0; num6 < activeQuests.Count; num6++) { Quest obj2 = activeQuests[num6]; List<QuestEntry> val = ((obj2 != null) ? obj2.Entries : null); if (val == null) { continue; } for (int num7 = 0; num7 < val.Count; num7++) { QuestEntry val2 = val[num7]; if ((Object)(object)val2 != (Object)null && (int)val2.State == 1 && (Object)(object)val2.PoI != (Object)null) { hashSet2.Add(((Il2CppObjectBase)val2.PoI).Pointer); } } } } IntPtr intPtr = IntPtr.Zero; try { if ((Object)(object)me.PoI != (Object)null) { intPtr = ((Il2CppObjectBase)me.PoI).Pointer; } } catch { } foreach (Object item in (Il2CppArrayBase<Object>)(object)Object.FindObjectsOfType(Il2CppType.Of<POI>())) { POI poi = ((item != null) ? ((Il2CppObjectBase)item).TryCast<POI>() : null); if ((Object)(object)poi == (Object)null || !((Behaviour)poi).enabled || ((Il2CppObjectBase)poi).Pointer == intPtr || !poi.UISetup || (Object)(object)poi.UI == (Object)null || (Object)(object)poi.IconContainer == (Object)null || !((Component)poi.UI).gameObject.activeSelf) { continue; } NPCPoI val3 = ((Il2CppObjectBase)poi).TryCast<NPCPoI>(); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.NPC != (Object)null && hashSet.Contains(((Il2CppObjectBase)val3.NPC).Pointer)) { continue; } Pin pin = Want(((Il2CppObjectBase)poi).Pointer, () => PoiPin(poi)); pin.Seen = true; pin.Clamp = hashSet2.Contains(((Il2CppObjectBase)poi).Pointer); if (!SyncIcon(pin)) { Remove(((Il2CppObjectBase)poi).Pointer); continue; } num3++; if (pin.Clamp) { num4++; } } List<IntPtr> list = new List<IntPtr>(); foreach (KeyValuePair<IntPtr, Pin> pin2 in _pins) { if (!pin2.Value.Seen) { list.Add(pin2.Key); } } foreach (IntPtr item2 in list) { Remove(item2); } string text = num + " customers, " + num2 + " dealers, " + num3 + " map markers (" + num4 + " missions/deals)"; if (text != _lastCounts && Time.unscaledTime >= _nextCountLog) { _lastCounts = text; _nextCountLog = Time.unscaledTime + 60f; Mod.Log.Msg("Showing " + text + "."); } } private Pin Want(IntPtr key, Func<Pin> make) { if (_pins.TryGetValue(key, out var value) && (Object)(object)value.Rt != (Object)null) { return value; } value = make(); _pins[key] = value; return value; } private void Remove(IntPtr key) { if (!_pins.TryGetValue(key, out var value)) { return; } try { if ((Object)(object)value.Rt != (Object)null) { Object.Destroy((Object)(object)((Component)value.Rt).gameObject); } } catch { } _pins.Remove(key); } private Pin NpcPin(NPC npc, bool dealer) { //IL_002f: 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_0086: 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) Pin pin = new Pin { Npc = npc, IsDealer = dealer }; pin.Rt = Center(NewRect(dealer ? "Dealer" : "Customer", (Transform)(object)_pinLayer), Vector2.zero); float num = (dealer ? 18f : 15f); pin.Body = Center(NewRect("Icon", (Transform)(object)pin.Rt), new Vector2(num, num)); pin.Dot = AddImage(pin.Body, dealer ? Shapes.Dealer : Shapes.Customer, Color.white); Shade((Graphic)(object)pin.Dot); if (dealer) { Text(pin.Body, "D", 10f, Color.white); } if (dealer) { ((Transform)pin.Rt).SetAsLastSibling(); } else { ((Transform)pin.Rt).SetAsFirstSibling(); } return pin; } private Pin PoiPin(POI poi) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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) Pin pin = new Pin { Poi = poi }; pin.Rt = Center(NewRect("Marker", (Transform)(object)_pinLayer), Vector2.zero); ((Transform)pin.Rt).SetAsLastSibling(); pin.Arrow = Center(NewRect("Arrow", (Transform)(object)pin.Rt), new Vector2(12f, 12f)); AddImage(pin.Arrow, Shapes.EdgeArrow, Color.white); ((Component)pin.Arrow).gameObject.SetActive(false); pin.DistRt = Center(NewRect("Distance", (Transform)(object)pin.Rt), new Vector2(70f, 16f)); pin.Dist = Text(pin.DistRt, "", 11f, Color.white); ((Component)pin.DistRt).gameObject.SetActive(false); Clone(pin); return pin; } private static void Clone(Pin pin) { //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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b5: 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_00c4: 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_00de: 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_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pin.Body != (Object)null) { Object.Destroy((Object)(object)((Component)pin.Body).gameObject); } RectTransform iconContainer = pin.Poi.IconContainer; GameObject val = Object.Instantiate<GameObject>(((Component)iconContainer).gameObject); ((Object)val).name = "Icon"; RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)pin.Rt, false); Rect rect = iconContainer.rect; Vector2 size = ((Rect)(ref rect)).size; if (size.x < 1f || size.y < 1f) { ((Vector2)(ref size))..ctor(30f, 30f); } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.sizeDelta = size; component.anchoredPosition = Vector2.zero; ((Transform)component).localRotation = Quaternion.identity; float num = 22f / Mathf.Max(size.x, size.y); ((Transform)component).localScale = new Vector3(num, num, 1f); foreach (Graphic componentsInChild in val.GetComponentsInChildren<Graphic>(true)) { componentsInChild.raycastTarget = false; } pin.Body = component; ((Transform)pin.Body).SetSiblingIndex(0); pin.Src = ((Component)iconContainer).GetComponentsInChildren<Image>(true); pin.Dst = val.GetComponentsInChildren<Image>(true); } private static bool SyncIcon(Pin pin) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)pin.Poi == (Object)null || (Object)(object)pin.Poi.IconContainer == (Object)null) { return false; } Il2CppArrayBase<Image> componentsInChildren = ((Component)pin.Poi.IconContainer).GetComponentsInChildren<Image>(true); if (pin.Dst == null || componentsInChildren.Length != pin.Dst.Length) { Clone(pin); } else { for (int i = 0; i < componentsInChildren.Length; i++) { Image val = componentsInChildren[i]; Image val2 = pin.Dst[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { val2.sprite = val.sprite; ((Graphic)val2).color = ((Graphic)val).color; ((Behaviour)val2).enabled = ((Behaviour)val).enabled; if (((Component)val2).gameObject.activeSelf != ((Component)val).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(((Component)val).gameObject.activeSelf); } } } } return true; } catch { return false; } } private void Draw(Player me) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_068a: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0695: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) float num = ((_mode == Mode.Big) ? Mod.BigSize.Value : Mod.Size.Value); if (Mathf.Abs(_frame.sizeDelta.x - num) > 0.5f) { Place(); } float num2 = num * 0.5f; Vector3 position = ((Component)me).transform.position; float y = ((Component)me).transform.eulerAngles.y; float num3 = y; PlayerCamera instance = PlayerSingleton<PlayerCamera>.Instance; if ((Object)(object)instance != (Object)null) { num3 = ((Component)instance).transform.eulerAngles.y; } float num4 = (Mod.Rotate.Value ? num3 : 0f); bool flag = false; try { flag = me.IsInVehicle; } catch { } float num5 = Mathf.Max(20f, flag ? Mod.CarMeters.Value : Mod.Meters.Value); _meters = ((_meters < 0f) ? num5 : Mathf.Lerp(_meters, num5, 1f - Mathf.Exp((0f - Time.unscaledDeltaTime) * 2.5f))); float num6 = num / _meters; ((Transform)_mapLayer).localEulerAngles = new Vector3(0f, 0f, num4); if (_cal != null) { float num7 = (_cal.X1 - _cal.X0) * num6; float num8 = (_cal.Z1 - _cal.Z0) * num6; _mapRt.sizeDelta = new Vector2(Mathf.Abs(num7), Mathf.Abs(num8)); ((Transform)_mapRt).localScale = new Vector3(Mathf.Sign(num7), Mathf.Sign(num8), 1f); ((Transform)_mapRt).localPosition = new Vector3(((_cal.X0 + _cal.X1) * 0.5f - position.x) * num6, ((_cal.Z0 + _cal.Z1) * 0.5f - position.z) * num6, 0f); } ((Transform)_playerRt).localEulerAngles = new Vector3(0f, 0f, num4 - y); Vector2 val = Turn(new Vector2(0f, 1f), num4); float num9 = Mathf.Max(Mathf.Abs(val.x), Mathf.Abs(val.y)); _northRt.anchoredPosition = val * ((num2 - 12f) / num9); foreach (Pin value in _pins.Values) { if ((Object)(object)value.Rt == (Object)null) { continue; } bool flag2 = false; Vector3 val2; try { if ((Object)(object)value.Npc != (Object)null) { val2 = (((Object)(object)value.Npc.Movement != (Object)null) ? value.Npc.Movement.FootPosition : ((Component)value.Npc).transform.position); flag2 = value.Npc.isInBuilding; goto IL_0355; } if ((Object)(object)value.Poi != (Object)null) { val2 = ((Component)value.Poi).transform.position; goto IL_0355; } } catch { } continue; IL_0355: Vector2 val3 = Turn(new Vector2(val2.x - position.x, val2.z - position.z) * num6, num4); float num10 = num2 - 13f; bool flag3 = Mathf.Abs(val3.x) > num10 || Mathf.Abs(val3.y) > num10; if (flag3 && !value.Clamp) { if (((Component)value.Rt).gameObject.activeSelf) { ((Component)value.Rt).gameObject.SetActive(false); } continue; } if (!((Component)value.Rt).gameObject.activeSelf) { ((Component)value.Rt).gameObject.SetActive(true); } if (flag3) { float num11 = Mathf.Max(Mathf.Abs(val3.x), Mathf.Abs(val3.y)); Vector2 val4 = val3 / num11; val3 = val4 * (num10 - 10f); float num12 = Mathf.Atan2(val4.y, val4.x) * 57.29578f; ((Component)value.Arrow).gameObject.SetActive(true); value.Arrow.anchoredPosition = ((Vector2)(ref val4)).normalized * 17f; ((Transform)value.Arrow).localEulerAngles = new Vector3(0f, 0f, num12); Vector2 val5 = new Vector2(val2.x - position.x, val2.z - position.z); int num13 = Mathf.RoundToInt(((Vector2)(ref val5)).magnitude); if (num13 != value.LastMeters) { value.LastMeters = num13; ((TMP_Text)value.Dist).text = num13 + " m"; } if (!((Component)value.DistRt).gameObject.activeSelf) { ((Component)value.DistRt).gameObject.SetActive(true); } value.DistRt.anchoredPosition = new Vector2(0f, (val3.y < 0f) ? 19f : (-19f)); } else if ((Object)(object)value.Arrow != (Object)null && ((Component)value.Arrow).gameObject.activeSelf) { ((Component)value.Arrow).gameObject.SetActive(false); ((Component)value.DistRt).gameObject.SetActive(false); } value.Rt.anchoredPosition = val3; if ((Object)(object)value.Dot != (Object)null) { Color color = ((Graphic)value.Dot).color; float num14 = (flag2 ? 0.45f : 1f); if (Mathf.Abs(color.a - num14) > 0.01f) { ((Graphic)value.Dot).color = new Color(1f, 1f, 1f, num14); } } if ((Object)(object)value.Poi != (Object)null && (Object)(object)value.Body != (Object)null) { bool flag4 = false; try { flag4 = value.Poi.Rotate; } catch { } ((Transform)value.Body).localEulerAngles = new Vector3(0f, 0f, flag4 ? (num4 - ((Component)value.Poi).transform.eulerAngles.y) : 0f); } } } private static Vector2 Turn(Vector2 v, float deg) { //IL_0014: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) float num = deg * ((float)Math.PI / 180f); float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); return new Vector2(v.x * num2 - v.y * num3, v.x * num3 + v.y * num2); } private void SelfTestShot(Player me) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) try { string text = Path.Combine(MelonEnvironment.UserDataDirectory, "TacosMinimap"); Directory.CreateDirectory(text); ScreenCapture.CaptureScreenshot(Path.Combine(text, "selftest.png")); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("calibration: " + _cal.Info); stringBuilder.AppendLine("player: " + ((object)((Component)me).transform.position/*cast due to .constrained prefix*/).ToString() + " yaw " + ((Component)me).transform.eulerAngles.y); foreach (Pin value in _pins.Values) { string text2 = (((Object)(object)value.Npc != (Object)null) ? ((value.IsDealer ? "dealer " : "customer ") + value.Npc.FirstName) : ("marker " + (((Object)(object)value.Poi != (Object)null) ? (((Object)((Component)value.Poi).gameObject).name + " '" + value.Poi.MainText + "'") : "?"))); stringBuilder.AppendLine(text2 + (value.Clamp ? " [mission]" : "") + " at " + (((Object)(object)value.Rt != (Object)null) ? ((object)value.Rt.anchoredPosition/*cast due to .constrained prefix*/).ToString() : "-") + (((Object)(object)value.Rt != (Object)null && !((Component)value.Rt).gameObject.activeSelf) ? " (off the map)" : "")); } File.WriteAllText(Path.Combine(text, "selftest.txt"), stringBuilder.ToString()); Mod.Log.Msg("[selftest] saved " + text); } catch (Exception ex) { Mod.Log.Warning("[selftest] " + ex.Message); } } private static RectTransform NewRect(string name, Transform parent) { //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) RectTransform obj = new GameObject(name) { layer = 5 }.AddComponent<RectTransform>(); ((Transform)obj).SetParent(parent, false); return obj; } private static RectTransform Fill(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; return rt; } private static RectTransform Center(RectTransform rt, Vector2 size) { //IL_0014: 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_001b: 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_0022: 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_0030: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.sizeDelta = size; rt.anchoredPosition = Vector2.zero; return rt; } private static Image AddImage(RectTransform rt, Sprite sprite, Color color) { //IL_0014: 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_0037: 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_004a: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)rt).gameObject.AddComponent<Image>(); val.sprite = sprite; ((Graphic)val).color = color; ((Graphic)val).raycastTarget = false; if ((Object)(object)sprite != (Object)null) { val.preserveAspect = true; } if (rt.sizeDelta == Vector2.zero && rt.anchorMin == rt.anchorMax) { Fill(rt); } return val; } private static void Shade(Graphic g) { //IL_0020: 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) Shadow obj = ((Component)g).gameObject.AddComponent<Shadow>(); obj.effectColor = new Color(0f, 0f, 0f, 0.65f); obj.effectDistance = new Vector2(1f, -1.5f); } private TextMeshProUGUI Text(RectTransform parent, string text, float size, Color color) { //IL_0056: 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) TextMeshProUGUI val = ((Component)Fill(NewRect("Text", (Transform)(object)parent))).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)_font != (Object)null) { ((TMP_Text)val).font = _font; } ((TMP_Text)val).text = text; ((TMP_Text)val).fontSize = size; ((TMP_Text)val).fontStyle = (FontStyles)1; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((Graphic)val).color = color; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).enableWordWrapping = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; try { ((TMP_Text)val).outlineWidth = 0.22f; ((TMP_Text)val).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220); } catch { } return val; } private static void Bar(RectTransform parent, Vector2 aMin, Vector2 aMax, Vector2 offMin, Vector2 offMax, Color color) { //IL_000c: 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_001a: 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_0033: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = NewRect("Line", (Transform)(object)parent); obj.anchorMin = aMin; obj.anchorMax = aMax; obj.offsetMin = offMin; obj.offsetMax = offMax; Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); ((Graphic)obj2).color = color; ((Graphic)obj2).raycastTarget = false; } private static void Corner(RectTransform parent, Vector2 corner, Vector2 size) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0015: 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_0023: 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_0039: 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_0059: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = NewRect("Corner", (Transform)(object)parent); Vector2 anchorMin = (obj.anchorMax = corner); obj.anchorMin = anchorMin; obj.pivot = corner; obj.sizeDelta = new Vector2(Mathf.Abs(size.x), Mathf.Abs(size.y)); obj.anchoredPosition = Vector2.zero; Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); ((Graphic)obj2).color = Shapes.BlueHi; ((Graphic)obj2).raycastTarget = false; } } internal static class Shapes { private const int Px = 64; private static Sprite _customer; private static Sprite _dealer; private static Sprite _player; private static Sprite _edgeArrow; private static Sprite _ring; internal static readonly Color Green = new Color(0.36f, 0.89f, 0.48f); internal static readonly Color Purple = new Color(0.71f, 0.49f, 1f); internal static readonly Color Blue = new Color(14f / 51f, 2f / 3f, 46f / 51f); internal static readonly Color BlueHi = new Color(20f / 51f, 38f / 51f, 0.972549f); internal static readonly Color Gold = new Color(1f, 0.79f, 0.24f); internal static Sprite Customer => _customer ?? (_customer = Make(CustomerPixel)); internal static Sprite Dealer => _dealer ?? (_dealer = Make(DealerPixel)); internal static Sprite PlayerArrow => _player ?? (_player = Make(PlayerPixel)); internal static Sprite EdgeArrow => _edgeArrow ?? (_edgeArrow = Make(EdgePixel)); internal static Sprite Ring => _ring ?? (_ring = Make(RingPixel)); private static Color CustomerPixel(float x, float y) { //IL_0015: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(x * x + y * y); if (num > 0.92f) { return Color.clear; } if (num > 0.74f) { return Color.white; } Color result = default(Color); ((Color)(ref result))..ctor(0.08f, 0.22f, 0.12f); float num2 = y - 0.2f; if (x * x + num2 * num2 < 0.040000003f) { return result; } if (y < -0.05f && y > -0.5f && x * x / 0.16f + (y + 0.5f) * (y + 0.5f) / 0.2f < 1f) { return result; } return Green; } private static Color DealerPixel(float x, float y) { //IL_0016: 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_0024: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(x) + Mathf.Abs(y); if (num > 0.96f) { return Color.clear; } if (num > 0.78f) { return Color.white; } return Purple; } private static Color PlayerPixel(float x, float y) { //IL_0027: 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_0030: Unknown result type (might be due to invalid IL or missing references) bool num = InArrow(x, y, 1f); bool flag = InArrow(x, y * 1f + 0.04f, 0.72f); if (!num) { return Color.clear; } if (!flag) { return Blue; } return Color.white; } private static bool InArrow(float x, float y, float s) { return InPoly(x / s, y / s, new float[8] { 0f, 0.95f, 0.75f, -0.85f, 0f, -0.42f, -0.75f, -0.85f }); } private static Color EdgePixel(float x, float y) { //IL_0047: 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_0050: Unknown result type (might be due to invalid IL or missing references) bool flag = InPoly(x, y, new float[6] { 0.95f, 0f, -0.6f, 0.75f, -0.6f, -0.75f }); bool flag2 = InPoly(x * 1.25f + 0.08f, y * 1.25f, new float[6] { 0.95f, 0f, -0.6f, 0.75f, -0.6f, -0.75f }); if (!flag) { return Color.clear; } if (!flag2) { return Color.white; } return Gold; } private static Color RingPixel(float x, float y) { //IL_0015: 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_0023: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(x * x + y * y); if (num > 0.95f) { return Color.clear; } if (num > 0.8f) { return Blue; } return new Color(0.04f, 0.055f, 0.08f, 0.9f); } private static bool InPoly(float x, float y, float[] p) { bool flag = false; int num = p.Length / 2; int num2 = 0; int num3 = num - 1; while (num2 < num) { float num4 = p[num2 * 2]; float num5 = p[num2 * 2 + 1]; float num6 = p[num3 * 2]; float num7 = p[num3 * 2 + 1]; if (num5 > y != num7 > y && x < (num6 - num4) * (y - num5) / (num7 - num5) + num4) { flag = !flag; } num3 = num2++; } return flag; } private static Sprite Make(Func<float, float, Color> shape) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Object)val).hideFlags = (HideFlags)61; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { float arg = ((float)j + ((float)l + 0.5f) / 4f) / 64f * 2f - 1f; float arg2 = ((float)i + ((float)k + 0.5f) / 4f) / 64f * 2f - 1f; Color val2 = shape(arg, arg2); num += val2.r * val2.a; num2 += val2.g * val2.a; num3 += val2.b * val2.a; num4 += val2.a; } } float num5 = 16f; Color val3 = (Color)((num4 > 0f) ? new Color(num / num4, num2 / num4, num3 / num4, num4 / num5) : Color.clear); array[i * 64 + j] = Color32.op_Implicit(val3); } } val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array)); val.Apply(false, false); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).hideFlags = (HideFlags)61; return obj; } } public class Mod : MelonMod { internal static Instance Log; internal static MelonPreferences_Entry<KeyCode> Key; internal static MelonPreferences_Entry<float> Size; internal static MelonPreferences_Entry<float> BigSize; internal static MelonPreferences_Entry<float> Meters; internal static MelonPreferences_Entry<float> CarMeters; internal static MelonPreferences_Entry<string> Corner; internal static MelonPreferences_Entry<bool> Rotate; internal static MelonPreferences_Entry<bool> HideInMenus; internal static MelonPreferences_Entry<bool> SelfTest; private MiniMap _map; private bool _inWorld; public override void OnInitializeMelon() { //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) Log = ((MelonBase)this).LoggerInstance; MelonPreferences_Category obj = MelonPreferences.CreateCategory("TacosMinimap", "Tacos Minimap"); obj.SetFilePath(Path.Combine(MelonEnvironment.UserDataDirectory, "TacosMinimap.cfg")); Key = obj.CreateEntry<KeyCode>("ToggleKey", (KeyCode)110, "Key that switches the minimap between normal, big and hidden", (string)null, false, false, (ValueValidator)null, (string)null); Size = obj.CreateEntry<float>("Size", 250f, "Width of the square in pixels at 1080p", (string)null, false, false, (ValueValidator)null, (string)null); BigSize = obj.CreateEntry<float>("BigSize", 420f, "Width of the square when switched to big", (string)null, false, false, (ValueValidator)null, (string)null); Corner = obj.CreateEntry<string>("Corner", "TopRight", "Where it sits: BottomLeft, TopLeft, TopRight or BottomRight", (string)null, false, false, (ValueValidator)null, (string)null); Meters = obj.CreateEntry<float>("Meters", 140f, "How many meters across the square shows when on foot", (string)null, false, false, (ValueValidator)null, (string)null); CarMeters = obj.CreateEntry<float>("CarMeters", 260f, "How many meters across the square shows when in a vehicle", (string)null, false, false, (ValueValidator)null, (string)null); Rotate = obj.CreateEntry<bool>("RotateWithCamera", true, "true = the map turns so the way you look is up; false = north is always up", (string)null, false, false, (ValueValidator)null, (string)null); HideInMenus = obj.CreateEntry<bool>("HideInMenus", true, "Hide the minimap while a menu, the phone or a storage window has the mouse", (string)null, false, false, (ValueValidator)null, (string)null); SelfTest = obj.CreateEntry<bool>("SelfTest", false, "Developer check: save a screenshot and a marker list a few seconds after a world loads", (string)null, false, false, (ValueValidator)null, (string)null); obj.SaveToFile(false); ((MelonBase)this).LoggerInstance.Msg("Ready. Press " + ((object)Key.Value/*cast due to .constrained prefix*/).ToString() + " in a world to switch the minimap size."); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { _inWorld = sceneName == "Main"; _map?.Destroy(); _map = (_inWorld ? new MiniMap() : null); } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { if (!(sceneName != "Main")) { _inWorld = false; _map?.Destroy(); _map = null; } } public override void OnUpdate() { if (!_inWorld || _map == null) { return; } try { _map.Tick(); } catch (Exception e) { _map.Fail(e); } } } }