using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Timers; using AngryLevelLoader; using AngryLevelLoader.Containers; using AngryLevelLoader.Managers; using AngryLevelLoader.Notifications; using AngryLevelLoader.UserInterface; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using SettingsMenu.Components; using SettingsMenu.Models; using Steamworks; using Steamworks.Data; using TMPro; using UltraBINGO; using UltraBINGO.Components; using UltraBINGO.NetworkMessages; using UltraBINGO.UI_Elements; using UltraEditor.Classes; using UltraEditor.Classes.Canvas; using UltraEditor.Libraries; using UltrakillBingoClient; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; using WebSocketSharp; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class BingoMapBrowser { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__41_0; public static UnityAction <>9__41_1; public static UnityAction <>9__41_4; public static UnityAction <>9__43_0; public static UnityAction <>9__43_1; public static UnityAction <>9__43_2; internal void b__41_0(BaseEventData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ShowMapData((PointerEventData)data); } internal void b__41_1(BaseEventData data) { HideMapData(); } internal void b__41_4(BaseEventData data) { HideMapData(); } internal void b__43_0() { ReturnToLobby(); } internal void b__43_1() { GameManager.isUsingCustomMappool = true; GameManager.customMappool = selectedLevels; ReturnToLobby(); } internal void b__43_2(int ) { onCategoryUpdate(mapCategoryDropdown.value); } } public static GameObject LoadingText; public static GameObject MapBrowserWindow; public static GameObject SelectedMapsList; public static GameObject selectedMapsCount; public static GameObject BackButton; public static GameObject FinishButton; public static string angryCatalogURL = "https://raw.githubusercontent.com/eternalUnion/AngryLevels/release/V2/LevelCatalog.json"; public static string angryThumbnailURL = "https://raw.githubusercontent.com/eternalUnion/AngryLevels/release/Levels/"; public static string ultraEditorAPIURL = "https://duviz.xyz/api/ultraeditor/"; public static string ultraEditorCatalogURL = "fetchlevels"; public static string ultraEditorLevelURL = "getlevel/"; public static string ultraEditorLevelImageURL = "getimg/"; public static string ultraEditorDownloadURL = "downloadlevel/"; public static GameObject CampaignCategory; public static GameObject AngryCategory; public static GameObject UltraEditorCategory; public static List categoryList = new List(); public static GameObject MapTemplate; public static bool hasFetched = false; public static AngryMapCatalog catalog = null; public static List ultraEditorCatalog = null; public static TMP_Dropdown mapCategoryDropdown = null; public static Dictionary selectedLevels = new Dictionary(); public static List selectedLevelNames = new List(); public static List campaignLevelCatalog = new List(); public static List angryLevelCatalog = new List(); public static List ultraEditorLevelCatalog = new List(); public static List campaignLevelIds; public static void ReturnToLobby() { BingoEncapsulator.BingoMapSelection.SetActive(false); BingoEncapsulator.BingoLobbyScreen.SetActive(true); } public static void ShowMapData(PointerEventData pointerEventData, AngryBundle parentBundle = null, AngryLevel level = null) { } public static void HideMapData() { } public static void ClearCategories() { angryLevelCatalog.Clear(); ultraEditorLevelCatalog.Clear(); } public static async Task asyncFetchUltraEditorThumbnail(string imageName, string imageUrl) { if (File.Exists(Path.Combine(Main.ModFolder, "ThumbnailCache", imageName + ".png"))) { Logging.Message("Loading " + imageName + ".png from thumbnail cache"); byte[] array = File.ReadAllBytes(Path.Combine(Main.ModFolder, "ThumbnailCache", imageName + ".png")); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); return val; } Logging.Warn("Downloading " + imageName); UnityWebRequest texture = UnityWebRequestTexture.GetTexture(imageUrl); try { texture.SendWebRequest(); while (!texture.isDone) { await Task.Yield(); } if ((int)texture.result == 1) { Logging.Message("Saving " + imageName + ".png to thumbnail cache"); byte[] bytes = ImageConversion.EncodeToPNG(DownloadHandlerTexture.GetContent(texture)); File.WriteAllBytes(Path.Combine(Main.ModFolder, "ThumbnailCache", imageName + ".png"), bytes); return DownloadHandlerTexture.GetContent(texture); } Logging.Error("Error while trying to download image from thumbnail catalog!"); Logging.Error(texture.responseCode.ToString()); return null; } finally { ((IDisposable)texture)?.Dispose(); } } public static async Task FetchThumbnail(string thumbnailGuid) { if (File.Exists(Path.Combine(Main.ModFolder, "ThumbnailCache", thumbnailGuid + ".png"))) { byte[] array = File.ReadAllBytes(Path.Combine(Main.ModFolder, "ThumbnailCache", thumbnailGuid + ".png")); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); return val; } string text = angryThumbnailURL + "/" + thumbnailGuid + "/thumbnail.png"; UnityWebRequest texture = UnityWebRequestTexture.GetTexture(text); try { texture.SendWebRequest(); while (!texture.isDone) { await Task.Yield(); } if ((int)texture.result == 1) { Logging.Message("Saving " + thumbnailGuid + ".png to thumbnail cache"); byte[] bytes = ImageConversion.EncodeToPNG(DownloadHandlerTexture.GetContent(texture)); File.WriteAllBytes(Path.Combine(Main.ModFolder, "ThumbnailCache", thumbnailGuid + ".png"), bytes); return DownloadHandlerTexture.GetContent(texture); } Logging.Error("Error while trying to download image from thumbnail catalog!"); Logging.Error(texture.responseCode.ToString()); return null; } finally { ((IDisposable)texture)?.Dispose(); } } public static void UpdateSelectedMaps() { int num = GameManager.CurrentGame.gameSettingsArray["gridSize"]; int num2 = (3 + num) * (3 + num); ((TMP_Text)SelectedMapsList.GetComponent()).text = string.Join("\n", selectedLevelNames); ((TMP_Text)selectedMapsCount.GetComponent()).text = ((selectedLevels.Count >= num2) ? "" : "") + selectedLevels.Count + "/" + num2 + ""; } public static void ToggleMapSelection(ref GameObject levelPanel, string levelId, string levelName) { if (!selectedLevels.ContainsKey(levelId)) { selectedLevels.Add(levelId, levelPanel.GetComponent()); CommonFunctions.GetGameObjectChild(levelPanel, "SelectionIndicator").SetActive(true); selectedLevelNames.Add(levelName); } else { selectedLevels.Remove(levelId); CommonFunctions.GetGameObjectChild(levelPanel, "SelectionIndicator").SetActive(false); selectedLevelNames.Remove(levelName); } UpdateSelectedMaps(); } public static async Task fetchAngryCatalog() { try { catalog = JsonConvert.DeserializeObject(await NetworkManager.FetchCatalog(angryCatalogURL)); return 0; } catch (Exception ex) { Logging.Error(ex.ToString()); return -1; } } public static void setupCampaignLevelIds() { campaignLevelIds = new List(); for (int i = 1; i < 34; i++) { campaignLevelIds.Add(i); } List second = new List { 100, 101 }; List second2 = new List { 666, 667 }; campaignLevelIds = campaignLevelIds.Concat(second).Concat(second2).ToList(); } public static async Task asyncFetchUltraEditorThumbnails() { foreach (GameObject ultraeditorLevel in ultraEditorLevelCatalog) { Texture2D val = await asyncFetchUltraEditorThumbnail(ultraeditorLevel.GetComponent().UltraEditorImageName, ultraeditorLevel.GetComponent().UltraEditorImageURL); if ((Object)(object)val != (Object)null) { CommonFunctions.GetGameObjectChild(ultraeditorLevel, "BundleImage").GetComponent().sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } } public static async Task asyncFetchAngryThumbnails() { foreach (GameObject angryLevel in angryLevelCatalog) { if (!((Object)angryLevel).name.Contains("Level ")) { Texture2D val = await FetchThumbnail(angryLevel.GetComponent().angryBundleId); if ((Object)(object)val != (Object)null) { CommonFunctions.GetGameObjectChild(angryLevel, "BundleImage").GetComponent().sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } } } public static void ResetListPosition() { ((TMP_Text)SelectedMapsList.GetComponent()).text = ""; ((TMP_Text)selectedMapsCount.GetComponent()).text = ""; } public static async void Setup() { MapBrowserWindow.SetActive(true); if (hasFetched) { return; } setupCampaignLevelIds(); GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CampaignCategory, "Grid"), "Scroll View"), "Viewport"), "Content"), "MapTemplate"); foreach (int campaignLevel in campaignLevelIds) { GameObject levelPanel = Object.Instantiate(gameObjectChild, gameObjectChild.transform.parent); CommonFunctions.GetGameObjectChild(levelPanel, "BundleName").GetComponent().text = "CAMPAIGN"; CommonFunctions.GetGameObjectChild(levelPanel, "MapName").GetComponent().text = GetMissionName.GetMissionNameOnly(campaignLevel); CommonFunctions.GetGameObjectChild(levelPanel, "SelectionIndicator").SetActive(false); Entry val = new Entry(); val.eventID = (EventTriggerType)0; ((UnityEvent)(object)val.callback).AddListener((UnityAction)delegate(BaseEventData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ShowMapData((PointerEventData)data); }); levelPanel.AddComponent(); levelPanel.GetComponent().triggers.Add(val); ((UnityEvent)(object)new Entry { eventID = (EventTriggerType)1 }.callback).AddListener((UnityAction)delegate { HideMapData(); }); string text = "assets/bingo/lvlimg/campaign/" + GetMissionName.GetSceneName(campaignLevel) + ".png"; Texture2D val2 = AssetLoader.Assets.LoadAsset(text); Sprite sprite = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f); CommonFunctions.GetGameObjectChild(levelPanel, "BundleImage").GetComponent().sprite = sprite; ((Object)levelPanel).name = GetMissionName.GetSceneName(campaignLevel); levelPanel.SetActive(true); levelPanel.AddComponent(); levelPanel.GetComponent().levelType = BingoLevelType.Campaign; levelPanel.GetComponent().levelName = GetMissionName.GetMissionNameOnly(campaignLevel); levelPanel.GetComponent().levelId = GetMissionName.GetSceneName(campaignLevel); levelPanel.AddComponent