Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of DifficultySelection v0.1.3
DifficultySelection.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using RoR2; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.3.0")] namespace Local.Difficulty.Selection; [BepInPlugin("local.difficulty.selection", "DifficultySelection", "0.1.3")] public class Plugin : BaseUnityPlugin { public const string versionNumber = "0.1.3"; private static ConfigFile configuration; public void Awake() { configuration = ((BaseUnityPlugin)this).Config; Harmony.CreateAndPatchAll(typeof(Plugin), (string)null); } [HarmonyPatch(typeof(RuleCatalog), "Init")] [HarmonyFinalizer] private static void Initialize(Exception __exception) { if (__exception != null) { throw __exception; } UpdateSelection(); } [HarmonyPatch(typeof(PreGameController), "ResolveChoiceMask")] [HarmonyPrefix] private static void UpdateSelection() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Invalid comparison between Unknown and I4 RuleDef val = RuleCatalog.allRuleDefs?.FirstOrDefault(); List<RuleChoiceDef> list = val?.choices; if (list == null) { Console.WriteLine("ERROR: Unable to update difficulty selection."); return; } string[] array = list.Select((RuleChoiceDef choice) => choice.localName).ToArray(); string value = configuration.Bind<string>("General", "Default Difficulty", list.Find((RuleChoiceDef choice) => (int)choice.difficultyIndex == 2)?.localName, new ConfigDescription("If no other option is chosen in the lobby, this one will be selected by default.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array), Array.Empty<object>())).Value; foreach (RuleChoiceDef item in list) { IEnumerable<char> values = item.localName.Where(delegate(char letter) { bool flag; switch (letter) { case '\t': case '\n': case '"': case '\'': case '=': case '[': case '\\': case ']': flag = true; break; default: flag = false; break; } return !flag; }); ConfigFile obj = configuration; string text = string.Join("", values); string text2 = "Adjust this value to " + (item.excludeByDefault ? "show" : "hide") + " the \"" + Language.GetString(item.tooltipNameToken) + "\" difficulty option in the lobby."; item.excludeByDefault = !obj.Bind<bool>("Options", text, (int)item.difficultyIndex == 10 || !item.excludeByDefault, text2).Value; if (value == item.localName) { val.defaultChoiceIndex = item.localIndex; item.excludeByDefault = false; } } } }