Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of 4x3Minimap v1.0.6
Minimap.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyMinimap.Component; using LethalCompanyMinimap.Patches; using TMPro; 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.5")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.5.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(); } } } public class VersionChecker { public static string latestVersion; private static async Task<bool> GetVersionFromUrlAsync(string url) { HttpClient client = new HttpClient(); try { ((HttpHeaders)client.DefaultRequestHeaders).Add("User-Agent", BuildUserAgentString()); try { latestVersion = ParseTagNameFromJson(await client.GetStringAsync(url)); return true; } catch (Exception ex) { MinimapMod.mls.LogError((object)("Failed to get the latest version from " + url + " for Minimap Mod. Error: " + ex.Message)); return false; } } finally { ((IDisposable)client)?.Dispose(); } } public static async Task GetLatestVersionAsync() { string fallbackUrl = "https://api.github.com/repos/tyzeron/LethalCompanyMinimap/releases/latest"; if (!(await GetVersionFromUrlAsync("http://lethalminimap.tyzeron.com"))) { await GetVersionFromUrlAsync(fallbackUrl); } } private static string ParseTagNameFromJson(string jsonString) { string text = "\"tag_name\":\""; int num = jsonString.IndexOf(text); if (num != -1) { int num2 = num + text.Length; int num3 = jsonString.IndexOf("\"", num2); if (num3 != -1) { return LStrip(jsonString.Substring(num2, num3 - num2), 'v'); } } return null; } private static string LStrip(string input, char charToStrip) { int i; for (i = 0; i < input.Length && input[i] == charToStrip; i++) { } return input.Substring(i); } private static string BuildUserAgentString() { string operatingSystemInfo = GetOperatingSystemInfo(); string text = (Environment.Is64BitOperatingSystem ? "x64" : "x86"); return "LethalCompanyMinimap/1.0.5 (" + operatingSystemInfo + "; " + text + ")"; } private static string GetOperatingSystemInfo() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return $"Windows NT {Environment.OSVersion.Version}"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return $"Mac OS X {Environment.OSVersion.Version}"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return $"Linux {Environment.OSVersion.Version}"; } return $"Unknown OS {Environment.OSVersion.Version}"; } } [BepInPlugin("LethalCompanyMinimap", "Minimap", "1.0.5")] public class MinimapMod : BaseUnityPlugin { public const string modGUID = "LethalCompanyMinimap"; public const string modName = "Minimap"; public const string modVersion = "1.0.5"; public const string modAuthor = "Tyzeron"; public const string modRepository = "tyzeron/LethalCompanyMinimap"; 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 = 150; 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> 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> freezePlayerIndexConfig; public static MinimapMod Instance; public static ManualLogSource mls; private readonly Harmony harmony = new Harmony("LethalCompanyMinimap"); public static MinimapGUI minimapGUI; private void Awake() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("LethalCompanyMinimap"); mls.LogInfo((object)"Minimap 1.0.5 loaded!"); VersionChecker.GetLatestVersionAsync(); 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(TimeOfDayPatch)); harmony.PatchAll(typeof(DeadBodyInfoPatch)); 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 = ((BaseUnityPlugin)this).Config.Bind<MouseAndKeyboard>("Hotkeys", "Open Mod Menu", defaultGuiKey, "Hotkey to open the Minimap mod menu"); toggleMinimapKeyConfig = ((BaseUnityPlugin)this).Config.Bind<MouseAndKeyboard>("Hotkeys", "Toggle Minimap", defaultToggleMinimapKey, "Hotkey to toggle the visibility of your Minimap"); toggleOverrideKeyConfig = ((BaseUnityPlugin)this).Config.Bind<MouseAndKeyboard>("Hotkeys", "Toggle Override Ship", defaultToggleOverrideKey, "Hotkey to toggle the override ship controls"); switchTargetKeyConfig = ((BaseUnityPlugin)this).Config.Bind<MouseAndKeyboard>("Hotkeys", "Switch Minimap Focus", defaultSwitchTargetKey, "Hotkey to switch the Minimap focus"); enableMinimapConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Basic Settings", "Enable Minimap", true, "Toggles visibility of your Minimap"); autoRotateConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Basic Settings", "Auto Rotate", true, "Auto-rotate the Map based on where you are facing"); minimapSizeConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Basic Settings", "Minimap Size", 150, "Adjusts the size of your Minimap"); minimapXPosConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Basic Settings", "X Offset", 0f, "Shifts the Minimap position horizontally"); minimapYPosConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Basic Settings", "Y Offset", 0f, "Shifts the Minimap position vertically"); minimapZoomConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Basic Settings", "Map Zoom", 19.7f, "Adjust the Map zoom level"); brightnessConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Basic Settings", "Brightness", 0f, "Adjust the brightness level"); showLootsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Loots", true, "Toggles visibility of loots (small triangles) on your Minimap"); showEnemiesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Enemies", true, "Toggles visibility of enemies (red circles) on your Minimap"); showLivePlayersConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Live Players", true, "Toggles visibility of live players (cyan circles) on your Minimap"); showDeadPlayersConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Dead Players", true, "Toggles visibility of dead players (greyed-out cyan circles) on your Minimap"); showRadarBoostersConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Radar Boosters", true, "Toggles visibility of radar boosters (blue circles) on your Minimap"); showTerminalCodesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Terminal Codes", true, "Toggles visibility of terminal codes on your Minimap"); showShipArrowConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap Icons", "Show Ship Arrow", true, "Toggles visibility of the arrow pointing to the Ship"); freezePlayerIndexConfig = ((BaseUnityPlugin)this).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"); } public void SyncGUIFromConfigs() { minimapGUI.guiKey.Key = guiKeyConfig.Value; minimapGUI.toggleMinimapKey.Key = toggleMinimapKeyConfig.Value; minimapGUI.toggleOverrideKey.Key = toggleOverrideKeyConfig.Value; minimapGUI.switchTargetKey.Key = switchTargetKeyConfig.Value; minimapGUI.enableMinimap = enableMinimapConfig.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.showLoots = showLootsConfig.Value; minimapGUI.showEnemies = showEnemiesConfig.Value; minimapGUI.showLivePlayers = showLivePlayersConfig.Value; minimapGUI.showDeadPlayers = showDeadPlayersConfig.Value; minimapGUI.showRadarBoosters = showRadarBoostersConfig.Value; minimapGUI.showTerminalCodes = showTerminalCodesConfig.Value; minimapGUI.showShipArrow = showShipArrowConfig.Value; minimapGUI.freezePlayerIndex = freezePlayerIndexConfig.Value; } public void SyncConfigFromGUI() { guiKeyConfig.Value = minimapGUI.guiKey.Key; toggleMinimapKeyConfig.Value = minimapGUI.toggleMinimapKey.Key; toggleOverrideKeyConfig.Value = minimapGUI.toggleOverrideKey.Key; switchTargetKeyConfig.Value = minimapGUI.switchTargetKey.Key; enableMinimapConfig.Value = minimapGUI.enableMinimap; autoRotateConfig.Value = minimapGUI.autoRotate; minimapSizeConfig.Value = minimapGUI.minimapSize; minimapXPosConfig.Value = minimapGUI.minimapXPos; minimapYPosConfig.Value = minimapGUI.minimapYPos; minimapZoomConfig.Value = minimapGUI.minimapZoom; brightnessConfig.Value = minimapGUI.brightness; showLootsConfig.Value = minimapGUI.showLoots; showEnemiesConfig.Value = minimapGUI.showEnemies; showLivePlayersConfig.Value = minimapGUI.showLivePlayers; showDeadPlayersConfig.Value = minimapGUI.showDeadPlayers; showRadarBoostersConfig.Value = minimapGUI.showRadarBoosters; showTerminalCodesConfig.Value = minimapGUI.showTerminalCodes; showShipArrowConfig.Value = minimapGUI.showShipArrow; 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 showLivePlayers; public bool showDeadPlayers; public bool showRadarBoosters; public bool showTerminalCodes; public bool showShipArrow; public bool freezePlayerIndex; 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 = "MONITORING"; 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 { 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 ? "LOCKED" : "MONITORING"); ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = prefix + ": " + StartOfRound.Instance.mapScreen.radarTargets[playerIndex].name; } if (!freezePlayerIndex && playerIndex != realPlayerIndex) { realPlayerIndex = CalculateValidTargetIndex(realPlayerIndex); SetMinimapTarget(realPlayerIndex); } } 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_026b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Unknown result type (might be due to invalid IL or missing references) //IL_0953: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) //IL_095c: Unknown result type (might be due to invalid IL or missing references) //IL_0961: Unknown result type (might be due to invalid IL or missing references) //IL_097f: 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.5\t\t\tby Tyzeron", tinyLabelStyle); navbarIndex = GUI.Toolbar(new Rect(num, num2 - 30f, 500f, 30f), navbarIndex, navbarStr, buttonStyle); num2 += 20f; switch (navbarIndex) { case 0: enableMinimap = GUI.Toggle(new Rect(num3, num2 + 90f, 300f, 30f), enableMinimap, "Toggle Minimap", toggleStyle); 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 = 150; } 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: 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); showLivePlayers = GUI.Toggle(new Rect(num3, num2 + 170f, 300f, 30f), showLivePlayers, "Show Live Players", toggleStyle); showDeadPlayers = GUI.Toggle(new Rect(num3, num2 + 210f, 300f, 30f), showDeadPlayers, "Show Dead Players", toggleStyle); showRadarBoosters = GUI.Toggle(new Rect(num3, num2 + 250f, 300f, 30f), showRadarBoosters, "Show Radar Boosters", toggleStyle); showTerminalCodes = GUI.Toggle(new Rect(num3, num2 + 290f, 300f, 30f), showTerminalCodes, "Show Terminal Codes", toggleStyle); showShipArrow = GUI.Toggle(new Rect(num3, num2 + 330f, 300f, 30f), showShipArrow, "Show Ship Arrow", toggleStyle); 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 num4 = 0; if (freezePlayerIndex) { float num5 = num2 + 180f; scrollPos = GUI.BeginScrollView(new Rect(num3, num5, 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 * num4), 270f, 30f), list[i].name)) { SetMinimapTarget(i); } num4++; } } GUI.EndScrollView(); } validTargetCount = num4; 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 != 0) { 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).Dispose(); } } break; } } MinimapMod.Instance.SyncConfigFromGUI(); } 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(HUDManager))] internal class HUDManagerPatch { public static readonly string prefix = "<color=#00ffffff>[Minimap]</color> "; public static readonly string prefixForBroadcast = "Tyzeron.Minimap"; private static readonly Regex parserRegex = new Regex("\\A<size=0>" + Regex.Escape(prefixForBroadcast) + "/([ -~]+)/([ -~]+)/([ -~]+)</size>\\z", RegexOptions.Compiled); private static IDictionary<string, string> myBroadcasts = new Dictionary<string, string>(); private static string lastMessage = ""; public static void SendClientMessage(string message) { HUDManager.Instance.AddTextToChatOnServer(prefix + message, -1); } [HarmonyPatch("AddTextMessageServerRpc")] [HarmonyPrefix] private static bool DontSendMinimapMessagesPatch(string chatMessage) { if (chatMessage.StartsWith(prefix)) { return false; } return true; } public static void SendMinimapBroadcast(string signature, string data = "null") { int num = (int)GameNetworkManager.Instance.localPlayerController.playerClientId; if (!myBroadcasts.ContainsKey(signature)) { myBroadcasts.Add(signature, data); } else { myBroadcasts[signature] = data; } HUDManager.Instance.AddTextToChatOnServer($"<size=0>{prefixForBroadcast}/{num}/{signature}/{data}</size>", -1); } } [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 const float aspectRatio = 1.3333334f; 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0280: 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) string text = null; if (VersionChecker.latestVersion == null) { text = "<color=red>Failed to check for latest version</color>"; } else if (new Version("1.0.5") < new Version(VersionChecker.latestVersion)) { text = "<color=white>There is a new version available: </color><color=green>" + VersionChecker.latestVersion + "</color>"; } if (text != null) { HUDManagerPatch.SendClientMessage(text); } int minimapSize = MinimapMod.minimapGUI.minimapSize; int num = (int)((float)minimapSize * 1.3333334f); 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)num, (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 = 6500f; 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); HUDManagerPatch.SendMinimapBroadcast("VersionReq"); HUDManagerPatch.SendMinimapBroadcast("VersionResp", "1.0.5"); } [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdateMinimapPatch(PlayerControllerB __instance) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0163: Unknown result type (might be due to invalid IL or missing references) if (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) { RectTransform obj = tooltips; obj.anchoredPosition -= new Vector2(0f, (float)MinimapMod.minimapGUI.minimapSize); } else { tooltips.anchoredPosition = tooltipsOriginalPos; } } if ((float)MinimapMod.minimapGUI.minimapSize != ((Graphic)minimap).rectTransform.sizeDelta.y) { int minimapSize = MinimapMod.minimapGUI.minimapSize; int num = (int)((float)minimapSize * 1.3333334f); ((Graphic)minimap).rectTransform.sizeDelta = new Vector2((float)num, (float)minimapSize); 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 = MinimapMod.minimapGUI.showTerminalCodes; [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void LootVisibilityOnMapPatch(GrabbableObject __instance) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) 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) { showTerminalCodes = MinimapMod.minimapGUI.showTerminalCodes; TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>(); FieldInfo fieldInfo = AccessTools.Field(typeof(TerminalAccessibleObject), "mapRadarText"); for (int i = 0; i < array.Length; i++) { ((Component)(TextMeshProUGUI)fieldInfo.GetValue(array[i])).gameObject.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) { 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 Light ___mapCameraLight, ref Transform ___shipArrowPointer, GameObject ___shipArrowUI) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)___mapCamera != (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>(); foreach (TerminalAccessibleObject val in array) { FieldInfo field = ((object)val).GetType().GetField("mapRadarText", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { ((TMP_Text)(TextMeshProUGUI)field.GetValue(val)).transform.eulerAngles = new Vector3(defaultEulerAngles.x, ((Component)___mapCamera).transform.eulerAngles.y, defaultEulerAngles.z); } } } if ((Object)(object)___mapCameraLight != (Object)null && (Object)(object)___targetedPlayer != (Object)null) { ((Behaviour)___mapCameraLight).enabled = ___targetedPlayer.isInsideFactory; if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { ___mapCameraLight.cullingMask = ~GameNetworkManager.Instance.localPlayerController.gameplayCamera.cullingMask; } } if (!((Object)(object)___shipArrowPointer != (Object)null) || !((Object)(object)___shipArrowUI != (Object)null) || !((Object)(object)___targetedPlayer != (Object)null)) { return; } 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); } } [HarmonyPatch("updateMapTarget")] [HarmonyPrefix] private static bool RadarMapSwitchTargetPatch(int setRadarTargetIndex, ref int ___targetTransformIndex, ref IEnumerator __result) { 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 (MinimapMod.minimapGUI.freezePlayerIndex) { MinimapMod.minimapGUI.SwitchTarget(); } } [HarmonyPatch("SwitchRadarTargetForward")] [HarmonyPrefix] private static bool DontSwitchTargetForwardPatch() { if (MinimapMod.minimapGUI.freezePlayerIndex) { return false; } return true; } } }