Decompiled source of DynamicRebirth v1.2.0

DynamicRebirth.dll

Decompiled a day ago
using 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;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HG;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
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("DynamicRebirth")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[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.2.0")]
	public class DynamicRebirth : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetVote <0>__PreGameRuleVoteController_SetVote;

			public static hook_Init <1>__RuleCatalog_Init;

			public static Func<bool> <2>__HiddenTestFalse;
		}

		private const string PluginGUID = "MajOfMyth.DynamicRebirth";

		private const string PluginAuthor = "MajOfMyth";

		private const string PluginName = "DynamicRebirth";

		private const string PluginVersion = "1.2.0";

		private static ConfigEntry<bool> enableInternal;

		private static ConfigEntry<bool> enableTiers;

		private static ConfigEntry<bool> enableBlacklist;

		public void Awake()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			enableBlacklist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Blacklist", false, "Allow blacklisted items to show up in the list?");
			enableInternal = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Internal", false, "Allow internal items to show up in the list?");
			enableTiers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Banned Tiers", false, "Allow non-rebirth tiers to show up in the list?");
			object obj = <>O.<0>__PreGameRuleVoteController_SetVote;
			if (obj == null)
			{
				hook_SetVote val = PreGameRuleVoteController_SetVote;
				<>O.<0>__PreGameRuleVoteController_SetVote = val;
				obj = (object)val;
			}
			PreGameRuleVoteController.SetVote += (hook_SetVote)obj;
			object obj2 = <>O.<1>__RuleCatalog_Init;
			if (obj2 == null)
			{
				hook_Init val2 = RuleCatalog_Init;
				<>O.<1>__RuleCatalog_Init = val2;
				obj2 = (object)val2;
			}
			RuleCatalog.Init += (hook_Init)obj2;
		}

		private static void PreGameRuleVoteController_SetVote(orig_SetVote orig, PreGameRuleVoteController self, int ruleIndex, int choiceValue)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, ruleIndex, choiceValue);
			if (RuleCatalog.GetRuleDef(ruleIndex).globalName == "Rebirth")
			{
				self.networkUser.RpcStoreRebirthItems(RuleCatalog.GetChoiceDef(choiceValue).itemIndex);
			}
		}

		private static void RuleCatalog_Init(orig_Init orig)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)), "", "", (Func<bool>)RuleCatalog.HiddenTestFalse, (RuleCategoryType)1, (GridFormattingOverride)null);
			RuleCatalog.AddRule(Rebirth());
			orig.Invoke();
		}

		private static RuleDef Rebirth()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			//IL_0049: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			RuleDef val = new RuleDef("Rebirth", "You dream of rebirth.");
			List<ItemDef> list = ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).ToList();
			Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemTierDef current = enumerator.Current;
					Enumerator<ItemDef> enumerator2 = ItemCatalog.allItemDefs.GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							ItemDef current2 = enumerator2.Current;
							ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(current2.tier);
							if ((Object)(object)itemTierDef == (Object)(object)current)
							{
								if ((current.canRebirth || enableTiers.Value) && (!current2.ContainsTag((ItemTag)22) || enableBlacklist.Value))
								{
									RuleChoiceDef val2 = rebirthDefine(current2, val);
									val2.tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(current.colorIndex));
								}
								list.Remove(current2);
							}
						}
					}
					finally
					{
						((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			if (enableInternal.Value)
			{
				foreach (ItemDef item in list)
				{
					rebirthDefine(item, val);
				}
			}
			val.displayChoicesAsMultipleButtons = true;
			val.defaultChoiceIndex = 0;
			return val;
		}

		private static RuleChoiceDef rebirthDefine(ItemDef def, RuleDef ruleDef)
		{
			//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)
			RuleChoiceDef val = ruleDef.AddChoice(((Object)def).name, (object)null, false);
			val.spriteReference = def.pickupIconSpriteReference;
			val.tooltipNameToken = def.nameToken;
			val.tooltipBodyToken = def.descriptionToken;
			val.itemIndex = def.itemIndex;
			return val;
		}
	}
}