Decompiled source of MegabonkBetterMinimapMelonLoader v1.4.1

MegabonkBetterMinimapMelonLoader.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2Cpp;
using Il2CppAssets.Scripts.Actors;
using Il2CppAssets.Scripts.Actors.Enemies;
using Il2CppAssets.Scripts.Actors.Player;
using Il2CppAssets.Scripts.Camera;
using Il2CppAssets.Scripts.Inventory__Items__Pickups.Chests;
using Il2CppAssets.Scripts.Inventory__Items__Pickups.Interactables;
using Il2CppAssets.Scripts.Inventory__Items__Pickups.Items;
using Il2CppAssets.Scripts.Inventory__Items__Pickups.Weapons.Projectiles;
using Il2CppAssets.Scripts.Managers;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MegabonkBetterMinimapMelonLoader;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Bindings;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "MegabonkBetterMinimapMelonLoader", "1.4.1", "WafuRuns", null)]
[assembly: MelonGame("Ved", "Megabonk")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MegabonkBetterMinimapMelonLoader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+aed44da0eaf08513d3a849d26fd50088f380777f")]
[assembly: AssemblyProduct("MegabonkBetterMinimapMelonLoader")]
[assembly: AssemblyTitle("MegabonkBetterMinimapMelonLoader")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MegabonkBetterMinimapMelonLoader
{
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(MinimapUi), "Awake")]
		public static class MinimapUi_Awake_Patch
		{
			private static void Postfix(MinimapUi __instance)
			{
				__instance.UpdateScale(_currentScale);
			}
		}

		[HarmonyPatch(typeof(MinimapUi), "Update")]
		public static class MinimapUi_Update_Patch
		{
			private static Vector3? originalLocalPosition;

			private static Vector2 originalAnchorMin;

			private static Vector2 originalAnchorMax;

			private static Vector2 originalPivot;

			private static void Postfix(MinimapUi __instance)
			{
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: 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_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: 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_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: 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)
				if (KeyHelper.IsKeyPressedOnce((KeyCode)282) && !_onMinimap)
				{
					_currentScale += 0.1f;
					if (_currentScale > 4.5f)
					{
						_currentScale = 1f;
					}
					__instance.UpdateScale(_currentScale);
					CurrentScaleConfig.Value = _currentScale;
				}
				if (KeyHelper.IsKeyPressedOnce((KeyCode)109))
				{
					Time.timeScale = ((Time.timeScale == 0f) ? 1f : 0f);
					RectTransform component = ((Component)__instance).GetComponent<RectTransform>();
					if ((Object)(object)component == (Object)null)
					{
						return;
					}
					if (Time.timeScale == 0f)
					{
						if (!originalLocalPosition.HasValue)
						{
							originalLocalPosition = ((Transform)component).localPosition;
							originalAnchorMin = component.anchorMin;
							originalAnchorMax = component.anchorMax;
							originalPivot = component.pivot;
						}
						Vector2 val = default(Vector2);
						((Vector2)(ref val))..ctor(0.5f, 0.5f);
						component.pivot = val;
						Vector2 anchorMin = (component.anchorMax = val);
						component.anchorMin = anchorMin;
						((Transform)component).localPosition = Vector3.zero;
						((Component)__instance.border).gameObject.active = false;
						__instance.UpdateScale(5f);
						Transform val3 = ((Component)__instance).transform.Find("MapRenderer");
						if ((Object)(object)val3 != (Object)null)
						{
							Mask component2 = ((Component)val3).GetComponent<Mask>();
							if ((Object)(object)component2 != (Object)null)
							{
								((Behaviour)component2).enabled = false;
							}
						}
						_onMinimap = true;
					}
					else
					{
						if (originalLocalPosition.HasValue)
						{
							component.anchorMin = originalAnchorMin;
							component.anchorMax = originalAnchorMax;
							component.pivot = originalPivot;
							((Transform)component).localPosition = originalLocalPosition.Value;
						}
						((Component)__instance.border).gameObject.active = true;
						__instance.UpdateScale(_currentScale);
						Transform val4 = ((Component)__instance).transform.Find("MapRenderer");
						if ((Object)(object)val4 != (Object)null)
						{
							Mask component3 = ((Component)val4).GetComponent<Mask>();
							if ((Object)(object)component3 != (Object)null)
							{
								((Behaviour)component3).enabled = true;
							}
						}
						_onMinimap = false;
					}
				}
				if (KeyHelper.IsKeyPressedOnce((KeyCode)284))
				{
					_hideJunk = !_hideJunk;
				}
			}
		}

		[HarmonyPatch(typeof(GameManager), "Update")]
		private class GameManager_Update_Patch
		{
			private static void Postfix()
			{
				if (KeyHelper.IsKeyPressedOnce((KeyCode)112))
				{
					MapController.RestartRun();
				}
			}
		}

		[HarmonyPatch(typeof(MinimapCamera), "Update")]
		public static class MinimapCamera_Update_Patch
		{
			private static Vector3? originalPosition = null;

			private static readonly Quaternion CenterRotation = Quaternion.Euler(90f, 0f, 0f);

			private static readonly Vector3 CenterPosition = new Vector3(0f, 1000f, 0f);

			private static void Postfix(MinimapCamera __instance)
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				RenderTexture targetTexture = __instance.minimapCamera.targetTexture;
				if ((Object)(object)targetTexture != (Object)null)
				{
					targetTexture.Release();
					((Texture)targetTexture).width = 1024;
					((Texture)targetTexture).height = 1024;
					targetTexture.Create();
				}
				if (_onMinimap)
				{
					if (!originalPosition.HasValue)
					{
						originalPosition = ((Component)__instance.minimapCamera).transform.position;
					}
					((Component)__instance.minimapCamera).transform.SetPositionAndRotation(CenterPosition, CenterRotation);
					if (__instance.minimapCamera.orthographicSize != (float)_currentFullZoom)
					{
						__instance.minimapCamera.orthographicSize = _currentFullZoom;
					}
				}
				else
				{
					if (originalPosition.HasValue)
					{
						((Component)__instance.minimapCamera).transform.position = originalPosition.Value;
						originalPosition = null;
					}
					if (__instance.minimapCamera.orthographicSize != (float)_currentZoom)
					{
						__instance.minimapCamera.orthographicSize = _currentZoom;
					}
				}
				if (!KeyHelper.IsKeyPressedOnce((KeyCode)283) || (Object)(object)((__instance != null) ? __instance.minimapCamera : null) == (Object)null)
				{
					return;
				}
				if (_onMinimap)
				{
					_currentFullZoom += 5;
					if (_currentFullZoom > 500)
					{
						_currentFullZoom = 100;
					}
					CurrentZoomConfig.Value = _currentZoom;
				}
				else
				{
					_currentZoom += 5;
					if (_currentZoom > 500)
					{
						_currentZoom = 100;
					}
					CurrentZoomConfig.Value = _currentZoom;
				}
			}
		}

		[HarmonyPatch(typeof(InteractableChest), "Start")]
		private class InteractableChest_Start_Patch
		{
			private static void Postfix(InteractableChest __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: 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_0034: Invalid comparison between Unknown and I4
				//IL_0015: 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)
				EChest chestType = __instance.chestType;
				EItemRarity val = (((int)chestType == 0) ? ((EItemRarity)0) : (((int)chestType != 2) ? ((EItemRarity)0) : ((EItemRarity)3)));
				EItemRarity rarity = val;
				Statistics.AddInteractable(((object)__instance).GetType().Name, rarity);
				if ((int)__instance.chestType == 2)
				{
					ChangeMinimapIcon(__instance.icon, "ChestFree");
				}
			}
		}

		[HarmonyPatch(typeof(OpenChest), "Awake")]
		private class OpenChest_Awake_Patch
		{
			private static void Postfix()
			{
				Statistics.AddInteractable(typeof(InteractableChest).Name, (EItemRarity)2);
			}
		}

		[HarmonyPatch(typeof(OpenChest), "OnTriggerStay")]
		private class OpenChest_OnTriggerStay_Patch
		{
			private static void Postfix()
			{
				Statistics.RemoveInteractable(typeof(InteractableChest).Name, (EItemRarity)2);
			}
		}

		[HarmonyPatch(typeof(InteractableChest), "OnDestroy")]
		private class InteractableChest_OnDestroy_Patch
		{
			private static void Postfix(InteractableChest __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				EChest chestType = __instance.chestType;
				EItemRarity val = (((int)chestType == 0) ? ((EItemRarity)0) : (((int)chestType != 2) ? ((EItemRarity)0) : ((EItemRarity)3)));
				EItemRarity rarity = val;
				Statistics.RemoveInteractable(((object)__instance).GetType().Name, rarity);
			}
		}

		[HarmonyPatch(typeof(ChargeShrine), "Start")]
		private class ChargeShrine_Start_Patch
		{
			private static void Postfix(ChargeShrine __instance)
			{
				Statistics.AddInteractable(((object)__instance).GetType().Name, (EItemRarity)(__instance.isGolden ? 3 : 0));
				if (__instance.isGolden)
				{
					ChangeMinimapIcon(__instance.minimapIcon.transform, "Shrine", (EItemRarity)3);
				}
				else
				{
					ChangeMinimapIcon(__instance.minimapIcon.transform, "Shrine", (EItemRarity)0);
				}
			}
		}

		[HarmonyPatch(typeof(ChargeShrine), "Complete")]
		private class ChargeShrine_Complete_Patch
		{
			private static void Postfix(ChargeShrine __instance)
			{
				Statistics.RemoveInteractable(((object)__instance).GetType().Name, (EItemRarity)(__instance.isGolden ? 3 : 0));
			}
		}

		[HarmonyPatch(typeof(InteractableMicrowave), "Start")]
		private class InteractableMicrowave_Start_Patch
		{
			private static void Postfix(InteractableMicrowave __instance)
			{
				//IL_0015: 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)
				if (__instance.usesLeft > 0)
				{
					Statistics.AddInteractable(((object)__instance).GetType().Name, __instance.rarity);
					ChangeMinimapIcon(__instance.minimapIcon.transform, "Microwave", __instance.rarity);
				}
			}
		}

		[HarmonyPatch(typeof(InteractableMicrowave), "Explode")]
		private class InteractableMicrowave_Explode_Patch
		{
			private static void Postfix(InteractableMicrowave __instance)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Statistics.RemoveInteractable(((object)__instance).GetType().Name, __instance.rarity);
			}
		}

		[HarmonyPatch(typeof(InteractableShadyGuy), "Start")]
		private class InteractableShadyGuy_Start_Patch
		{
			private static void Postfix(InteractableShadyGuy __instance)
			{
				//IL_000c: 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)
				Statistics.AddInteractable(((object)__instance).GetType().Name, __instance.rarity);
				ChangeMinimapIcon(((IEnumerable<GameObject>)__instance.hideAfterPurchase).First().transform, "ShadyGuy", __instance.rarity);
			}
		}

		[HarmonyPatch(typeof(InteractableShadyGuy), "OnDestroy")]
		private class InteractableShadyGuy_OnDestroy_Patch
		{
			private static void Postfix(InteractableShadyGuy __instance)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Statistics.RemoveInteractable(((object)__instance).GetType().Name, __instance.rarity);
			}
		}

		[HarmonyPatch(typeof(InteractableShrineChallenge), "Awake")]
		private class InteractableShrineChallenge_Awake_Patch
		{
			private static void Postfix(InteractableShrineChallenge __instance)
			{
				if (!__instance.done)
				{
					Statistics.AddInteractable(((object)__instance).GetType().Name, (EItemRarity)0);
					ChangeMinimapIcon(__instance.minimapIcon.transform, "Challenge");
				}
			}
		}

		[HarmonyPatch(typeof(InteractableShrineChallenge), "OnDestroy")]
		private class InteractableShrineChallenge_OnDestroy_Patch
		{
			private static void Postfix(InteractableShrineChallenge __instance)
			{
				Statistics.RemoveInteractable(((object)__instance).GetType().Name, (EItemRarity)0);
			}
		}

		[HarmonyPatch(typeof(BaseInteractable), "Start")]
		public static class BaseInteractable_Start_Patch
		{
			private static void Postfix(BaseInteractable __instance)
			{
				switch (((MemberInfo)((Object)__instance).GetIl2CppType()).Name)
				{
				case "InteractableShrineCursed":
				{
					InteractableShrineCursed component2 = ((Component)__instance).GetComponent<InteractableShrineCursed>();
					if ((Object)(object)component2 != (Object)null)
					{
						Statistics.AddInteractable(((object)component2).GetType().Name, (EItemRarity)0);
						ChangeMinimapIcon(component2.minimapIcon.transform, "BossCurse");
					}
					break;
				}
				case "InteractableShrineMagnet":
				{
					InteractableShrineMagnet component3 = ((Component)__instance).GetComponent<InteractableShrineMagnet>();
					if ((Object)(object)component3 != (Object)null)
					{
						Statistics.AddInteractable(((object)component3).GetType().Name, (EItemRarity)0);
						ChangeMinimapIcon(component3.minimapIcon.transform, "Magnet");
					}
					break;
				}
				case "InteractableShrineMoai":
				{
					InteractableShrineMoai component = ((Component)__instance).GetComponent<InteractableShrineMoai>();
					if ((Object)(object)component != (Object)null)
					{
						Statistics.AddInteractable(((object)component).GetType().Name, (EItemRarity)0);
						ChangeMinimapIcon(component.minimapIcon.transform, "Moai");
					}
					break;
				}
				}
			}
		}

		[HarmonyPatch(typeof(BaseInteractable), "OnDestroy")]
		public static class BaseInteractable_OnDestroy_Patch
		{
			private static void Postfix(BaseInteractable __instance)
			{
				switch (((MemberInfo)((Object)__instance).GetIl2CppType()).Name)
				{
				case "InteractableShrineCursed":
				{
					InteractableShrineCursed component2 = ((Component)__instance).GetComponent<InteractableShrineCursed>();
					if ((Object)(object)component2 != (Object)null)
					{
						Statistics.RemoveInteractable(((object)component2).GetType().Name, (EItemRarity)0);
					}
					break;
				}
				case "InteractableShrineMagnet":
				{
					InteractableShrineMagnet component3 = ((Component)__instance).GetComponent<InteractableShrineMagnet>();
					if ((Object)(object)component3 != (Object)null)
					{
						Statistics.RemoveInteractable(((object)component3).GetType().Name, (EItemRarity)0);
					}
					break;
				}
				case "InteractableShrineMoai":
				{
					InteractableShrineMoai component = ((Component)__instance).GetComponent<InteractableShrineMoai>();
					if ((Object)(object)component != (Object)null)
					{
						Statistics.RemoveInteractable(((object)component).GetType().Name, (EItemRarity)0);
					}
					break;
				}
				}
			}
		}

		[HarmonyPatch(typeof(PauseHandler), "Start")]
		public static class PauseHandler_Start_Patch
		{
			private static void Postfix()
			{
				Statistics.ResetCounter();
			}
		}

		[HarmonyPatch(typeof(Enemy), "InitEnemy")]
		public static class Enemy_InitEnemy_Patch
		{
			private static void Postfix(Enemy __instance)
			{
				if (!_hideJunk)
				{
					return;
				}
				foreach (Renderer componentsInChild in ((Component)__instance).GetComponentsInChildren<Renderer>())
				{
					componentsInChild.enabled = false;
				}
			}
		}

		[HarmonyPatch(typeof(ProjectileBase), "Set")]
		public static class ProjectileBase_Set_Patch
		{
			private static void Postfix(ProjectileBase __instance)
			{
				if (!_hideJunk)
				{
					return;
				}
				foreach (Renderer componentsInChild in ((Component)__instance).GetComponentsInChildren<Renderer>())
				{
					componentsInChild.enabled = false;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerInput), "Update")]
		public static class PlayerInput_Update_Patch
		{
			private static bool lastCanInput;

			private static void Postfix(PlayerInput __instance)
			{
				bool flag = __instance.CanInput();
				if (!lastCanInput && lastCanInput != flag && Statistics.IsReset())
				{
					Statistics.ResetRunStats();
				}
				lastCanInput = flag;
			}
		}

		[HarmonyPatch(typeof(Enemy), "EnemyDied")]
		[HarmonyPatch(new Type[] { typeof(DamageContainer) })]
		public static class Enemy_EnemyDied_Patch
		{
			private static void Postfix()
			{
				Statistics.AddKill();
			}
		}

		[HarmonyPatch(typeof(Enemy), "EnemyDied")]
		[HarmonyPatch(new Type[] { })]
		public static class Enemy_EnemyDied2_Patch
		{
			private static void Postfix()
			{
				Statistics.AddKill();
			}
		}

		[HarmonyPatch(typeof(MapController), "LoadNextStage")]
		public static class MapController_LoadNextStage_Patch
		{
			private static void Postfix()
			{
				AddRunStats();
			}
		}

		[HarmonyPatch(typeof(MapController), "LoadFinalStage")]
		public static class MapController_LoadFinalStage_Patch
		{
			private static void Postfix()
			{
				AddRunStats();
			}
		}

		[HarmonyPatch(typeof(MapController), "RestartRun")]
		public static class MapController_RestartRun_Patch
		{
			private static void Postfix()
			{
				Statistics.SetDefaultRunFlags();
			}
		}

		[HarmonyPatch(typeof(MapController), "StartNewMap")]
		public static class MapController_StartNewMap_Patch
		{
			private static void Postfix()
			{
				Statistics.SetDefaultRunFlags();
			}
		}

		[HarmonyPatch(typeof(PlayerRenderer), "OnDeath")]
		public static class PlayerRenderer_OnDeath_Patch
		{
			private static void Postfix()
			{
				AddRunStats();
				Statistics.PrintStats();
			}
		}

		private static float _currentScale = 1f;

		private const float ScaleIncrement = 0.1f;

		private const float MaxScale = 4.5f;

		private static int _currentZoom = 100;

		private static int _currentFullZoom = 300;

		private const int ZoomIncrement = 5;

		private const int MaxZoom = 500;

		private static bool _onMinimap = false;

		private static readonly Dictionary<EItemRarity, Color> RarityColors = new Dictionary<EItemRarity, Color>
		{
			{
				(EItemRarity)0,
				new Color(0.225f, 1f, 0f, 1f)
			},
			{
				(EItemRarity)1,
				new Color(0f, 0.317f, 0.965f, 1f)
			},
			{
				(EItemRarity)2,
				new Color(0.965f, 0f, 0.691f, 1f)
			},
			{
				(EItemRarity)3,
				new Color(0.951f, 0.965f, 0f, 1f)
			}
		};

		private static bool _hideJunk = false;

		internal static MelonPreferences_Category MinimapCategory;

		internal static MelonPreferences_Entry<float> CurrentScaleConfig;

		internal static MelonPreferences_Entry<int> CurrentZoomConfig;

		internal static MelonPreferences_Entry<int> CurrentFullZoomConfig;

		public override void OnInitializeMelon()
		{
			//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_00ce: Expected O, but got Unknown
			MinimapCategory = MelonPreferences.CreateCategory("Minimap");
			CurrentScaleConfig = MinimapCategory.CreateEntry<float>("CurrentScale", 1f, "Current minimap scale", (string)null, false, false, (ValueValidator)null, (string)null);
			CurrentZoomConfig = MinimapCategory.CreateEntry<int>("CurrentZoom", 100, "Current normal zoom", (string)null, false, false, (ValueValidator)null, (string)null);
			CurrentFullZoomConfig = MinimapCategory.CreateEntry<int>("CurrentFullZoom", 300, "Current full/minimap zoom", (string)null, false, false, (ValueValidator)null, (string)null);
			_currentScale = CurrentScaleConfig.Value;
			_currentZoom = CurrentZoomConfig.Value;
			_currentFullZoom = CurrentFullZoomConfig.Value;
			if (!ClassInjector.IsTypeRegisteredInIl2Cpp(typeof(StatsUI)))
			{
				ClassInjector.RegisterTypeInIl2Cpp<StatsUI>();
			}
			GameObject val = new GameObject("StatsUI");
			val.AddComponent<StatsUI>();
			Object.DontDestroyOnLoad((Object)val);
			MelonLogger.Msg("Loaded MegabonkBetterMinimapMelonLoader");
		}

		public static void ChangeMinimapIcon(Transform icon, string iconName, EItemRarity? rarity = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer component = ((Component)icon).GetComponent<MeshRenderer>();
			if (!((Object)(object)component == (Object)null))
			{
				Transform transform = ((Component)component).transform;
				transform.localScale *= 1.3f;
				Texture2D val = TextureManager.Load(iconName);
				if ((Object)(object)val != (Object)null)
				{
					((Renderer)component).material.mainTexture = (Texture)(object)val;
					((Renderer)component).material.color = (rarity.HasValue ? RarityColors[rarity.Value] : Color.white);
				}
			}
		}

		private static void AddRunStats()
		{
			MyPlayer val = Object.FindAnyObjectByType<MyPlayer>();
			if ((Object)(object)val != (Object)null)
			{
				Statistics.AddRunStat(Statistics.GetKills());
				Statistics.AddRunStat(val.inventory.playerXp.level);
			}
		}
	}
	public static class KeyHelper
	{
		private static DateTime _lastKeyPressTime = DateTime.MinValue;

		public static TimeSpan KeyCooldown { get; set; } = TimeSpan.FromMilliseconds(100.0);


		public static bool IsKeyPressedOnce(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKey(key))
			{
				return false;
			}
			DateTime utcNow = DateTime.UtcNow;
			if (utcNow - _lastKeyPressTime < KeyCooldown)
			{
				return false;
			}
			_lastKeyPressTime = utcNow;
			return true;
		}
	}
	public static class StatDisplayNames
	{
		public static readonly Dictionary<string, string> Interactable = new Dictionary<string, string>
		{
			{
				typeof(InteractableChest).Name,
				"Chest"
			},
			{
				typeof(InteractableMicrowave).Name,
				"Microwave"
			},
			{
				typeof(InteractableShadyGuy).Name,
				"Shady Guy"
			},
			{
				typeof(ChargeShrine).Name,
				"Shrine"
			},
			{
				typeof(InteractableShrineChallenge).Name,
				"Challenge"
			},
			{
				typeof(InteractableShrineCursed).Name,
				"Cursed"
			},
			{
				typeof(InteractableShrineMagnet).Name,
				"Magnet"
			},
			{
				typeof(InteractableShrineMoai).Name,
				"Moai"
			}
		};

		public static readonly Dictionary<string, Dictionary<EItemRarity, string>> RarityOverrides = new Dictionary<string, Dictionary<EItemRarity, string>>
		{
			{
				typeof(InteractableChest).Name,
				new Dictionary<EItemRarity, string>
				{
					{
						(EItemRarity)2,
						"Elite"
					},
					{
						(EItemRarity)3,
						"Free"
					}
				}
			},
			{
				typeof(ChargeShrine).Name,
				new Dictionary<EItemRarity, string> { 
				{
					(EItemRarity)3,
					"Golden"
				} }
			}
		};

		public static string GetInteractableName(string type)
		{
			if (!Interactable.TryGetValue(type, out var value))
			{
				return type;
			}
			return value;
		}

		public static string GetRarityName(string interactableType, EItemRarity rarity)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (RarityOverrides.TryGetValue(interactableType, out var value) && value.TryGetValue(rarity, out var value2))
			{
				return value2;
			}
			return ((object)(EItemRarity)(ref rarity)).ToString();
		}
	}
	public static class Statistics
	{
		private static readonly Dictionary<string, Dictionary<EItemRarity, int>> defaultInteractableCounter = new Dictionary<string, Dictionary<EItemRarity, int>>
		{
			{
				typeof(InteractableChest).Name,
				new Dictionary<EItemRarity, int>
				{
					{
						(EItemRarity)0,
						0
					},
					{
						(EItemRarity)2,
						0
					},
					{
						(EItemRarity)3,
						0
					}
				}
			},
			{
				typeof(InteractableMicrowave).Name,
				new Dictionary<EItemRarity, int>
				{
					{
						(EItemRarity)0,
						0
					},
					{
						(EItemRarity)1,
						0
					},
					{
						(EItemRarity)2,
						0
					},
					{
						(EItemRarity)3,
						0
					}
				}
			},
			{
				typeof(InteractableShadyGuy).Name,
				new Dictionary<EItemRarity, int>
				{
					{
						(EItemRarity)0,
						0
					},
					{
						(EItemRarity)1,
						0
					},
					{
						(EItemRarity)2,
						0
					},
					{
						(EItemRarity)3,
						0
					}
				}
			},
			{
				typeof(ChargeShrine).Name,
				new Dictionary<EItemRarity, int>
				{
					{
						(EItemRarity)0,
						0
					},
					{
						(EItemRarity)3,
						0
					}
				}
			},
			{
				typeof(InteractableShrineChallenge).Name,
				new Dictionary<EItemRarity, int> { 
				{
					(EItemRarity)0,
					0
				} }
			},
			{
				typeof(InteractableShrineCursed).Name,
				new Dictionary<EItemRarity, int> { 
				{
					(EItemRarity)0,
					0
				} }
			},
			{
				typeof(InteractableShrineMagnet).Name,
				new Dictionary<EItemRarity, int> { 
				{
					(EItemRarity)0,
					0
				} }
			},
			{
				typeof(InteractableShrineMoai).Name,
				new Dictionary<EItemRarity, int> { 
				{
					(EItemRarity)0,
					0
				} }
			}
		};

		private static Dictionary<string, Dictionary<EItemRarity, int>> interactableCounter = CopyDefault();

		private static bool _isReset;

		private static List<int> _runStats;

		private static int _kills = 0;

		public static void ResetCounter()
		{
			interactableCounter = CopyDefault();
		}

		public static bool IsReset()
		{
			return _isReset;
		}

		public static void SetDefaultRunFlags()
		{
			_isReset = true;
			_kills = 0;
		}

		public static void AddInteractable(string type, EItemRarity rarity)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			interactableCounter[type][rarity]++;
			StatsUI.Instance?.UpdateUI();
		}

		public static void RemoveInteractable(string type, EItemRarity rarity)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			interactableCounter[type][rarity]--;
			StatsUI.Instance?.UpdateUI();
		}

		public static Dictionary<string, Dictionary<EItemRarity, int>> GetCounters()
		{
			return interactableCounter;
		}

		private static Dictionary<string, Dictionary<EItemRarity, int>> CopyDefault()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Dictionary<EItemRarity, int>> dictionary = new Dictionary<string, Dictionary<EItemRarity, int>>();
			foreach (KeyValuePair<string, Dictionary<EItemRarity, int>> item in defaultInteractableCounter)
			{
				Dictionary<EItemRarity, int> dictionary2 = new Dictionary<EItemRarity, int>();
				foreach (KeyValuePair<EItemRarity, int> item2 in item.Value)
				{
					dictionary2[item2.Key] = item2.Value;
				}
				dictionary[item.Key] = dictionary2;
			}
			return dictionary;
		}

		public static float GetRating()
		{
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<(string, EItemRarity), float> dictionary = new Dictionary<(string, EItemRarity), float>
			{
				{
					(typeof(InteractableChest).Name, (EItemRarity)3),
					1f
				},
				{
					(typeof(InteractableShadyGuy).Name, (EItemRarity)2),
					3f
				},
				{
					(typeof(InteractableShadyGuy).Name, (EItemRarity)3),
					10f
				},
				{
					(typeof(ChargeShrine).Name, (EItemRarity)3),
					5f
				},
				{
					(typeof(InteractableShrineChallenge).Name, (EItemRarity)0),
					1f
				},
				{
					(typeof(InteractableShrineCursed).Name, (EItemRarity)0),
					3f
				},
				{
					(typeof(InteractableShrineMoai).Name, (EItemRarity)0),
					1.5f
				},
				{
					(typeof(InteractableShrineMagnet).Name, (EItemRarity)0),
					0.25f
				}
			};
			float num = 0f;
			foreach (KeyValuePair<string, Dictionary<EItemRarity, int>> item in interactableCounter)
			{
				string key = item.Key;
				foreach (KeyValuePair<EItemRarity, int> item2 in item.Value)
				{
					(string, EItemRarity) key2 = (key, item2.Key);
					if (dictionary.TryGetValue(key2, out var value))
					{
						num += (float)item2.Value * value;
					}
				}
			}
			return num;
		}

		public static void PrintStats()
		{
			_runStats.AddRange(new int[16 - _runStats.Count]);
			MelonLogger.Msg("Stats for map rating research: " + string.Join(",", _runStats));
		}

		public static void ResetRunStats()
		{
			_isReset = false;
			_runStats = new(string, EItemRarity)[8]
			{
				("InteractableChest", (EItemRarity)3),
				("InteractableShadyGuy", (EItemRarity)2),
				("InteractableShadyGuy", (EItemRarity)3),
				("ChargeShrine", (EItemRarity)3),
				("InteractableShrineChallenge", (EItemRarity)0),
				("InteractableShrineCursed", (EItemRarity)0),
				("InteractableShrineMoai", (EItemRarity)0),
				("InteractableShrineMagnet", (EItemRarity)0)
			}.Select(((string, EItemRarity) k) => interactableCounter[k.Item1][k.Item2]).ToList();
		}

		public static void AddRunStat(int value)
		{
			_runStats.Add(value);
		}

		public static void AddKill()
		{
			_kills++;
		}

		public static int GetKills()
		{
			return _kills;
		}
	}
	public class StatsUI : MonoBehaviour
	{
		private Canvas _canvas;

		private RectTransform _panel;

		private VerticalLayoutGroup _layoutGroup;

		private readonly Dictionary<string, GameObject> _statLines = new Dictionary<string, GameObject>();

		private static Font gameFont;

		private static Sprite borderSprite;

		private bool _initialized;

		private bool _visible = true;

		public static StatsUI Instance { get; private set; }

		private void Update()
		{
			if (_initialized)
			{
				if (KeyHelper.IsKeyPressedOnce((KeyCode)116))
				{
					_visible = !_visible;
					((Component)_canvas).gameObject.SetActive(_visible);
				}
			}
			else if ((Object)(object)Object.FindObjectOfType<InteractableChest>() != (Object)null)
			{
				InitializeResources();
				CreateCanvas();
				UpdateUI();
				_initialized = true;
			}
		}

		public static void InitializeResources()
		{
			if ((Object)(object)gameFont == (Object)null)
			{
				gameFont = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == "alagard"));
				if ((Object)(object)gameFont != (Object)null)
				{
					Material material = gameFont.material;
					if ((Object)(object)((material != null) ? material.mainTexture : null) != (Object)null)
					{
						gameFont.material.mainTexture.filterMode = (FilterMode)0;
					}
				}
			}
			if ((Object)(object)borderSprite == (Object)null)
			{
				borderSprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "Border2_Gray"));
			}
		}

		private void CreateCanvas()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00c2: 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_00f6: 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_012a: 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_017c: 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_0189: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			Instance = this;
			GameObject val = new GameObject("StatsCanvas");
			val.transform.SetParent(((Component)this).transform, false);
			_canvas = val.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.pixelPerfect = true;
			CanvasScaler obj = val.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(1920f, 1080f);
			obj.screenMatchMode = (ScreenMatchMode)0;
			obj.matchWidthOrHeight = 1f;
			val.AddComponent<GraphicRaycaster>();
			GameObject val2 = new GameObject("StatsPanel");
			val2.transform.SetParent(val.transform, false);
			_panel = val2.AddComponent<RectTransform>();
			Image obj2 = val2.AddComponent<Image>();
			obj2.sprite = borderSprite;
			obj2.type = (Type)1;
			((Graphic)obj2).color = Color.white;
			_panel.anchorMin = new Vector2(0f, 0f);
			_panel.anchorMax = new Vector2(0f, 0f);
			_panel.pivot = new Vector2(0f, 0f);
			_panel.anchoredPosition = new Vector2(30f, 140f);
			_panel.sizeDelta = new Vector2(380f, 600f);
			_layoutGroup = val2.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)_layoutGroup).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)_layoutGroup).spacing = 3f;
			((LayoutGroup)_layoutGroup).padding = new RectOffset
			{
				left = 32,
				right = 32,
				top = 24,
				bottom = 24
			};
			UpdateUI();
			_visible = !_visible;
			((Component)_canvas).gameObject.SetActive(_visible);
		}

		private GameObject CreateLine(string content, int indent = 0)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00d7: 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)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Line");
			val.transform.SetParent((Transform)(object)_panel, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			((Transform)obj).localScale = Vector3.one;
			obj.sizeDelta = new Vector2(0f, 24f);
			GameObject val2 = new GameObject("Text");
			val2.transform.SetParent(val.transform, false);
			Text obj2 = val2.AddComponent<Text>();
			obj2.font = gameFont;
			obj2.fontSize = 22;
			((Graphic)obj2).color = Color.white;
			obj2.alignment = (TextAnchor)3;
			obj2.horizontalOverflow = (HorizontalWrapMode)1;
			obj2.verticalOverflow = (VerticalWrapMode)1;
			obj2.text = content;
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(0f, 1f);
			component.pivot = new Vector2(0f, 1f);
			component.anchoredPosition = new Vector2((float)(indent * 24), 0f);
			component.sizeDelta = new Vector2(_panel.sizeDelta.x - (float)(indent * 24), 24f);
			return val;
		}

		public void UpdateUI()
		{
			//IL_0159: 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)
			foreach (KeyValuePair<string, GameObject> statLine in _statLines)
			{
				Object.Destroy((Object)(object)statLine.Value);
			}
			_statLines.Clear();
			_statLines["rating"] = CreateLine($"Map Rating: {Statistics.GetRating()}");
			foreach (KeyValuePair<string, Dictionary<EItemRarity, int>> counter in Statistics.GetCounters())
			{
				string key = counter.Key;
				Dictionary<EItemRarity, int> value = counter.Value;
				string interactableName = StatDisplayNames.GetInteractableName(key);
				if (value.Count == 1 && value.ContainsKey((EItemRarity)0))
				{
					string content = $"{interactableName}: {value[(EItemRarity)0]}";
					_statLines[key] = CreateLine(content);
					continue;
				}
				_statLines[key] = CreateLine(interactableName);
				foreach (KeyValuePair<EItemRarity, int> item in value)
				{
					string content2 = $"{StatDisplayNames.GetRarityName(key, item.Key)}: {item.Value}";
					_statLines[$"{key}_{item.Key}"] = CreateLine(content2, 1);
				}
			}
		}
	}
	public static class TextureManager
	{
		public unsafe static Texture2D Load(string resourceName)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0087: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MegabonkBetterMinimapMelonLoader.Assets.Resources.Textures." + resourceName + ".png");
			if (stream == null)
			{
				MelonLogger.Error("Embedded resource not found: " + resourceName);
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, false);
			IntPtr intPtr = MarshalledUnityObject.MarshalNotNull<Texture2D>(val);
			fixed (byte* ptr = array)
			{
				ManagedSpanWrapper val2 = default(ManagedSpanWrapper);
				((ManagedSpanWrapper)(ref val2))..ctor((void*)ptr, array.Length);
				ImageConversion.LoadImage_Injected(intPtr, ref val2, false);
			}
			return val;
		}
	}
}