using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Security; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; using BoneLib; using BoneLib.BoneMenu; using BoneLib.BoneMenu.UI; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Forklift.Model; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.SceneStreaming; using Il2CppSLZ.Marrow.Warehouse; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using LabFusion.Data; using LabFusion.Downloading; using LabFusion.Downloading.ModIO; using LabFusion.Entities; using LabFusion.Marrow; using LabFusion.Marrow.Pool; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.Player; using LabFusion.RPC; using LabFusion.SDK.Modules; using LabFusion.Scene; using LabFusion.Senders; using LabFusion.UI.Popups; using LabFusion.Utilities; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using ModIoModNetworker.Ui; using ModioModNetworker; using ModioModNetworker.Data; using ModioModNetworker.Queue; using ModioModNetworker.UI; using ModioModNetworker.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ThunderstoreModAssistant.Utilities; using UnityEngine; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(MainClass), "ModioModNetworker", "2.8.0", "notnotnotswipez", null)] [assembly: AssemblyTitle("ModioModNetworker")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ModioModNetworker")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cdde6516-f286-4f2c-ad4b-d75164eb3e75")] [assembly: AssemblyFileVersion("2.8.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("2.8.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public class DownloadQueueElement { public PlayerID associatedPlayer; public ModInfo info; public bool notify = true; public bool lobby = false; } public class DownloadAction { public int delayFrames; public DownloadAction(int delayFrames) { this.delayFrames = delayFrames; } public bool Check() { if (delayFrames > 0) { delayFrames--; return false; } return true; } public void Handle() { Thread thread = new Thread((ThreadStart)delegate { try { string text = Path.Combine(ModFileManager.MOD_FOLDER_PATH, "tempfolder"); if (Directory.Exists(text)) { Directory.Delete(text, recursive: true); } Directory.CreateDirectory(text); MelonLogger.Msg("Extracting " + ModFileManager.downloadPath + " to " + text); using (ZipArchive zipArchive = ZipFile.OpenRead(ModFileManager.downloadPath)) { foreach (ZipArchiveEntry entry in zipArchive.Entries) { string text2 = Path.Combine(text, entry.FullName); if (entry.FullName.EndsWith("/")) { text2 = text2.Substring(0, text2.Length - 1); Directory.CreateDirectory(text2); } else { Directory.CreateDirectory(Path.GetDirectoryName(text2)); string fileName = Path.GetFileName(text2); string text3 = Path.Combine(Path.GetDirectoryName(text2), "tempExtractedFile.temp"); entry.ExtractToFile(text3, overwrite: true); File.Move(text3, Path.Combine(Path.GetDirectoryName(text3), fileName)); } } zipArchive.Dispose(); } MelonLogger.Msg("Extracted " + ModFileManager.downloadPath + " to " + text); string text4 = ModFileManager.FindFile(text, "pallet.json"); while (text4 != "") { string fullName = Directory.GetParent(text4).FullName; MelonLogger.Msg("Mod folder is: " + fullName); string text5 = (HelperMethods.IsAndroid() ? fullName.Split('/') : fullName.Split('\\'))[^1]; string text6 = ModFileManager.MOD_FOLDER_PATH + "/" + text5; bool flag = false; MelonLogger.Msg("Checking directory if it exists: " + text6); if (Directory.Exists(text6)) { MelonLogger.Msg("Directory exists: " + text6); flag = true; string text7 = ModFileManager.FindFile(text6, "pallet.json"); if (text7 != "") { string text8 = File.ReadAllText(text7); dynamic val = JsonConvert.DeserializeObject(text8); string item = (string)val["objects"]["1"]["barcode"]; MainClass.warehousePalletReloadTargets.Add(item); } else { flag = false; } Directory.Delete(text6, recursive: true); } Directory.Move(fullName, text6); string path = text6 + "/modinfo.json"; string contents = JsonConvert.SerializeObject((object)ModlistMenu.activeDownloadModInfo); File.WriteAllText(path, contents); if (!flag) { MainClass.warehouseReloadFolders.Add(ModFileManager.FindFile(text6, "pallet.json")); } text4 = ModFileManager.FindFile(text, "pallet.json"); MelonLogger.Msg(fullName + " Downloaded and extracted!"); } File.Delete(ModFileManager.downloadPath); Directory.Delete(text, recursive: true); MainClass.warehouseReloadRequested = true; MainClass.RequestInstallCheck(); MainClass.subsChanged = true; } catch (Exception ex) { MelonLogger.Error("Error while downloading mod " + ModlistMenu.activeDownloadModInfo.modId + ": " + ex); ModFileManager.isDownloading = false; ModFileManager.activeDownloadQueueElement = null; ModFileManager.activeDownloadWebRequest = null; ModlistMenu.activeDownloadModInfo = null; } }); thread.Start(); } } public class StalledAction { public int frameCount; public Action action; } namespace ThunderstoreModAssistant.Utilities { public class TimerManager { private static List timerDelayedJobs = new List(); public static void Update() { foreach (TimerDelayedAction timerDelayedJob in timerDelayedJobs) { timerDelayedJob.time -= Time.deltaTime; if (timerDelayedJob.time <= 0f) { timerDelayedJob.onTimeOver(); timerDelayedJob.completed = true; } } timerDelayedJobs.RemoveAll((TimerDelayedAction x) => x.completed); } public static void DelayAction(float time, Action onCompleted) { timerDelayedJobs.Add(new TimerDelayedAction { time = time, onTimeOver = onCompleted }); } } public class TimerDelayedAction { public float time; public Action onTimeOver; public bool completed = false; } } namespace ModIoModNetworker.Ui { [RegisterTypeInIl2Cpp] public class ModInfoDisplay : MonoBehaviour { public TMP_Text title; private RawImage thumbnailImage; public RawImage borderImage; public ModInfo modInfo; public Button button; public NetworkerMenuController controller; public GameObject subscriptionButton; private bool hasAddedThumbnail = false; public ModInfoDisplay(IntPtr intPtr) : base(intPtr) { } public void Awake() { thumbnailImage = ((Component)((Component)this).transform.Find("Thumbnail")).GetComponent(); title = ((Component)((Component)this).transform.Find("Text (TMP)")).GetComponent(); borderImage = ((Component)((Component)this).transform.Find("BaseOverlay")).GetComponent(); button = ((Component)((Component)this).transform.Find("Button")).GetComponent