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 DynamicRebirth v1.3.2
DynamicRebirth.dll
Decompiled 4 days 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 HG; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MajOfMyth")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9000151d39dd0e55c2baf84da8b54ca43445218a")] [assembly: AssemblyProduct("DynamicRebirth")] [assembly: AssemblyTitle("DynamicRebirth")] [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 DynamicRebirth { [BepInPlugin("MajOfMyth.DynamicRebirth", "DynamicRebirth", "1.3.2")] public class DynamicRebirth : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_Init <0>__RuleCatalogOnInit; public static hook_SetVote <1>__PreGameRuleVoteControllerOnSetVote; public static hook_RpcStoreRebirthItems <2>__NetworkUserOnRpcStoreRebirthItems; public static hook_ResolveChoiceMask <3>__PreGameControllerOnResolveChoiceMask; public static hook_Start <4>__RuleChoiceControllerOnStart; public static Func<bool> <5>__HiddenTestFalse; } private const string PluginGUID = "MajOfMyth.DynamicRebirth"; private const string PluginAuthor = "MajOfMyth"; private const string PluginName = "DynamicRebirth"; private const string PluginVersion = "1.3.2"; private static ConfigEntry<bool> unlockSystem; private static ConfigEntry<bool> hideLocked; private static ConfigEntry<bool> enableBlacklist; private static ConfigEntry<bool> enableTiers; private static ConfigEntry<bool> enableInternal; private static ConfigEntry<string> extraBans; private static readonly string SavesDirectory = Path.Combine(Application.persistentDataPath, "DynamicRebirth"); public void Awake() { //IL_0016: 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_0021: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown Configs(); object obj = <>O.<0>__RuleCatalogOnInit; if (obj == null) { hook_Init val = RuleCatalogOnInit; <>O.<0>__RuleCatalogOnInit = val; obj = (object)val; } RuleCatalog.Init += (hook_Init)obj; object obj2 = <>O.<1>__PreGameRuleVoteControllerOnSetVote; if (obj2 == null) { hook_SetVote val2 = PreGameRuleVoteControllerOnSetVote; <>O.<1>__PreGameRuleVoteControllerOnSetVote = val2; obj2 = (object)val2; } PreGameRuleVoteController.SetVote += (hook_SetVote)obj2; object obj3 = <>O.<2>__NetworkUserOnRpcStoreRebirthItems; if (obj3 == null) { hook_RpcStoreRebirthItems val3 = NetworkUserOnRpcStoreRebirthItems; <>O.<2>__NetworkUserOnRpcStoreRebirthItems = val3; obj3 = (object)val3; } NetworkUser.RpcStoreRebirthItems += (hook_RpcStoreRebirthItems)obj3; object obj4 = <>O.<3>__PreGameControllerOnResolveChoiceMask; if (obj4 == null) { hook_ResolveChoiceMask val4 = PreGameControllerOnResolveChoiceMask; <>O.<3>__PreGameControllerOnResolveChoiceMask = val4; obj4 = (object)val4; } PreGameController.ResolveChoiceMask += (hook_ResolveChoiceMask)obj4; object obj5 = <>O.<4>__RuleChoiceControllerOnStart; if (obj5 == null) { hook_Start val5 = RuleChoiceControllerOnStart; <>O.<4>__RuleChoiceControllerOnStart = val5; obj5 = (object)val5; } RuleChoiceController.Start += (hook_Start)obj5; } private void Configs() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown unlockSystem = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Unlock System", true, "Unlock items by putting them in the shrine instead of having access to all of them?"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(unlockSystem)); hideLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide Locked Items", true, "Prevent locked items from showing up in the list?"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(hideLocked)); enableBlacklist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Blacklisted Items", false, "Allow blacklisted items to show up in the list?"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableBlacklist)); enableTiers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Blacklisted Tiers", false, "Allow blacklisted tiers to show up in the list?"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableTiers)); enableInternal = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Internal Items", false, "Allow internal (untiered) items to show up in the list?"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableInternal)); extraBans = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Extra Item Bans", "ArtifactKey,MasterBattery,HelpWake", "What other items shouldn't show up? (Internal name, separated by commas, no spaces)"); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(extraBans)); } private static void RuleCatalogOnInit(orig_Init orig) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) RuleCatalog.AddCategory("Rebirth", "Gifted With Rebirth.", Color32.op_Implicit(new Color32((byte)63, (byte)185, (byte)137, byte.MaxValue)), "You have no Rebirth items available.", "", (Func<bool>)RuleCatalog.HiddenTestFalse, (RuleCategoryType)1, (GridFormattingOverride)null); RuleCatalog.AddRule(Rebirth()); orig.Invoke(); } private static void PreGameRuleVoteControllerOnSetVote(orig_SetVote orig, PreGameRuleVoteController self, int ruleIndex, int choiceValue) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, ruleIndex, choiceValue); if (!(RuleCatalog.GetRuleDef(ruleIndex).globalName != "DynamicRebirth") && self.localUser != null && choiceValue != -1) { ItemIndex itemIndex = RuleCatalog.GetChoiceDef(choiceValue).itemIndex; self.localUser.userProfile.RebirthItem = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(itemIndex))?.internalName; self.networkUser.SyncRebirthItemsToServer(); } } private static void NetworkUserOnRpcStoreRebirthItems(orig_RpcStoreRebirthItems orig, NetworkUser self, ItemIndex item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, item); if (self.localUser != null) { string path = Path.Combine(SavesDirectory, self.localUser.userProfile.fileName); Directory.CreateDirectory(SavesDirectory); List<string> list = new List<string>(); if (File.Exists(path)) { list = File.ReadAllLines(path).ToList(); } list.Add(((Object)ItemCatalog.GetItemDef(item)).name); File.WriteAllLines(path, list); } } private static void PreGameControllerOnResolveChoiceMask(orig_ResolveChoiceMask orig, PreGameController self) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!unlockSystem.Value) { return; } ItemIndex[] rebornItems = GetRebornItems(); for (int i = 0; i < ((SerializableBitArray)self.choiceMaskBuffer).length; i++) { RuleChoiceDef choiceDef = RuleCatalog.GetChoiceDef(i); if (choiceDef.ruleDef.globalName == "DynamicRebirth") { ((SerializableBitArray)self.choiceMaskBuffer)[i] = rebornItems.Contains(choiceDef.itemIndex); } } self.networkRuleChoiceMaskComponent.SetRuleChoiceMask(self.choiceMaskBuffer); self.EnforceValidRuleChoices(); } private static void RuleChoiceControllerOnStart(orig_Start orig, RuleChoiceController self) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!(self.choiceDef.ruleDef.globalName != "DynamicRebirth") && unlockSystem.Value && !((SerializableBitArray)PreGameController.instance.resolvedRuleChoiceMask)[self.choiceDef.globalIndex]) { ((Graphic)self.image).color = Color.black; } } private static RuleDef Rebirth() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) RuleDef val = new RuleDef("DynamicRebirth", "Rebirth"); List<ItemDef> list = ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).ToList(); List<ItemDef> list2 = new List<ItemDef>(); string[] array = extraBans.Value.Split(','); foreach (string text in array) { try { list2.Add(ItemCatalog.GetItemDef(ItemCatalog.itemNameToIndex[text])); } catch { Debug.LogError((object)("DynamicRebirth: Invalid item \"" + text + "\".")); } } Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemTierDef tierDef = enumerator.Current; foreach (ItemDef item in ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).Where((ItemDef itemDef) => (Object)(object)tierDef == (Object)(object)ItemTierCatalog.GetItemTierDef(itemDef.tier))) { if ((tierDef.canRebirth || enableTiers.Value) && (!item.ContainsTag((ItemTag)22) || enableBlacklist.Value) && !list2.Contains(item)) { rebirthDefine(item, val).tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(tierDef.colorIndex)); } list.Remove(item); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (enableInternal.Value) { foreach (ItemDef item2 in list) { rebirthDefine(item2, val); } } val.displayChoicesAsMultipleButtons = true; val.hideLockedChoicesInLobby = hideLocked.Value; val.defaultChoiceIndex = 0; return val; } private static RuleChoiceDef rebirthDefine(ItemDef def, RuleDef ruleDef) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) RuleChoiceDef obj = ruleDef.AddChoice(((Object)def).name, (object)null, false); obj.spriteReference = def.pickupIconSpriteReference; obj.tooltipNameToken = def.nameToken; obj.tooltipBodyToken = def.descriptionToken; obj.itemIndex = def.itemIndex; obj.sprite = def.pickupIconSprite; return obj; } private static ItemIndex[] GetRebornItems() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) LocalUser localUser = ((MPEventSystem)EventSystem.current).localUser; string text = ((localUser != null) ? localUser.userProfile.fileName : null); List<ItemIndex> list = new List<ItemIndex>(); if (text != null) { string path = Path.Combine(SavesDirectory, text); if (File.Exists(path)) { string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { ItemIndex val = ItemCatalog.FindItemIndex(array[i]); if ((int)val != -1) { list.Add(val); } } } } return list.ToArray(); } } }