Decompiled source of Minimap Buzzers v1.0.8

LethalCompanyMinimap.dll

Decompiled 12 hours 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyMinimap.Component;
using LethalCompanyMinimap.Patches;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LethalCompanyMinimap")]
[assembly: AssemblyDescription("A Minimap mod for Lethal Company")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tyzeron")]
[assembly: AssemblyProduct("LethalCompanyMinimap")]
[assembly: AssemblyCopyright("Copyright © Tyzeron 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("64cfb19d-f865-41f9-9d7d-f591e1f0435a")]
[assembly: AssemblyFileVersion("1.0.6")]
[assembly: AssemblyInformationalVersion("1.0.6")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.6.0")]
namespace LethalCompanyMinimap
{
	public class ModUser
	{
		public string Version { get; set; }

		public bool Comply { get; set; }

		public ModUser(string version = null, bool comply = false)
		{
			Version = version;
			Comply = comply;
		}
	}
	public enum SyncSettingsAction
	{
		AlwaysAsk,
		Allow,
		Deny
	}
	public enum SettingAsHostAction
	{
		DontSync,
		SyncIcons
	}
	public class HostSettingsToSync
	{
		public bool ShowLoots { get; set; }

		public bool ShowEnemies { get; set; }

		public bool ShowLivePlayers { get; set; }

		public bool ShowDeadPlayers { get; set; }

		public bool ShowRadarBoosters { get; set; }

		public bool ShowTerminalCodes { get; set; }

		public HostSettingsToSync()
		{
			ShowLoots = true;
			ShowEnemies = true;
			ShowLivePlayers = true;
			ShowDeadPlayers = true;
			ShowRadarBoosters = true;
			ShowTerminalCodes = true;
		}

		public void Sync()
		{
			MinimapMod.minimapGUI.showLoots = ShowLoots;
			MinimapMod.minimapGUI.showEnemies = ShowEnemies;
			MinimapMod.minimapGUI.showLivePlayers = ShowLivePlayers;
			MinimapMod.minimapGUI.showDeadPlayers = ShowDeadPlayers;
			MinimapMod.minimapGUI.showRadarBoosters = ShowRadarBoosters;
			MinimapMod.minimapGUI.showTerminalCodes = ShowTerminalCodes;
		}

		public bool IsSync()
		{
			if (MinimapMod.minimapGUI.showLoots == ShowLoots && MinimapMod.minimapGUI.showEnemies == ShowEnemies && MinimapMod.minimapGUI.showLivePlayers == ShowLivePlayers && MinimapMod.minimapGUI.showDeadPlayers == ShowDeadPlayers && MinimapMod.minimapGUI.showRadarBoosters == ShowRadarBoosters)
			{
				return MinimapMod.minimapGUI.showTerminalCodes == ShowTerminalCodes;
			}
			return false;
		}

		public static HostSettingsToSync Parse(string data)
		{
			if (string.IsNullOrEmpty(data))
			{
				return null;
			}
			string[] array = data.Split(new char[1] { ';' });
			if (array.Length != 6)
			{
				return null;
			}
			HostSettingsToSync hostSettingsToSync = new HostSettingsToSync();
			HashSet<string> hashSet = new HashSet<string> { "loots", "enemies", "livePlayers", "deadPlayers", "radarBoosters", "terminalCodes" };
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string[] array3 = array2[i].Split(new char[1] { '=' });
				if (array3.Length != 2)
				{
					return null;
				}
				string text = array3[0].Trim();
				string text2 = array3[1].Trim();
				if (!hashSet.Remove(text))
				{
					return null;
				}
				bool flag;
				if (text2 == "show")
				{
					flag = true;
				}
				else
				{
					if (!(text2 == "hide"))
					{
						return null;
					}
					flag = false;
				}
				switch (text)
				{
				case "loots":
					hostSettingsToSync.ShowLoots = flag;
					break;
				case "enemies":
					hostSettingsToSync.ShowEnemies = flag;
					break;
				case "livePlayers":
					hostSettingsToSync.ShowLivePlayers = flag;
					break;
				case "deadPlayers":
					hostSettingsToSync.ShowDeadPlayers = flag;
					break;
				case "radarBoosters":
					hostSettingsToSync.ShowRadarBoosters = flag;
					break;
				case "terminalCodes":
					hostSettingsToSync.ShowTerminalCodes = flag;
					break;
				default:
					return null;
				}
			}
			if (hashSet.Count > 0)
			{
				return null;
			}
			return hostSettingsToSync;
		}
	}
	public enum MouseAndKeyboard
	{
		MouseLeft = -1,
		MouseMiddle = -2,
		MouseRight = -3,
		MouseForward = -4,
		MouseBack = -5,
		None = 0,
		Space = 1,
		Enter = 2,
		Tab = 3,
		Backquote = 4,
		Quote = 5,
		Semicolon = 6,
		Comma = 7,
		Period = 8,
		Slash = 9,
		Backslash = 10,
		LeftBracket = 11,
		RightBracket = 12,
		Minus = 13,
		Equals = 14,
		A = 15,
		B = 16,
		C = 17,
		D = 18,
		E = 19,
		F = 20,
		G = 21,
		H = 22,
		I = 23,
		J = 24,
		K = 25,
		L = 26,
		M = 27,
		N = 28,
		O = 29,
		P = 30,
		Q = 31,
		R = 32,
		S = 33,
		T = 34,
		U = 35,
		V = 36,
		W = 37,
		X = 38,
		Y = 39,
		Z = 40,
		Digit1 = 41,
		Digit2 = 42,
		Digit3 = 43,
		Digit4 = 44,
		Digit5 = 45,
		Digit6 = 46,
		Digit7 = 47,
		Digit8 = 48,
		Digit9 = 49,
		Digit0 = 50,
		LeftShift = 51,
		RightShift = 52,
		LeftAlt = 53,
		RightAlt = 54,
		AltGr = 54,
		LeftCtrl = 55,
		RightCtrl = 56,
		LeftMeta = 57,
		RightMeta = 58,
		LeftWindows = 57,
		RightWindows = 58,
		LeftApple = 57,
		RightApple = 58,
		LeftCommand = 57,
		RightCommand = 58,
		ContextMenu = 59,
		Escape = 60,
		LeftArrow = 61,
		RightArrow = 62,
		UpArrow = 63,
		DownArrow = 64,
		Backspace = 65,
		PageDown = 66,
		PageUp = 67,
		Home = 68,
		End = 69,
		Insert = 70,
		Delete = 71,
		CapsLock = 72,
		NumLock = 73,
		PrintScreen = 74,
		ScrollLock = 75,
		Pause = 76,
		NumpadEnter = 77,
		NumpadDivide = 78,
		NumpadMultiply = 79,
		NumpadPlus = 80,
		NumpadMinus = 81,
		NumpadPeriod = 82,
		NumpadEquals = 83,
		Numpad0 = 84,
		Numpad1 = 85,
		Numpad2 = 86,
		Numpad3 = 87,
		Numpad4 = 88,
		Numpad5 = 89,
		Numpad6 = 90,
		Numpad7 = 91,
		Numpad8 = 92,
		Numpad9 = 93,
		F1 = 94,
		F2 = 95,
		F3 = 96,
		F4 = 97,
		F5 = 98,
		F6 = 99,
		F7 = 100,
		F8 = 101,
		F9 = 102,
		F10 = 103,
		F11 = 104,
		F12 = 105,
		OEM1 = 106,
		OEM2 = 107,
		OEM3 = 108,
		OEM4 = 109,
		OEM5 = 110,
		IMESelected = 111
	}
	public class ModHotkey
	{
		public MouseAndKeyboard DefaultKey { get; set; }

		public MouseAndKeyboard Key { get; set; }

		public bool KeyWasDown { get; set; }

		public bool IsSettingKey { get; set; }

		public Action OnKey { get; set; }

		public ModHotkey(MouseAndKeyboard defaultKey, Action onKey)
		{
			DefaultKey = defaultKey;
			Key = defaultKey;
			KeyWasDown = false;
			IsSettingKey = false;
			OnKey = onKey;
		}

		public void Update()
		{
			Mouse current = Mouse.current;
			Keyboard current2 = Keyboard.current;
			if (current != null && current2 != null)
			{
				ButtonControl val = (ButtonControl)(Key switch
				{
					MouseAndKeyboard.MouseLeft => current.leftButton, 
					MouseAndKeyboard.MouseMiddle => current.middleButton, 
					MouseAndKeyboard.MouseRight => current.rightButton, 
					MouseAndKeyboard.MouseForward => current.forwardButton, 
					MouseAndKeyboard.MouseBack => current.backButton, 
					_ => current2[(Key)Key], 
				});
				if (val.wasPressedThisFrame && !KeyWasDown && !IsSettingKey)
				{
					KeyWasDown = true;
				}
				if (val.wasReleasedThisFrame && KeyWasDown)
				{
					KeyWasDown = false;
					OnKey?.Invoke();
				}
			}
		}
	}
	public class HotkeyManager
	{
		public ModHotkey[] AllHotkeys;

		public HotkeyManager(int numberOfHotkeys)
		{
			AllHotkeys = new ModHotkey[numberOfHotkeys];
		}

		public bool AnyHotkeyIsSettingKey()
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			for (int i = 0; i < allHotkeys.Length; i++)
			{
				if (allHotkeys[i].IsSettingKey)
				{
					return true;
				}
			}
			return false;
		}

		private static MouseAndKeyboard ConvertToExtendedKey(Key key)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (MouseAndKeyboard value in Enum.GetValues(typeof(MouseAndKeyboard)))
			{
				if (Enum.GetName(typeof(Key), key) == Enum.GetName(typeof(MouseAndKeyboard), value))
				{
					return value;
				}
			}
			return MouseAndKeyboard.None;
		}

		public bool SetHotKey(Key key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			MouseAndKeyboard hotKey = ConvertToExtendedKey(key);
			return SetHotKey(hotKey);
		}

		public bool SetHotKey(MouseAndKeyboard key)
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			foreach (ModHotkey modHotkey in allHotkeys)
			{
				if (modHotkey.IsSettingKey)
				{
					modHotkey.Key = key;
					ResetIsSettingKey();
					return true;
				}
			}
			return false;
		}

		public void ResetIsSettingKey()
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			for (int i = 0; i < allHotkeys.Length; i++)
			{
				allHotkeys[i].IsSettingKey = false;
			}
		}

		public void ResetSettingKey()
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			for (int i = 0; i < allHotkeys.Length; i++)
			{
				allHotkeys[i].IsSettingKey = false;
			}
		}

		public void ResetToDefaultKey()
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			foreach (ModHotkey obj in allHotkeys)
			{
				obj.Key = obj.DefaultKey;
			}
		}

		public void Update()
		{
			ModHotkey[] allHotkeys = AllHotkeys;
			for (int i = 0; i < allHotkeys.Length; i++)
			{
				allHotkeys[i].Update();
			}
		}
	}
	[BepInPlugin("LethalCompanyMinimap", "Minimap", "1.0.8")]
	public class MinimapMod : BaseUnityPlugin
	{
		public const string modGUID = "LethalCompanyMinimap";

		public const string modName = "Minimap";

		public const string modVersion = "1.0.8";

		public const string modAuthor = "BennyTheBee";

		public static MouseAndKeyboard defaultGuiKey = MouseAndKeyboard.F1;

		public static MouseAndKeyboard defaultToggleMinimapKey = MouseAndKeyboard.F2;

		public static MouseAndKeyboard defaultToggleOverrideKey = MouseAndKeyboard.F3;

		public static MouseAndKeyboard defaultSwitchTargetKey = MouseAndKeyboard.F4;

		public const int defaultMinimapSize = 200;

		public const float defaultXoffset = 0f;

		public const float defaultYoffset = 0f;

		public const float defaultMapZoom = 19.7f;

		public const float defaultBrightness = 0f;

		private static ConfigEntry<MouseAndKeyboard> guiKeyConfig;

		private static ConfigEntry<MouseAndKeyboard> toggleMinimapKeyConfig;

		private static ConfigEntry<MouseAndKeyboard> toggleOverrideKeyConfig;

		private static ConfigEntry<MouseAndKeyboard> switchTargetKeyConfig;

		private static ConfigEntry<bool> enableMinimapConfig;

		private static ConfigEntry<bool> autoRotateConfig;

		private static ConfigEntry<int> minimapSizeConfig;

		private static ConfigEntry<float> minimapXPosConfig;

		private static ConfigEntry<float> minimapYPosConfig;

		private static ConfigEntry<float> minimapZoomConfig;

		private static ConfigEntry<float> brightnessConfig;

		private static ConfigEntry<bool> showLootsConfig;

		private static ConfigEntry<bool> showEnemiesConfig;

		private static ConfigEntry<bool> showTurretsConfig;

		private static ConfigEntry<bool> showLivePlayersConfig;

		private static ConfigEntry<bool> showDeadPlayersConfig;

		private static ConfigEntry<bool> showRadarBoostersConfig;

		private static ConfigEntry<bool> showTerminalCodesConfig;

		private static ConfigEntry<bool> showShipArrowConfig;

		private static ConfigEntry<bool> showCompassConfig;

		private static ConfigEntry<bool> showHeadCamConfig;

		private static ConfigEntry<bool> freezePlayerIndexConfig;

		public static ConfigEntry<bool> hostOverrideActive;

		public static MinimapMod Instance;

		public static ManualLogSource mls;

		private readonly Harmony harmony = new Harmony("LethalCompanyMinimap");

		public static MinimapGUI minimapGUI;

		public static ConfigFile Config;

		private void Awake()
		{
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Config = ((BaseUnityPlugin)this).Config;
			mls = Logger.CreateLogSource("LethalCompanyMinimap");
			mls.LogInfo((object)"Minimap 1.0.8 loaded!");
			harmony.PatchAll(typeof(ManualCameraRendererPatch));
			harmony.PatchAll(typeof(QuickMenuManagerPatch));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(TerminalAccessibleObjectPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(RadarBoosterItemPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(TimeOfDayPatch));
			harmony.PatchAll(typeof(DeadBodyInfoPatch));
			harmony.PatchAll(typeof(TurretPatch));
			GameObject val = new GameObject("MinimapGUI");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<MinimapGUI>();
			minimapGUI = (MinimapGUI)(object)val.GetComponent("MinimapGUI");
			SetBindings();
			SyncGUIFromConfigs();
		}

		private void SetBindings()
		{
			guiKeyConfig = Config.Bind<MouseAndKeyboard>("Hotkeys", "Open Mod Menu", defaultGuiKey, "Hotkey to open the Minimap mod menu");
			toggleMinimapKeyConfig = Config.Bind<MouseAndKeyboard>("Hotkeys", "Toggle Minimap", defaultToggleMinimapKey, "Hotkey to toggle the visibility of your Minimap");
			toggleOverrideKeyConfig = Config.Bind<MouseAndKeyboard>("Hotkeys", "Toggle Override Ship", defaultToggleOverrideKey, "Hotkey to toggle the override ship controls");
			switchTargetKeyConfig = Config.Bind<MouseAndKeyboard>("Hotkeys", "Switch Minimap Focus", defaultSwitchTargetKey, "Hotkey to switch the Minimap focus");
			enableMinimapConfig = Config.Bind<bool>("Basic Settings", "Enable Minimap", true, "Toggles visibility of your Minimap");
			autoRotateConfig = Config.Bind<bool>("Basic Settings", "Auto Rotate", true, "Auto-rotate the Map based on where you are facing");
			minimapSizeConfig = Config.Bind<int>("Basic Settings", "Minimap Size", 200, "Adjusts the size of your Minimap");
			minimapXPosConfig = Config.Bind<float>("Basic Settings", "X Offset", 0f, "Shifts the Minimap position horizontally");
			minimapYPosConfig = Config.Bind<float>("Basic Settings", "Y Offset", 0f, "Shifts the Minimap position vertically");
			minimapZoomConfig = Config.Bind<float>("Basic Settings", "Map Zoom", 19.7f, "Adjust the Map zoom level");
			brightnessConfig = Config.Bind<float>("Basic Settings", "Brightness", 0f, "Adjust the brightness level");
			showLootsConfig = Config.Bind<bool>("Minimap Icons", "Show Loots", true, "Toggles visibility of loots (small triangles) on your Minimap");
			showEnemiesConfig = Config.Bind<bool>("Minimap Icons", "Show Enemies", true, "Toggles visibility of enemies (red circles) on your Minimap");
			showTurretsConfig = Config.Bind<bool>("Minimap Icons", "Show Turrets", true, "Toggles visibility of turrets (red cone) on your Minimap");
			showLivePlayersConfig = Config.Bind<bool>("Minimap Icons", "Show Live Players", true, "Toggles visibility of live players (cyan circles) on your Minimap");
			showDeadPlayersConfig = Config.Bind<bool>("Minimap Icons", "Show Dead Players", true, "Toggles visibility of dead players (greyed-out cyan circles) on your Minimap");
			showRadarBoostersConfig = Config.Bind<bool>("Minimap Icons", "Show Radar Boosters", true, "Toggles visibility of radar boosters (blue circles) on your Minimap");
			showTerminalCodesConfig = Config.Bind<bool>("Minimap Icons", "Show Terminal Codes", true, "Toggles visibility of terminal codes on your Minimap");
			showShipArrowConfig = Config.Bind<bool>("Minimap Icons", "Show Ship Arrow", true, "Toggles visibility of the arrow pointing to the Ship");
			showCompassConfig = Config.Bind<bool>("Minimap Icons", "Show Compass", true, "Toggles visibility of the compass on on your Minimap");
			showHeadCamConfig = Config.Bind<bool>("Minimap Icons", "Show Head Camera", true, "Toggles visibility of the head-mounted camera on your Minimap");
			freezePlayerIndexConfig = Config.Bind<bool>("Advance Settings", "Override Ship Controls", false, "Disables the ability to change the Minimap focus through the ship control panel, allowing Minimap focus changes only through the mod menu");
			hostOverrideActive = Config.Bind<bool>("Host Override", "Host Override Active", false, "Indicates if host override is currently active (managed by the mod, do not edit manually)");
			hostOverrideActive.Value = false;
			Config.Save();
		}

		public void SyncGUIFromConfigs()
		{
			if (!((Object)(object)minimapGUI == (Object)null))
			{
				minimapGUI.guiKey.Key = guiKeyConfig.Value;
				minimapGUI.toggleMinimapKey.Key = toggleMinimapKeyConfig.Value;
				minimapGUI.toggleOverrideKey.Key = toggleOverrideKeyConfig.Value;
				minimapGUI.switchTargetKey.Key = switchTargetKeyConfig.Value;
				minimapGUI.autoRotate = autoRotateConfig.Value;
				minimapGUI.minimapSize = minimapSizeConfig.Value;
				minimapGUI.minimapXPos = minimapXPosConfig.Value;
				minimapGUI.minimapYPos = minimapYPosConfig.Value;
				minimapGUI.minimapZoom = minimapZoomConfig.Value;
				minimapGUI.brightness = brightnessConfig.Value;
				minimapGUI.freezePlayerIndex = freezePlayerIndexConfig.Value;
				if (((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost) || hostOverrideActive == null || !hostOverrideActive.Value)
				{
					minimapGUI.enableMinimap = enableMinimapConfig.Value;
					minimapGUI.showLoots = showLootsConfig.Value;
					minimapGUI.showEnemies = showEnemiesConfig.Value;
					minimapGUI.showTurrets = showTurretsConfig.Value;
					minimapGUI.showLivePlayers = showLivePlayersConfig.Value;
					minimapGUI.showDeadPlayers = showDeadPlayersConfig.Value;
					minimapGUI.showRadarBoosters = showRadarBoostersConfig.Value;
					minimapGUI.showTerminalCodes = showTerminalCodesConfig.Value;
					minimapGUI.showShipArrow = showShipArrowConfig.Value;
					minimapGUI.showCompass = showCompassConfig.Value;
					minimapGUI.showHeadCam = showHeadCamConfig.Value;
				}
			}
		}

		public void SyncConfigFromGUI()
		{
			guiKeyConfig.Value = minimapGUI.guiKey.Key;
			toggleMinimapKeyConfig.Value = minimapGUI.toggleMinimapKey.Key;
			toggleOverrideKeyConfig.Value = minimapGUI.toggleOverrideKey.Key;
			switchTargetKeyConfig.Value = minimapGUI.switchTargetKey.Key;
			autoRotateConfig.Value = minimapGUI.autoRotate;
			minimapSizeConfig.Value = minimapGUI.minimapSize;
			minimapXPosConfig.Value = minimapGUI.minimapXPos;
			minimapYPosConfig.Value = minimapGUI.minimapYPos;
			minimapZoomConfig.Value = minimapGUI.minimapZoom;
			brightnessConfig.Value = minimapGUI.brightness;
			if (((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost) || !hostOverrideActive.Value)
			{
				enableMinimapConfig.Value = minimapGUI.enableMinimap;
				showLootsConfig.Value = minimapGUI.showLoots;
				showEnemiesConfig.Value = minimapGUI.showEnemies;
				showTurretsConfig.Value = minimapGUI.showTurrets;
				showLivePlayersConfig.Value = minimapGUI.showLivePlayers;
				showDeadPlayersConfig.Value = minimapGUI.showDeadPlayers;
				showRadarBoostersConfig.Value = minimapGUI.showRadarBoosters;
				showTerminalCodesConfig.Value = minimapGUI.showTerminalCodes;
				showShipArrowConfig.Value = minimapGUI.showShipArrow;
				showCompassConfig.Value = minimapGUI.showCompass;
				showHeadCamConfig.Value = minimapGUI.showHeadCam;
			}
			freezePlayerIndexConfig.Value = minimapGUI.freezePlayerIndex;
		}
	}
}
namespace LethalCompanyMinimap.Component
{
	public class MinimapGUI : MonoBehaviour
	{
		private const int GUI_WIDTH = 500;

		private const int GUI_HEIGHT = 650;

		private const int ITEMWIDTH = 300;

		public ModHotkey guiKey = new ModHotkey(MinimapMod.defaultGuiKey, null);

		public ModHotkey toggleMinimapKey = new ModHotkey(MinimapMod.defaultToggleMinimapKey, null);

		public ModHotkey toggleOverrideKey = new ModHotkey(MinimapMod.defaultToggleOverrideKey, null);

		public ModHotkey switchTargetKey = new ModHotkey(MinimapMod.defaultSwitchTargetKey, null);

		public HotkeyManager hotkeyManager = new HotkeyManager(4);

		public bool enableMinimap;

		public bool autoRotate;

		public int minimapSize;

		public float minimapXPos;

		public float minimapYPos;

		public float minimapZoom;

		public float brightness;

		public bool showLoots;

		public bool showEnemies;

		public bool showTurrets;

		public bool showLivePlayers;

		public bool showDeadPlayers;

		public bool showRadarBoosters;

		public bool showTerminalCodes;

		public bool showShipArrow;

		public bool showCompass;

		public bool showHeadCam;

		public bool freezePlayerIndex;

		public bool hostOverride;

		private bool lastHostOverrideState;

		private bool lastClientHostOverrideActive;

		private bool lastEnableMinimap;

		private bool lastShowLoots;

		private bool lastShowEnemies;

		private bool lastShowTurrets;

		private bool lastShowLivePlayers;

		private bool lastShowDeadPlayers;

		private bool lastShowRadarBoosters;

		private bool lastShowTerminalCodes;

		private bool lastShowShipArrow;

		private bool lastShowCompass;

		private bool lastShowHeadCam;

		private bool? lockedEnableMinimap;

		private bool? lockedShowLoots;

		private bool? lockedShowEnemies;

		private bool? lockedShowTurrets;

		private bool? lockedShowLivePlayers;

		private bool? lockedShowDeadPlayers;

		private bool? lockedShowRadarBoosters;

		private bool? lockedShowTerminalCodes;

		private bool? lockedShowShipArrow;

		private bool? lockedShowCompass;

		private bool? lockedShowHeadCam;

		private string[] navbarStr = new string[4] { "Minimap", "Icons", "Select Target", "Keybinds" };

		private readonly KeyboardShortcut escapeKey = new KeyboardShortcut((KeyCode)27, Array.Empty<KeyCode>());

		private int navbarIndex;

		public bool isGUIOpen;

		private bool escKeyWasDown;

		public int playerIndex;

		public int realPlayerIndex;

		private bool lockPrefix;

		private string prefix = "";

		private CursorLockMode lastCursorState = Cursor.lockState;

		private Vector2 scrollPos = Vector2.zero;

		private int validTargetCount;

		public IDictionary<PlayerControllerB, ModUser> modUsers;

		private GUIStyle menuStyle;

		private GUIStyle buttonStyle;

		private GUIStyle labelStyle;

		private GUIStyle midLabelStyle;

		private GUIStyle tinyLabelStyle;

		private GUIStyle toggleStyle;

		private GUIStyle midToggleStyle;

		private void Awake()
		{
			MinimapMod.mls.LogInfo((object)"MinimapGUI loaded.");
			modUsers = new Dictionary<PlayerControllerB, ModUser>();
			guiKey.OnKey = ToggleGUI;
			toggleMinimapKey.OnKey = delegate
			{
				if (((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost) || MinimapMod.hostOverrideActive == null || !MinimapMod.hostOverrideActive.Value)
				{
					enableMinimap = !enableMinimap;
				}
			};
			toggleOverrideKey.OnKey = delegate
			{
				freezePlayerIndex = !freezePlayerIndex;
			};
			switchTargetKey.OnKey = SwitchTarget;
			hotkeyManager.AllHotkeys[0] = guiKey;
			hotkeyManager.AllHotkeys[1] = toggleMinimapKey;
			hotkeyManager.AllHotkeys[2] = toggleOverrideKey;
			hotkeyManager.AllHotkeys[3] = switchTargetKey;
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		public string GetPlayerNameAtIndex(int index)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return "n/a";
			}
			List<TransformAndName> radarTargets = StartOfRound.Instance.mapScreen.radarTargets;
			if (index < 0 || index >= radarTargets.Count)
			{
				return "n/a";
			}
			return radarTargets[index].name;
		}

		public void SetMinimapTarget(int targetTransformIndex)
		{
			playerIndex = targetTransformIndex;
			StartOfRound.Instance.mapScreen.targetTransformIndex = playerIndex;
			StartOfRound.Instance.mapScreen.targetedPlayer = ((Component)StartOfRound.Instance.mapScreen.radarTargets[playerIndex].transform).gameObject.GetComponent<PlayerControllerB>();
			((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = prefix + StartOfRound.Instance.mapScreen.radarTargets[playerIndex].name;
		}

		private void IntitializeMenu()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			if (menuStyle == null)
			{
				menuStyle = new GUIStyle(GUI.skin.box);
				buttonStyle = new GUIStyle(GUI.skin.button);
				labelStyle = new GUIStyle(GUI.skin.label);
				midLabelStyle = new GUIStyle(GUI.skin.label);
				tinyLabelStyle = new GUIStyle(GUI.skin.label);
				toggleStyle = new GUIStyle(GUI.skin.toggle);
				midToggleStyle = new GUIStyle(GUI.skin.toggle);
				menuStyle.normal.textColor = Color.white;
				menuStyle.normal.background = MakeTex(2, 2, new Color(0.19f, 0.2f, 0.22f, 0.9f));
				menuStyle.fontSize = 30;
				((Object)menuStyle.normal.background).hideFlags = (HideFlags)61;
				buttonStyle.normal.textColor = Color.white;
				buttonStyle.fontSize = 18;
				labelStyle.normal.textColor = Color.white;
				labelStyle.normal.background = MakeTex(2, 2, new Color(0.19f, 0.2f, 0.22f, 0f));
				labelStyle.fontSize = 18;
				labelStyle.alignment = (TextAnchor)4;
				((Object)labelStyle.normal.background).hideFlags = (HideFlags)61;
				midLabelStyle.normal.textColor = Color.white;
				midLabelStyle.normal.background = MakeTex(2, 2, new Color(0.19f, 0.2f, 0.22f, 0f));
				midLabelStyle.fontSize = 14;
				midLabelStyle.alignment = (TextAnchor)4;
				((Object)midLabelStyle.normal.background).hideFlags = (HideFlags)61;
				tinyLabelStyle.normal.textColor = Color.white;
				tinyLabelStyle.normal.background = MakeTex(2, 2, new Color(0.19f, 0.2f, 0.22f, 0f));
				tinyLabelStyle.fontSize = 11;
				tinyLabelStyle.alignment = (TextAnchor)4;
				((Object)tinyLabelStyle.normal.background).hideFlags = (HideFlags)61;
				toggleStyle.normal.textColor = Color.white;
				toggleStyle.fontSize = 18;
				midToggleStyle.normal.textColor = Color.white;
				midToggleStyle.fontSize = 14;
			}
		}

		public int CalculateValidTargetIndex(int setRadarTargetIndex)
		{
			List<TransformAndName> radarTargets = StartOfRound.Instance.mapScreen.radarTargets;
			if (radarTargets.Count <= setRadarTargetIndex)
			{
				setRadarTargetIndex = radarTargets.Count - 1;
			}
			for (int i = 0; i < radarTargets.Count; i++)
			{
				if (radarTargets[setRadarTargetIndex] == null)
				{
					setRadarTargetIndex = (setRadarTargetIndex + 1) % radarTargets.Count;
					continue;
				}
				PlayerControllerB component = ((Component)radarTargets[setRadarTargetIndex].transform).gameObject.GetComponent<PlayerControllerB>();
				if (!((Object)(object)component != (Object)null) || component.isPlayerControlled || component.isPlayerDead)
				{
					break;
				}
				setRadarTargetIndex = (setRadarTargetIndex + 1) % radarTargets.Count;
			}
			return setRadarTargetIndex;
		}

		public void SwitchTarget()
		{
			List<TransformAndName> list = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.mapScreen.radarTargets : new List<TransformAndName>());
			if (freezePlayerIndex && list.Count >= 1)
			{
				int setRadarTargetIndex = (playerIndex + 1) % list.Count;
				setRadarTargetIndex = CalculateValidTargetIndex(setRadarTargetIndex);
				SetMinimapTarget(setRadarTargetIndex);
			}
		}

		private void ToggleGUI()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			if (!isGUIOpen)
			{
				isGUIOpen = true;
				Cursor.visible = true;
				lastCursorState = Cursor.lockState;
				Cursor.lockState = (CursorLockMode)2;
			}
			else
			{
				isGUIOpen = false;
				Cursor.visible = false;
				Cursor.lockState = lastCursorState;
			}
		}

		public void Update()
		{
			//IL_000c: 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_004d: 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)
			hotkeyManager.Update();
			KeyboardShortcut val = escapeKey;
			if (((KeyboardShortcut)(ref val)).IsDown())
			{
				escKeyWasDown = true;
				if (isGUIOpen)
				{
					if (hotkeyManager.AnyHotkeyIsSettingKey())
					{
						Cursor.lockState = (CursorLockMode)2;
					}
					else
					{
						isGUIOpen = false;
						Cursor.visible = false;
					}
				}
			}
			val = escapeKey;
			if (((KeyboardShortcut)(ref val)).IsUp() && escKeyWasDown)
			{
				escKeyWasDown = false;
			}
			if (freezePlayerIndex != lockPrefix && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				lockPrefix = freezePlayerIndex;
				prefix = (freezePlayerIndex ? "*" : "");
				((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = prefix + StartOfRound.Instance.mapScreen.radarTargets[playerIndex].name;
			}
			if (!freezePlayerIndex && playerIndex != realPlayerIndex)
			{
				realPlayerIndex = CalculateValidTargetIndex(realPlayerIndex);
				SetMinimapTarget(realPlayerIndex);
			}
			EnforceHostSettings();
			HandleHostOverrideSync();
			EnforceHostSettings();
		}

		private void EnforceHostSettings()
		{
			if ((!((Object)(object)StartOfRound.Instance != (Object)null) || !((NetworkBehaviour)StartOfRound.Instance).IsHost) && MinimapMod.hostOverrideActive != null && MinimapMod.hostOverrideActive.Value)
			{
				if (lockedEnableMinimap.HasValue)
				{
					enableMinimap = lockedEnableMinimap.Value;
				}
				if (lockedShowLoots.HasValue)
				{
					showLoots = lockedShowLoots.Value;
				}
				if (lockedShowEnemies.HasValue)
				{
					showEnemies = lockedShowEnemies.Value;
				}
				if (lockedShowTurrets.HasValue)
				{
					showTurrets = lockedShowTurrets.Value;
				}
				if (lockedShowLivePlayers.HasValue)
				{
					showLivePlayers = lockedShowLivePlayers.Value;
				}
				if (lockedShowDeadPlayers.HasValue)
				{
					showDeadPlayers = lockedShowDeadPlayers.Value;
				}
				if (lockedShowRadarBoosters.HasValue)
				{
					showRadarBoosters = lockedShowRadarBoosters.Value;
				}
				if (lockedShowTerminalCodes.HasValue)
				{
					showTerminalCodes = lockedShowTerminalCodes.Value;
				}
				if (lockedShowShipArrow.HasValue)
				{
					showShipArrow = lockedShowShipArrow.Value;
				}
				if (lockedShowCompass.HasValue)
				{
					showCompass = lockedShowCompass.Value;
				}
				if (lockedShowHeadCam.HasValue)
				{
					showHeadCam = lockedShowHeadCam.Value;
				}
			}
		}

		private void HandleHostOverrideSync()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				if (hostOverride != lastHostOverrideState)
				{
					lastHostOverrideState = hostOverride;
					if (hostOverride)
					{
						UpdateLastToggleValues();
						SendHostSettingsToClients();
					}
					else
					{
						HUDManagerPatch.SendMinimapBroadcast("HostOverrideDisabled", "restore");
					}
				}
				if (hostOverride && HasToggleSettingsChanged())
				{
					SendHostSettingsToClients();
					UpdateLastToggleValues();
				}
				return;
			}
			if (MinimapMod.hostOverrideActive != null)
			{
				bool value = MinimapMod.hostOverrideActive.Value;
				if (lastClientHostOverrideActive && !value)
				{
					RestoreFromConfig();
				}
				lastClientHostOverrideActive = value;
			}
			lastHostOverrideState = false;
		}

		private void UpdateLastToggleValues()
		{
			lastEnableMinimap = enableMinimap;
			lastShowLoots = showLoots;
			lastShowEnemies = showEnemies;
			lastShowTurrets = showTurrets;
			lastShowLivePlayers = showLivePlayers;
			lastShowDeadPlayers = showDeadPlayers;
			lastShowRadarBoosters = showRadarBoosters;
			lastShowTerminalCodes = showTerminalCodes;
			lastShowShipArrow = showShipArrow;
			lastShowCompass = showCompass;
			lastShowHeadCam = showHeadCam;
		}

		private bool HasToggleSettingsChanged()
		{
			if (lastEnableMinimap == enableMinimap && lastShowLoots == showLoots && lastShowEnemies == showEnemies && lastShowTurrets == showTurrets && lastShowLivePlayers == showLivePlayers && lastShowDeadPlayers == showDeadPlayers && lastShowRadarBoosters == showRadarBoosters && lastShowTerminalCodes == showTerminalCodes && lastShowShipArrow == showShipArrow && lastShowCompass == showCompass)
			{
				return lastShowHeadCam != showHeadCam;
			}
			return true;
		}

		public void SendHostSettingsToClients()
		{
			string data = SerializeToggleSettings();
			HUDManagerPatch.SendMinimapBroadcast("HostOverrideSettings", data);
		}

		public string SerializeToggleSettings()
		{
			return "enableMinimap=" + (enableMinimap ? "show" : "hide") + ";loots=" + (showLoots ? "show" : "hide") + ";enemies=" + (showEnemies ? "show" : "hide") + ";turrets=" + (showTurrets ? "show" : "hide") + ";livePlayers=" + (showLivePlayers ? "show" : "hide") + ";deadPlayers=" + (showDeadPlayers ? "show" : "hide") + ";radarBoosters=" + (showRadarBoosters ? "show" : "hide") + ";terminalCodes=" + (showTerminalCodes ? "show" : "hide") + ";shipArrow=" + (showShipArrow ? "show" : "hide") + ";compass=" + (showCompass ? "show" : "hide") + ";headCam=" + (showHeadCam ? "show" : "hide");
		}

		public void ApplyHostSettings(string settingsData)
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				return;
			}
			if (MinimapMod.hostOverrideActive != null)
			{
				lastClientHostOverrideActive = MinimapMod.hostOverrideActive.Value;
				MinimapMod.hostOverrideActive.Value = true;
				if (MinimapMod.Config != null)
				{
					try
					{
						MinimapMod.Config.Save();
					}
					catch (Exception ex)
					{
						MinimapMod.mls.LogError((object)("Error saving config: " + ex.Message));
					}
				}
				else
				{
					MinimapMod.mls.LogError((object)"Config is null! Cannot save hostOverrideActive.");
				}
			}
			else
			{
				MinimapMod.mls.LogError((object)"hostOverrideActive config entry is null! Cannot set value.");
			}
			string[] array = settingsData.Split(new char[1] { ';' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { '=' });
				if (array2.Length == 2)
				{
					string text = array2[0].Trim();
					bool value = array2[1].Trim() == "show";
					switch (text)
					{
					case "enableMinimap":
						enableMinimap = value;
						lockedEnableMinimap = value;
						break;
					case "loots":
						showLoots = value;
						lockedShowLoots = value;
						break;
					case "enemies":
						showEnemies = value;
						lockedShowEnemies = value;
						break;
					case "turrets":
						showTurrets = value;
						lockedShowTurrets = value;
						break;
					case "livePlayers":
						showLivePlayers = value;
						lockedShowLivePlayers = value;
						break;
					case "deadPlayers":
						showDeadPlayers = value;
						lockedShowDeadPlayers = value;
						break;
					case "radarBoosters":
						showRadarBoosters = value;
						lockedShowRadarBoosters = value;
						break;
					case "terminalCodes":
						showTerminalCodes = value;
						lockedShowTerminalCodes = value;
						break;
					case "shipArrow":
						showShipArrow = value;
						lockedShowShipArrow = value;
						break;
					case "compass":
						showCompass = value;
						lockedShowCompass = value;
						break;
					case "headCam":
						showHeadCam = value;
						lockedShowHeadCam = value;
						break;
					}
				}
			}
			EnforceHostSettings();
		}

		public void RestoreFromConfig()
		{
			lockedEnableMinimap = null;
			lockedShowLoots = null;
			lockedShowEnemies = null;
			lockedShowTurrets = null;
			lockedShowLivePlayers = null;
			lockedShowDeadPlayers = null;
			lockedShowRadarBoosters = null;
			lockedShowTerminalCodes = null;
			lockedShowShipArrow = null;
			lockedShowCompass = null;
			lockedShowHeadCam = null;
			if (MinimapMod.hostOverrideActive != null)
			{
				MinimapMod.hostOverrideActive.Value = false;
				if (MinimapMod.Config != null)
				{
					MinimapMod.Config.Save();
					MinimapMod.mls.LogInfo((object)$"Set hostOverrideActive to false and saved config. Current value: {MinimapMod.hostOverrideActive.Value}");
				}
				else
				{
					MinimapMod.mls.LogError((object)"Config is null! Cannot save hostOverrideActive.");
				}
			}
			else
			{
				MinimapMod.mls.LogError((object)"hostOverrideActive config entry is null! Cannot set value.");
			}
			MinimapMod.Instance.SyncGUIFromConfigs();
		}

		private static MouseAndKeyboard MouseWasPressedThisFrame()
		{
			Mouse current = Mouse.current;
			if (current == null)
			{
				return MouseAndKeyboard.None;
			}
			if (current.leftButton.wasPressedThisFrame)
			{
				return MouseAndKeyboard.None;
			}
			if (current.middleButton.wasPressedThisFrame)
			{
				return MouseAndKeyboard.MouseMiddle;
			}
			if (current.rightButton.wasPressedThisFrame)
			{
				return MouseAndKeyboard.MouseRight;
			}
			if (current.forwardButton.wasPressedThisFrame)
			{
				return MouseAndKeyboard.MouseForward;
			}
			if (current.backButton.wasPressedThisFrame)
			{
				return MouseAndKeyboard.MouseBack;
			}
			return MouseAndKeyboard.None;
		}

		public void OnGUI()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_093a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: 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)
			//IL_051e: 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_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: 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_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab9: 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_0822: Unknown result type (might be due to invalid IL or missing references)
			//IL_09be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6f: Unknown result type (might be due to invalid IL or missing references)
			if (menuStyle == null)
			{
				IntitializeMenu();
			}
			if (!isGUIOpen)
			{
				return;
			}
			float num = Screen.width / 2 - 250;
			float num2 = Screen.height / 2 - 325;
			float num3 = num + 100f;
			GUI.Box(new Rect(num, num2, 500f, 650f), "\nMinimap Mod\n", menuStyle);
			GUI.Label(new Rect(num3, num2 + 60f, 300f, 30f), "v1.0.8\t\t\tby BennyTheBee", tinyLabelStyle);
			navbarIndex = GUI.Toolbar(new Rect(num, num2 - 30f, 500f, 30f), navbarIndex, navbarStr, buttonStyle);
			num2 += 20f;
			switch (navbarIndex)
			{
			case 0:
			{
				bool num5 = (!((Object)(object)StartOfRound.Instance != (Object)null) || !((NetworkBehaviour)StartOfRound.Instance).IsHost) && MinimapMod.hostOverrideActive != null && MinimapMod.hostOverrideActive.Value;
				bool flag12 = enableMinimap;
				GUI.enabled = !num5;
				enableMinimap = GUI.Toggle(new Rect(num3, num2 + 90f, 300f, 30f), enableMinimap, "Toggle Minimap", toggleStyle);
				if (num5)
				{
					enableMinimap = flag12;
				}
				GUI.enabled = true;
				autoRotate = GUI.Toggle(new Rect(num3, num2 + 130f, 300f, 30f), autoRotate, "Auto Rotate Map", toggleStyle);
				GUI.Label(new Rect(num3, num2 + 170f, 300f, 30f), $"Minimap Size: {minimapSize}", labelStyle);
				minimapSize = (int)GUI.HorizontalSlider(new Rect(num3, num2 + 200f, 300f, 30f), (float)minimapSize, 0f, 1000f);
				GUI.Label(new Rect(num3, num2 + 220f, 300f, 30f), $"X Position Offset: {minimapXPos}", labelStyle);
				minimapXPos = GUI.HorizontalSlider(new Rect(num3, num2 + 250f, 300f, 30f), minimapXPos, -1000f, 1000f);
				GUI.Label(new Rect(num3, num2 + 270f, 300f, 30f), $"Y Position Offset: {minimapYPos}", labelStyle);
				minimapYPos = GUI.HorizontalSlider(new Rect(num3, num2 + 300f, 300f, 30f), minimapYPos, -1000f, 1000f);
				GUI.Label(new Rect(num3, num2 + 320f, 300f, 30f), $"Map Zoom: {minimapZoom}", labelStyle);
				minimapZoom = GUI.HorizontalSlider(new Rect(num3, num2 + 350f, 300f, 30f), minimapZoom, 0f, 100f);
				GUI.Label(new Rect(num3, num2 + 370f, 300f, 30f), $"Extra Brightness: {brightness}", labelStyle);
				brightness = GUI.HorizontalSlider(new Rect(num3, num2 + 400f, 300f, 30f), brightness, 0f, 50f);
				if (LeftClickButton(new Rect(num3, num2 + 440f, 300f, 30f), "Reset to Default Size"))
				{
					minimapSize = 200;
				}
				if (LeftClickButton(new Rect(num3, num2 + 480f, 300f, 30f), "Reset to Default Position"))
				{
					minimapXPos = 0f;
					minimapYPos = 0f;
				}
				if (LeftClickButton(new Rect(num3, num2 + 520f, 300f, 30f), "Reset to Default Zoom"))
				{
					minimapZoom = 19.7f;
				}
				if (LeftClickButton(new Rect(num3, num2 + 560f, 300f, 30f), "Reset to Default Brightness"))
				{
					brightness = 0f;
				}
				break;
			}
			case 1:
			{
				bool flag = (Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost;
				bool num4 = !flag && MinimapMod.hostOverrideActive != null && MinimapMod.hostOverrideActive.Value;
				bool flag2 = showLoots;
				bool flag3 = showEnemies;
				bool flag4 = showTurrets;
				bool flag5 = showLivePlayers;
				bool flag6 = showDeadPlayers;
				bool flag7 = showRadarBoosters;
				bool flag8 = showTerminalCodes;
				bool flag9 = showShipArrow;
				bool flag10 = showCompass;
				bool flag11 = showHeadCam;
				GUI.enabled = !num4;
				showLoots = GUI.Toggle(new Rect(num3, num2 + 90f, 300f, 30f), showLoots, "Show Loots", toggleStyle);
				showEnemies = GUI.Toggle(new Rect(num3, num2 + 130f, 300f, 30f), showEnemies, "Show Enemies", toggleStyle);
				showTurrets = GUI.Toggle(new Rect(num3, num2 + 170f, 300f, 30f), showTurrets, "Show Turrets", toggleStyle);
				showLivePlayers = GUI.Toggle(new Rect(num3, num2 + 210f, 300f, 30f), showLivePlayers, "Show Live Players", toggleStyle);
				showDeadPlayers = GUI.Toggle(new Rect(num3, num2 + 250f, 300f, 30f), showDeadPlayers, "Show Dead Players", toggleStyle);
				showRadarBoosters = GUI.Toggle(new Rect(num3, num2 + 290f, 300f, 30f), showRadarBoosters, "Show Radar Boosters", toggleStyle);
				showTerminalCodes = GUI.Toggle(new Rect(num3, num2 + 330f, 300f, 30f), showTerminalCodes, "Show Terminal Codes", toggleStyle);
				showShipArrow = GUI.Toggle(new Rect(num3, num2 + 370f, 300f, 30f), showShipArrow, "Show Ship Arrow", toggleStyle);
				showCompass = GUI.Toggle(new Rect(num3, num2 + 410f, 300f, 30f), showCompass, "Show Compass", toggleStyle);
				showHeadCam = GUI.Toggle(new Rect(num3, num2 + 450f, 300f, 30f), showHeadCam, "Show Head Camera", toggleStyle);
				if (num4)
				{
					showLoots = flag2;
					showEnemies = flag3;
					showTurrets = flag4;
					showLivePlayers = flag5;
					showDeadPlayers = flag6;
					showRadarBoosters = flag7;
					showTerminalCodes = flag8;
					showShipArrow = flag9;
					showCompass = flag10;
					showHeadCam = flag11;
				}
				GUI.enabled = flag;
				hostOverride = GUI.Toggle(new Rect(num3, num2 + 490f, 300f, 30f), hostOverride, "Host Override", toggleStyle);
				GUI.enabled = true;
				GUI.enabled = !num4;
				if (LeftClickButton(new Rect(num3, num2 + 530f, 300f, 30f), "Show all Icons"))
				{
					showLoots = true;
					showEnemies = true;
					showTurrets = true;
					showLivePlayers = true;
					showDeadPlayers = true;
					showRadarBoosters = true;
					showTerminalCodes = true;
					showShipArrow = true;
					showCompass = true;
					showHeadCam = true;
				}
				if (LeftClickButton(new Rect(num3, num2 + 570f, 300f, 30f), "Hide all Icons"))
				{
					showLoots = false;
					showEnemies = false;
					showTurrets = false;
					showLivePlayers = false;
					showDeadPlayers = false;
					showRadarBoosters = false;
					showTerminalCodes = false;
					showShipArrow = false;
					showCompass = false;
					showHeadCam = false;
				}
				GUI.enabled = true;
				break;
			}
			case 2:
			{
				List<TransformAndName> list = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.mapScreen.radarTargets : new List<TransformAndName>());
				GUI.Label(new Rect(num3, num2 + 90f, 300f, 30f), "Selected Target: " + GetPlayerNameAtIndex(playerIndex), labelStyle);
				freezePlayerIndex = GUI.Toggle(new Rect(num3, num2 + 140f, 300f, 30f), freezePlayerIndex, "Override Ship Controls", toggleStyle);
				int num6 = 0;
				if (freezePlayerIndex)
				{
					float num7 = num2 + 180f;
					scrollPos = GUI.BeginScrollView(new Rect(num3, num7, 300f, 400f), scrollPos, new Rect(0f, 0f, 280f, (float)(40 * validTargetCount)));
					for (int i = 0; i < list.Count; i++)
					{
						PlayerControllerB component = ((Component)list[i].transform).gameObject.GetComponent<PlayerControllerB>();
						if (!((Object)(object)component != (Object)null) || component.isPlayerControlled || component.isPlayerDead)
						{
							if (LeftClickButton(new Rect(0f, (float)(40 * num6), 270f, 30f), list[i].name))
							{
								SetMinimapTarget(i);
							}
							num6++;
						}
					}
					GUI.EndScrollView();
				}
				validTargetCount = num6;
				break;
			}
			case 3:
			{
				string text = (guiKey.IsSettingKey ? "Press a Key..." : $"Open Mod Menu: {guiKey.Key}");
				if (LeftClickButton(new Rect(num3, num2 + 90f, 300f, 30f), text))
				{
					hotkeyManager.ResetSettingKey();
					guiKey.IsSettingKey = true;
				}
				string text2 = (toggleMinimapKey.IsSettingKey ? "Press a Key..." : $"Toggle Minimap: {toggleMinimapKey.Key}");
				if (LeftClickButton(new Rect(num3, num2 + 130f, 300f, 30f), text2))
				{
					hotkeyManager.ResetSettingKey();
					toggleMinimapKey.IsSettingKey = true;
				}
				string text3 = (toggleOverrideKey.IsSettingKey ? "Press a Key..." : $"Override Ship Controls: {toggleOverrideKey.Key}");
				if (LeftClickButton(new Rect(num3, num2 + 170f, 300f, 30f), text3))
				{
					hotkeyManager.ResetSettingKey();
					toggleOverrideKey.IsSettingKey = true;
				}
				string text4 = (switchTargetKey.IsSettingKey ? "Press a Key..." : $"Switch Minimap Target: {switchTargetKey.Key}");
				if (LeftClickButton(new Rect(num3, num2 + 210f, 300f, 30f), text4))
				{
					hotkeyManager.ResetSettingKey();
					switchTargetKey.IsSettingKey = true;
				}
				if (LeftClickButton(new Rect(num3, num2 + 280f, 300f, 30f), "Reset to Default Keybinds"))
				{
					hotkeyManager.ResetToDefaultKey();
				}
				if (!hotkeyManager.AnyHotkeyIsSettingKey())
				{
					break;
				}
				MouseAndKeyboard mouseAndKeyboard = MouseWasPressedThisFrame();
				if (mouseAndKeyboard != MouseAndKeyboard.None)
				{
					hotkeyManager.SetHotKey(mouseAndKeyboard);
				}
				else if (((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
				{
					hotkeyManager.ResetIsSettingKey();
				}
				else
				{
					if (!((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame)
					{
						break;
					}
					Enumerator<KeyControl> enumerator = Keyboard.current.allKeys.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							KeyControl current = enumerator.Current;
							if (((ButtonControl)current).wasPressedThisFrame && hotkeyManager.SetHotKey(current.keyCode))
							{
								break;
							}
						}
					}
					finally
					{
						((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
					}
				}
				break;
			}
			}
			MinimapMod.Instance.SyncConfigFromGUI();
			EnforceHostSettings();
		}

		private bool LeftClickButton(Rect rect, string text, GUIStyle style = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0024: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected I4, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			GUIContent val = new GUIContent(text);
			if (style == null)
			{
				style = GUI.skin.button;
			}
			Event current = Event.current;
			int controlID = GUIUtility.GetControlID((FocusType)2);
			EventType type = current.type;
			switch ((int)type)
			{
			default:
				if ((int)type == 7)
				{
					style.Draw(rect, val, controlID);
				}
				break;
			case 0:
				if (GUIUtility.hotControl == 0 && ((Rect)(ref rect)).Contains(current.mousePosition) && current.button == 0)
				{
					GUIUtility.hotControl = controlID;
					current.Use();
				}
				break;
			case 3:
				if (GUIUtility.hotControl == controlID)
				{
					current.Use();
				}
				break;
			case 1:
				if (GUIUtility.hotControl == controlID && ((Rect)(ref rect)).Contains(current.mousePosition) && current.button == 0)
				{
					GUIUtility.hotControl = 0;
					current.Use();
					return true;
				}
				break;
			case 2:
				break;
			}
			return false;
		}
	}
}
namespace LethalCompanyMinimap.Patches
{
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void TurretVisibilityOnMapPatch(ref Transform ___turretRod)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)___turretRod != (Object)null))
			{
				return;
			}
			foreach (Transform item in ((Component)___turretRod).gameObject.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("Plane"))
				{
					GameObject gameObject = ((Component)val).gameObject;
					if (MinimapMod.minimapGUI.showTurrets != gameObject.activeSelf)
					{
						gameObject.SetActive(MinimapMod.minimapGUI.showTurrets);
					}
				}
			}
		}
	}
	internal class HUDManagerPatch
	{
		private const string RequestMessage = "LethalCompanyMinimap_HostOverrideRequest";

		private const string StateMessage = "LethalCompanyMinimap_HostOverrideState";

		private static bool registered;

		public unsafe static void SendMinimapBroadcast(string signature, string data = "null", ulong? clientId = null)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null)
			{
				return;
			}
			string text = signature + "\n" + data;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize(text, false), (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				if (clientId.HasValue)
				{
					singleton.CustomMessagingManager.SendNamedMessage("LethalCompanyMinimap_HostOverrideState", clientId.Value, val, (NetworkDelivery)2);
				}
				else
				{
					singleton.CustomMessagingManager.SendNamedMessageToAll("LethalCompanyMinimap_HostOverrideState", val, (NetworkDelivery)2);
				}
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public unsafe static void RegisterAndRequest()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0089: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null)
			{
				return;
			}
			if (!registered)
			{
				singleton.CustomMessagingManager.RegisterNamedMessageHandler("LethalCompanyMinimap_HostOverrideRequest", new HandleNamedMessageDelegate(OnRequest));
				singleton.CustomMessagingManager.RegisterNamedMessageHandler("LethalCompanyMinimap_HostOverrideState", new HandleNamedMessageDelegate(OnState));
				registered = true;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
			try
			{
				int num = 1;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				singleton.CustomMessagingManager.SendNamedMessage("LethalCompanyMinimap_HostOverrideRequest", 0uL, val, (NetworkDelivery)2);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public static void OnDisconnect()
		{
			registered = false;
			if ((Object)(object)MinimapMod.minimapGUI != (Object)null)
			{
				MinimapMod.minimapGUI.RestoreFromConfig();
			}
		}

		private static void OnRequest(ulong senderId, FastBufferReader reader)
		{
			if (!((Object)(object)StartOfRound.Instance == (Object)null) && ((NetworkBehaviour)StartOfRound.Instance).IsHost && !((Object)(object)MinimapMod.minimapGUI == (Object)null))
			{
				if (MinimapMod.minimapGUI.hostOverride)
				{
					SendMinimapBroadcast("HostOverrideSettings", MinimapMod.minimapGUI.SerializeToggleSettings(), senderId);
				}
				else
				{
					SendMinimapBroadcast("HostOverrideDisabled", "restore", senderId);
				}
			}
		}

		private static void OnState(ulong senderId, FastBufferReader reader)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || senderId != 0L || ((Object)(object)StartOfRound.Instance != (Object)null && ((NetworkBehaviour)StartOfRound.Instance).IsHost) || (Object)(object)MinimapMod.minimapGUI == (Object)null)
			{
				return;
			}
			string text = default(string);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
			int num = text.IndexOf('\n');
			if (num >= 0)
			{
				string text2 = text.Substring(0, num);
				string settingsData = text.Substring(num + 1);
				if (text2 == "HostOverrideSettings")
				{
					MinimapMod.minimapGUI.ApplyHostSettings(settingsData);
				}
				else if (text2 == "HostOverrideDisabled")
				{
					MinimapMod.minimapGUI.RestoreFromConfig();
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("StartDisconnect")]
		[HarmonyPostfix]
		private static void StartDisconnectPatch()
		{
			HUDManagerPatch.OnDisconnect();
		}
	}
	[HarmonyPatch(typeof(DeadBodyInfo))]
	internal class DeadBodyInfoPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void MapCameraAlwaysEnabledPatch(ref Transform ___radarDot)
		{
			if (MinimapMod.minimapGUI.showDeadPlayers != ((Component)___radarDot).gameObject.activeSelf)
			{
				((Component)___radarDot).gameObject.SetActive(MinimapMod.minimapGUI.showDeadPlayers);
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("SetInsideLightingDimness")]
		[HarmonyPostfix]
		private static void MinimapBrightnessPatch()
		{
			if ((Object)(object)TimeOfDay.Instance.sunDirect != (Object)null)
			{
				((Behaviour)TimeOfDay.Instance.sunDirect).enabled = true;
			}
		}
	}
	[HarmonyPatch(typeof(RadarBoosterItem))]
	internal class RadarBoosterItemPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void RadarBoosterVisibilityPatch(RadarBoosterItem __instance)
		{
			if (MinimapMod.minimapGUI.showRadarBoosters != __instance.radarDot.activeSelf)
			{
				__instance.radarDot.SetActive(MinimapMod.minimapGUI.showRadarBoosters);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private const int padding = -5;

		private static GameObject minimapObj;

		private static RawImage minimap;

		private static RectTransform tooltips;

		private static Vector2 tooltipsOriginalPos;

		private static GameObject minimapLightObj;

		public static Light minimapLight;

		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void DisplayMinimapPatch()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_013e: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)MinimapMod.minimapGUI == (Object)null))
			{
				HUDManagerPatch.RegisterAndRequest();
				int minimapSize = MinimapMod.minimapGUI.minimapSize;
				if ((Object)(object)minimap == (Object)null || (Object)(object)minimapObj == (Object)null)
				{
					minimapObj = new GameObject("Minimap");
					minimap = minimapObj.AddComponent<RawImage>();
					((Graphic)minimap).rectTransform.anchorMin = new Vector2(1f, 1f);
					((Graphic)minimap).rectTransform.anchorMax = new Vector2(1f, 1f);
					((Graphic)minimap).rectTransform.pivot = new Vector2(1f, 1f);
					((Graphic)minimap).rectTransform.sizeDelta = new Vector2((float)minimapSize, (float)minimapSize);
					((Graphic)minimap).rectTransform.anchoredPosition = new Vector2(MinimapMod.minimapGUI.minimapXPos, MinimapMod.minimapGUI.minimapYPos + -5f);
				}
				if ((Object)(object)minimapLight == (Object)null || (Object)(object)minimapLightObj == (Object)null)
				{
					minimapLightObj = new GameObject("MinimapLight");
					minimapLightObj.transform.position = new Vector3(0f, 100f, 0f);
					minimapLightObj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
					minimapLight = minimapLightObj.AddComponent<Light>();
					minimapLight.type = (LightType)1;
					minimapLight.range = 100f;
					minimapLight.color = Color.white;
					minimapLight.colorTemperature = 5000f;
					minimapLight.intensity = 0f;
					minimapLight.cullingMask = 0;
				}
				minimap.texture = (Texture)(object)StartOfRound.Instance.mapScreen.cam.targetTexture;
				((Component)minimap).transform.SetParent(((Component)HUDManager.Instance.playerScreenTexture).transform, false);
				tooltips = ((Component)HUDManager.Instance.Tooltips.canvasGroup).gameObject.GetComponent<RectTransform>();
				_ = tooltipsOriginalPos;
				RectTransform obj = tooltips;
				obj.anchoredPosition -= new Vector2(0f, (float)minimapSize);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateMinimapPatch(PlayerControllerB __instance)
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			if ((Object)(object)MinimapMod.minimapGUI == (Object)null)
			{
				return;
			}
			if ((Object)(object)__instance.mapRadarDotAnimator != (Object)null && (Object)(object)((Component)__instance.mapRadarDotAnimator).gameObject != (Object)null && MinimapMod.minimapGUI.showLivePlayers != ((Component)__instance.mapRadarDotAnimator).gameObject.activeSelf)
			{
				((Component)__instance.mapRadarDotAnimator).gameObject.SetActive(MinimapMod.minimapGUI.showLivePlayers);
			}
			if ((Object)(object)minimap != (Object)null)
			{
				if (MinimapMod.minimapGUI.enableMinimap != ((Component)minimap).gameObject.activeSelf)
				{
					((Component)minimap).gameObject.SetActive(MinimapMod.minimapGUI.enableMinimap);
					if (MinimapMod.minimapGUI.enableMinimap && (Object)(object)tooltips != (Object)null)
					{
						RectTransform obj = tooltips;
						obj.anchoredPosition -= new Vector2(0f, (float)MinimapMod.minimapGUI.minimapSize);
					}
					else if ((Object)(object)tooltips != (Object)null)
					{
						tooltips.anchoredPosition = tooltipsOriginalPos;
					}
				}
				if ((float)MinimapMod.minimapGUI.minimapSize != ((Graphic)minimap).rectTransform.sizeDelta.y)
				{
					int minimapSize = MinimapMod.minimapGUI.minimapSize;
					((Graphic)minimap).rectTransform.sizeDelta = new Vector2((float)minimapSize, (float)minimapSize);
					if ((Object)(object)tooltips != (Object)null)
					{
						tooltips.anchoredPosition = tooltipsOriginalPos - new Vector2(0f, (float)minimapSize);
					}
				}
				if (MinimapMod.minimapGUI.minimapXPos != ((Graphic)minimap).rectTransform.anchoredPosition.x || MinimapMod.minimapGUI.minimapYPos != ((Graphic)minimap).rectTransform.anchoredPosition.y)
				{
					((Graphic)minimap).rectTransform.anchoredPosition = new Vector2(MinimapMod.minimapGUI.minimapXPos, MinimapMod.minimapGUI.minimapYPos + -5f);
				}
			}
			if ((Object)(object)minimapLight != (Object)null)
			{
				if (minimapLight.cullingMask == 0 && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					minimapLight.cullingMask = ~GameNetworkManager.Instance.localPlayerController.gameplayCamera.cullingMask;
				}
				minimapLight.intensity = MinimapMod.minimapGUI.brightness;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private static GameObject FindMapDot(GameObject enemyObject, bool isModel = false)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			foreach (Transform item in enemyObject.transform)
			{
				Transform val = item;
				if (((Object)val).name.StartsWith("MapDot"))
				{
					return ((Component)val).gameObject;
				}
				if (!isModel && (((Object)val).name.EndsWith("Model") || ((Object)val).name.EndsWith("ModelContainer")))
				{
					GameObject val2 = FindMapDot(((Component)val).gameObject, isModel = true);
					if ((Object)(object)val2 != (Object)null)
					{
						return val2;
					}
				}
			}
			return null;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void EnemyVisibilityOnMapPatch(EnemyAI __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).gameObject != (Object)null)
			{
				GameObject val = FindMapDot(((Component)__instance).gameObject);
				if ((Object)(object)val != (Object)null && MinimapMod.minimapGUI.showEnemies != val.activeSelf)
				{
					val.SetActive(MinimapMod.minimapGUI.showEnemies);
				}
			}
		}
	}
	[HarmonyPatch(typeof(TerminalAccessibleObject))]
	internal class TerminalAccessibleObjectPatch
	{
		[HarmonyPatch("InitializeValues")]
		[HarmonyPostfix]
		private static void TerminalCodeVisibilityPatch(ref TextMeshProUGUI ___mapRadarText)
		{
			((Component)___mapRadarText).gameObject.SetActive(MinimapMod.minimapGUI.showTerminalCodes);
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		private static bool showTerminalCodes = false;

		private static readonly FieldInfo mapRadarTextField = AccessTools.Field(typeof(TerminalAccessibleObject), "mapRadarText");

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LootVisibilityOnMapPatch(GrabbableObject __instance)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			if ((Object)(object)MinimapMod.minimapGUI == (Object)null)
			{
				return;
			}
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.radarIcon != (Object)null && (Object)(object)((Component)__instance.radarIcon).gameObject != (Object)null && MinimapMod.minimapGUI.showLoots != ((Component)__instance.radarIcon).gameObject.activeSelf)
			{
				((Component)__instance.radarIcon).gameObject.SetActive(MinimapMod.minimapGUI.showLoots);
			}
			if (showTerminalCodes == MinimapMod.minimapGUI.showTerminalCodes)
			{
				return;
			}
			showTerminalCodes = MinimapMod.minimapGUI.showTerminalCodes;
			TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
			for (int i = 0; i < array.Length; i++)
			{
				TextMeshProUGUI val = (TextMeshProUGUI)mapRadarTextField.GetValue(array[i]);
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null)
				{
					((Component)val).gameObject.SetActive(MinimapMod.minimapGUI.showTerminalCodes);
				}
				if ((Object)(object)array[i].mapRadarObject != (Object)null)
				{
					array[i].mapRadarObject.SetActive(MinimapMod.minimapGUI.showTerminalCodes);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporterPatch
	{
		private static PlayerControllerB playerToBeamUp;

		[HarmonyPatch("beamUpPlayer")]
		[HarmonyPrefix]
		private static void BeforeTeleportPatch()
		{
			int realPlayerIndex = MinimapMod.minimapGUI.realPlayerIndex;
			if (StartOfRound.Instance.mapScreen.targetTransformIndex != realPlayerIndex)
			{
				realPlayerIndex = MinimapMod.minimapGUI.CalculateValidTargetIndex(realPlayerIndex);
				playerToBeamUp = ((Component)StartOfRound.Instance.mapScreen.radarTargets[realPlayerIndex].transform).gameObject.GetComponent<PlayerControllerB>();
				StartOfRound.Instance.mapScreen.targetedPlayer = playerToBeamUp;
			}
		}

		[HarmonyPatch("SetPlayerTeleporterId")]
		[HarmonyPrefix]
		private static void DuringTeleportPatch()
		{
			if ((Object)(object)playerToBeamUp != (Object)null)
			{
				playerToBeamUp = null;
				MinimapMod.minimapGUI.SetMinimapTarget(MinimapMod.minimapGUI.playerIndex);
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class QuickMenuManagerPatch
	{
		private static bool isRealMenuOpen;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void FreezeWhenOpenedGUIPatch(ref bool ___isMenuOpen)
		{
			if (!((Object)(object)MinimapMod.minimapGUI == (Object)null))
			{
				bool flag = MinimapMod.minimapGUI.isGUIOpen || isRealMenuOpen;
				if (___isMenuOpen != flag)
				{
					___isMenuOpen = flag;
				}
			}
		}

		[HarmonyPatch("OpenQuickMenu")]
		[HarmonyPostfix]
		private static void OpenQuickMenuPatch()
		{
			isRealMenuOpen = true;
		}

		[HarmonyPatch("CloseQuickMenu")]
		[HarmonyPostfix]
		private static void CloseQuickMenuPatch()
		{
			isRealMenuOpen = false;
		}
	}
	[HarmonyPatch(typeof(ManualCameraRenderer))]
	internal class ManualCameraRendererPatch
	{
		private static Vector3 defaultEulerAngles = new Vector3(90f, 315f, 0f);

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void MapCameraAlwaysEnabledPatch(ref Camera ___mapCamera, ref PlayerControllerB ___targetedPlayer, ref Transform ___shipArrowPointer, GameObject ___shipArrowUI, ref Image ___compassRose, ref bool ___enableHeadMountedCam)
		{
			//IL_009e: 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_00b6: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)___mapCamera != (Object)null && (Object)(object)MinimapMod.minimapGUI != (Object)null)
			{
				((Behaviour)___mapCamera).enabled = true;
				if (___mapCamera.orthographicSize != MinimapMod.minimapGUI.minimapZoom)
				{
					___mapCamera.orthographicSize = MinimapMod.minimapGUI.minimapZoom;
				}
				if (MinimapMod.minimapGUI.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++)
				{
					array[i].mapRadarObject.transform.eulerAngles = new Vector3(defaultEulerAngles.x, ((Component)___mapCamera).transform.eulerAngles.y, defaultEulerAngles.z);
				}
				((Transform)((Graphic)___compassRose).rectTransform).localEulerAngles = new Vector3(0f, 0f, ((Component)___mapCamera).transform.eulerAngles.y);
			}
			if ((Object)(object)___shipArrowPointer != (Object)null && (Object)(object)___shipArrowUI != (Object)null && (Object)(object)___targetedPlayer != (Object)null && (Object)(object)MinimapMod.minimapGUI != (Object)null)
			{
				if (MinimapMod.minimapGUI.showShipArrow && !___targetedPlayer.isInsideFactory && Vector3.Distance(((Component)___targetedPlayer).transform.position, ((Component)StartOfRound.Instance.elevatorTransform).transform.position) > 16f)
				{
					if ((Object)(object)StartOfRound.Instance != (Object)null)
					{
						___shipArrowPointer.LookAt(StartOfRound.Instance.elevatorTransform);
					}
					int num = (MinimapMod.minimapGUI.autoRotate ? 45 : 0);
					___shipArrowPointer.eulerAngles = new Vector3(0f, ___shipArrowPointer.eulerAngles.y + (float)num, 0f);
					___shipArrowUI.SetActive(true);
				}
				else
				{
					___shipArrowUI.SetActive(false);
				}
			}
			if ((Object)(object)___compassRose != (Object)null && (Object)(object)MinimapMod.minimapGUI != (Object)null)
			{
				if (!StartOfRound.Instance.inShipPhase)
				{
					if (MinimapMod.minimapGUI.showCompass != ((Behaviour)___compassRose).enabled)
					{
						((Behaviour)___compassRose).enabled = MinimapMod.minimapGUI.showCompass;
					}
				}
				else if (((Behaviour)___compassRose).enabled)
				{
					((Behaviour)___compassRose).enabled = false;
				}
			}
			if ((Object)(object)MinimapMod.minimapGUI != (Object)null && !StartOfRound.Instance.inShipPhase && MinimapMod.minimapGUI.showHeadCam != ___enableHeadMountedCam)
			{
				___enableHeadMountedCam = MinimapMod.minimapGUI.showHeadCam;
			}
			else if (___enableHeadMountedCam)
			{
				___enableHeadMountedCam = false;
			}
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void HideHeadCamPlaceholderPatch(ref Image ___localPlayerPlaceholder)
		{
			if ((Object)(object)___localPlayerPlaceholder != (Object)null && (Object)(object)MinimapMod.minimapGUI != (Object)null && !MinimapMod.minimapGUI.showHeadCam && ((Behaviour)___localPlayerPlaceholder).enabled)
			{
				((Behaviour)___localPlayerPlaceholder).enabled = MinimapMod.minimapGUI.showHeadCam;
			}
		}

		[HarmonyPatch("updateMapTarget")]
		[HarmonyPrefix]
		private static bool RadarMapSwitchTargetPatch(int setRadarTargetIndex, ref int ___targetTransformIndex, ref IEnumerator __result)
		{
			if ((Object)(object)MinimapMod.minimapGUI == (Object)null)
			{
				return true;
			}
			MinimapMod.minimapGUI.realPlayerIndex = setRadarTargetIndex;
			if (MinimapMod.minimapGUI.freezePlayerIndex)
			{
				MinimapMod.minimapGUI.SetMinimapTarget(MinimapMod.minimapGUI.playerIndex);
				__result = DoNothingCoroutine();
				return false;
			}
			MinimapMod.minimapGUI.playerIndex = ___targetTransformIndex;
			return true;
		}

		private static IEnumerator DoNothingCoroutine()
		{
			yield break;
		}

		[HarmonyPatch("RemoveTargetFromRadar")]
		[HarmonyPostfix]
		private static void RemoveTargetFromMapPatch()
		{
			if ((Object)(object)MinimapMod.minimapGUI != (Object)null && MinimapMod.minimapGUI.freezePlayerIndex)
			{
				MinimapMod.minimapGUI.SwitchTarget();
			}
		}

		[HarmonyPatch("SwitchRadarTargetForward")]
		[HarmonyPrefix]
		private static bool DontSwitchTargetForwardPatch()
		{
			if ((Object)(object)MinimapMod.minimapGUI != (Object)null && MinimapMod.minimapGUI.freezePlayerIndex)
			{
				return false;
			}
			return true;
		}
	}
}