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 Empress StartAtLevel v1.0.0
Over9000.dll
Decompiled 6 months agousing System; 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 BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Over9000")] [assembly: AssemblyTitle("Over9000")] [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.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; } } [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 Empress.StartAtLevel { [BepInPlugin("Empress.StartAtLevel", "StartAtLevel", "1.0.1")] public class StartAtLevelPlugin : BaseUnityPlugin { public const string PluginGuid = "Empress.StartAtLevel"; public const string PluginName = "StartAtLevel"; public const string PluginVersion = "1.0.1"; internal static ConfigEntry<int> StartLevelCfg; internal static bool AppliedThisRun; internal static StartAtLevelPlugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; StartLevelCfg = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StartLevel", 9001, "Start the run at this level number (1-based). Host-only authority. Set >= 1."); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded. Starting level: {StartLevelCfg.Value}"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel", new Type[] { typeof(bool), typeof(bool), typeof(ChangeLevelType) })] internal static class Patch_RunManager_ChangeLevel { private static void Prefix(bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType) { try { if (!SemiFunc.IsMasterClientOrSingleplayer() || StartAtLevelPlugin.AppliedThisRun) { return; } RunManager instance = RunManager.instance; if ((Object)(object)instance == (Object)null) { return; } int num = Mathf.Max(1, StartAtLevelPlugin.StartLevelCfg.Value); int num2 = num - 1; if (instance.levelsCompleted < num2) { bool flag = _completedLevel && instance.levelsCompleted == 0 && ((Object)(object)instance.levelCurrent == (Object)(object)instance.levelLobby || (Object)(object)instance.levelCurrent == (Object)(object)instance.levelLobbyMenu); bool flag2 = !_completedLevel && !_levelFailed && instance.levelsCompleted == 0; if (flag || flag2) { instance.levelsCompleted = num2; SemiFunc.StatSetRunLevel(num2); StartAtLevelPlugin.AppliedThisRun = true; StartAtLevelPlugin.Logger.LogInfo((object)$"Forcing start level to {num} (levelsCompleted={num2}). Host-only, applied."); } } } catch (Exception arg) { StartAtLevelPlugin.Logger.LogError((object)$"StartAtLevel prefix failed: {arg}"); } } } [HarmonyPatch(typeof(RunManager), "ResetProgress")] internal static class Patch_RunManager_ResetProgress { private static void Postfix() { StartAtLevelPlugin.AppliedThisRun = false; StartAtLevelPlugin.Logger.LogInfo((object)"Progress reset detected. StartAtLevel will re-apply on next run start."); } } }