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 PauseOnLoad v1.0.0
PauseOnLoad.dll
Decompiled a week agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("PauseOnLoad")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PauseOnLoad")] [assembly: AssemblyTitle("PauseOnLoad")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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; } } } namespace PauseOnLoad { [BepInPlugin("ArchUmbra.PauseOnLoad", "PauseOnLoad", "1.0.0")] public class PauseOnLoadPlugin : BaseUnityPlugin { public const string PluginGUID = "ArchUmbra.PauseOnLoad"; public const string PluginName = "PauseOnLoad"; public const string PluginVersion = "1.0.0"; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<float> PauseDelay; public static bool HasPausedThisSession; public static MethodInfo ShowMenuMethod; public static FieldInfo MenuInstanceField; public static PropertyInfo MenuInstanceProperty; private Harmony harmony; private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Set to false to disable auto-pausing on world load."); PauseDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PauseDelay", 1f, new ConfigDescription("Delay in seconds after spawning before pausing the game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); MenuInstanceField = AccessTools.Field(typeof(Menu), "m_instance"); MenuInstanceProperty = AccessTools.Property(typeof(Menu), "instance"); ShowMenuMethod = AccessTools.Method(typeof(Menu), "Show", (Type[])null, (Type[])null); harmony = new Harmony("ArchUmbra.PauseOnLoad"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PauseOnLoad v1.0.0 successfully loaded!"); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } [HarmonyPatch(typeof(ZNet), "Awake")] public static class ZNet_Awake_Patch { private static void Prefix() { PauseOnLoadPlugin.HasPausedThisSession = false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class Player_OnSpawned_Patch { private static void Postfix(Player __instance) { if (PauseOnLoadPlugin.ModEnabled.Value && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && ZNet.IsSinglePlayer && !PauseOnLoadPlugin.HasPausedThisSession) { PauseOnLoadPlugin.HasPausedThisSession = true; ((MonoBehaviour)__instance).StartCoroutine(PauseRoutine()); } } private static IEnumerator PauseRoutine() { float value = PauseOnLoadPlugin.PauseDelay.Value; if (value > 0f) { yield return (object)new WaitForSeconds(value); } yield return (object)new WaitForEndOfFrame(); if (!Menu.IsVisible() && PauseOnLoadPlugin.ShowMenuMethod != null) { object obj = PauseOnLoadPlugin.MenuInstanceField?.GetValue(null) ?? PauseOnLoadPlugin.MenuInstanceProperty?.GetValue(null); if (obj != null) { PauseOnLoadPlugin.ShowMenuMethod.Invoke(obj, null); } } } } }