Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Schedule I Minimap v1.0.1
Mods/ScheduleIMinimap.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Il2CppFishNet.Object; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.Map; using Il2CppScheduleOne.Vehicles; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using ScheduleIMinimap; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(MinimapMod), "Schedule I Minimap", "1.0.1", "nacho", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ScheduleIMinimap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+c02009702c06e41397470955ed5c61813b6c6995")] [assembly: AssemblyProduct("ScheduleIMinimap")] [assembly: AssemblyTitle("ScheduleIMinimap")] [assembly: AssemblyVersion("1.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 ScheduleIMinimap { internal sealed class CustomerBadgeSprites : IDisposable { private Texture2D? checkTexture; private Texture2D? clockTexture; private Texture2D? lockTexture; private Sprite? checkSprite; private Sprite? clockSprite; private Sprite? lockSprite; private bool disposed; internal Sprite Check => checkSprite; internal Sprite Clock => clockSprite; internal Sprite Lock => lockSprite; internal CustomerBadgeSprites() { try { (checkTexture, checkSprite) = CreateGlyph((double x, double y) => Math.Min(SegmentDistance(x, y, -0.68, -0.02, -0.2, -0.45), SegmentDistance(x, y, -0.2, -0.45, 0.68, 0.5)) - 0.115); (clockTexture, clockSprite) = CreateGlyph(delegate(double x, double y) { double val = Math.Abs(Math.Sqrt(x * x + y * y) - 0.7) - 0.075; double val2 = SegmentDistance(x, y, 0.0, 0.0, 0.0, 0.42) - 0.07; double val3 = SegmentDistance(x, y, 0.0, 0.0, 0.32, -0.15) - 0.07; return Math.Min(val, Math.Min(val2, val3)); }); (lockTexture, lockSprite) = CreateGlyph(delegate(double x, double y) { double val = Math.Max(Math.Abs(x) - 0.5, Math.Max(-0.65 - y, y - 0.1)); double val2 = Math.Abs(Math.Sqrt(x * x + (y - 0.18) * (y - 0.18)) - 0.33) - 0.09; double val3 = Math.Sqrt(x * x + (y + 0.22) * (y + 0.22)) - 0.085; return Math.Max(val2: 0.0 - Math.Min(val3, Math.Max(Math.Abs(x) - 0.05, Math.Max(-0.48 - y, y + 0.24))), val1: Math.Min(val, val2)); }); } catch { Dispose(); throw; } } private static double SegmentDistance(double x, double y, double ax, double ay, double bx, double by) { double num = bx - ax; double num2 = by - ay; double num3 = Math.Clamp(((x - ax) * num + (y - ay) * num2) / (num * num + num2 * num2), 0.0, 1.0); double num4 = x - (ax + num3 * num); double num5 = y - (ay + num3 * num2); return Math.Sqrt(num4 * num4 + num5 * num5); } private static (Texture2D Texture, Sprite Sprite) CreateGlyph(Func<double, double, double> distance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_013d: 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_00ef: 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) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); try { ((Object)val).name = "Schedule I Minimap status glyph"; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { double num = distance(((double)j + 0.5) / 64.0 * 2.0 - 1.0, ((double)i + 0.5) / 64.0 * 2.0 - 1.0); float num2 = (float)Math.Clamp(0.5 - num * 64.0 / 2.0, 0.0, 1.0); array[i * 64 + j] = new Color(1f, 1f, 1f, num2); } } val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array)); val.Apply(false, true); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); if ((Object)(object)val2 == (Object)null) { throw new InvalidOperationException("Unable to create a customer status sprite."); } return (Texture: val, Sprite: val2); } catch { Object.Destroy((Object)(object)val); throw; } } public void Dispose() { if (!disposed) { disposed = true; if ((Object)(object)checkSprite != (Object)null) { Object.Destroy((Object)(object)checkSprite); } if ((Object)(object)clockSprite != (Object)null) { Object.Destroy((Object)(object)clockSprite); } if ((Object)(object)lockSprite != (Object)null) { Object.Destroy((Object)(object)lockSprite); } if ((Object)(object)checkTexture != (Object)null) { Object.Destroy((Object)(object)checkTexture); } if ((Object)(object)clockTexture != (Object)null) { Object.Destroy((Object)(object)clockTexture); } if ((Object)(object)lockTexture != (Object)null) { Object.Destroy((Object)(object)lockTexture); } checkSprite = (clockSprite = (lockSprite = null)); checkTexture = (clockTexture = (lockTexture = null)); } } } internal sealed class CustomerMarkers : IDisposable { private sealed class Marker { internal RectTransform Root; internal RectTransform HaloRect; internal Image Halo; internal RectTransform RingRect; internal Image Ring; internal RectTransform PortraitMask; internal Image Portrait; internal RectTransform LabelRect; internal Text Label; internal RectTransform PurchasedBadge; internal Image PurchasedGlyph; internal RectTransform DealBadge; internal Image DealGlyph; internal RectTransform RegionBadge; internal Image RegionGlyph; internal Transform TrackingTransform; internal Sprite? Mugshot; internal CustomerStatus Status; internal bool Potential; internal bool UsesName; internal float Radius; internal float LabelWidth; } private readonly RectTransform layer; private readonly Sprite circleSprite; private readonly Font? font; private readonly CustomerBadgeSprites badgeSprites; private readonly Dictionary<int, Marker> markers = new Dictionary<int, Marker>(); private readonly HashSet<int> liveIds = new HashSet<int>(); private readonly List<int> staleIds = new List<int>(); private readonly List<Rect> occupiedLabels = new List<Rect>(); private float nextRefresh; private float markerSize = 24f; private int nameSize = 11; private bool show = true; private bool showPotential = true; private bool highlightPotential = true; private bool showAlreadyPurchased = true; private bool showActiveDeals = true; private bool showRegionLockedCustomers = true; private CustomerMarkerStyle style; private Color customerColor = new Color(0.25f, 0.9f, 0.65f, 1f); private Color potentialColor = new Color(0.75f, 0.35f, 1f, 1f); private Color purchasedColor = new Color(0.2f, 0.85f, 0.3f, 1f); private Color dealColor = new Color(0.25f, 0.65f, 1f, 1f); private Color regionLockedColor = new Color(0.7f, 0.72f, 0.77f, 1f); private bool disposed; private IReadOnlySet<int>? dealerNpcIds; internal List<Rect> OccupiedLabels => occupiedLabels; internal CustomerMarkers(RectTransform parent, Sprite circleSprite, Font? font) { //IL_007e: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00db: 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_00fa: 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_013a: Unknown result type (might be due to invalid IL or missing references) this.circleSprite = circleSprite; this.font = font; badgeSprites = new CustomerBadgeSprites(); try { layer = NewRect("Customers", (Transform)(object)parent); ((Transform)layer).localRotation = Quaternion.identity; } catch { if ((Object)(object)layer != (Object)null) { Object.Destroy((Object)(object)((Component)layer).gameObject); } badgeSprites.Dispose(); throw; } } internal void Apply(Settings settings) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if (disposed || (Object)(object)layer == (Object)null) { return; } show = settings.ShowCustomers.Value; showPotential = settings.ShowPotentialCustomers.Value; highlightPotential = settings.HighlightPotentialCustomers.Value; showAlreadyPurchased = settings.ShowAlreadyPurchased.Value; showActiveDeals = settings.ShowActiveDeals.Value; showRegionLockedCustomers = settings.ShowRegionLockedCustomers.Value; style = (Enum.IsDefined(typeof(CustomerMarkerStyle), settings.CustomerStyle.Value) ? settings.CustomerStyle.Value : CustomerMarkerStyle.Portraits); markerSize = (float)MapMath.ClampFinite(settings.CustomerMarkerSize.Value, 12.0, 40.0, 24.0); nameSize = (int)MapMath.ClampFinite(settings.CustomerNameSize.Value, 8.0, 18.0, 11.0); customerColor = ClampColor(settings.CustomerColor.Value, new Color(0.25f, 0.9f, 0.65f, 1f)); potentialColor = ClampColor(settings.PotentialCustomerColor.Value, new Color(0.75f, 0.35f, 1f, 1f)); purchasedColor = ClampColor(settings.AlreadyPurchasedColor.Value, new Color(0.2f, 0.85f, 0.3f, 1f)); dealColor = ClampColor(settings.ActiveDealColor.Value, new Color(0.25f, 0.65f, 1f, 1f)); regionLockedColor = ClampColor(settings.RegionLockedColor.Value, new Color(0.7f, 0.72f, 0.77f, 1f)); ((Component)layer).gameObject.SetActive(show); foreach (Marker value in markers.Values) { ApplyAppearance(value); } nextRefresh = 0f; } internal void Update(Settings settings, MapProjection projection, Vector2 center, float zoom, float rotation, float viewportSize, bool circle, IReadOnlySet<int>? dealerNpcIds = null) { //IL_00a9: 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_00b3: 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_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) this.dealerNpcIds = dealerNpcIds; occupiedLabels.Clear(); if (disposed || (Object)(object)layer == (Object)null || !show) { return; } if (Time.unscaledTime >= nextRefresh) { RefreshSources(); } float num = viewportSize / 2f; foreach (Marker value in markers.Values) { if ((Object)(object)value.Root == (Object)null) { continue; } if ((Object)(object)value.TrackingTransform == (Object)null) { ((Component)value.Root).gameObject.SetActive(false); continue; } Vector2 val = projection.Project(value.TrackingTransform.position); (double, double) tuple = MapMath.RelativePoint(val.x, val.y, center.x, center.y, zoom, rotation); bool flag = num > value.Radius && MapMath.IsInside(tuple.Item1, tuple.Item2, num - value.Radius, circle); ((Component)value.Root).gameObject.SetActive(flag); if (flag) { value.Root.anchoredPosition = new Vector2((float)tuple.Item1, (float)tuple.Item2); ((Transform)value.Root).localRotation = Quaternion.identity; bool flag2 = value.UsesName && (Object)(object)font != (Object)null && value.LabelWidth > 0f; if (flag2) { flag2 = PlaceLabel(value, (float)tuple.Item1, (float)tuple.Item2, num, circle); } ((Component)value.LabelRect).gameObject.SetActive(flag2); } } } private void RefreshSources() { nextRefresh = Time.unscaledTime + 1f; liveIds.Clear(); List<Customer> unlockedCustomers = Customer.UnlockedCustomers; if (unlockedCustomers != null) { for (int i = 0; i < unlockedCustomers.Count; i++) { Register(unlockedCustomers[i], potential: false); } } if (showPotential || showRegionLockedCustomers) { List<Customer> lockedCustomers = Customer.LockedCustomers; if (lockedCustomers != null) { for (int j = 0; j < lockedCustomers.Count; j++) { Customer val = lockedCustomers[j]; if ((Object)(object)val == (Object)null) { continue; } if (CustomerStatusReader.GetRegionLockState(val) == true) { if (showRegionLockedCustomers) { Register(val, potential: false, regionLocked: true); } } else if (showPotential) { NPCPoI potentialCustomerPoI = val.potentialCustomerPoI; if ((Object)(object)potentialCustomerPoI != (Object)null && ((Behaviour)potentialCustomerPoI).enabled) { Register(val, potential: true); } } } } } staleIds.Clear(); foreach (int key in markers.Keys) { if (!liveIds.Contains(key)) { staleIds.Add(key); } } foreach (int staleId in staleIds) { DestroyMarker(markers[staleId]); markers.Remove(staleId); } } private void Register(Customer? customer, bool potential, bool regionLocked = false) { if ((Object)(object)customer == (Object)null) { return; } NPC nPC = customer.NPC; if ((Object)(object)nPC == (Object)null || (Object)(object)((Component)nPC).gameObject == (Object)null || !((Component)nPC).gameObject.activeInHierarchy) { return; } NPCHealth health = nPC.Health; if ((Object)(object)health != (Object)null && health.IsDead) { return; } Transform transform = ((Component)nPC).transform; if ((Object)(object)transform == (Object)null) { return; } int instanceID = ((Object)nPC).GetInstanceID(); IReadOnlySet<int>? readOnlySet = dealerNpcIds; if ((readOnlySet != null && readOnlySet.Contains(instanceID)) || !liveIds.Add(instanceID)) { return; } if (!markers.TryGetValue(instanceID, out Marker value) || (Object)(object)value.Root == (Object)null) { if (value != null) { DestroyMarker(value); } value = CreateMarker(transform); markers[instanceID] = value; } value.TrackingTransform = transform; value.Potential = potential && !regionLocked; value.Status = (regionLocked ? CustomerStatus.RegionLocked : ((!potential) ? CustomerStatusReader.Read(customer, showAlreadyPurchased, showActiveDeals) : CustomerStatus.None)); value.Mugshot = nPC.MugshotSprite; value.Label.text = (string.IsNullOrWhiteSpace(nPC.FullName) ? "Customer" : nPC.FullName); ApplyAppearance(value); } private Marker CreateMarker(Transform tracking) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d1: 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_0114: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRect("Customer marker", (Transform)(object)layer); try { RectTransform val2 = NewRect("Potential halo", (Transform)(object)val); Image val3 = ((Component)val2).gameObject.AddComponent<Image>(); val3.sprite = circleSprite; ((Graphic)val3).raycastTarget = false; RectTransform val4 = NewRect("Customer ring or dot", (Transform)(object)val); Image val5 = ((Component)val4).gameObject.AddComponent<Image>(); val5.sprite = circleSprite; ((Graphic)val5).raycastTarget = false; RectTransform val6 = NewRect("Portrait clip", (Transform)(object)val); Image obj = ((Component)val6).gameObject.AddComponent<Image>(); obj.sprite = circleSprite; ((Graphic)obj).raycastTarget = false; ((Component)val6).gameObject.AddComponent<Mask>().showMaskGraphic = false; RectTransform obj2 = NewRect("Portrait", (Transform)(object)val6); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; Vector2 offsetMin = (obj2.offsetMax = Vector2.zero); obj2.offsetMin = offsetMin; Image val7 = ((Component)obj2).gameObject.AddComponent<Image>(); val7.preserveAspect = false; ((Graphic)val7).raycastTarget = false; RectTransform val8 = NewRect("Customer name", (Transform)(object)val); val8.pivot = new Vector2(0f, 0.5f); Text val9 = ((Component)val8).gameObject.AddComponent<Text>(); if ((Object)(object)font != (Object)null) { val9.font = font; } ((Graphic)val9).color = Color.white; val9.alignment = (TextAnchor)3; val9.horizontalOverflow = (HorizontalWrapMode)1; val9.verticalOverflow = (VerticalWrapMode)1; val9.supportRichText = false; val9.resizeTextForBestFit = false; ((Graphic)val9).raycastTarget = false; Shadow obj3 = ((Component)val8).gameObject.AddComponent<Shadow>(); obj3.effectColor = new Color(0f, 0f, 0f, 0.95f); obj3.effectDistance = new Vector2(1f, -1f); obj3.useGraphicAlpha = true; var (purchasedBadge, purchasedGlyph) = CreateBadge("Already purchased", val, badgeSprites.Check); var (dealBadge, dealGlyph) = CreateBadge("Active accepted deal", val, badgeSprites.Clock); var (regionBadge, regionGlyph) = CreateBadge("Region locked", val, badgeSprites.Lock); ((Component)val).gameObject.SetActive(false); return new Marker { Root = val, HaloRect = val2, Halo = val3, RingRect = val4, Ring = val5, PortraitMask = val6, Portrait = val7, LabelRect = val8, Label = val9, PurchasedBadge = purchasedBadge, PurchasedGlyph = purchasedGlyph, DealBadge = dealBadge, DealGlyph = dealGlyph, RegionBadge = regionBadge, RegionGlyph = regionGlyph, TrackingTransform = tracking }; } catch { Object.Destroy((Object)(object)((Component)val).gameObject); throw; } } private (RectTransform Badge, Image Glyph) CreateBadge(string name, RectTransform parent, Sprite symbol) { //IL_0034: 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) //IL_005b: 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_0085: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRect(name, (Transform)(object)parent); Image obj = ((Component)val).gameObject.AddComponent<Image>(); obj.sprite = circleSprite; ((Graphic)obj).color = new Color(0.015f, 0.025f, 0.035f, 0.98f); ((Graphic)obj).raycastTarget = false; RectTransform obj2 = NewRect("Status symbol", (Transform)(object)val); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(1f, 1f); obj2.offsetMax = new Vector2(-1f, -1f); Image val2 = ((Component)obj2).gameObject.AddComponent<Image>(); val2.sprite = symbol; ((Graphic)val2).raycastTarget = false; ((Component)val).gameObject.SetActive(false); return (Badge: val, Glyph: val2); } private void ApplyAppearance(Marker marker) { //IL_008d: 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_009c: 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_00be: 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_00dd: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0142: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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) if (!((Object)(object)marker.Root == (Object)null)) { bool flag = style == CustomerMarkerStyle.Portraits && (Object)(object)marker.Mugshot != (Object)null; bool num = (marker.Status & CustomerStatus.RegionLocked) != 0; bool flag2 = !num && marker.Potential && highlightPotential; float num2 = (flag ? markerSize : Math.Clamp(markerSize * 0.42f, 5f, 14f)); float num3 = num2 + 6f; Color val = (num ? regionLockedColor : (flag2 ? potentialColor : customerColor)); marker.Root.sizeDelta = new Vector2(num2, num2); marker.RingRect.sizeDelta = new Vector2(num2, num2); ((Graphic)marker.Ring).color = val; marker.HaloRect.sizeDelta = new Vector2(num3, num3); ((Graphic)marker.Halo).color = new Color(val.r, val.g, val.b, val.a * 0.4f); ((Component)marker.HaloRect).gameObject.SetActive(flag2); marker.PortraitMask.sizeDelta = new Vector2(Math.Max(4f, num2 - 4f), Math.Max(4f, num2 - 4f)); ((Component)marker.PortraitMask).gameObject.SetActive(flag); marker.Portrait.sprite = marker.Mugshot; ((Graphic)marker.Portrait).color = Color.white; marker.Radius = (flag2 ? num3 : num2) / 2f; bool flag3 = !num && showAlreadyPurchased && (marker.Status & CustomerStatus.AlreadyPurchased) != 0; bool flag4 = !num && showActiveDeals && (marker.Status & CustomerStatus.ActiveDeal) != 0; bool flag5 = num && showRegionLockedCustomers; float num4 = Math.Clamp(num2 * 0.45f, 8f, 14f); float num5 = Math.Max(num2 * 0.4f, num4 * 0.65f); RectTransform purchasedBadge = marker.PurchasedBadge; RectTransform dealBadge = marker.DealBadge; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(num4, num4); dealBadge.sizeDelta = sizeDelta; purchasedBadge.sizeDelta = sizeDelta; marker.RegionBadge.sizeDelta = new Vector2(num4, num4); marker.PurchasedBadge.anchoredPosition = new Vector2((flag3 && flag4) ? (0f - num5) : num5, 0f - num5); marker.DealBadge.anchoredPosition = new Vector2(num5, 0f - num5); marker.RegionBadge.anchoredPosition = new Vector2(num5, 0f - num5); RectTransform purchasedBadge2 = marker.PurchasedBadge; Quaternion localRotation = (((Transform)marker.DealBadge).localRotation = Quaternion.identity); ((Transform)purchasedBadge2).localRotation = localRotation; ((Transform)marker.RegionBadge).localRotation = Quaternion.identity; ((Graphic)marker.PurchasedGlyph).color = purchasedColor; ((Graphic)marker.DealGlyph).color = dealColor; ((Graphic)marker.RegionGlyph).color = regionLockedColor; ((Component)marker.PurchasedBadge).gameObject.SetActive(flag3); ((Component)marker.DealBadge).gameObject.SetActive(flag4); ((Component)marker.RegionBadge).gameObject.SetActive(flag5); if (flag3 || flag4 || flag5) { float val2 = MathF.Sqrt(2f * num5 * num5) + num4 / 2f; marker.Radius = Math.Max(marker.Radius, val2); } marker.UsesName = !flag; marker.Label.fontSize = nameSize; marker.LabelWidth = ((marker.UsesName && (Object)(object)font != (Object)null) ? Math.Max(1f, marker.Label.preferredWidth + 4f) : 0f); marker.LabelRect.sizeDelta = new Vector2(marker.LabelWidth, (float)(nameSize + 6)); ((Component)marker.LabelRect).gameObject.SetActive(false); } } private bool PlaceLabel(Marker marker, float x, float y, float halfSize, bool circle) { //IL_0060: 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) int num = nameSize + 6; Rect bounds = default(Rect); ((Rect)(ref bounds))..ctor(x + marker.Radius + 4f, y - (float)num / 2f, marker.LabelWidth, (float)num); Rect bounds2 = default(Rect); ((Rect)(ref bounds2))..ctor(x - marker.Radius - 4f - marker.LabelWidth, y - (float)num / 2f, marker.LabelWidth, (float)num); if (TryPlaceLabel(marker, bounds, x, halfSize, circle)) { return true; } return TryPlaceLabel(marker, bounds2, x, halfSize, circle); } private bool TryPlaceLabel(Marker marker, Rect bounds, float markerX, float halfSize, bool circle) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00b5: 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_00df: Unknown result type (might be due to invalid IL or missing references) if (!MapMath.IsInside(((Rect)(ref bounds)).xMin, ((Rect)(ref bounds)).yMin, halfSize, circle) || !MapMath.IsInside(((Rect)(ref bounds)).xMin, ((Rect)(ref bounds)).yMax, halfSize, circle) || !MapMath.IsInside(((Rect)(ref bounds)).xMax, ((Rect)(ref bounds)).yMin, halfSize, circle) || !MapMath.IsInside(((Rect)(ref bounds)).xMax, ((Rect)(ref bounds)).yMax, halfSize, circle)) { return false; } foreach (Rect occupiedLabel in occupiedLabels) { Rect current = occupiedLabel; if (((Rect)(ref current)).Overlaps(bounds)) { return false; } } occupiedLabels.Add(bounds); marker.LabelRect.anchoredPosition = new Vector2(((Rect)(ref bounds)).xMin - markerX, 0f); ((Transform)marker.LabelRect).localRotation = Quaternion.identity; return true; } private static RectTransform NewRect(string name, Transform parent) { //IL_0001: 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) //IL_002d: 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_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent(parent, false); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); obj.pivot = val; Vector2 anchorMin = (obj.anchorMax = val); obj.anchorMin = anchorMin; obj.sizeDelta = Vector2.zero; return obj; } private static Color ClampColor(Color value, Color fallback) { //IL_0000: 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_0026: 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_004c: 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_008b: 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) return new Color((float)MapMath.ClampFinite(value.r, 0.0, 1.0, fallback.r), (float)MapMath.ClampFinite(value.g, 0.0, 1.0, fallback.g), (float)MapMath.ClampFinite(value.b, 0.0, 1.0, fallback.b), (float)MapMath.ClampFinite(value.a, 0.0, 1.0, fallback.a)); } private static void DestroyMarker(Marker marker) { if (!((Object)(object)marker.Root == (Object)null)) { ((Component)marker.Root).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)marker.Root).gameObject); } } public void Dispose() { if (!disposed) { disposed = true; if ((Object)(object)layer != (Object)null) { ((Component)layer).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)layer).gameObject); } markers.Clear(); liveIds.Clear(); staleIds.Clear(); occupiedLabels.Clear(); badgeSprites.Dispose(); } } } [Flags] internal enum CustomerStatus { None = 0, AlreadyPurchased = 1, ActiveDeal = 2, RegionLocked = 4 } internal static class CustomerStatusPolicy { internal const string RecentPurchaseReason = "Customer recently completed a deal"; internal static bool? ClassifyRegionLock(bool? relationUnlocked, bool? regionUnlocked) { if (relationUnlocked == true || regionUnlocked == true) { return false; } if (!relationUnlocked.HasValue || !regionUnlocked.HasValue) { return null; } return true; } internal static CustomerStatus Classify(bool offerValid, string? invalidReason, bool activeContract) { CustomerStatus customerStatus = (activeContract ? CustomerStatus.ActiveDeal : CustomerStatus.None); if (!offerValid && string.Equals(invalidReason, "Customer recently completed a deal", StringComparison.Ordinal)) { customerStatus |= CustomerStatus.AlreadyPurchased; } return customerStatus; } } internal static class CustomerStatusReader { private static bool purchaseWarningShown; private static bool contractWarningShown; private static bool regionWarningShown; internal static bool? GetRegionLockState(Customer customer) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) try { NPC nPC = customer.NPC; if ((Object)(object)nPC == (Object)null || nPC.RelationData == null) { return null; } if (nPC.RelationData.Unlocked) { return false; } Map instance = Singleton<Map>.Instance; if ((Object)(object)instance == (Object)null) { return null; } MapRegionData regionData = instance.GetRegionData(nPC.Region); return CustomerStatusPolicy.ClassifyRegionLock(false, (regionData == null) ? ((bool?)null) : new bool?(regionData.IsUnlocked)); } catch (Exception ex) { if (!regionWarningShown) { regionWarningShown = true; MelonLogger.Warning("Minimap region lock query failed: " + ex.GetType().Name + ": " + ex.Message); } return null; } } internal static CustomerStatus Read(Customer customer, bool showAlreadyPurchased, bool showActiveDeals) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 bool offerValid = true; string invalidReason = null; bool activeContract = false; if (showAlreadyPurchased) { try { string text = default(string); offerValid = customer.OfferDealValid(ref text); invalidReason = text; } catch (Exception ex) { if (!purchaseWarningShown) { purchaseWarningShown = true; MelonLogger.Warning("Minimap purchase badge query failed: " + ex.GetType().Name + ": " + ex.Message); } } } if (showActiveDeals) { try { Contract currentContract = customer.CurrentContract; activeContract = (Object)(object)currentContract != (Object)null && (int)((Quest)currentContract).State == 1; } catch (Exception ex2) { if (!contractWarningShown) { contractWarningShown = true; MelonLogger.Warning("Minimap active deal badge query failed: " + ex2.GetType().Name + ": " + ex2.Message); } } } return CustomerStatusPolicy.Classify(offerValid, invalidReason, activeContract); } } internal static class MapMath { internal const double MinimumZoom = 0.1; internal const double MaximumZoom = 12.0; internal const double DefaultZoom = 3.0; internal static double ClampZoom(double value) { return ClampFinite(value, 0.1, 12.0, 3.0); } internal static float NextZoom(double current, double step, bool increase) { double num = ClampFinite(step, 0.1, 3.0, 0.5); return (float)Math.Clamp(ClampZoom(current) + (increase ? num : (0.0 - num)), 0.1, 12.0); } internal static double ClampFinite(double value, double min, double max, double fallback) { if (!double.IsFinite(value)) { return fallback; } return Math.Clamp(value, min, max); } internal static (double X, double Y) Rotate(double x, double y, double degrees) { double num = degrees * Math.PI / 180.0; double num2 = Math.Sin(num); double num3 = Math.Cos(num); return (X: x * num3 - y * num2, Y: x * num2 + y * num3); } internal static double Heading(double dx, double dy) { return Math.Atan2(dx, dy) * 180.0 / Math.PI; } internal static (double X, double Y) RelativePoint(double x, double y, double centerX, double centerY, double zoom, double rotation) { return Rotate((x - centerX) * zoom, (y - centerY) * zoom, rotation); } internal static bool IsInside(double x, double y, double halfSize, bool circle) { if (!circle) { if (Math.Abs(x) <= halfSize) { return Math.Abs(y) <= halfSize; } return false; } return x * x + y * y <= halfSize * halfSize; } internal static (double X, double Y, double Width, double Height) FitAspect(double x, double y, double width, double height, double aspect, double pivotX, double pivotY) { if (width <= 0.0 || height <= 0.0 || aspect <= 0.0 || !double.IsFinite(aspect)) { return (X: x, Y: y, Width: width, Height: height); } if (width / height > aspect) { double num = height * aspect; return (X: x + (width - num) * pivotX, Y: y, Width: num, Height: height); } double num2 = width / aspect; return (X: x, Y: y + (height - num2) * pivotY, Width: width, Height: num2); } } internal readonly struct MapProjection { private readonly MapPositionUtility utility; private readonly Transform parent; private readonly Vector3 anchorOffset; private readonly RectTransform background; private readonly Vector2 drawingCenter; internal MapProjection(MapPositionUtility utility, Transform parent, Vector3 anchorOffset, RectTransform background, Rect drawingRect) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) this.utility = utility; this.parent = parent; this.anchorOffset = anchorOffset; this.background = background; drawingCenter = ((Rect)(ref drawingRect)).center; } internal Vector2 Project(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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: 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_0041: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector2 mapPosition = utility.GetMapPosition(world); Vector3 val = parent.TransformPoint(new Vector3(mapPosition.x, mapPosition.y, 0f) + anchorOffset); Vector3 val2 = ((Transform)background).InverseTransformPoint(val); return new Vector2(val2.x - drawingCenter.x, val2.y - drawingCenter.y); } } internal sealed class MinimapHud : IDisposable { private readonly MapApp source; private readonly GameObject root; private readonly RectTransform frame; private readonly RectTransform outline; private readonly RectTransform viewport; private readonly RectTransform mapLayer; private readonly Image maskImage; private readonly Image mapImage; private readonly RectTransform arrow; private readonly CanvasGroup group; private readonly Sprite circleSprite; private readonly Sprite arrowSprite; private readonly Texture2D circleTexture; private readonly Texture2D arrowTexture; private readonly CustomerMarkers customers; private readonly WorldMarkers worldMarkers; private readonly Dictionary<int, (Player Player, RectTransform Marker)> peers = new Dictionary<int, (Player, RectTransform)>(); private readonly HashSet<int> livePeerIds = new HashSet<int>(); private readonly List<int> stalePeerIds = new List<int>(); private float nextPeerRefresh; private float size; private float zoom; private bool circular; private bool disposed; internal bool IsAlive { get { if ((Object)(object)root != (Object)null) { return !disposed; } return false; } } internal bool IsBoundTo(MapApp app) { return (Object)(object)source == (Object)(object)app; } internal MinimapHud(MapApp app) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) source = app; root = new GameObject("Schedule I Minimap HUD"); try { root.AddComponent<RectTransform>(); Canvas obj = root.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 5; CanvasScaler obj2 = root.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.screenMatchMode = (ScreenMatchMode)0; obj2.matchWidthOrHeight = 0.5f; group = root.AddComponent<CanvasGroup>(); group.interactable = false; group.blocksRaycasts = false; (Texture2D, Sprite) tuple = MakeSprite(128, delegate(float x, float y) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) double num = Math.Sqrt(x * x + y * y); return new Color(1f, 1f, 1f, (float)Math.Clamp((1.0 - num) * 64.0, 0.0, 1.0)); }); circleTexture = tuple.Item1; circleSprite = tuple.Item2; tuple = MakeSprite(64, delegate(float x, float y) { //IL_0071: 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) bool num = (double)y > -0.65 && (double)y < 0.9 && (double)Math.Abs(x) < (0.9 - (double)y) * 0.48; bool flag = (double)y < -0.1 && (double)Math.Abs(x) < (-0.1 - (double)y) * 0.38; return (!num || flag) ? Color.clear : Color.white; }); arrowTexture = tuple.Item1; arrowSprite = tuple.Item2; outline = NewRect("Outer outline", root.transform); ((Graphic)((Component)outline).gameObject.AddComponent<Image>()).raycastTarget = false; frame = NewRect("Frame", root.transform); Image obj3 = ((Component)frame).gameObject.AddComponent<Image>(); ((Graphic)obj3).raycastTarget = false; ((Graphic)obj3).color = new Color(0.06f, 0.075f, 0.09f, 0.98f); viewport = NewRect("Viewport", root.transform); maskImage = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)maskImage).raycastTarget = false; ((Graphic)maskImage).color = Color.white; ((Component)viewport).gameObject.AddComponent<Mask>().showMaskGraphic = false; RectTransform obj4 = NewRect("Backdrop", (Transform)(object)viewport); Stretch(obj4); Image obj5 = ((Component)obj4).gameObject.AddComponent<Image>(); ((Graphic)obj5).raycastTarget = false; ((Graphic)obj5).color = new Color(0.08f, 0.1f, 0.12f, 1f); mapLayer = NewRect("Map rotation", (Transform)(object)viewport); mapImage = ((Component)NewRect("Native map", (Transform)(object)mapLayer)).gameObject.AddComponent<Image>(); ((Graphic)mapImage).raycastTarget = false; ((Graphic)mapImage).color = Color.white; mapImage.type = (Type)0; mapImage.preserveAspect = false; RectTransform parent = NewRect("Customers", (Transform)(object)viewport); Font val = null; if ((Object)(object)source.LabelGroup != (Object)null) { Text componentInChildren = ((Component)source.LabelGroup).GetComponentInChildren<Text>(true); val = ((componentInChildren != null) ? componentInChildren.font : null); } HUD instance = Singleton<HUD>.Instance; if ((Object)(object)val == (Object)null && (Object)(object)instance != (Object)null && (Object)(object)instance.fpsLabel != (Object)null) { val = instance.fpsLabel.font; } if ((Object)(object)val == (Object)null) { val = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } customers = new CustomerMarkers(parent, circleSprite, val); worldMarkers = new WorldMarkers(viewport, circleSprite, val); worldMarkers.PlaceVehiclesBehind(parent); arrow = NewRect("You", (Transform)(object)viewport); arrow.sizeDelta = new Vector2(24f, 24f); Image obj6 = ((Component)arrow).gameObject.AddComponent<Image>(); obj6.sprite = arrowSprite; ((Graphic)obj6).color = new Color(1f, 0.9f, 0.32f, 1f); ((Graphic)obj6).raycastTarget = false; root.SetActive(false); } catch { Object.Destroy((Object)(object)root); if (customers != null) { customers.Dispose(); } if (worldMarkers != null) { worldMarkers.Dispose(); } if ((Object)(object)circleSprite != (Object)null) { Object.Destroy((Object)(object)circleSprite); } if ((Object)(object)arrowSprite != (Object)null) { Object.Destroy((Object)(object)arrowSprite); } if ((Object)(object)circleTexture != (Object)null) { Object.Destroy((Object)(object)circleTexture); } if ((Object)(object)arrowTexture != (Object)null) { Object.Destroy((Object)(object)arrowTexture); } throw; } } internal void Apply(Settings settings) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) size = (float)MapMath.ClampFinite(settings.Size.Value, 120.0, 480.0, 240.0); zoom = (float)MapMath.ClampZoom(settings.Zoom.Value); group.alpha = (float)MapMath.ClampFinite(settings.Opacity.Value, 0.1, 1.0, 0.95); circular = settings.Shape.Value != MapShape.Square; maskImage.sprite = (circular ? circleSprite : null); Image component = ((Component)frame).GetComponent<Image>(); Image component2 = ((Component)outline).GetComponent<Image>(); Sprite sprite = (component2.sprite = (circular ? circleSprite : null)); component.sprite = sprite; ((Graphic)component).color = ClampColor(settings.BorderColor.Value, new Color(0.18f, 0.22f, 0.27f, 1f)); ((Graphic)component2).color = ClampColor(settings.OutlineColor.Value, new Color(0.02f, 0.025f, 0.03f, 1f)); float num = (settings.BorderEnabled.Value ? ((float)MapMath.ClampFinite(settings.BorderWidth.Value, 0.0, 24.0, 4.0)) : 0f); float num2 = (settings.OutlineEnabled.Value ? ((float)MapMath.ClampFinite(settings.OutlineWidth.Value, 0.0, 12.0, 2.0)) : 0f); ((Component)frame).gameObject.SetActive(num > 0f); ((Component)outline).gameObject.SetActive(num2 > 0f); MapCorner mapCorner = (Enum.IsDefined(typeof(MapCorner), settings.Corner.Value) ? settings.Corner.Value : MapCorner.TopRight); bool flag = mapCorner == MapCorner.TopRight || mapCorner == MapCorner.BottomRight; bool flag2 = mapCorner == MapCorner.TopRight || mapCorner == MapCorner.TopLeft; Vector2 anchor = default(Vector2); ((Vector2)(ref anchor))..ctor((float)(flag ? 1 : 0), (float)(flag2 ? 1 : 0)); float num3 = (float)MapMath.ClampFinite(settings.Margin.Value, 0.0, 200.0, 24.0) + num + num2 + size * 0.5f; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(flag ? (0f - num3) : num3, flag2 ? (0f - num3) : num3); val2 += new Vector2((float)MapMath.ClampFinite(settings.OffsetX.Value, -1000.0, 1000.0, 0.0), (float)MapMath.ClampFinite(settings.OffsetY.Value, -1000.0, 1000.0, 0.0)); Place(viewport, anchor, val2, size); Place(frame, anchor, val2, size + 2f * num); Place(outline, anchor, val2, size + 2f * (num + num2)); nextPeerRefresh = 0f; customers.Apply(settings); worldMarkers.Apply(settings); } internal void SetVisible(bool visible) { if (root.activeSelf != visible) { root.SetActive(visible); } } internal void Update(Player player, PlayerCamera? camera, MapPositionUtility projection, Settings settings) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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_00be: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_0137: 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_0152: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0256: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) Image backgroundImage = source.BackgroundImage; Sprite val = (((Object)(object)backgroundImage.overrideSprite != (Object)null) ? backgroundImage.overrideSprite : (((Object)(object)backgroundImage.sprite != (Object)null) ? backgroundImage.sprite : source.MainMapSprite)); if ((Object)(object)val == (Object)null) { SetVisible(visible: false); return; } RectTransform rectTransform = ((Graphic)backgroundImage).rectTransform; Rect drawingRect = DrawingRect(rectTransform.rect, rectTransform.pivot, val, backgroundImage.preserveAspect); if (((Rect)(ref drawingRect)).width <= 0f || ((Rect)(ref drawingRect)).height <= 0f) { SetVisible(visible: false); return; } mapImage.sprite = val; ((Graphic)mapImage).rectTransform.sizeDelta = new Vector2(((Rect)(ref drawingRect)).width, ((Rect)(ref drawingRect)).height); ((Transform)((Graphic)mapImage).rectTransform).localScale = new Vector3(zoom, zoom, 1f); RectTransform val2 = (((Object)(object)player.PoI != (Object)null) ? player.PoI.UI : null); Transform parent; Vector3 anchorOffset = default(Vector3); if ((Object)(object)val2 != (Object)null && (Object)(object)((Transform)val2).parent != (Object)null) { parent = ((Transform)val2).parent; anchorOffset = ((Transform)val2).localPosition - new Vector3(val2.anchoredPosition.x, val2.anchoredPosition.y, 0f); } else { parent = (Transform)(object)source.PoIContainer; Rect rect = source.PoIContainer.rect; Vector2 center = ((Rect)(ref rect)).center; ((Vector3)(ref anchorOffset))..ctor(center.x, center.y, 0f); } MapProjection projection2 = new MapProjection(projection, parent, anchorOffset, rectTransform, drawingRect); Transform val3 = ((player.IsInVehicle && (Object)(object)player.CurrentVehicle != (Object)null) ? ((Component)player.CurrentVehicle).transform : ((Component)player).transform); Vector3 position = val3.position; Vector2 val4 = projection2.Project(position); Vector3 val5 = (((Object)(object)camera != (Object)null && (Object)(object)camera.Camera != (Object)null) ? ((Component)camera.Camera).transform.forward : val3.forward); val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.001f) { val5 = val3.forward; } Vector2 val6 = projection2.Project(position + val5) - val4; float num = (float)MapMath.Heading(val6.x, val6.y); float num2 = (settings.Rotate.Value ? num : 0f); ((Transform)mapLayer).localRotation = Quaternion.Euler(0f, 0f, num2); ((Graphic)mapImage).rectTransform.anchoredPosition = -val4 * zoom; ((Transform)arrow).localRotation = Quaternion.Euler(0f, 0f, num2 - num); worldMarkers.RefreshSources(); customers.Update(settings, projection2, val4, zoom, num2, size, circular, worldMarkers.DealerNpcIds); worldMarkers.Update(player, settings.ShowCoop.Value, projection2, val4, zoom, num2, size, circular, customers.OccupiedLabels); RefreshPeers(player, settings.ShowCoop.Value); foreach (var value in peers.Values) { var (val7, _) = value; if ((Object)(object)val7 == (Object)null) { ((Component)value.Marker).gameObject.SetActive(false); continue; } Transform val8 = ((val7.IsInVehicle && (Object)(object)val7.CurrentVehicle != (Object)null) ? ((Component)val7.CurrentVehicle).transform : ((Component)val7).transform); Vector2 val9 = projection2.Project(val8.position); (double, double) tuple2 = MapMath.RelativePoint(val9.x, val9.y, val4.x, val4.y, zoom, num2); bool flag = MapMath.IsInside(tuple2.Item1, tuple2.Item2, size / 2f - 7f, circular); ((Component)value.Marker).gameObject.SetActive(flag); if (flag) { value.Marker.anchoredPosition = new Vector2((float)tuple2.Item1, (float)tuple2.Item2); } } } private void RefreshPeers(Player local, bool show) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!show) { if (peers.Count > 0) { ClearPeers(); } } else { if (Time.unscaledTime < nextPeerRefresh) { return; } nextPeerRefresh = Time.unscaledTime + 1f; livePeerIds.Clear(); List<Player> playerList = Player.PlayerList; if (playerList != null) { for (int i = 0; i < playerList.Count; i++) { Player val = playerList[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)local)) { int instanceID = ((Object)val).GetInstanceID(); livePeerIds.Add(instanceID); if (!peers.ContainsKey(instanceID)) { RectTransform val2 = NewRect("Co-op player", (Transform)(object)viewport); val2.sizeDelta = new Vector2(12f, 12f); Image obj = ((Component)val2).gameObject.AddComponent<Image>(); obj.sprite = circleSprite; ((Graphic)obj).color = new Color(0.2f, 0.87f, 1f, 1f); ((Graphic)obj).raycastTarget = false; peers.Add(instanceID, (val, val2)); } } } } ((Transform)arrow).SetAsLastSibling(); stalePeerIds.Clear(); foreach (int key in peers.Keys) { if (!livePeerIds.Contains(key)) { stalePeerIds.Add(key); } } foreach (int stalePeerId in stalePeerIds) { Object.Destroy((Object)(object)((Component)peers[stalePeerId].Marker).gameObject); peers.Remove(stalePeerId); } } } private static Rect DrawingRect(Rect rect, Vector2 pivot, Sprite sprite, bool preserveAspect) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_006f: 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_009f: Unknown result type (might be due to invalid IL or missing references) if (preserveAspect) { Rect rect2 = sprite.rect; if (!(((Rect)(ref rect2)).height <= 0f)) { rect2 = sprite.rect; if (!(((Rect)(ref rect2)).width <= 0f)) { rect2 = sprite.rect; float width = ((Rect)(ref rect2)).width; rect2 = sprite.rect; float num = width / ((Rect)(ref rect2)).height; (double, double, double, double) tuple = MapMath.FitAspect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, num, pivot.x, pivot.y); return new Rect((float)tuple.Item1, (float)tuple.Item2, (float)tuple.Item3, (float)tuple.Item4); } } } return rect; } private static Color ClampColor(Color color, Color fallback) { //IL_0000: 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_0026: 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_004c: 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_008b: 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) return new Color((float)MapMath.ClampFinite(color.r, 0.0, 1.0, fallback.r), (float)MapMath.ClampFinite(color.g, 0.0, 1.0, fallback.g), (float)MapMath.ClampFinite(color.b, 0.0, 1.0, fallback.b), (float)MapMath.ClampFinite(color.a, 0.0, 1.0, fallback.a)); } private static RectTransform NewRect(string name, Transform parent) { //IL_0001: 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) //IL_002d: 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_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent(parent, false); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); obj.pivot = val; Vector2 anchorMin = (obj.anchorMax = val); obj.anchorMin = anchorMin; obj.sizeDelta = Vector2.zero; return obj; } private static void Stretch(RectTransform rect) { //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_0018: 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_001e: 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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; Vector2 offsetMin = (rect.offsetMax = Vector2.zero); rect.offsetMin = offsetMin; } private static void Place(RectTransform rect, Vector2 anchor, Vector2 position, float diameter) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector2 anchorMin = (rect.anchorMax = anchor); rect.anchorMin = anchorMin; rect.anchoredPosition = position; rect.sizeDelta = new Vector2(diameter, diameter); } private static (Texture2D Texture, Sprite Sprite) MakeSprite(int size, Func<float, float, Color> pixel) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0066: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); try { ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { array[i * size + j] = pixel(((float)j + 0.5f) / (float)size * 2f - 1f, ((float)i + 0.5f) / (float)size * 2f - 1f); } } val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array)); val.Apply(false, true); Sprite item = Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f); return (Texture: val, Sprite: item); } catch { Object.Destroy((Object)(object)val); throw; } } private void ClearPeers() { foreach (var value in peers.Values) { if ((Object)(object)value.Marker != (Object)null) { Object.Destroy((Object)(object)((Component)value.Marker).gameObject); } } peers.Clear(); nextPeerRefresh = 0f; } public void Dispose() { if (!disposed) { disposed = true; if ((Object)(object)root != (Object)null) { root.SetActive(false); Object.Destroy((Object)(object)root); } customers.Dispose(); worldMarkers.Dispose(); peers.Clear(); Object.Destroy((Object)(object)circleSprite); Object.Destroy((Object)(object)arrowSprite); Object.Destroy((Object)(object)circleTexture); Object.Destroy((Object)(object)arrowTexture); } } } public sealed class MinimapMod : MelonMod { private Settings? settings; private MinimapHud? hud; private bool settingsDirty = true; private float retryAt; private int consecutiveFailures; private readonly ZoomInput zoomInput = new ZoomInput(); public override void OnInitializeMelon() { settings = new Settings(delegate { settingsDirty = true; }); ((MelonBase)this).LoggerInstance.Msg("v1.0.1 local dealer/vehicle marker test. Settings are available in Mod Manager & Phone App."); } public override void OnLateUpdate() { if (settings == null || Time.unscaledTime < retryAt) { return; } try { LoadManager instance = Singleton<LoadManager>.Instance; Player local = Player.Local; if ((Object)(object)instance == (Object)null || !instance.IsGameLoaded || instance.IsLoading || (Object)(object)local == (Object)null) { DestroyHud(); return; } MapApp instance2 = PlayerSingleton<MapApp>.Instance; MapPositionUtility instance3 = Singleton<MapPositionUtility>.Instance; if ((Object)(object)instance2 == (Object)null || (Object)(object)instance3 == (Object)null || (Object)(object)instance2.BackgroundImage == (Object)null || (Object)(object)instance2.PoIContainer == (Object)null) { DestroyHud(); retryAt = Time.unscaledTime + 1f; return; } Phone instance4 = PlayerSingleton<Phone>.Instance; PauseMenu instance5 = Singleton<PauseMenu>.Instance; PlayerCamera instance6 = PlayerSingleton<PlayerCamera>.Instance; bool flag = ((Object)(object)instance4 != (Object)null && instance4.IsOpen) || ((Object)(object)instance5 != (Object)null && instance5.IsPaused) || ((Object)(object)instance6 != (Object)null && instance6.ActiveUIElementCount > 0) || Time.timeScale == 0f; if (!flag && settings.Enabled.Value && zoomInput.Update(settings)) { settingsDirty = true; } if (hud == null || !hud.IsAlive || !hud.IsBoundTo(instance2)) { DestroyHud(); hud = new MinimapHud(instance2); settingsDirty = true; ((MelonBase)this).LoggerInstance.Msg("Minimap HUD created from the native phone map."); } if (settingsDirty) { hud.Apply(settings); settingsDirty = false; } bool flag2 = settings.Enabled.Value && (!settings.HideInMenus.Value || !flag); hud.SetVisible(flag2); if (flag2) { hud.Update(local, instance6, instance3, settings); } consecutiveFailures = 0; } catch (Exception ex) { DestroyHud(); retryAt = Time.unscaledTime + 5f; if (consecutiveFailures++ < 3) { ((MelonBase)this).LoggerInstance.Warning("Minimap unavailable; retrying in 5s: " + ex.GetType().Name + ": " + ex.Message); } } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { DestroyHud(); retryAt = 0f; consecutiveFailures = 0; } public override void OnDeinitializeMelon() { DestroyHud(); settings?.Dispose(); } private void DestroyHud() { hud?.Dispose(); hud = null; } } public enum MapShape { Circle, Square } public enum MapCorner { TopRight, TopLeft, BottomRight, BottomLeft } public enum CustomerMarkerStyle { Portraits, DotsWithNames } internal sealed class Settings { private readonly MelonPreferences_Category category; private readonly List<Action> unsubscribe = new List<Action>(); internal readonly MelonPreferences_Entry<bool> Enabled; internal readonly MelonPreferences_Entry<MapShape> Shape; internal readonly MelonPreferences_Entry<MapCorner> Corner; internal readonly MelonPreferences_Entry<int> Size; internal readonly MelonPreferences_Entry<float> Zoom; internal readonly MelonPreferences_Entry<float> Opacity; internal readonly MelonPreferences_Entry<bool> Rotate; internal readonly MelonPreferences_Entry<bool> HideInMenus; internal readonly MelonPreferences_Entry<bool> ShowCoop; internal readonly MelonPreferences_Entry<int> Margin; internal readonly MelonPreferences_Entry<int> OffsetX; internal readonly MelonPreferences_Entry<int> OffsetY; internal readonly MelonPreferences_Entry<KeyCode> ZoomInKey; internal readonly MelonPreferences_Entry<KeyCode> ZoomOutKey; internal readonly MelonPreferences_Entry<float> ZoomStep; internal readonly MelonPreferences_Entry<bool> BorderEnabled; internal readonly MelonPreferences_Entry<int> BorderWidth; internal readonly MelonPreferences_Entry<Color> BorderColor; internal readonly MelonPreferences_Entry<bool> OutlineEnabled; internal readonly MelonPreferences_Entry<int> OutlineWidth; internal readonly MelonPreferences_Entry<Color> OutlineColor; internal readonly MelonPreferences_Entry<bool> ShowCustomers; internal readonly MelonPreferences_Entry<CustomerMarkerStyle> CustomerStyle; internal readonly MelonPreferences_Entry<int> CustomerMarkerSize; internal readonly MelonPreferences_Entry<int> CustomerNameSize; internal readonly MelonPreferences_Entry<bool> ShowPotentialCustomers; internal readonly MelonPreferences_Entry<bool> HighlightPotentialCustomers; internal readonly MelonPreferences_Entry<Color> CustomerColor; internal readonly MelonPreferences_Entry<Color> PotentialCustomerColor; internal readonly MelonPreferences_Entry<bool> ShowAlreadyPurchased; internal readonly MelonPreferences_Entry<bool> ShowActiveDeals; internal readonly MelonPreferences_Entry<Color> AlreadyPurchasedColor; internal readonly MelonPreferences_Entry<Color> ActiveDealColor; internal readonly MelonPreferences_Entry<bool> ShowRegionLockedCustomers; internal readonly MelonPreferences_Entry<Color> RegionLockedColor; internal readonly MelonPreferences_Entry<bool> ShowDealers; internal readonly MelonPreferences_Entry<CustomerMarkerStyle> DealerStyle; internal readonly MelonPreferences_Entry<int> DealerMarkerSize; internal readonly MelonPreferences_Entry<int> DealerNameSize; internal readonly MelonPreferences_Entry<Color> DealerColor; internal readonly MelonPreferences_Entry<bool> ShowVehicles; internal readonly MelonPreferences_Entry<bool> ShowVehicleNames; internal readonly MelonPreferences_Entry<int> VehicleMarkerSize; internal readonly MelonPreferences_Entry<int> VehicleNameSize; internal readonly MelonPreferences_Entry<Color> VehicleColor; internal Settings(Action changed) { //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) category = MelonPreferences.CreateCategory("ScheduleIMinimap", "Minimap"); Enabled = Add("Enabled", defaultValue: true, "Show minimap", "Enable or disable the HUD map.", changed); Shape = Add("Shape", MapShape.Circle, "Map shape", "Circle or square clipping.", changed); Corner = Add("Corner", MapCorner.TopRight, "Screen corner", "Choose a corner to avoid other HUD mods.", changed); Size = Add("Size", 240, "Map size", "120–480 units, relative to a 1920x1080 HUD.", changed); Zoom = Add("Zoom", 3f, "Zoom", "0.1–12. Lower values show much more of the town.", changed); Opacity = Add("Opacity", 0.95f, "Opacity", "0.1–1. Applies to the entire minimap.", changed); Rotate = Add("Rotate", defaultValue: false, "Rotate with view", "Keep your viewing direction at the top.", changed); HideInMenus = Add("HideInMenus", defaultValue: true, "Hide during menus", "Hide while the phone, pause menu or another game UI is open.", changed); ShowCoop = Add("ShowCoop", defaultValue: true, "Show co-op players", "Show nearby connected players in cyan.", changed); Margin = Add("Margin", 24, "Corner margin", "0–200 units from the screen edges.", changed); OffsetX = Add("OffsetX", 0, "Horizontal offset", "-1000–1000 HUD units. Positive moves right from the chosen corner.", changed); OffsetY = Add("OffsetY", 0, "Vertical offset", "-1000–1000 HUD units. Positive moves up from the chosen corner.", changed); ZoomInKey = Add<KeyCode>("ZoomInKey", (KeyCode)280, "Zoom in key", "Keyboard key; None disables it. Ignored while a menu is open.", changed); ZoomOutKey = Add<KeyCode>("ZoomOutKey", (KeyCode)281, "Zoom out key", "Keyboard key; None disables it. Ignored while a menu is open.", changed); ZoomStep = Add("ZoomStep", 0.5f, "Zoom per key press", "0.1–3. Each press saves the new zoom level.", changed); BorderEnabled = Add("BorderEnabled", defaultValue: true, "Show border", "Show a border around either map shape.", changed); BorderWidth = Add("BorderWidth", 4, "Border thickness", "0–24 reference HUD units.", changed); BorderColor = Add<Color>("BorderColor", new Color(0.18f, 0.22f, 0.27f, 1f), "Border color", "Color and transparency of the border.", changed); OutlineEnabled = Add("OutlineEnabled", defaultValue: true, "Show outer outline", "Draw an outer outline around the border.", changed); OutlineWidth = Add("OutlineWidth", 2, "Outline thickness", "0–12 reference HUD units.", changed); OutlineColor = Add<Color>("OutlineColor", new Color(0.02f, 0.025f, 0.03f, 1f), "Outline color", "Color and transparency of the outer outline.", changed); ShowCustomers = Add("ShowCustomers", defaultValue: true, "Show customers", "Show customers and eligible potential customers on the map.", changed); CustomerStyle = Add("CustomerStyle", CustomerMarkerStyle.Portraits, "Customer marker style", "Small faces or dots with names. Missing faces use named dots.", changed); CustomerMarkerSize = Add("CustomerMarkerSize", 24, "Customer marker size", "12–40 reference HUD units for portraits. Dots are smaller.", changed); CustomerNameSize = Add("CustomerNameSize", 11, "Customer name size", "8–18 reference HUD units.", changed); ShowPotentialCustomers = Add("ShowPotentialCustomers", defaultValue: true, "Show potential customers", "Show the potential customers identified by the game's map.", changed); HighlightPotentialCustomers = Add("HighlightPotentialCustomers", defaultValue: true, "Highlight potential customers", "Give potential customers a colored halo.", changed); CustomerColor = Add<Color>("CustomerColor", new Color(0.25f, 0.9f, 0.65f, 1f), "Customer color", "Color of customer dots and portrait borders.", changed); PotentialCustomerColor = Add<Color>("PotentialCustomerColor", new Color(0.75f, 0.35f, 1f, 1f), "Potential customer color", "Highlight color for potential customers.", changed); ShowAlreadyPurchased = Add("ShowAlreadyPurchased", defaultValue: true, "Show already purchased", "Show a check while a completed purchase blocks another offer in the game's dialogue.", changed); ShowActiveDeals = Add("ShowActiveDeals", defaultValue: true, "Show active deals", "Show a clock for accepted deals awaiting delivery.", changed); AlreadyPurchasedColor = Add<Color>("AlreadyPurchasedColor", new Color(0.2f, 0.85f, 0.3f, 1f), "Already purchased color", "Color of the completed-purchase check badge.", changed); ActiveDealColor = Add<Color>("ActiveDealColor", new Color(0.25f, 0.65f, 1f, 1f), "Active deal color", "Color of the accepted-deal clock badge.", changed); ShowRegionLockedCustomers = Add("ShowRegionLockedCustomers", defaultValue: true, "Show region-locked customers", "Show customers in locked regions with a lock badge.", changed); RegionLockedColor = Add<Color>("RegionLockedColor", new Color(0.7f, 0.72f, 0.77f, 1f), "Region lock color", "Color of locked-region customer markers and lock badges.", changed); ShowDealers = Add("ShowDealers", defaultValue: true, "Show dealers", "Show hired dealers on the minimap.", changed); DealerStyle = Add("DealerStyle", CustomerMarkerStyle.Portraits, "Dealer marker style", "Portraits or dots with names, plus a dealer badge. Missing faces use named dots.", changed); DealerMarkerSize = Add("DealerMarkerSize", 24, "Dealer marker size", "12–40 reference HUD units for portraits. Dots are smaller.", changed); DealerNameSize = Add("DealerNameSize", 11, "Dealer name size", "8–18 reference HUD units for dealer names.", changed); DealerColor = Add<Color>("DealerColor", new Color(1f, 0.7f, 0.2f, 1f), "Dealer color", "Color of dealer dots, portrait borders, and dealer badges.", changed); ShowVehicles = Add("ShowVehicles", defaultValue: true, "Show owned vehicles", "Show owned vehicles. Hide your current vehicle, and occupied co-op vehicles while co-op markers are shown.", changed); ShowVehicleNames = Add("ShowVehicleNames", defaultValue: true, "Show vehicle names", "Show the native vehicle name or vehicle code beside its icon.", changed); VehicleMarkerSize = Add("VehicleMarkerSize", 18, "Vehicle marker size", "12–32 reference HUD units for car and bike icons.", changed); VehicleNameSize = Add("VehicleNameSize", 11, "Vehicle name size", "8–18 reference HUD units for vehicle names.", changed); VehicleColor = Add<Color>("VehicleColor", new Color(0.5f, 0.8f, 1f, 1f), "Vehicle color", "Color of owned vehicle icons.", changed); category.SaveToFile(false); } internal void Save() { category.SaveToFile(false); } private MelonPreferences_Entry<T> Add<T>(string key, T defaultValue, string title, string description, Action changed) { MelonPreferences_Entry<T> entry = category.CreateEntry<T>(key, defaultValue, title, description, false, false, (ValueValidator)null, (string)null); LemonAction<T, T> handler = delegate { changed(); }; ((MelonEventBase<LemonAction<T, T>>)(object)entry.OnEntryValueChanged).Subscribe(handler, 0, false); unsubscribe.Add(delegate { ((MelonEventBase<LemonAction<T, T>>)(object)entry.OnEntryValueChanged).Unsubscribe(handler); }); return entry; } internal void Dispose() { foreach (Action item in unsubscribe) { item(); } unsubscribe.Clear(); } } internal enum WorldMarkerKind { Dealer, Vehicle, Bike } internal readonly record struct WorldMarkerSource(int Id, WorldMarkerKind Kind, Object Target, Transform Tracking, string Name, Sprite? Portrait); internal static class WorldMarkerReader { private const int MaximumScanItems = 4096; internal static List<WorldMarkerSource> ReadDealers() { List<WorldMarkerSource> list = new List<WorldMarkerSource>(); HashSet<int> hashSet = new HashSet<int>(); try { List<Dealer> allPlayerDealers = Dealer.AllPlayerDealers; if (allPlayerDealers == null) { return list; } int num = Math.Min(allPlayerDealers.Count, 4096); for (int i = 0; i < num; i++) { try { Dealer val = allPlayerDealers[i]; if ((Object)(object)val == (Object)null || !val.IsRecruited || (Object)(object)((Component)val).gameObject == (Object)null || !((Component)val).gameObject.activeInHierarchy) { continue; } NPCHealth health = ((NPC)val).Health; if ((Object)(object)health != (Object)null && health.IsDead) { continue; } Transform transform = ((Component)val).transform; if (((NPC)val).IsInVehicle && (Object)(object)((NPC)val).CurrentVehicle != (Object)null) { transform = ((Component)((NPC)val).CurrentVehicle).transform; } if (!((Object)(object)transform == (Object)null)) { int instanceID = ((Object)val).GetInstanceID(); string name = KnownName(((NPC)val).FullName, ((NPC)val).FirstName, "Dealer"); Sprite mugshotSprite = ((NPC)val).MugshotSprite; if (hashSet.Add(instanceID)) { list.Add(new WorldMarkerSource(instanceID, WorldMarkerKind.Dealer, (Object)(object)val, transform, name, mugshotSprite)); } } } catch { } } } catch { } return list; } internal static List<WorldMarkerSource> ReadVehicles() { List<WorldMarkerSource> result = new List<WorldMarkerSource>(); HashSet<int> seen = new HashSet<int>(); try { VehicleManager instance = NetworkSingleton<VehicleManager>.Instance; if ((Object)(object)instance == (Object)null) { return result; } try { AddVehicles(instance.PlayerOwnedVehicles, result, seen); } catch { } try { AddVehicles(instance.AllVehicles, result, seen); } catch { } } catch { } return result; } private static void AddVehicles(List<LandVehicle>? vehicles, List<WorldMarkerSource> result, HashSet<int> seen) { if (vehicles == null) { return; } int num = Math.Min(vehicles.Count, 4096); for (int i = 0; i < num; i++) { try { LandVehicle val = vehicles[i]; if (!((Object)(object)val == (Object)null) && val.IsPlayerOwned && !((Object)(object)((Component)val).gameObject == (Object)null) && ((Component)val).gameObject.activeInHierarchy && !((Object)(object)((Component)val).transform == (Object)null)) { int instanceID = ((Object)val).GetInstanceID(); string vehicleCode = val.VehicleCode; string text = KnownName(val.VehicleName, vehicleCode, "Vehicle"); WorldMarkerKind kind = ((!IsBikeName(vehicleCode) && !IsBikeName(text)) ? WorldMarkerKind.Vehicle : WorldMarkerKind.Bike); if (seen.Add(instanceID)) { result.Add(new WorldMarkerSource(instanceID, kind, (Object)(object)val, ((Component)val).transform, text, null)); } } } catch { } } } internal static void FillOccupiedVehicleIds(Player local, bool includePeers, HashSet<int> result) { result.Clear(); AddOccupiedVehicle(local, result); if (!includePeers) { return; } try { List<Player> playerList = Player.PlayerList; if (playerList == null) { return; } int num = Math.Min(playerList.Count, 4096); for (int i = 0; i < num; i++) { try { AddOccupiedVehicle(playerList[i], result); } catch { } } } catch { } } private static void AddOccupiedVehicle(Player? player, HashSet<int> occupied) { try { if ((Object)(object)player == (Object)null || !player.IsInVehicle) { return; } NetworkObject currentVehicle = player.CurrentVehicle; if (!((Object)(object)currentVehicle == (Object)null)) { LandVehicle val = ((Component)currentVehicle).GetComponent<LandVehicle>(); if ((Object)(object)val == (Object)null) { val = ((Component)currentVehicle).GetComponentInParent<LandVehicle>(); } if ((Object)(object)val == (Object)null) { val = ((Component)currentVehicle).GetComponentInChildren<LandVehicle>(); } if ((Object)(object)val != (Object)null) { occupied.Add(((Object)val).GetInstanceID()); } } } catch { } } private static string KnownName(string? primary, string? secondary, string fallback) { if (string.IsNullOrWhiteSpace(primary)) { if (string.IsNullOrWhiteSpace(secondary)) { return fallback; } return secondary.Trim(); } return primary.Trim(); } private static bool IsBikeName(string? value) { if (!string.IsNullOrWhiteSpace(value)) { if (!value.Contains("bike", StringComparison.OrdinalIgnoreCase) && !value.Contains("motorcycle", StringComparison.OrdinalIgnoreCase)) { return value.Contains("bicycle", StringComparison.OrdinalIgnoreCase); } return true; } return false; } } internal sealed class WorldMarkers : IDisposable { private sealed class Marker { internal WorldMarkerSource Source; internal RectTransform Root; internal Image Ring; internal RectTransform FaceMask; internal Image Face; internal RectTransform GlyphRect; internal Image Glyph; internal RectTransform Badge; internal Image BadgeGlyph; internal RectTransform LabelRect; internal Text Label; internal float Radius; internal float LabelWidth; internal int NameSize; internal bool UsesName; } private readonly RectTransform dealerLayer; private readonly RectTransform vehicleLayer; private readonly Sprite circleSprite; private readonly Font? font; private readonly WorldMarkerSprites sprites; private readonly Dictionary<int, Marker> markers = new Dictionary<int, Marker>(); private readonly HashSet<int> liveIds = new HashSet<int>(); private readonly HashSet<int> dealerNpcIds = new HashSet<int>(); private readonly HashSet<int> occupiedVehicleIds = new HashSet<int>(); private readonly List<int> staleIds = new List<int>(); private float nextRefresh; private bool showDealers; private bool showVehicles; private bool showVehicleNames; private CustomerMarkerStyle dealerStyle; private float dealerSize; private float vehicleSize; private int dealerNameSize; private int vehicleNameSize; private Color dealerColor; private Color vehicleColor; private bool disposed; internal IReadOnlySet<int> DealerNpcIds => dealerNpcIds; internal WorldMarkers(RectTransform parent, Sprite circleSprite, Font? font) { this.circleSprite = circleSprite; this.font = font; sprites = new WorldMarkerSprites(); try { vehicleLayer = NewRect("Owned vehicles", (Transform)(object)parent); dealerLayer = NewRect("Hired dealers", (Transform)(object)parent); } catch { if ((Object)(object)vehicleLayer != (Object)null) { Object.Destroy((Object)(object)((Component)vehicleLayer).gameObject); } if ((Object)(object)dealerLayer != (Object)null) { Object.Destroy((Object)(object)((Component)dealerLayer).gameObject); } sprites.Dispose(); throw; } } internal void PlaceVehiclesBehind(RectTransform customers) { ((Transform)vehicleLayer).SetSiblingIndex(((Transform)customers).GetSiblingIndex()); } internal void Apply(Settings settings) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) showDealers = settings.ShowDealers.Value; showVehicles = settings.ShowVehicles.Value; showVehicleNames = settings.ShowVehicleNames.Value; dealerStyle = (Enum.IsDefined(typeof(CustomerMarkerStyle), settings.DealerStyle.Value) ? settings.DealerStyle.Value : CustomerMarkerStyle.Portraits); dealerSize = (float)MapMath.ClampFinite(settings.DealerMarkerSize.Value, 12.0, 40.0, 24.0); vehicleSize = (float)MapMath.ClampFinite(settings.VehicleMarkerSize.Value, 12.0, 32.0, 18.0); dealerNameSize = (int)MapMath.ClampFinite(settings.DealerNameSize.Value, 8.0, 18.0, 11.0); vehicleNameSize = (int)MapMath.ClampFinite(settings.VehicleNameSize.Value, 8.0, 18.0, 11.0); dealerColor = ClampColor(settings.DealerColor.Value, new Color(1f, 0.7f, 0.2f, 1f)); vehicleColor = ClampColor(settings.VehicleColor.Value, new Color(0.5f, 0.8f, 1f, 1f)); ((Component)dealerLayer).gameObject.SetActive(showDealers); ((Component)vehicleLayer).gameObject.SetActive(showVehicles); dealerNpcIds.Clear(); foreach (Marker value in markers.Values) { ApplyAppearance(value); } nextRefresh = 0f; } internal void RefreshSources() { if (disposed || Time.unscaledTime < nextRefresh) { return; } nextRefresh = Time.unscaledTime + 1f; liveIds.Clear(); dealerNpcIds.Clear(); if (showDealers) { foreach (WorldMarkerSource item in WorldMarkerReader.ReadDealers()) { Register(item); } } if (showVehicles) { foreach (WorldMarkerSource item2 in WorldMarkerReader.ReadVehicles()) { Register(item2); } } staleIds.Clear(); foreach (int key in markers.Keys) { if (!liveIds.Contains(key)) { staleIds.Add(key); } } foreach (int staleId in staleIds) { DestroyMarker(markers[staleId]); markers.Remove(staleId); } } private void Register(WorldMarkerSource source) { try { if (source.Target == (Object)null || (Object)(object)source.Tracking == (Object)null || !liveIds.Add(source.Id)) { return; } if (!markers.TryGetValue(source.Id, out Marker value) || (Object)(object)value.Root == (Object)null) { if (value != null) { DestroyMarker(value); } value = CreateMarker((source.Kind == WorldMarkerKind.Dealer) ? dealerLayer : vehicleLayer); markers[source.Id] = value; } value.Source = source; value.Label.text = source.Name; ApplyAppearance(value); if (source.Kind == WorldMarkerKind.Dealer) { dealerNpcIds.Add(source.Id); } } catch { liveIds.Remove(source.Id); } } internal void Update(Player localPlayer, bool showCoop, MapProjection projection, Vector2 center, float zoom, float rotation, float viewportSize, bool circle, List<Rect> occupiedLabels) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (disposed || (!showDealers && !showVehicles)) { return; } occupiedVehicleIds.Clear(); if (showVehicles) { WorldMarkerReader.FillOccupiedVehicleIds(localPlayer, showCoop, occupiedVehicleIds); } foreach (Marker value in markers.Values) { if (value.Source.Kind == WorldMarkerKind.Dealer) { UpdateMarker(value, projection, center, zoom, rotation, viewportSize, circle, occupiedLabels, occupiedVehicleIds); } } foreach (Marker value2 in markers.Values) { if (value2.Source.Kind != WorldMarkerKind.Dealer) { UpdateMarker(value2, projection, center, zoom, rotation, viewportSize, circle, occupiedLabels, occupiedVehicleIds); } } } private void UpdateMarker(Marker marker, MapProjection projection, Vector2 center, float zoom, float rotation, float size, bool circle, List<Rect> occupiedLabels, HashSet<int>? occupiedVehicles) { //IL_00a0: 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_00aa: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0145: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)marker.Root == (Object)null) { return; } WorldMarkerSource source = marker.Source; if (!((source.Kind == WorldMarkerKind.Dealer) ? showDealers : showVehicles) || source.Target == (Object)null || (Object)(object)source.Tracking == (Object)null || !((Component)source.Tracking).gameObject.activeInHierarchy || (source.Kind != WorldMarkerKind.Dealer && occupiedVehicles != null && occupiedVehicles.Contains(source.Id))) { ((Component)marker.Root).gameObject.SetActive(false); return; } Vector2 val = projection.Project(source.Tracking.position); (double, double) tuple = MapMath.RelativePoint(val.x, val.y, center.x, center.y, zoom, rotation); float num = size / 2f; bool flag = num > marker.Radius && MapMath.IsInside(tuple.Item1, tuple.Item2, num - marker.Radius, circle); ((Component)marker.Root).gameObject.SetActive(flag); if (flag) { marker.Root.anchoredPosition = new Vector2((float)tuple.Item1, (float)tuple.Item2); ((Transform)marker.Root).localRotation = Quaternion.identity; bool active = marker.UsesName && (Object)(object)font != (Object)null && marker.LabelWidth > 0f && PlaceLabel(marker, (float)tuple.Item1, (float)tuple.Item2, num, circle, occupiedLabels); ((Component)marker.LabelRect).gameObject.SetActive(active); } } catch { if ((Object)(object)marker.Root != (Object)null) { ((Component)marker.Root).gameObject.SetActive(false); } } } private Marker CreateMarker(RectTransform parent) { //IL_00e5: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRect("World marker", (Transform)(object)parent); try { Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = circleSprite; ((Graphic)val2).raycastTarget = false; RectTransform val3 = NewRect("Portrait clip", (Transform)(object)val); Image obj = ((Component)val3).gameObject.AddComponent<Image>(); obj.sprite = circleSprite; ((Graphic)obj).raycastTarget = false; ((Component)val3).gameObject.AddComponent<Mask>().showMaskGraphic = false; RectTransform obj2 = NewRect("Portrait", (Transform)(object)val3); Stretch(obj2); Image val4 = ((Component)obj2).gameObject.Add