/// <summary> /// Main bootstrap method. Loads and patches all mods. /// </summary> public void Patch(bool hotload = false) { if (Patched && !hotload) { return; } Patched = true; string tungVersion = GetTungVersion(); MDebug.WriteLine("PiTUNG Framework version {0} on TUNG {1}", 0, new Version(PiTUNG.FrameworkVersion.Major, PiTUNG.FrameworkVersion.Minor, PiTUNG.FrameworkVersion.Build), tungVersion); MDebug.WriteLine("-------------Patching-------------" + (hotload ? " (reloading)" : "")); if (!hotload) { Configuration.LoadPitungConfig(); _Mods.Clear(); _Harmony = HarmonyInstance.Create("me.pipe01.pitung"); if (!Testing) { try { _Harmony.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception ex) { MDebug.WriteLine("[ERROR] PiTUNG failed to load! Exception: \n" + ex); return; } ModInput.LoadBinds(); IGConsole.Init(); } SceneManager.activeSceneChanged += SceneManager_activeSceneChanged; } if (!Testing) { AddDummyComponent(SceneManager.GetActiveScene()); } SelectionMenu.AllowModdedComponents = true; var mods = ModLoader.Order(ModLoader.GetMods()); foreach (var item in mods.Where(o => !o.MultiThreadedLoad)) { LoadMod(item, hotload); } CurrentlyLoading = null; new Thread(() => PatchThread(mods, hotload)).Start(); }