Decompiled source of minimapa diman3012 v1.1.8

MIniMap.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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("MIniMap")]
[assembly: AssemblyDescription("Minimalistic Minimap mod for Lethal Company")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Diman3012")]
[assembly: AssemblyProduct("MIniMap")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4d061c1c-dea6-41cf-ac43-cd97a23e03fa")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace MIniMap;

[HarmonyPatch(typeof(ManualCameraRenderer))]
internal class ManualCameraRendererPatch
{
	private static Vector3 defaultEulerAngles = new Vector3(90f, 0f, 0f);

	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void MapCameraLogic(ref Camera ___mapCamera, ref PlayerControllerB ___targetedPlayer, ref Image ___compassRose)
	{
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: 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_00dd: 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_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		if (!MinimalMinimap.Instance.ConfigEnabled.Value || (Object)(object)___mapCamera == (Object)null)
		{
			return;
		}
		if (((Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.inShipPhase) || MinimalMinimap.Data.IsEditMode)
		{
			((Behaviour)___mapCamera).enabled = true;
		}
		if (___mapCamera.orthographicSize != MinimalMinimap.Data.Zoom)
		{
			___mapCamera.orthographicSize = MinimalMinimap.Data.Zoom;
		}
		if (MinimalMinimap.Data.AutoRotate && (Object)(object)___targetedPlayer != (Object)null)
		{
			((Component)___mapCamera).transform.eulerAngles = new Vector3(defaultEulerAngles.x, ((Component)___targetedPlayer).transform.eulerAngles.y, defaultEulerAngles.z);
		}
		else if (((Component)___mapCamera).transform.eulerAngles != defaultEulerAngles)
		{
			((Component)___mapCamera).transform.eulerAngles = defaultEulerAngles;
		}
		TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
		for (int i = 0; i < array.Length; i++)
		{
			if ((Object)(object)array[i].mapRadarObject != (Object)null)
			{
				array[i].mapRadarObject.transform.eulerAngles = new Vector3(defaultEulerAngles.x, ((Component)___mapCamera).transform.eulerAngles.y, defaultEulerAngles.z);
			}
		}
		if ((Object)(object)___compassRose != (Object)null)
		{
			((Transform)((Graphic)___compassRose).rectTransform).localEulerAngles = new Vector3(0f, 0f, ((Component)___mapCamera).transform.eulerAngles.y);
		}
	}
}
[BepInPlugin("com.diman3012.minimap", "Minimal Minimap", "1.1.6")]
public class MinimalMinimap : BaseUnityPlugin
{
	public static MinimalMinimap Instance;

	public static MinimapData Data;

	public ConfigEntry<bool> ConfigEnabled;

	public ConfigEntry<float> ConfigZoom;

	public ConfigEntry<int> ConfigSize;

	public ConfigEntry<float> ConfigXOffset;

	public ConfigEntry<float> ConfigYOffset;

	private Harmony harmony;

	private void Awake()
	{
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		Instance = this;
		Data = new MinimapData();
		ConfigEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the minimap");
		ConfigZoom = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Zoom", 20f, "Camera Orthographic Zoom ( lower = closer )");
		ConfigSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Size", 200, "Minimap UI width and height");
		ConfigXOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "XOffset", -10f, "Minimap X position offset");
		ConfigYOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "YOffset", -10f, "Minimap Y position offset");
		Data.Zoom = ConfigZoom.Value;
		Data.Size = ConfigSize.Value;
		Data.XOffset = ConfigXOffset.Value;
		Data.YOffset = ConfigYOffset.Value;
		harmony = new Harmony("com.diman3012.minimap");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Minimal Minimap (Minimal Minimap) loaded successfully!");
	}
}
public static class MyPluginInfo
{
	public const string PLUGIN_GUID = "com.diman3012.minimap";

	public const string PLUGIN_NAME = "Minimal Minimap";

	public const string PLUGIN_VERSION = "1.1.6";
}
public class MinimapData
{
	public int Size = 200;

	public float XOffset = -10f;

	public float YOffset = -10f;

	public float Zoom = 20f;

	public bool AutoRotate = true;

	public bool IsEditMode = false;

	public bool FreezeTarget = true;

	public KeyCode SwitchKey = (KeyCode)284;

	public KeyCode ToggleKey = (KeyCode)283;
}
[HarmonyPatch(typeof(NetworkManager))]
internal static class NetworkPrefabPatch
{
	[HarmonyPostfix]
	[HarmonyPatch("SetSingleton")]
	private static void RegisterPrefab()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_000e: 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)
		GameObject val = new GameObject("com.diman3012.minimap Prefab");
		((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
		Object.DontDestroyOnLoad((Object)(object)val);
		NetworkObject obj = val.AddComponent<NetworkObject>();
		FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field != null)
		{
			field.SetValue(obj, GetHash("com.diman3012.minimap"));
		}
		NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
	}

	private static uint GetHash(string value)
	{
		return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class MinimapPatch
{
	private enum ResizeCorner
	{
		None,
		TopLeft,
		TopRight,
		BottomLeft,
		BottomRight
	}

	private static GameObject minimapObject;

	private static RawImage minimapImage;

	private static GameObject zoomCardObj;

	private static RectTransform zoomCardRt;

	private static RectTransform trackRt;

	private static RectTransform fillRt;

	private static RectTransform handleRt;

	private static TextMeshProUGUI valText;

	private static float f2HoldTimer;

	private static bool f2HoldTriggered;

	private static bool wasEditMode;

	private static bool isDraggingMap;

	private static bool isResizingMap;

	private static bool isDraggingSlider;

	private static ResizeCorner activeCorner;

	private static bool tooltipInitialized;

	private static float originalTooltipY;

	private static bool allowOneUpdate;

	private static Sprite CreateRoundedSprite(int width, int height, int radius, Color color)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < height; i++)
		{
			for (int j = 0; j < width; j++)
			{
				float num = ((j < radius) ? (radius - j) : ((j >= width - radius) ? (j - (width - radius - 1)) : 0));
				float num2 = ((i < radius) ? (radius - i) : ((i >= height - radius) ? (i - (height - radius - 1)) : 0));
				float num3 = num * num + num2 * num2;
				if (num3 > (float)(radius * radius))
				{
					array[i * width + j] = Color.clear;
				}
				else
				{
					array[i * width + j] = color;
				}
			}
		}
		val.SetPixels(array);
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f));
	}

	[HarmonyPatch("ConnectClientToPlayerObject")]
	[HarmonyPostfix]
	private static void CreateMinimap()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)minimapObject != (Object)null))
		{
			minimapObject = new GameObject("MIniMap_UI");
			minimapImage = minimapObject.AddComponent<RawImage>();
			((Graphic)minimapImage).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)minimapImage).rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(1f, 1f);
			rectTransform.sizeDelta = new Vector2((float)MinimalMinimap.Data.Size, (float)MinimalMinimap.Data.Size);
			rectTransform.anchoredPosition = new Vector2(MinimalMinimap.Data.XOffset, MinimalMinimap.Data.YOffset);
			minimapObject.transform.SetParent(((Component)HUDManager.Instance.playerScreenTexture).transform, false);
			CreateCubeXZoomUI();
			UpdateMinimapVisibility();
		}
	}

	private static void CreateCubeXZoomUI()
	{
		//IL_0059: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_010c: Expected O, but got Unknown
		//IL_0145: 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_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Expected O, but got Unknown
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Expected O, but got Unknown
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Expected O, but got Unknown
		//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0416: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Expected O, but got Unknown
		//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0503: Unknown result type (might be due to invalid IL or missing references)
		//IL_051d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0551: Unknown result type (might be due to invalid IL or missing references)
		//IL_0558: Expected O, but got Unknown
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Expected O, but got Unknown
		//IL_0684: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_070f: Unknown result type (might be due to invalid IL or missing references)
		TMP_FontAsset val = (((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.controlTipLines != null && HUDManager.Instance.controlTipLines.Length != 0) ? ((TMP_Text)HUDManager.Instance.controlTipLines[0]).font : null);
		Sprite sprite = CreateRoundedSprite(120, 240, 12, new Color(0.094f, 0.106f, 0.157f, 0.95f));
		Sprite sprite2 = CreateRoundedSprite(24, 180, 12, new Color(0.063f, 0.071f, 0.102f, 1f));
		Sprite sprite3 = CreateRoundedSprite(24, 180, 12, new Color(0.529f, 0.761f, 1f, 1f));
		Sprite sprite4 = CreateRoundedSprite(32, 16, 6, new Color(1f, 1f, 1f, 1f));
		Sprite sprite5 = CreateRoundedSprite(100, 4, 2, new Color(0.282f, 0.549f, 0.941f, 1f));
		zoomCardObj = new GameObject("CUBEX_Zoom_Card");
		zoomCardObj.transform.SetParent(minimapObject.transform, false);
		zoomCardRt = zoomCardObj.AddComponent<RectTransform>();
		zoomCardRt.anchorMin = new Vector2(0f, 0.5f);
		zoomCardRt.anchorMax = new Vector2(0f, 0.5f);
		zoomCardRt.pivot = new Vector2(1f, 0.5f);
		zoomCardRt.sizeDelta = new Vector2(54f, 210f);
		zoomCardRt.anchoredPosition = new Vector2(-10f, 0f);
		Image val2 = zoomCardObj.AddComponent<Image>();
		val2.sprite = sprite;
		val2.type = (Type)1;
		((Graphic)val2).raycastTarget = false;
		GameObject val3 = new GameObject("Title");
		val3.transform.SetParent(zoomCardObj.transform, false);
		TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)val != (Object)null)
		{
			((TMP_Text)val4).font = val;
		}
		((TMP_Text)val4).text = "Zoom";
		((TMP_Text)val4).fontSize = 13f;
		((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
		((Graphic)val4).color = new Color(0.353f, 0.635f, 1f, 1f);
		((TMP_Text)val4).fontStyle = (FontStyles)1;
		((Graphic)val4).raycastTarget = false;
		RectTransform rectTransform = ((TMP_Text)val4).rectTransform;
		rectTransform.anchorMin = new Vector2(0f, 1f);
		rectTransform.anchorMax = new Vector2(1f, 1f);
		rectTransform.pivot = new Vector2(0.5f, 1f);
		rectTransform.anchoredPosition = new Vector2(0f, -6f);
		rectTransform.sizeDelta = new Vector2(0f, 18f);
		GameObject val5 = new GameObject("Divider");
		val5.transform.SetParent(zoomCardObj.transform, false);
		Image val6 = val5.AddComponent<Image>();
		val6.sprite = sprite5;
		val6.type = (Type)1;
		((Graphic)val6).raycastTarget = false;
		RectTransform component = val5.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.1f, 1f);
		component.anchorMax = new Vector2(0.9f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(0f, -26f);
		component.sizeDelta = new Vector2(0f, 3f);
		GameObject val7 = new GameObject("Track");
		val7.transform.SetParent(zoomCardObj.transform, false);
		trackRt = val7.AddComponent<RectTransform>();
		trackRt.anchorMin = new Vector2(0.5f, 0.5f);
		trackRt.anchorMax = new Vector2(0.5f, 0.5f);
		trackRt.pivot = new Vector2(0.5f, 0.5f);
		trackRt.sizeDelta = new Vector2(16f, 135f);
		trackRt.anchoredPosition = new Vector2(0f, -5f);
		Image val8 = val7.AddComponent<Image>();
		val8.sprite = sprite2;
		val8.type = (Type)1;
		((Graphic)val8).raycastTarget = false;
		GameObject val9 = new GameObject("Fill");
		val9.transform.SetParent(val7.transform, false);
		fillRt = val9.AddComponent<RectTransform>();
		fillRt.anchorMin = new Vector2(0f, 0f);
		fillRt.anchorMax = new Vector2(1f, 0f);
		fillRt.pivot = new Vector2(0.5f, 0f);
		fillRt.sizeDelta = new Vector2(0f, 0f);
		Image val10 = val9.AddComponent<Image>();
		val10.sprite = sprite3;
		val10.type = (Type)1;
		((Graphic)val10).raycastTarget = false;
		GameObject val11 = new GameObject("Handle");
		val11.transform.SetParent(val7.transform, false);
		handleRt = val11.AddComponent<RectTransform>();
		handleRt.anchorMin = new Vector2(0.5f, 0f);
		handleRt.anchorMax = new Vector2(0.5f, 0f);
		handleRt.pivot = new Vector2(0.5f, 0.5f);
		handleRt.sizeDelta = new Vector2(24f, 10f);
		Image val12 = val11.AddComponent<Image>();
		val12.sprite = sprite4;
		val12.type = (Type)1;
		((Graphic)val12).raycastTarget = false;
		GameObject val13 = new GameObject("ValueText");
		val13.transform.SetParent(zoomCardObj.transform, false);
		valText = val13.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)val != (Object)null)
		{
			((TMP_Text)valText).font = val;
		}
		((TMP_Text)valText).text = "20m";
		((TMP_Text)valText).fontSize = 10f;
		((TMP_Text)valText).alignment = (TextAlignmentOptions)514;
		((Graphic)valText).color = Color.white;
		((Graphic)valText).raycastTarget = false;
		RectTransform rectTransform2 = ((TMP_Text)valText).rectTransform;
		rectTransform2.anchorMin = new Vector2(0f, 0f);
		rectTransform2.anchorMax = new Vector2(1f, 0f);
		rectTransform2.pivot = new Vector2(0.5f, 0f);
		rectTransform2.anchoredPosition = new Vector2(0f, 4f);
		rectTransform2.sizeDelta = new Vector2(0f, 14f);
		zoomCardObj.SetActive(false);
	}

	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void HandleHotkeys(PlayerControllerB __instance)
	{
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_057c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: 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_05cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_065f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0667: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_064a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_062e: Unknown result type (might be due to invalid IL or missing references)
		//IL_067c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0683: Unknown result type (might be due to invalid IL or missing references)
		//IL_069a: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0727: Unknown result type (might be due to invalid IL or missing references)
		//IL_072c: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0706: Unknown result type (might be due to invalid IL or missing references)
		//IL_070b: Unknown result type (might be due to invalid IL or missing references)
		//IL_073c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0748: Unknown result type (might be due to invalid IL or missing references)
		//IL_074d: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)__instance).IsOwner || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || (!__instance.isPlayerControlled && !__instance.isPlayerDead))
		{
			return;
		}
		bool flag = __instance.isTypingChat || __instance.inTerminalMenu;
		if (Keyboard.current != null && ((ButtonControl)Keyboard.current[(Key)95]).isPressed && !flag)
		{
			f2HoldTimer += Time.deltaTime;
			if (f2HoldTimer >= 1f && !f2HoldTriggered)
			{
				f2HoldTriggered = true;
				MinimalMinimap.Data.IsEditMode = !MinimalMinimap.Data.IsEditMode;
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.DisplayTip("Minimap Edit Mode", MinimalMinimap.Data.IsEditMode ? "ON: Drag, Resize & CUBE-X Zoom" : "OFF", false, false, "LC_Tip1");
				}
			}
		}
		if (Keyboard.current != null && ((ButtonControl)Keyboard.current[(Key)95]).wasReleasedThisFrame && !flag)
		{
			if (!f2HoldTriggered)
			{
				bool value = !MinimalMinimap.Instance.ConfigEnabled.Value;
				MinimalMinimap.Instance.ConfigEnabled.Value = value;
			}
			f2HoldTriggered = false;
			f2HoldTimer = 0f;
		}
		UpdateMinimapVisibility();
		if (MinimalMinimap.Data.IsEditMode != wasEditMode)
		{
			wasEditMode = MinimalMinimap.Data.IsEditMode;
			if (!wasEditMode)
			{
				__instance.disableLookInput = false;
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
				if ((Object)(object)minimapImage != (Object)null)
				{
					MinimalMinimap.Data.XOffset = ((Graphic)minimapImage).rectTransform.anchoredPosition.x;
					MinimalMinimap.Data.YOffset = ((Graphic)minimapImage).rectTransform.anchoredPosition.y;
					MinimalMinimap.Data.Size = Mathf.RoundToInt(((Graphic)minimapImage).rectTransform.sizeDelta.x);
					MinimalMinimap.Instance.ConfigXOffset.Value = MinimalMinimap.Data.XOffset;
					MinimalMinimap.Instance.ConfigYOffset.Value = MinimalMinimap.Data.YOffset;
					MinimalMinimap.Instance.ConfigSize.Value = MinimalMinimap.Data.Size;
					MinimalMinimap.Instance.ConfigZoom.Value = MinimalMinimap.Data.Zoom;
					((BaseUnityPlugin)MinimalMinimap.Instance).Config.Save();
				}
			}
		}
		if (MinimalMinimap.Data.IsEditMode && (Object)(object)minimapObject != (Object)null && (Object)(object)minimapImage != (Object)null && Mouse.current != null)
		{
			__instance.disableLookInput = true;
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			RectTransform rectTransform = ((Graphic)minimapImage).rectTransform;
			Canvas canvas = ((Graphic)minimapImage).canvas;
			Camera val = (((Object)(object)canvas != (Object)null && (int)canvas.renderMode != 0) ? canvas.worldCamera : null);
			Vector2 val2 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			Vector2 val3 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).delta).ReadValue();
			float num = (((Object)(object)canvas != (Object)null && canvas.scaleFactor > 0f) ? canvas.scaleFactor : 1f);
			UpdateCubeXSliderVisuals();
			Rect rect;
			if (Mouse.current.leftButton.wasPressedThisFrame)
			{
				if ((Object)(object)zoomCardRt != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(zoomCardRt, val2, val))
				{
					isDraggingSlider = true;
					isDraggingMap = false;
					isResizingMap = false;
				}
				else if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, val2, val))
				{
					Vector2 val4 = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val2, val, ref val4);
					float num2 = 35f;
					float x = val4.x;
					rect = rectTransform.rect;
					bool flag2 = x < ((Rect)(ref rect)).xMin + num2;
					float x2 = val4.x;
					rect = rectTransform.rect;
					bool flag3 = x2 > ((Rect)(ref rect)).xMax - num2;
					float y = val4.y;
					rect = rectTransform.rect;
					bool flag4 = y < ((Rect)(ref rect)).yMin + num2;
					float y2 = val4.y;
					rect = rectTransform.rect;
					bool flag5 = y2 > ((Rect)(ref rect)).yMax - num2;
					if (flag5 && flag2)
					{
						activeCorner = ResizeCorner.TopLeft;
					}
					else if (flag5 && flag3)
					{
						activeCorner = ResizeCorner.TopRight;
					}
					else if (flag4 && flag2)
					{
						activeCorner = ResizeCorner.BottomLeft;
					}
					else if (flag4 && flag3)
					{
						activeCorner = ResizeCorner.BottomRight;
					}
					else
					{
						activeCorner = ResizeCorner.None;
					}
					if (activeCorner != ResizeCorner.None)
					{
						isResizingMap = true;
						isDraggingMap = false;
					}
					else
					{
						isDraggingMap = true;
						isResizingMap = false;
					}
					isDraggingSlider = false;
				}
			}
			if (Mouse.current.leftButton.isPressed)
			{
				if (isDraggingSlider && (Object)(object)trackRt != (Object)null)
				{
					Vector2 val5 = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(trackRt, val2, val, ref val5);
					rect = trackRt.rect;
					float height = ((Rect)(ref rect)).height;
					float num3 = (0f - height) / 2f;
					float num4 = height / 2f;
					float num5 = Mathf.Clamp(val5.y, num3, num4);
					float num6 = Mathf.InverseLerp(num3, num4, num5);
					MinimalMinimap.Data.Zoom = Mathf.Lerp(60f, 5f, num6);
				}
				else if (isDraggingMap)
				{
					rectTransform.anchoredPosition += val3 / num;
				}
				else if (isResizingMap)
				{
					float num7 = 0f;
					switch (activeCorner)
					{
					case ResizeCorner.BottomLeft:
						num7 = (0f - val3.x - val3.y) / 2f / num;
						break;
					case ResizeCorner.TopRight:
						num7 = (val3.x + val3.y) / 2f / num;
						break;
					case ResizeCorner.TopLeft:
						num7 = (0f - val3.x + val3.y) / 2f / num;
						break;
					case ResizeCorner.BottomRight:
						num7 = (val3.x - val3.y) / 2f / num;
						break;
					}
					float x3 = rectTransform.sizeDelta.x;
					float num8 = Mathf.Clamp(x3 + num7, 50f, 800f);
					float num9 = num8 - x3;
					rectTransform.sizeDelta = new Vector2(num8, num8);
					switch (activeCorner)
					{
					case ResizeCorner.TopRight:
						rectTransform.anchoredPosition += new Vector2(num9, num9);
						break;
					case ResizeCorner.TopLeft:
						rectTransform.anchoredPosition += new Vector2(0f, num9);
						break;
					case ResizeCorner.BottomRight:
						rectTransform.anchoredPosition += new Vector2(num9, 0f);
						break;
					}
				}
			}
			if (Mouse.current.leftButton.wasReleasedThisFrame)
			{
				isDraggingMap = false;
				isResizingMap = false;
				isDraggingSlider = false;
				activeCorner = ResizeCorner.None;
			}
		}
		if ((Object)(object)minimapObject != (Object)null && minimapObject.activeSelf)
		{
			if (UnityInput.Current.GetKeyDown(MinimalMinimap.Data.SwitchKey) && !flag)
			{
				SwitchTarget();
			}
			if (__instance.isPlayerDead)
			{
				if (MinimalMinimap.Data.FreezeTarget)
				{
					MinimalMinimap.Data.FreezeTarget = false;
				}
				if ((Object)(object)__instance.spectatedPlayerScript != (Object)null)
				{
					SetMapTargetToPlayer(__instance.spectatedPlayerScript);
				}
			}
			else if (!MinimalMinimap.Data.FreezeTarget)
			{
				MinimalMinimap.Data.FreezeTarget = true;
				SetMapTargetToPlayer(__instance);
			}
		}
		HandleTooltipOverlap();
	}

	private static void UpdateCubeXSliderVisuals()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)trackRt == (Object)null) && !((Object)(object)fillRt == (Object)null) && !((Object)(object)handleRt == (Object)null))
		{
			Rect rect = trackRt.rect;
			float height = ((Rect)(ref rect)).height;
			float num = Mathf.InverseLerp(60f, 5f, MinimalMinimap.Data.Zoom);
			fillRt.sizeDelta = new Vector2(0f, num * height);
			handleRt.anchoredPosition = new Vector2(0f, num * height);
			if ((Object)(object)valText != (Object)null)
			{
				((TMP_Text)valText).text = $"{Mathf.RoundToInt(MinimalMinimap.Data.Zoom)}m";
			}
		}
	}

	private static void UpdateMinimapVisibility()
	{
		if ((Object)(object)minimapObject == (Object)null)
		{
			return;
		}
		bool flag = (Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.inShipPhase;
		bool flag2 = MinimalMinimap.Data.IsEditMode || (MinimalMinimap.Instance.ConfigEnabled.Value && flag);
		if (minimapObject.activeSelf != flag2)
		{
			minimapObject.SetActive(flag2);
		}
		if ((Object)(object)zoomCardObj != (Object)null)
		{
			zoomCardObj.SetActive(MinimalMinimap.Data.IsEditMode);
		}
		if (flag2 && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.mapScreen != (Object)null && (Object)(object)StartOfRound.Instance.mapScreen.cam != (Object)null)
		{
			Texture targetTexture = (Texture)(object)StartOfRound.Instance.mapScreen.cam.targetTexture;
			if ((Object)(object)minimapImage.texture != (Object)(object)targetTexture && (Object)(object)targetTexture != (Object)null)
			{
				minimapImage.texture = targetTexture;
			}
		}
	}

	private static void HandleTooltipOverlap()
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)HUDManager.Instance == (Object)null || HUDManager.Instance.controlTipLines == null || HUDManager.Instance.controlTipLines.Length == 0)
		{
			return;
		}
		TextMeshProUGUI val = HUDManager.Instance.controlTipLines[0];
		if ((Object)(object)val == (Object)null || (Object)(object)((TMP_Text)val).transform.parent == (Object)null)
		{
			return;
		}
		RectTransform component = ((Component)((TMP_Text)val).transform.parent).GetComponent<RectTransform>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		if (!tooltipInitialized)
		{
			originalTooltipY = component.anchoredPosition.y;
			tooltipInitialized = true;
		}
		float x = component.anchoredPosition.x;
		if ((Object)(object)minimapObject == (Object)null || !minimapObject.activeSelf)
		{
			if (component.anchoredPosition.y != originalTooltipY)
			{
				component.anchoredPosition = new Vector2(x, originalTooltipY);
			}
			return;
		}
		Bounds val2 = RectTransformUtility.CalculateRelativeRectTransformBounds(((Transform)component).parent, (Transform)(object)((Graphic)minimapImage).rectTransform);
		float num = float.MaxValue;
		float num2 = float.MinValue;
		float num3 = float.MaxValue;
		float num4 = float.MinValue;
		bool flag = false;
		TextMeshProUGUI[] controlTipLines = HUDManager.Instance.controlTipLines;
		foreach (TextMeshProUGUI val3 in controlTipLines)
		{
			if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy && !string.IsNullOrEmpty(((TMP_Text)val3).text))
			{
				Bounds val4 = RectTransformUtility.CalculateRelativeRectTransformBounds(((Transform)component).parent, (Transform)(object)((TMP_Text)val3).rectTransform);
				float num5 = ((Bounds)(ref val4)).max.x - ((TMP_Text)val3).preferredWidth;
				float x2 = ((Bounds)(ref val4)).max.x;
				if (num5 < num)
				{
					num = num5;
				}
				if (x2 > num2)
				{
					num2 = x2;
				}
				if (((Bounds)(ref val4)).min.y < num3)
				{
					num3 = ((Bounds)(ref val4)).min.y;
				}
				if (((Bounds)(ref val4)).max.y > num4)
				{
					num4 = ((Bounds)(ref val4)).max.y;
				}
				flag = true;
			}
		}
		if (flag)
		{
			float num6 = component.anchoredPosition.y - originalTooltipY;
			float num7 = num3 - num6;
			float num8 = num4 - num6;
			if (((Bounds)(ref val2)).min.x < num2 && ((Bounds)(ref val2)).max.x > num && ((Bounds)(ref val2)).min.y < num8 && ((Bounds)(ref val2)).max.y > num7)
			{
				float num9 = ((Bounds)(ref val2)).min.y - 10f;
				float num10 = num8 - num9;
				component.anchoredPosition = new Vector2(x, originalTooltipY - num10);
			}
			else if (component.anchoredPosition.y != originalTooltipY)
			{
				component.anchoredPosition = new Vector2(x, originalTooltipY);
			}
		}
	}

	private static void SetMapTargetToPlayer(PlayerControllerB target)
	{
		ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
		if ((Object)(object)mapScreen == (Object)null || (Object)(object)target == (Object)null || (Object)(object)mapScreen.targetedPlayer == (Object)(object)target)
		{
			return;
		}
		for (int i = 0; i < mapScreen.radarTargets.Count; i++)
		{
			TransformAndName val = mapScreen.radarTargets[i];
			if (val != null && (Object)(object)val.transform != (Object)null && (Object)(object)((Component)val.transform).GetComponent<PlayerControllerB>() == (Object)(object)target)
			{
				mapScreen.targetTransformIndex = i;
				mapScreen.targetedPlayer = target;
				break;
			}
		}
	}

	private static void SwitchTarget()
	{
		ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
		if ((Object)(object)mapScreen == (Object)null || mapScreen.radarTargets == null || mapScreen.radarTargets.Count == 0)
		{
			return;
		}
		int count = mapScreen.radarTargets.Count;
		int num = mapScreen.targetTransformIndex;
		for (int i = 0; i < count; i++)
		{
			num = (num + 1) % count;
			TransformAndName val = mapScreen.radarTargets[num];
			if (val != null && !((Object)(object)val.transform == (Object)null))
			{
				PlayerControllerB component = ((Component)val.transform).GetComponent<PlayerControllerB>();
				if (!((Object)(object)component == (Object)null) && (component.isPlayerControlled || component.isPlayerDead))
				{
					mapScreen.targetTransformIndex = num;
					mapScreen.targetedPlayer = component;
					break;
				}
			}
		}
	}

	[HarmonyPatch(typeof(ManualCameraRenderer), "updateMapTarget")]
	[HarmonyPrefix]
	private static bool PreventAutoUpdate()
	{
		if (allowOneUpdate)
		{
			allowOneUpdate = false;
			return true;
		}
		return !MinimalMinimap.Data.FreezeTarget;
	}

	[HarmonyPatch(typeof(ManualCameraRenderer), "SwitchRadarTargetForward")]
	[HarmonyPrefix]
	private static bool BlockOriginalSwitch()
	{
		SwitchTarget();
		return false;
	}
}