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 StageToggle v1.0.0
plugins/stageRemover/StageToggle.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; 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 Microsoft.CodeAnalysis; using On.RoR2; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("StageToggle")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("StageToggle")] [assembly: AssemblyTitle("StageToggle")] [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 StageToggle { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("virgile.StageToggle", "StageToggle", "1.0.0")] public class StageTogglePlugin : BaseUnityPlugin { private class StageEntry { public string Title; public ConfigEntry<bool> Enabled; public string[] SceneNames; } public const string PluginGUID = "virgile.StageToggle"; public const string PluginAuthor = "virgile"; public const string PluginName = "StageToggle"; public const string PluginVersion = "1.0.0"; private static readonly List<StageEntry> entries = new List<StageEntry>(); private static readonly HashSet<SceneDef> bannedScenes = new HashSet<SceneDef>(); public void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); InitConfig(); Run.PickNextStageScene += new hook_PickNextStageScene(OnPickNextStageScene); SetupRiskOfOptions(); Log.Info("StageToggle v1.0.0 loaded!", "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 55); } private void SetupRiskOfOptions() { try { Type type = FindType("RiskOfOptions.Options.CheckBoxOption"); Type type2 = FindType("RiskOfOptions.ModSettingsManager"); if (type == null || type2 == null) { Log.Info("Risk of Options not detected: settings available via the config file only.", "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 71); return; } ConstructorInfo constructor = type.GetConstructor(new Type[1] { typeof(ConfigEntry<bool>) }); if (constructor == null) { Log.Warning("Risk of Options: CheckBoxOption(ConfigEntry<bool>) not found.", "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 79); return; } MethodInfo methodInfo = type2.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "AddOption" && m.GetParameters().Length == 1); if (methodInfo == null) { Log.Warning("Risk of Options: ModSettingsManager.AddOption not found.", "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 89); return; } foreach (StageEntry entry in entries) { object obj = constructor.Invoke(new object[1] { entry.Enabled }); methodInfo.Invoke(null, new object[1] { obj }); } Log.Info("Risk of Options: stage toggles added to the menu.", "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 99); } catch (Exception ex) { Log.Warning("Risk of Options: integration failed: " + ex, "C:\\modRiskRain\\stageRemover\\stageRemover\\ExamplePlugin.cs", 103); } } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName); if (type != null) { return type; } } return null; } private void InitConfig() { Add("Distant Roost", "blackbeach", "blackbeach2"); Add("Titanic Plains", "golemplains", "golemplains2"); Add("Abandoned Aqueduct", "goolake"); Add("Wetland Aspect", "foggyswamp"); Add("Rallypoint Delta", "frozenwall"); Add("Scorched Acres", "wispgraveyard"); Add("Abyssal Depths", "dampcavesimple"); Add("Sirens Call", "shipgraveyard"); Add("Sundered Grove", "rootjungle"); Add("Sky Meadow", "skymeadow"); Add("Verdant Falls", "lakes", "lakesnight"); Add("Aphelian Sanctuary", "ancientloft"); Add("Siphoned Forest", "snowyforest"); Add("Sulfur Pools", "sulfurpools"); Add("Shattered Abodes", "village", "villagenight"); Add("Helminth Hatchery", "helminthroost"); } private void Add(string title, params string[] sceneNames) { ConfigEntry<bool> enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", title, true, "Allow '" + title + "' to appear in the stage rotation. Uncheck to ban it from your runs."); entries.Add(new StageEntry { Title = title, Enabled = enabled, SceneNames = sceneNames }); } private static void RebuildBannedScenes() { bannedScenes.Clear(); foreach (StageEntry entry in entries) { if (entry.Enabled.Value) { continue; } string[] sceneNames = entry.SceneNames; foreach (string text in sceneNames) { SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(text); if ((Object)(object)sceneDefFromSceneName != (Object)null) { bannedScenes.Add(sceneDefFromSceneName); } } } } private void OnPickNextStageScene(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && choices != null && choices.Count > 0) { RebuildBannedScenes(); if (bannedScenes.Count > 0) { WeightedSelection<SceneDef> val = new WeightedSelection<SceneDef>(8); int num = 0; for (int i = 0; i < choices.Count; i++) { ChoiceInfo<SceneDef> choice = choices.GetChoice(i); if ((Object)(object)choice.value == (Object)null || !bannedScenes.Contains(choice.value)) { val.AddChoice(choice.value, choice.weight); num++; } } if (num > 0 && num < choices.Count) { choices = val; } } } orig.Invoke(self, choices); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string Format(object data, string file, int line) { string fileName = Path.GetFileName(file); return $"[{fileName}:{line}] {data}"; } internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogDebug((object)Format(data, file, line)); } internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogError((object)Format(data, file, line)); } internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogFatal((object)Format(data, file, line)); } internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogInfo((object)Format(data, file, line)); } internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogMessage((object)Format(data, file, line)); } internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogWarning((object)Format(data, file, line)); } } }