Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of EclipseSelector v1.0.0
EclipseSelector.dll
Decompiled a year 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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using Dolso.RiskofOptions; using HG.Reflection; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EclipseSelector")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+483c4e297ef848fe36a66434768b37ebe0250f0c")] [assembly: AssemblyProduct("EclipseSelector")] [assembly: AssemblyTitle("EclipseSelector")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Dolso { internal static class log { private static ManualLogSource logger; internal static void start(ManualLogSource logSource) { logger = logSource; } internal static void start(string name) { logger = Logger.CreateLogSource(name); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } internal static void LogError(this ILCursor c, object data) { logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}")); } internal static void LogErrorCaller(this ILCursor c, object data) { logger.LogError((object)string.Format($"ILCursor failure in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}")); } } } namespace Dolso.RiskofOptions { internal static class RiskofOptions { internal const string rooGuid = "com.rune580.riskofoptions"; internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); internal static void SetSprite(Sprite sprite) { ModSettingsManager.SetModIcon(sprite); } internal static void SetSpriteDefaultIcon() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName); try { Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png")))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } else { log.error("Failed to load icon.png"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } internal static void AddOption(ConfigEntry<bool> entry) { AddOption(entry, "", ""); } internal static void AddOption(ConfigEntry<bool> entry, string categoryName = "", string name = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { category = categoryName, name = name, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddOption(ConfigEntry<Color> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddOption(ConfigEntry<KeyboardShortcut> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}") { AddFloatSlider(entry, min, max, format); } internal static void AddOption(ConfigEntry<int> entry) { AddIntField(entry); } internal static void AddOption(ConfigEntry<string> entry) { AddString(entry); } internal static void AddString(ConfigEntry<string> entry, bool restartRequired = false, string categoryName = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(), restartRequired = restartRequired })); } internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).Min = min; ((NumericFieldConfig<float>)val).Max = max; ((NumericFieldConfig<float>)val).FormatString = format; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format); ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val)); } internal static void AddFloatSlider(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}", string categoryName = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } internal static void AddIntField(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown IntFieldConfig val = new IntFieldConfig(); ((NumericFieldConfig<int>)val).Min = min; ((NumericFieldConfig<int>)val).Max = max; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(); ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val)); } internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max, string categoryName = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } private static string DescWithDefault(this ConfigEntryBase entry) { return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]"; } private static string DescWithDefault(this ConfigEntryBase entry, string format) { return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description); } } } namespace EclipseSelector { internal static class Config { private static ConfigFile configFile; internal static ConfigEntry<string> difficulties; internal static ConfigEntry<float> stripWidth; internal static void DoConfig(ConfigFile bepConfigFile) { configFile = bepConfigFile; stripWidth = bepConfigFile.Bind<float>("EclipseSelector", "Lobby Panel Width", -0.22175f, "Extends the right side lobby panel, vanilla is 0."); if (RiskofOptions.enabled) { DoRiskOfOptions(); } } private static void DoRiskOfOptions() { RiskofOptions.SetSpriteDefaultIcon(); RiskofOptions.AddOption(stripWidth, -1f, 0f, "{0:f5}"); } internal static void EnsureDifficulties(RuleDef difficultyRule) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (difficulties != null) { return; } List<RuleChoiceDef> choices = difficultyRule.choices; List<DifficultyIndex> list = new List<DifficultyIndex>(); foreach (RuleChoiceDef item in choices) { if (!item.excludeByDefault) { list.Add(item.difficultyIndex); } } EclipseSelectorPlugin.defaultDifficulties = list; difficulties = configFile.Bind<string>("EclipseSelector", "Difficulties", "All", "Which difficulties to reveal.\nAdding 'Default' will reveal all normaly visible.\nAcceptable values: All, Default, " + string.Join(", ", choices.Select((RuleChoiceDef a) => a.localName))); difficulties.SettingChanged += delegate { EclipseSelectorPlugin.ShowDifficulties(); }; if (RiskofOptions.enabled) { DoRiskOfOptionsDifficulties(); } } private static void DoRiskOfOptionsDifficulties() { RiskofOptions.AddOption(difficulties); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void ReloadConfig(ConCommandArgs args) { configFile.Reload(); Debug.Log((object)"EclipseSelector config reloaded"); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.EclipseSelector", "EclipseSelector", "1.0.0")] public class EclipseSelectorPlugin : BaseUnityPlugin { internal static List<DifficultyIndex> defaultDifficulties; private void Awake() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) log.start(((BaseUnityPlugin)this).Logger); Config.DoConfig(((BaseUnityPlugin)this).Config); Config.stripWidth.SettingChanged += delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/CharacterSelectUIMain.prefab"); val2.Completed += FixUIWidth; }; AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/CharacterSelectUIMain.prefab"); val.Completed += FixUIWidth; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ShowDifficulties)); try { new ILHook((MethodBase)typeof(RuleBookViewerStrip).GetMethod("SetData"), new Manipulator(FixPartialScrolling_IL_RuleBookViewerStrip_SetData)); } catch (Exception data) { log.error(data); } } private static void FixUIWidth(AsyncOperationHandle<GameObject> handle) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)handle.Result.transform.Find("SafeArea/RightHandPanel/RuleVerticalLayout"); val.anchorMin = new Vector2(Config.stripWidth.Value, val.anchorMin.y); Transform val2 = ((Transform)val).Find("RuleBookViewerVertical/RuleStripPrefab"); if (!Object.op_Implicit((Object)(object)((Component)val2).GetComponent<LayoutElement>())) { ((Behaviour)((Component)val2).GetComponent<VerticalLayoutGroup>()).enabled = false; ((Component)val2).gameObject.AddComponent<LayoutElement>().minHeight = 74f; } } internal static void ShowDifficulties() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) try { RuleDef val = RuleCatalog.FindRuleDef("Difficulty"); Config.EnsureDifficulties(val); string[] array = Regex.Replace(Config.difficulties.Value, "[\n\t ]", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries); bool flag = false; for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim(); if (string.Compare(array[i], "All", StringComparison.OrdinalIgnoreCase) == 0) { foreach (RuleChoiceDef choice in val.choices) { choice.excludeByDefault = false; } return; } if (string.Compare(array[i], "Default", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; } } foreach (RuleChoiceDef choice2 in val.choices) { if (flag && defaultDifficulties.Contains(choice2.difficultyIndex)) { choice2.excludeByDefault = false; continue; } string[] array2 = array; int num = 0; while (true) { if (num < array2.Length) { string strB = array2[num]; if (string.Compare(choice2.localName, strB, StringComparison.OrdinalIgnoreCase) == 0) { choice2.excludeByDefault = false; break; } num++; continue; } choice2.excludeByDefault = true; break; } } } catch (Exception data) { log.error(data); } } private static void FixPartialScrolling_IL_RuleBookViewerStrip_SetData(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(PreGameController), "get_instance") })) { Instruction next = val.Next; if (val.TryGotoPrev(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 2) })) { val.Emit(OpCodes.Br, next); int iIndex = 0; int num = default(int); if (val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchLdloc(a, ref iIndex), (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref num) }) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 2) })) { val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldloc, iIndex); } else { val.LogErrorCaller("3"); } } else { val.LogErrorCaller("2"); } } else { val.LogErrorCaller("1"); } } } }