Please disclose if any significant portion of your mod was created 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 Async Mod Loader v1.0.0
kg_AsyncModLoader.dll
Decompiled 8 months agousing 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 System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("AsyncModLoader")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("KG")] [assembly: AssemblyProduct("AsyncModLoader")] [assembly: AssemblyCopyright("Copyright © KG 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("46AFE45E-DE50-4228-B044-176AFA27CBCE")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace AsyncModLoader { public static class AsyncModLoaderExtensions { public static void AsyncModLoaderInit(this BaseUnityPlugin plugin) { AsyncModLoader.ToAsyncLoad.Add(plugin.Info.Metadata.GUID); } public static void AsyncModLoaderDone(this BaseUnityPlugin plugin) { AsyncModLoader.ToAsyncLoad.Remove(plugin.Info.Metadata.GUID); } } [BepInPlugin("kg.AsyncModLoader", "Async Mod Loader", "1.0.0")] internal class AsyncModLoader : BaseUnityPlugin { [HarmonyPatch(typeof(EntryPointSceneLoader), "Start")] private static class EntryPointSceneLoader_Start_Patch { private static bool Prefix(EntryPointSceneLoader __instance) { if (ToAsyncLoad.Count == 0) { Logger.LogInfo((object)"No mods require async loading, starting Valheim normally"); return true; } Logger.LogInfo((object)"Delaying Valheim start for mod async loading"); ((MonoBehaviour)__instance).StartCoroutine(AwaitMods()); return false; } } private const string GUID = "kg.AsyncModLoader"; private const string NAME = "Async Mod Loader"; private static readonly ManualLogSource Logger = Logger.CreateLogSource("kg.AsyncModLoader"); private const string VERSION = "1.0.0"; internal static HashSet<string> ToAsyncLoad = new HashSet<string>(); private static readonly Harmony Harmony = new Harmony("kg.AsyncModLoader"); private void Awake() { Harmony.PatchAll(); } private static IEnumerator AwaitMods() { while (ToAsyncLoad.Count > 0) { yield return null; } Harmony.UnpatchSelf(); SceneManager.LoadScene("EntryPoint", (LoadSceneMode)0); } } }