Decompiled source of SimpleMinimap v1.4.0

SimpleMinimap.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MelonLoader;
using MinimapMod;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MinimapMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MinimapMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("12345678-1234-1234-1234-123456789012")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: MelonInfo(typeof(MainMod), "MinimapMod", "1.0.0", "Hiccup", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MinimapMod;

public class MainMod : MelonMod
{
	[CompilerGenerated]
	private sealed class <ContractPoICheckerWorld>d__55 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public MainMod <>4__this;

		private GameObject <contractsRoot>5__1;

		private List<Transform> <activeCPs>5__2;

		private float <threshold>5__3;

		private Transform <contractsTransform>5__4;

		private int <i>5__5;

		private List<Transform>.Enumerator <>s__6;

		private Transform <cp>5__7;

		private Vector3 <wp>5__8;

		private Vector2 <desiredPos>5__9;

		private bool <markerFound>5__10;

		private int <i>5__11;

		private GameObject <marker>5__12;

		private RectTransform <rt>5__13;

		private int <i>5__14;

		private GameObject <marker>5__15;

		private RectTransform <rt>5__16;

		private bool <stillExists>5__17;

		private Vector2 <markerPos>5__18;

		private List<Transform>.Enumerator <>s__19;

		private Transform <cp>5__20;

		private Vector2 <desiredPos>5__21;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ContractPoICheckerWorld>d__55(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<contractsRoot>5__1 = null;
			<activeCPs>5__2 = null;
			<contractsTransform>5__4 = null;
			<>s__6 = default(List<Transform>.Enumerator);
			<cp>5__7 = null;
			<marker>5__12 = null;
			<rt>5__13 = null;
			<marker>5__15 = null;
			<rt>5__16 = null;
			<>s__19 = default(List<Transform>.Enumerator);
			<cp>5__20 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_0213: 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_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				<contractsRoot>5__1 = GameObject.Find("Managers/@Quests/Contracts");
				<activeCPs>5__2 = new List<Transform>();
				if ((Object)(object)<contractsRoot>5__1 != (Object)null)
				{
					<contractsTransform>5__4 = <contractsRoot>5__1.transform;
					<i>5__5 = 0;
					while (<i>5__5 < <contractsTransform>5__4.childCount)
					{
						<>4__this.RecursiveFind(<contractsTransform>5__4.GetChild(<i>5__5), "ContractPoI(Clone)", <activeCPs>5__2);
						<i>5__5++;
					}
					<contractsTransform>5__4 = null;
					<activeCPs>5__2.RemoveAll((Transform cp) => !((Component)cp).gameObject.activeInHierarchy);
					<threshold>5__3 = 0.1f;
					<>s__6 = <activeCPs>5__2.GetEnumerator();
					try
					{
						while (<>s__6.MoveNext())
						{
							<cp>5__7 = <>s__6.Current;
							<wp>5__8 = <cp>5__7.position;
							<desiredPos>5__9 = new Vector2(<wp>5__8.x * mapScale, <wp>5__8.z * mapScale);
							<desiredPos>5__9.x -= 5f;
							<markerFound>5__10 = false;
							<i>5__11 = 0;
							while (<i>5__11 < <>4__this.contractPoIMarkers.Count)
							{
								<marker>5__12 = <>4__this.contractPoIMarkers[<i>5__11];
								if (!((Object)(object)<marker>5__12 == (Object)null))
								{
									<rt>5__13 = <marker>5__12.GetComponent<RectTransform>();
									if ((Object)(object)<rt>5__13 != (Object)null && Vector2.Distance(<rt>5__13.anchoredPosition, <desiredPos>5__9) < <threshold>5__3)
									{
										<markerFound>5__10 = true;
										break;
									}
									<marker>5__12 = null;
									<rt>5__13 = null;
								}
								<i>5__11++;
							}
							if (!<markerFound>5__10)
							{
								<>4__this.AddContractPoIMarkerWorld(<cp>5__7);
							}
							<cp>5__7 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__6).Dispose();
					}
					<>s__6 = default(List<Transform>.Enumerator);
					<i>5__14 = <>4__this.contractPoIMarkers.Count - 1;
					while (<i>5__14 >= 0)
					{
						<marker>5__15 = <>4__this.contractPoIMarkers[<i>5__14];
						if ((Object)(object)<marker>5__15 == (Object)null)
						{
							<>4__this.contractPoIMarkers.RemoveAt(<i>5__14);
						}
						else
						{
							<rt>5__16 = <marker>5__15.GetComponent<RectTransform>();
							<stillExists>5__17 = false;
							if ((Object)(object)<rt>5__16 != (Object)null)
							{
								<markerPos>5__18 = <rt>5__16.anchoredPosition;
								<>s__19 = <activeCPs>5__2.GetEnumerator();
								try
								{
									while (<>s__19.MoveNext())
									{
										<cp>5__20 = <>s__19.Current;
										<desiredPos>5__21 = new Vector2(<cp>5__20.position.x * mapScale, <cp>5__20.position.z * mapScale);
										<desiredPos>5__21.x -= 5f;
										if (Vector2.Distance(<markerPos>5__18, <desiredPos>5__21) < <threshold>5__3)
										{
											<stillExists>5__17 = true;
											break;
										}
										<cp>5__20 = null;
									}
								}
								finally
								{
									((IDisposable)<>s__19).Dispose();
								}
								<>s__19 = default(List<Transform>.Enumerator);
							}
							if (!<stillExists>5__17)
							{
								Object.Destroy((Object)(object)<marker>5__15);
								<>4__this.contractPoIMarkers.RemoveAt(<i>5__14);
							}
							<marker>5__15 = null;
							<rt>5__16 = null;
						}
						<i>5__14--;
					}
					<contractsRoot>5__1 = null;
					<activeCPs>5__2 = null;
				}
				else
				{
					<>4__this.RemoveAllContractPoIMarkers();
				}
				break;
			}
			<>2__current = (object)new WaitForSeconds(20f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <FindGameObjectsRoutine>d__40 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public MainMod <>4__this;

		private int <attempts>5__1;

		private GameObject <gameplayMenu>5__2;

		private Transform <phoneTransform>5__3;

		private Transform <phoneChildTransform>5__4;

		private Transform <appsCanvas>5__5;

		private Transform <mapApp>5__6;

		private Transform <container>5__7;

		private Transform <scrollView>5__8;

		private Transform <viewport>5__9;

		private Exception <ex>5__10;

		private Transform <contentTransform>5__11;

		private Image <contentImage>5__12;

		private Image <minimapImage>5__13;

		private int <childCount>5__14;

		private int <i>5__15;

		private Transform <child>5__16;

		private Image <childImage>5__17;

		private Image <minimapImage>5__18;

		private Exception <ex>5__19;

		private Image <markerImage>5__20;

		private Transform <playerPoI>5__21;

		private Transform <realIcon>5__22;

		private GameObject <newMarker>5__23;

		private RectTransform <newRect>5__24;

		private Transform <arrowImage>5__25;

		private Transform <iconContainer>5__26;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <FindGameObjectsRoutine>d__40(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<gameplayMenu>5__2 = null;
			<phoneTransform>5__3 = null;
			<phoneChildTransform>5__4 = null;
			<appsCanvas>5__5 = null;
			<mapApp>5__6 = null;
			<container>5__7 = null;
			<scrollView>5__8 = null;
			<viewport>5__9 = null;
			<ex>5__10 = null;
			<contentTransform>5__11 = null;
			<contentImage>5__12 = null;
			<minimapImage>5__13 = null;
			<child>5__16 = null;
			<childImage>5__17 = null;
			<minimapImage>5__18 = null;
			<ex>5__19 = null;
			<markerImage>5__20 = null;
			<playerPoI>5__21 = null;
			<realIcon>5__22 = null;
			<newMarker>5__23 = null;
			<newRect>5__24 = null;
			<arrowImage>5__25 = null;
			<iconContainer>5__26 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Expected O, but got Unknown
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0913: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				MelonLogger.Msg("Looking for game objects...");
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<attempts>5__1 = 0;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			while (((Object)(object)mapAppObject == (Object)null || (Object)(object)playerObject == (Object)null) && <attempts>5__1 < 30)
			{
				<attempts>5__1++;
				try
				{
					if ((Object)(object)playerObject == (Object)null)
					{
						playerObject = GameObject.Find("Player_Local");
						if ((Object)(object)playerObject != (Object)null)
						{
							MelonLogger.Msg("Found Player_Local");
						}
					}
					if ((Object)(object)mapAppObject == (Object)null)
					{
						<gameplayMenu>5__2 = GameObject.Find("GameplayMenu");
						if ((Object)(object)<gameplayMenu>5__2 != (Object)null)
						{
							MelonLogger.Msg("Found GameplayMenu");
							<phoneTransform>5__3 = <gameplayMenu>5__2.transform.Find("Phone");
							if ((Object)(object)<phoneTransform>5__3 != (Object)null)
							{
								MelonLogger.Msg("Found Phone under GameplayMenu");
								<phoneChildTransform>5__4 = <phoneTransform>5__3.Find("phone");
								if ((Object)(object)<phoneChildTransform>5__4 != (Object)null)
								{
									MelonLogger.Msg("Found phone under Phone");
									<appsCanvas>5__5 = <phoneChildTransform>5__4.Find("AppsCanvas");
									if ((Object)(object)<appsCanvas>5__5 != (Object)null)
									{
										MelonLogger.Msg("Found AppsCanvas");
										<mapApp>5__6 = <appsCanvas>5__5.Find("MapApp");
										if ((Object)(object)<mapApp>5__6 != (Object)null)
										{
											mapAppObject = ((Component)<mapApp>5__6).gameObject;
											MelonLogger.Msg("Found MapApp");
										}
										<mapApp>5__6 = null;
									}
									<appsCanvas>5__5 = null;
								}
								<phoneChildTransform>5__4 = null;
							}
							<phoneTransform>5__3 = null;
						}
						<gameplayMenu>5__2 = null;
					}
					if ((Object)(object)mapAppObject != (Object)null && (Object)(object)viewportObject == (Object)null)
					{
						<container>5__7 = mapAppObject.transform.Find("Container");
						if ((Object)(object)<container>5__7 != (Object)null)
						{
							MelonLogger.Msg("Found Container in MapApp");
							<scrollView>5__8 = <container>5__7.Find("Scroll View");
							if ((Object)(object)<scrollView>5__8 != (Object)null)
							{
								MelonLogger.Msg("Found Scroll View in Container");
								<viewport>5__9 = <scrollView>5__8.Find("Viewport");
								if ((Object)(object)<viewport>5__9 != (Object)null)
								{
									viewportObject = ((Component)<viewport>5__9).gameObject;
									MelonLogger.Msg("Found Map Viewport");
								}
								<viewport>5__9 = null;
							}
							<scrollView>5__8 = null;
						}
						<container>5__7 = null;
					}
				}
				catch (Exception ex)
				{
					<ex>5__10 = ex;
					MelonLogger.Error("Error finding game objects: " + <ex>5__10.Message);
				}
				if ((Object)(object)mapAppObject == (Object)null || (Object)(object)playerObject == (Object)null)
				{
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				}
			}
			if ((Object)(object)mapAppObject == (Object)null)
			{
				MelonLogger.Warning("Could not find Map App after multiple attempts");
			}
			else if ((Object)(object)viewportObject == (Object)null)
			{
				MelonLogger.Warning("Found MapApp but could not find Viewport");
			}
			if ((Object)(object)playerObject == (Object)null)
			{
				MelonLogger.Warning("Could not find Player after multiple attempts");
			}
			MelonLogger.Msg("Game object search completed");
			if ((Object)(object)viewportObject != (Object)null)
			{
				try
				{
					if (viewportObject.transform.childCount > 0)
					{
						<contentTransform>5__11 = viewportObject.transform.GetChild(0);
						MelonLogger.Msg("Found viewport content: " + ((Object)<contentTransform>5__11).name);
						<contentImage>5__12 = ((Component)<contentTransform>5__11).GetComponent<Image>();
						if ((Object)(object)<contentImage>5__12 != (Object)null && (Object)(object)<contentImage>5__12.sprite != (Object)null)
						{
							MelonLogger.Msg("Found content image with sprite: " + ((Object)<contentImage>5__12.sprite).name);
							if ((Object)(object)mapContentObject != (Object)null)
							{
								<minimapImage>5__13 = mapContentObject.GetComponent<Image>();
								if ((Object)(object)<minimapImage>5__13 == (Object)null)
								{
									<minimapImage>5__13 = mapContentObject.AddComponent<Image>();
								}
								<minimapImage>5__13.sprite = <contentImage>5__12.sprite;
								<minimapImage>5__13.type = (Type)0;
								<minimapImage>5__13.preserveAspect = true;
								((Behaviour)<minimapImage>5__13).enabled = false;
								((Behaviour)<minimapImage>5__13).enabled = true;
								MelonLogger.Msg("Successfully applied map sprite to minimap!");
								if ((Object)(object)gridContainer != (Object)null)
								{
									((Component)gridContainer).gameObject.SetActive(false);
								}
								<minimapImage>5__13 = null;
							}
						}
						else
						{
							MelonLogger.Msg("Content doesn't have an Image component or sprite");
							<childCount>5__14 = <contentTransform>5__11.childCount;
							<i>5__15 = 0;
							while (<i>5__15 < <childCount>5__14)
							{
								<child>5__16 = <contentTransform>5__11.GetChild(<i>5__15);
								<childImage>5__17 = ((Component)<child>5__16).GetComponent<Image>();
								if ((Object)(object)<childImage>5__17 != (Object)null && (Object)(object)<childImage>5__17.sprite != (Object)null)
								{
									MelonLogger.Msg("Found image in content child: " + ((Object)<child>5__16).name + ", Sprite: " + ((Object)<childImage>5__17.sprite).name);
									if ((Object)(object)mapContentObject != (Object)null)
									{
										<minimapImage>5__18 = mapContentObject.GetComponent<Image>();
										if ((Object)(object)<minimapImage>5__18 == (Object)null)
										{
											<minimapImage>5__18 = mapContentObject.AddComponent<Image>();
										}
										<minimapImage>5__18.sprite = <childImage>5__17.sprite;
										<minimapImage>5__18.type = (Type)0;
										<minimapImage>5__18.preserveAspect = true;
										((Behaviour)<minimapImage>5__18).enabled = false;
										((Behaviour)<minimapImage>5__18).enabled = true;
										MelonLogger.Msg("Successfully applied map sprite to minimap!");
										if ((Object)(object)gridContainer != (Object)null)
										{
											((Component)gridContainer).gameObject.SetActive(false);
										}
										break;
									}
								}
								<child>5__16 = null;
								<childImage>5__17 = null;
								<i>5__15++;
							}
						}
						<contentTransform>5__11 = null;
						<contentImage>5__12 = null;
					}
				}
				catch (Exception ex)
				{
					<ex>5__19 = ex;
					MelonLogger.Error("Error accessing map content: " + <ex>5__19.Message);
				}
			}
			<>4__this.CreateVisualGrid();
			if ((Object)(object)<>4__this.cachedPlayerMarker != (Object)null)
			{
				<markerImage>5__20 = <>4__this.cachedPlayerMarker.GetComponent<Image>();
				if ((Object)(object)<markerImage>5__20 != (Object)null)
				{
					Color color = ((Graphic)<markerImage>5__20).color;
					if (((Color)(ref color)).Equals(new Color(0.2f, 0.6f, 1f, 1f)))
					{
						if ((Object)(object)<>4__this.cachedMapContent == (Object)null)
						{
							<>4__this.cachedMapContent = GameObject.Find("GameplayMenu/Phone/phone/AppsCanvas/MapApp/Container/Scroll View/Viewport/Content");
						}
						if ((Object)(object)<>4__this.cachedMapContent != (Object)null)
						{
							<playerPoI>5__21 = <>4__this.cachedMapContent.transform.Find("PlayerPoI(Clone)");
							if ((Object)(object)<playerPoI>5__21 != (Object)null)
							{
								<realIcon>5__22 = <playerPoI>5__21.Find("IconContainer");
								if ((Object)(object)<realIcon>5__22 != (Object)null)
								{
									<newMarker>5__23 = Object.Instantiate<GameObject>(((Component)<realIcon>5__22).gameObject);
									((Object)<newMarker>5__23).name = "PlayerMarker";
									<newMarker>5__23.transform.SetParent(<>4__this.cachedPlayerMarker.transform.parent, false);
									<newRect>5__24 = <newMarker>5__23.GetComponent<RectTransform>();
									if ((Object)(object)<newRect>5__24 != (Object)null)
									{
										<newRect>5__24.anchoredPosition = Vector2.zero;
										((Transform)<newRect>5__24).localScale = new Vector3(0.5f, 0.5f, 0.5f);
									}
									<arrowImage>5__25 = <newMarker>5__23.transform.Find("Image");
									if ((Object)(object)<arrowImage>5__25 != (Object)null)
									{
										MelonLogger.Msg("Removing arrow from player marker");
										Object.Destroy((Object)(object)((Component)<arrowImage>5__25).gameObject);
									}
									Object.Destroy((Object)(object)<>4__this.cachedPlayerMarker);
									<>4__this.cachedPlayerMarker = <newMarker>5__23;
									MelonLogger.Msg("Replaced fallback player marker with real player icon.");
									<newMarker>5__23 = null;
									<newRect>5__24 = null;
									<arrowImage>5__25 = null;
								}
								<realIcon>5__22 = null;
							}
							<playerPoI>5__21 = null;
						}
					}
				}
				<markerImage>5__20 = null;
			}
			if ((Object)(object)<>4__this.cachedMapContent == (Object)null)
			{
				<>4__this.cachedMapContent = GameObject.Find("GameplayMenu/Phone/phone/AppsCanvas/MapApp/Container/Scroll View/Viewport/Content");
			}
			if ((Object)(object)<>4__this.cachedMapContent != (Object)null)
			{
				if ((Object)(object)<>4__this.cachedPropertyPoI == (Object)null)
				{
					<>4__this.cachedPropertyPoI = <>4__this.cachedMapContent.transform.Find("PropertyPoI(Clone)");
				}
				if ((Object)(object)<>4__this.cachedPropertyPoI != (Object)null)
				{
					<iconContainer>5__26 = <>4__this.cachedPropertyPoI.Find("IconContainer");
					if ((Object)(object)<iconContainer>5__26 != (Object)null)
					{
						<>4__this.AddDefaultMarkers();
					}
					<iconContainer>5__26 = null;
				}
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <UpdateMinimapTimeCoroutine>d__47 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public MainMod <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <UpdateMinimapTimeCoroutine>d__47(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			<>4__this.UpdateMinimapTime();
			<>2__current = (object)new WaitForSeconds(1f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private bool guiVisible = false;

	private bool minimapEnabled = true;

	private bool timeBarEnabled = true;

	private const float markerXAdjustment = 5f;

	private Rect minimapToggleRect = new Rect((float)(Screen.width - 170), 260f, 150f, 25f);

	private Rect timeToggleRect = new Rect((float)(Screen.width - 170), 250f, 150f, 25f);

	private Rect guiBackgroundRect = new Rect((float)(Screen.width - 175), 290f, 160f, 100f);

	private GameObject minimapDisplayObject;

	private RectTransform minimapTimeContainer;

	private bool doubleSizeEnabled = false;

	private RectTransform minimapFrameRect;

	private static float mapScale = 1.2487098f;

	private Vector2 manualOffset = new Vector2(-61f, -71f);

	private Vector2 baseManualOffset = new Vector2(-61f, -71f);

	private static GameObject minimapObject;

	private static bool isInitializing = false;

	private static bool isEnabled = true;

	private RectTransform cachedDirectionIndicator;

	private GameObject cachedPlayerMarker;

	private Text cachedGameTimeText;

	private GameObject cachedMapContent;

	private Transform cachedPropertyPoI;

	private Text minimapTimeText;

	private GameObject contractPoIIconPrefab;

	private static GameObject mapAppObject;

	private static GameObject viewportObject;

	private static GameObject playerObject;

	private static GameObject mapContentObject;

	private static RectTransform gridContainer;

	private List<GameObject> contractPoIMarkers = new List<GameObject>();

	private static int gridSize = 20;

	private static Color gridColor = new Color(0.3f, 0.3f, 0.3f, 1f);

	private static Color bgColor = new Color(0.1f, 0.1f, 0.1f, 1f);

	private static float smoothingFactor = 10f;

	private Vector2 RotateVector(Vector2 v, float degrees)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		float num = degrees * ((float)Math.PI / 180f);
		float num2 = Mathf.Cos(num);
		float num3 = Mathf.Sin(num);
		return new Vector2(v.x * num2 - v.y * num3, v.x * num3 + v.y * num2);
	}

	public override void OnGUI()
	{
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: 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)
		if (!guiVisible)
		{
			return;
		}
		Rect val = default(Rect);
		Rect position = default(Rect);
		Rect position2 = default(Rect);
		Rect position3 = default(Rect);
		if (!doubleSizeEnabled)
		{
			((Rect)(ref val))..ctor((float)(Screen.width - 175), 220f, 160f, 100f);
			((Rect)(ref position))..ctor((float)(Screen.width - 170), 230f, 150f, 25f);
			((Rect)(ref position2))..ctor((float)(Screen.width - 170), 260f, 150f, 25f);
			((Rect)(ref position3))..ctor((float)(Screen.width - 170), 290f, 150f, 25f);
		}
		else
		{
			((Rect)(ref val))..ctor((float)(Screen.width - 250), 380f, 160f, 100f);
			((Rect)(ref position))..ctor((float)(Screen.width - 255), 390f, 300f, 25f);
			((Rect)(ref position2))..ctor((float)(Screen.width - 255), 420f, 300f, 25f);
			((Rect)(ref position3))..ctor((float)(Screen.width - 255), 450f, 300f, 25f);
		}
		GUI.color = Color.gray;
		GUI.Box(val, "");
		DrawToggle(position, "Minimap", ref minimapEnabled, delegate
		{
			//IL_00a7: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)minimapDisplayObject != (Object)null)
			{
				minimapDisplayObject.SetActive(minimapEnabled);
			}
			if ((Object)(object)minimapTimeContainer != (Object)null)
			{
				if (minimapEnabled)
				{
					minimapTimeContainer.anchorMin = new Vector2(0.5f, 0f);
					minimapTimeContainer.anchorMax = new Vector2(0.5f, 0f);
					minimapTimeContainer.pivot = new Vector2(0.5f, 1f);
				}
				else
				{
					minimapTimeContainer.anchorMin = new Vector2(1f, 1f);
					minimapTimeContainer.anchorMax = new Vector2(1f, 1f);
					minimapTimeContainer.pivot = new Vector2(1f, 1f);
					minimapTimeContainer.anchoredPosition = Vector2.zero;
				}
			}
		});
		DrawToggle(position2, "Time", ref timeBarEnabled, delegate
		{
			if ((Object)(object)minimapTimeContainer != (Object)null)
			{
				((Component)minimapTimeContainer).gameObject.SetActive(timeBarEnabled);
			}
		});
		DrawToggle(position3, "2x Size", ref doubleSizeEnabled, delegate
		{
			UpdateMinimapSize();
		});
	}

	private void DrawToggle(Rect position, string label, ref bool state, Action onToggle)
	{
		//IL_0001: 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_0076: 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_0081: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Expected O, but got Unknown
		GUI.color = Color.white;
		GUI.Label(new Rect(((Rect)(ref position)).x + 50f, ((Rect)(ref position)).y, ((Rect)(ref position)).width - 50f, ((Rect)(ref position)).height), label);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((Rect)(ref position)).x + 5f, ((Rect)(ref position)).y + 3f, 40f, 18f);
		GUI.color = (state ? Color.green : Color.gray);
		GUI.Box(val, "");
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(state ? (((Rect)(ref val)).x + 22f) : (((Rect)(ref val)).x + 2f), ((Rect)(ref val)).y + 2f, 14f, 14f);
		GUI.color = Color.white;
		GUI.Box(val2, "");
		if (GUI.Button(position, new GUIContent(""), GUIStyle.none))
		{
			state = !state;
			onToggle();
		}
	}

	private void CreateMinimapTimeDisplay(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: 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)
		GameObject val = new GameObject("MinimapTimeContainer");
		val.transform.SetParent(parent, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.sizeDelta = new Vector2(100f, 50f);
		val2.anchorMin = new Vector2(0.5f, 0f);
		val2.anchorMax = new Vector2(0.5f, 0f);
		val2.pivot = new Vector2(0.5f, 1f);
		if (doubleSizeEnabled)
		{
			val2.anchoredPosition = new Vector2(0f, 40f);
		}
		else
		{
			val2.anchoredPosition = new Vector2(0f, 10f);
		}
		minimapTimeContainer = val2;
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = new Color(0.2f, 0.2f, 0.2f, 0.5f);
		GameObject val4 = new GameObject("MinimapTime");
		val4.transform.SetParent(val.transform, false);
		RectTransform val5 = val4.AddComponent<RectTransform>();
		val5.anchorMin = new Vector2(0f, 0f);
		val5.anchorMax = new Vector2(1f, 1f);
		val5.offsetMin = Vector2.zero;
		val5.offsetMax = Vector2.zero;
		minimapTimeText = val4.AddComponent<Text>();
		minimapTimeText.text = "Time";
		minimapTimeText.alignment = (TextAnchor)4;
		((Graphic)minimapTimeText).color = Color.white;
		minimapTimeText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		minimapTimeText.horizontalOverflow = (HorizontalWrapMode)1;
		minimapTimeText.verticalOverflow = (VerticalWrapMode)1;
	}

	private void UpdateMinimapTime()
	{
		if ((Object)(object)cachedGameTimeText == (Object)null)
		{
			GameObject val = GameObject.Find("GameplayMenu/Phone/phone/HomeScreen/InfoBar/Time");
			if ((Object)(object)val != (Object)null)
			{
				cachedGameTimeText = val.GetComponent<Text>();
			}
		}
		if ((Object)(object)cachedGameTimeText != (Object)null && (Object)(object)minimapTimeText != (Object)null)
		{
			string text = cachedGameTimeText.text;
			string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length >= 3)
			{
				string text2 = array[0] + " " + array[1];
				string text3 = array[^1];
				minimapTimeText.text = text3 + "\n" + text2;
			}
			else
			{
				minimapTimeText.text = text;
			}
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		try
		{
			if (sceneName == "Main" && !isInitializing)
			{
				isInitializing = true;
				MelonLogger.Msg("Detected Main scene, initializing Minimap...");
				if ((Object)(object)minimapObject != (Object)null)
				{
					Object.Destroy((Object)(object)minimapObject);
					minimapObject = null;
				}
				CreateMinimapUI();
				MelonCoroutines.Start(FindGameObjectsRoutine());
				isInitializing = false;
				CacheContractPoIIcon();
				MelonCoroutines.Start(UpdateMinimapTimeCoroutine());
				MelonCoroutines.Start(ContractPoICheckerWorld());
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Failed to initialize MinimapMod: " + ex.Message + "\nStack trace: " + ex.StackTrace);
			isInitializing = false;
		}
	}

	[IteratorStateMachine(typeof(<FindGameObjectsRoutine>d__40))]
	private IEnumerator FindGameObjectsRoutine()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <FindGameObjectsRoutine>d__40(0)
		{
			<>4__this = this
		};
	}

	private void UpdateMinimapFramePosition()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if (doubleSizeEnabled)
		{
			minimapFrameRect.anchoredPosition = new Vector2(-20f, -60f);
		}
		else
		{
			minimapFrameRect.anchoredPosition = new Vector2(-20f, -20f);
		}
	}

	private void UpdateMinimapSize()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_0134: 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)
		float num = (doubleSizeEnabled ? 2f : 1f);
		if ((Object)(object)minimapFrameRect != (Object)null)
		{
			minimapFrameRect.sizeDelta = new Vector2(150f, 150f) * num;
		}
		if ((Object)(object)minimapDisplayObject != (Object)null)
		{
			RectTransform component = minimapDisplayObject.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.offsetMin = new Vector2(0f, 50f * num);
			}
		}
		Transform val = minimapDisplayObject.transform.Find("MinimapMask");
		if ((Object)(object)val != (Object)null)
		{
			RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.sizeDelta = new Vector2(140f, 140f) * num;
			}
		}
		Transform val2 = minimapDisplayObject.transform.Find("MinimapBorder");
		if ((Object)(object)val2 != (Object)null)
		{
			RectTransform component3 = ((Component)val2).GetComponent<RectTransform>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.sizeDelta = new Vector2(150f, 150f) * num;
			}
		}
		mapScale = 1.2487098f;
		ResetMapContentPosition();
		UpdateMinimapFramePosition();
		UpdateTimeDisplayPosition();
	}

	private void ResetMapContentPosition()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)playerObject == (Object)null || (Object)(object)mapContentObject == (Object)null || (Object)(object)minimapDisplayObject == (Object)null)
		{
			return;
		}
		Vector3 position = playerObject.transform.position;
		float num = (0f - position.x) * mapScale;
		float num2 = (0f - position.z) * mapScale;
		Transform val = minimapDisplayObject.transform.Find("MinimapMask");
		Vector2 zero = Vector2.zero;
		if ((Object)(object)val != (Object)null)
		{
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				Rect rect = component.rect;
				float num3 = ((Rect)(ref rect)).width * 0.5f;
				rect = component.rect;
				((Vector2)(ref zero))..ctor(num3, ((Rect)(ref rect)).height * 0.5f);
			}
		}
		Vector2 val2 = (doubleSizeEnabled ? new Vector2(-131f, -141f) : new Vector2(-61f, -71f));
		Vector2 anchoredPosition = new Vector2(num, num2) + zero + val2;
		RectTransform component2 = mapContentObject.GetComponent<RectTransform>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.anchoredPosition = anchoredPosition;
		}
	}

	private void CreateMinimapUI()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0073: 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_0090: Expected O, but got Unknown
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Expected O, but got Unknown
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: 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_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Expected O, but got Unknown
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_058f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			minimapObject = new GameObject("MinimapContainer");
			Object.DontDestroyOnLoad((Object)(object)minimapObject);
			GameObject val = new GameObject("MinimapCanvas");
			val.transform.SetParent(minimapObject.transform, false);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 9999;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val.AddComponent<GraphicRaycaster>();
			GameObject val4 = new GameObject("MinimapFrame");
			val4.transform.SetParent(val.transform, false);
			minimapFrameRect = val4.AddComponent<RectTransform>();
			minimapFrameRect.sizeDelta = new Vector2(150f, 150f);
			minimapFrameRect.anchorMin = new Vector2(1f, 1f);
			minimapFrameRect.anchorMax = new Vector2(1f, 1f);
			minimapFrameRect.pivot = new Vector2(1f, 1f);
			minimapFrameRect.anchoredPosition = new Vector2(-20f, -20f);
			minimapDisplayObject = new GameObject("MinimapDisplay");
			minimapDisplayObject.transform.SetParent(val4.transform, false);
			RectTransform val5 = minimapDisplayObject.AddComponent<RectTransform>();
			val5.anchorMin = new Vector2(0f, 0f);
			val5.anchorMax = new Vector2(1f, 1f);
			val5.offsetMin = new Vector2(0f, 50f);
			val5.offsetMax = Vector2.zero;
			GameObject val6 = new GameObject("MinimapMask");
			val6.transform.SetParent(minimapDisplayObject.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.sizeDelta = new Vector2(140f, 140f);
			val7.anchorMin = new Vector2(0.5f, 0.5f);
			val7.anchorMax = new Vector2(0.5f, 0.5f);
			val7.pivot = new Vector2(0.5f, 0.5f);
			val7.anchoredPosition = Vector2.zero;
			Mask val8 = val6.AddComponent<Mask>();
			val8.showMaskGraphic = false;
			Image val9 = val6.AddComponent<Image>();
			Sprite sprite = CreateCircleSprite(140, Color.white);
			val9.sprite = sprite;
			val9.type = (Type)1;
			((Graphic)val9).color = Color.white;
			GameObject val10 = new GameObject("MinimapBorder");
			val10.transform.SetParent(minimapDisplayObject.transform, false);
			RectTransform val11 = val10.AddComponent<RectTransform>();
			val11.sizeDelta = new Vector2(150f, 150f);
			val11.anchorMin = new Vector2(0.5f, 0.5f);
			val11.anchorMax = new Vector2(0.5f, 0.5f);
			val11.pivot = new Vector2(0.5f, 0.5f);
			val11.anchoredPosition = Vector2.zero;
			val10.transform.SetSiblingIndex(0);
			Image val12 = val10.AddComponent<Image>();
			Sprite sprite2 = CreateCircleSprite(150, Color.black);
			val12.sprite = sprite2;
			val12.type = (Type)1;
			((Graphic)val12).color = Color.black;
			mapContentObject = new GameObject("MapContent");
			mapContentObject.transform.SetParent(val6.transform, false);
			RectTransform val13 = mapContentObject.AddComponent<RectTransform>();
			val13.sizeDelta = new Vector2(500f, 500f);
			val13.anchorMin = new Vector2(0.5f, 0.5f);
			val13.anchorMax = new Vector2(0.5f, 0.5f);
			val13.pivot = new Vector2(0.5f, 0.5f);
			val13.anchoredPosition = Vector2.zero;
			GameObject val14 = new GameObject("GridContainer");
			val14.transform.SetParent(mapContentObject.transform, false);
			gridContainer = val14.AddComponent<RectTransform>();
			gridContainer.sizeDelta = new Vector2(500f, 500f);
			gridContainer.anchorMin = new Vector2(0.5f, 0.5f);
			gridContainer.anchorMax = new Vector2(0.5f, 0.5f);
			gridContainer.pivot = new Vector2(0.5f, 0.5f);
			gridContainer.anchoredPosition = Vector2.zero;
			CreateMinimapTimeDisplay((Transform)(object)minimapFrameRect);
			GameObject val15 = GameObject.Find("GameplayMenu/Phone/phone/AppsCanvas/MapApp/Container/Scroll View/Viewport/Content");
			if ((Object)(object)val15 != (Object)null)
			{
				Transform val16 = val15.transform.Find("PlayerPoI(Clone)");
				if ((Object)(object)val16 != (Object)null)
				{
					Transform val17 = val16.Find("IconContainer");
					if ((Object)(object)val17 != (Object)null)
					{
						cachedPlayerMarker = Object.Instantiate<GameObject>(((Component)val17).gameObject);
						((Object)cachedPlayerMarker).name = "PlayerMarker";
						cachedPlayerMarker.transform.SetParent(val6.transform, false);
						RectTransform component = cachedPlayerMarker.GetComponent<RectTransform>();
						if ((Object)(object)component != (Object)null)
						{
							component.anchoredPosition = Vector2.zero;
							((Transform)component).localScale = new Vector3(0.5f, 0.5f, 0.5f);
						}
						MelonLogger.Msg("Player icon cloned successfully.");
					}
					else
					{
						MelonLogger.Msg("IconContainer not found under PlayerPoI(Clone). Using fallback marker.");
						CreateFallbackPlayerMarker(val6);
					}
				}
				else
				{
					MelonLogger.Msg("PlayerPoI(Clone) not found under Content. Using fallback marker.");
					CreateFallbackPlayerMarker(val6);
				}
			}
			else
			{
				MelonLogger.Msg("Content object not found. Using fallback marker.");
				CreateFallbackPlayerMarker(val6);
			}
			MelonLogger.Msg("Minimap UI created successfully.");
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error creating minimap UI: " + ex.Message);
		}
	}

	private void CreateVisualGrid()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: 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)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Object)(object)gridContainer == (Object)null))
			{
				int num = 10;
				for (int i = 0; i <= num; i++)
				{
					GameObject val = new GameObject($"HLine_{i}");
					val.transform.SetParent((Transform)(object)gridContainer, false);
					RectTransform val2 = val.AddComponent<RectTransform>();
					val2.sizeDelta = new Vector2((float)(num * gridSize), 1f);
					val2.anchorMin = new Vector2(0.5f, 0.5f);
					val2.anchorMax = new Vector2(0.5f, 0.5f);
					val2.pivot = new Vector2(0.5f, 0.5f);
					float num2 = (i - num / 2) * gridSize;
					val2.anchoredPosition = new Vector2(0f, num2);
					Image val3 = val.AddComponent<Image>();
					((Graphic)val3).color = gridColor;
				}
				for (int j = 0; j <= num; j++)
				{
					GameObject val4 = new GameObject($"VLine_{j}");
					val4.transform.SetParent((Transform)(object)gridContainer, false);
					RectTransform val5 = val4.AddComponent<RectTransform>();
					val5.sizeDelta = new Vector2(1f, (float)(num * gridSize));
					val5.anchorMin = new Vector2(0.5f, 0.5f);
					val5.anchorMax = new Vector2(0.5f, 0.5f);
					val5.pivot = new Vector2(0.5f, 0.5f);
					float num3 = (j - num / 2) * gridSize;
					val5.anchoredPosition = new Vector2(num3, 0f);
					Image val6 = val4.AddComponent<Image>();
					((Graphic)val6).color = gridColor;
				}
				MelonLogger.Msg("Visual grid created successfully");
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error creating visual grid: " + ex.Message);
		}
	}

	public override void OnUpdate()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0123: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (Input.GetKeyDown((KeyCode)284))
			{
				guiVisible = !guiVisible;
			}
			if (!isEnabled || !((Object)(object)playerObject != (Object)null) || !((Object)(object)mapContentObject != (Object)null) || !((Object)(object)minimapDisplayObject != (Object)null))
			{
				return;
			}
			Vector3 position = playerObject.transform.position;
			float num = (0f - position.x) * mapScale;
			float num2 = (0f - position.z) * mapScale;
			Transform val = minimapDisplayObject.transform.Find("MinimapMask");
			Vector2 zero = Vector2.zero;
			if ((Object)(object)val != (Object)null)
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					Rect rect = component.rect;
					float num3 = ((Rect)(ref rect)).width * 0.5f;
					rect = component.rect;
					((Vector2)(ref zero))..ctor(num3, ((Rect)(ref rect)).height * 0.5f);
				}
			}
			Vector2 val2 = (doubleSizeEnabled ? new Vector2(-131f, -141f) : new Vector2(-61f, -71f));
			Vector2 val3 = new Vector2(num, num2) + zero + val2;
			RectTransform component2 = mapContentObject.GetComponent<RectTransform>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.anchoredPosition = Vector2.Lerp(component2.anchoredPosition, val3, Time.deltaTime * smoothingFactor);
				UpdatePlayerDirectionIndicator();
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error in OnUpdate: " + ex.Message);
		}
	}

	[IteratorStateMachine(typeof(<UpdateMinimapTimeCoroutine>d__47))]
	private IEnumerator UpdateMinimapTimeCoroutine()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <UpdateMinimapTimeCoroutine>d__47(0)
		{
			<>4__this = this
		};
	}

	private void UpdatePlayerDirectionIndicator()
	{
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_00b7: 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)
		if ((Object)(object)cachedPlayerMarker == (Object)null || (Object)(object)playerObject == (Object)null)
		{
			return;
		}
		if ((Object)(object)cachedDirectionIndicator == (Object)null)
		{
			Transform val = cachedPlayerMarker.transform.Find("DirectionIndicator");
			if ((Object)(object)val != (Object)null)
			{
				cachedDirectionIndicator = (RectTransform)(object)((val is RectTransform) ? val : null);
			}
			else
			{
				GameObject val2 = new GameObject("DirectionIndicator");
				val2.transform.SetParent(cachedPlayerMarker.transform, false);
				cachedDirectionIndicator = val2.AddComponent<RectTransform>();
				cachedDirectionIndicator.sizeDelta = new Vector2(6f, 6f);
				Image val3 = val2.AddComponent<Image>();
				((Graphic)val3).color = Color.white;
			}
		}
		cachedDirectionIndicator.pivot = new Vector2(0.5f, 0.5f);
		float num = 15f;
		Quaternion rotation = playerObject.transform.rotation;
		float y = ((Quaternion)(ref rotation)).eulerAngles.y;
		float num2 = (90f - y) * ((float)Math.PI / 180f);
		Vector2 anchoredPosition = default(Vector2);
		((Vector2)(ref anchoredPosition))..ctor(num * Mathf.Cos(num2), num * Mathf.Sin(num2));
		cachedDirectionIndicator.anchoredPosition = anchoredPosition;
	}

	private Sprite CreateCircleSprite(int diameter, Color color)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(diameter, diameter, (TextureFormat)5, false);
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
		for (int i = 0; i < diameter; i++)
		{
			for (int j = 0; j < diameter; j++)
			{
				val.SetPixel(j, i, val2);
			}
		}
		int num = diameter / 2;
		Vector2 val3 = default(Vector2);
		((Vector2)(ref val3))..ctor((float)num, (float)num);
		for (int k = 0; k < diameter; k++)
		{
			for (int l = 0; l < diameter; l++)
			{
				if (Vector2.Distance(new Vector2((float)l, (float)k), val3) <= (float)num)
				{
					val.SetPixel(l, k, color);
				}
			}
		}
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, (float)diameter, (float)diameter), new Vector2(0.5f, 0.5f));
	}

	private void AddWhiteStaticMarker(Vector3 worldPos)
	{
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		if ((Object)(object)mapContentObject == (Object)null)
		{
			MelonLogger.Warning("Map content object is null; cannot add marker.");
			return;
		}
		if ((Object)(object)cachedMapContent == (Object)null)
		{
			cachedMapContent = GameObject.Find("GameplayMenu/Phone/phone/AppsCanvas/MapApp/Container/Scroll View/Viewport/Content");
		}
		if ((Object)(object)cachedMapContent != (Object)null)
		{
			if ((Object)(object)cachedPropertyPoI == (Object)null)
			{
				cachedPropertyPoI = cachedMapContent.transform.Find("PropertyPoI(Clone)");
			}
			if ((Object)(object)cachedPropertyPoI != (Object)null)
			{
				Transform val = cachedPropertyPoI.Find("IconContainer");
				if ((Object)(object)val != (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject);
					((Object)val2).name = "StaticMarker_White";
					val2.transform.SetParent(mapContentObject.transform, false);
					RectTransform component = val2.GetComponent<RectTransform>();
					if ((Object)(object)component != (Object)null)
					{
						((Transform)component).localScale = new Vector3(0.5f, 0.5f, 0.5f);
						float num = worldPos.x * mapScale;
						float num2 = worldPos.z * mapScale;
						component.anchoredPosition = new Vector2(num, num2);
						Vector2 anchoredPosition = component.anchoredPosition;
						MelonLogger.Msg("White static marker added at mapped position: " + ((object)(Vector2)(ref anchoredPosition)).ToString());
						return;
					}
				}
			}
		}
		MelonLogger.Msg("White static marker asset not found. No marker added.");
	}

	private void AddRedStaticMarker(Vector3 worldPos)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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)
		if ((Object)(object)mapContentObject == (Object)null)
		{
			MelonLogger.Warning("Map content object is null; cannot add marker.");
			return;
		}
		GameObject val = new GameObject("StaticMarker_Red");
		val.transform.SetParent(mapContentObject.transform, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.sizeDelta = new Vector2(5f, 5f);
		float num = worldPos.x * mapScale;
		float num2 = worldPos.z * mapScale;
		val2.anchoredPosition = new Vector2(num, num2);
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = Color.red;
		Vector2 anchoredPosition = val2.anchoredPosition;
		MelonLogger.Msg("Red static marker added at mapped position: " + ((object)(Vector2)(ref anchoredPosition)).ToString());
	}

	private void AddDefaultMarkers()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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)
		AddWhiteStaticMarker(new Vector3(-67.17f, -3.03f, 138.31f));
		AddWhiteStaticMarker(new Vector3(-79.88f, -2.26f, 85.13f));
		AddWhiteStaticMarker(new Vector3(-179.99f, -3.03f, 113.69f));
		AddRedStaticMarker(new Vector3(-68.44f, -1.49f, 35.37f));
		AddRedStaticMarker(new Vector3(-34.55f, -1.54f, 27.06f));
		AddRedStaticMarker(new Vector3(70.33f, 1.37f, -10.01f));
	}

	private void UpdateTimeDisplayPosition()
	{
		//IL_004c: 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)
		if ((Object)(object)minimapTimeContainer != (Object)null)
		{
			if (doubleSizeEnabled)
			{
				minimapTimeContainer.anchoredPosition = new Vector2(0f, 40f);
			}
			else
			{
				minimapTimeContainer.anchoredPosition = new Vector2(0f, 10f);
			}
		}
	}

	private void RecursiveFind(Transform current, string targetName, List<Transform> result)
	{
		if (((Object)current).name == targetName)
		{
			result.Add(current);
		}
		for (int i = 0; i < current.childCount; i++)
		{
			RecursiveFind(current.GetChild(i), targetName, result);
		}
	}

	[IteratorStateMachine(typeof(<ContractPoICheckerWorld>d__55))]
	private IEnumerator ContractPoICheckerWorld()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ContractPoICheckerWorld>d__55(0)
		{
			<>4__this = this
		};
	}

	private void RemoveAllContractPoIMarkers()
	{
		foreach (GameObject contractPoIMarker in contractPoIMarkers)
		{
			if ((Object)(object)contractPoIMarker != (Object)null)
			{
				Object.Destroy((Object)(object)contractPoIMarker);
			}
		}
		contractPoIMarkers.Clear();
	}

	private void AddContractPoIMarkerWorld(Transform cpTransform)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cpTransform == (Object)null)
		{
			return;
		}
		Vector3 position = cpTransform.position;
		Vector2 anchoredPosition = default(Vector2);
		((Vector2)(ref anchoredPosition))..ctor(position.x * mapScale, position.z * mapScale);
		anchoredPosition.x -= 5f;
		if ((Object)(object)contractPoIIconPrefab == (Object)null)
		{
			CacheContractPoIIcon();
			if ((Object)(object)contractPoIIconPrefab == (Object)null)
			{
				return;
			}
		}
		GameObject val = Object.Instantiate<GameObject>(contractPoIIconPrefab);
		((Object)val).name = "ContractPoIMarker_" + ((Object)cpTransform).GetInstanceID();
		if ((Object)(object)mapContentObject != (Object)null)
		{
			val.transform.SetParent(mapContentObject.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchoredPosition = anchoredPosition;
				((Transform)component).localScale = new Vector3(0.5f, 0.5f, 0.5f);
			}
			else
			{
				MelonLogger.Warning("AddContractPoIMarkerWorld: Marker does not have a RectTransform.");
			}
			contractPoIMarkers.Add(val);
		}
	}

	private void CacheContractPoIIcon()
	{
		if (!((Object)(object)contractPoIIconPrefab != (Object)null))
		{
			string text = "GameplayMenu/Phone/phone/AppsCanvas/MapApp/Container/Scroll View/Viewport/Content/ContractPoI(Clone)/IconContainer";
			GameObject val = GameObject.Find(text);
			if ((Object)(object)val != (Object)null)
			{
				contractPoIIconPrefab = val;
			}
			else
			{
				MelonLogger.Warning("CacheContractPoIIcon: Could not find ContractPoI IconContainer at path: " + text);
			}
		}
	}

	private void CreateFallbackPlayerMarker(GameObject parent)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		cachedPlayerMarker = new GameObject("PlayerMarker");
		cachedPlayerMarker.transform.SetParent(parent.transform, false);
		RectTransform val = cachedPlayerMarker.AddComponent<RectTransform>();
		val.sizeDelta = new Vector2(5f, 5f);
		val.anchorMin = new Vector2(0.5f, 0.5f);
		val.anchorMax = new Vector2(0.5f, 0.5f);
		val.pivot = new Vector2(0.5f, 0.5f);
		val.anchoredPosition = Vector2.zero;
		Image val2 = cachedPlayerMarker.AddComponent<Image>();
		((Graphic)val2).color = new Color(0.2f, 0.6f, 1f, 1f);
		MelonLogger.Msg("Fallback player marker created.");
	}
}