Decompiled source of DynamicRebirth v1.1.0

DynamicRebirth.dll

Decompiled 2 weeks 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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DynamicRebirth")]
[assembly: AssemblyConfiguration("Release")]
[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]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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.1.0")]
	public class DynamicRebirth : BaseUnityPlugin
	{
		public const string PluginGUID = "MajOfMyth.DynamicRebirth";

		public const string PluginAuthor = "MajOfMyth";

		public const string PluginName = "DynamicRebirth";

		public const string PluginVersion = "1.1.0";

		public static ConfigEntry<bool> enableEquipment;

		public static ConfigEntry<bool> enableInternal;

		public static ConfigEntry<bool> enableVoid;

		public static ConfigEntry<bool> enableMeal;

		public static ConfigEntry<bool> enableLunar;

		public static ConfigEntry<bool> enableBlacklist;

		public void Awake()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			enableBlacklist = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Blacklist", false, "Allow blacklisted items to show up in the list?");
			enableEquipment = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Equipment", false, "Allow equipment to show up in the list? CURRENTLY NOT USABLE, WIP:tm:");
			enableInternal = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Internal", false, "Allow internal items to show up in the list?");
			enableVoid = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Void", false, "Allow void items to show up in the list?");
			enableMeal = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Meal", false, "Allow meal items to show up in the list?");
			enableLunar = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby List", "Enable Lunar", false, "Allow lunar items to show up in the list?");
			PreGameRuleVoteController.SetVote += new hook_SetVote(PreGameRuleVoteController_SetVote);
			RuleCatalog.Init += new hook_Init(RuleCatalog_Init);
		}

		private void PreGameRuleVoteController_SetVote(orig_SetVote orig, PreGameRuleVoteController self, int ruleIndex, int choiceValue)
		{
			//IL_002e: 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 void RuleCatalog_Init(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)196, (byte)143, (byte)51, byte.MaxValue)), "", (string)null, (Func<bool>)RuleCatalog.HiddenTestFalse, (RuleCategoryType)0);
			RuleCatalog.AddRule(Rebirth());
			orig.Invoke();
		}

		public 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Invalid comparison between Unknown and I4
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Invalid comparison between Unknown and I4
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Invalid comparison between Unknown and I4
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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;
					if (((int)current.tier == 9 && !enableVoid.Value) || ((int)current.tier == 6 && !enableVoid.Value) || ((int)current.tier == 7 && !enableVoid.Value) || ((int)current.tier == 8 && !enableVoid.Value) || ((int)current.tier == 10 && !enableMeal.Value) || ((int)current.tier == 3 && !enableLunar.Value))
					{
						continue;
					}
					Enumerator<ItemDef> enumerator2 = ItemCatalog.allItemDefs.GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							ItemDef current2 = enumerator2.Current;
							if ((!current2.ContainsTag((ItemTag)22) || enableBlacklist.Value) && (Object)(object)ItemTierCatalog.GetItemTierDef(current2.tier) == (Object)(object)current)
							{
								rebirthDefine(current2, val).tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(current.colorIndex));
								list.Remove(current2);
							}
						}
					}
					finally
					{
						((IDisposable)enumerator2).Dispose();
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			if (enableEquipment.Value)
			{
				AllEquipmentEnumerator enumerator3 = EquipmentCatalog.allEquipment.GetEnumerator();
				try
				{
					while (((AllEquipmentEnumerator)(ref enumerator3)).MoveNext())
					{
						EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(((AllEquipmentEnumerator)(ref enumerator3)).Current);
						rebirthDefine(equipmentDef, val).tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(equipmentDef.colorIndex));
					}
				}
				finally
				{
					((IDisposable)(AllEquipmentEnumerator)(ref enumerator3)).Dispose();
				}
			}
			if (enableInternal.Value)
			{
				foreach (ItemDef item in list)
				{
					rebirthDefine(item, val);
				}
			}
			val.defaultChoiceIndex = 0;
			return val;
		}

		public 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.sprite = def.pickupIconSprite;
			obj.tooltipNameToken = def.nameToken;
			obj.tooltipBodyToken = def.descriptionToken;
			obj.itemIndex = def.itemIndex;
			return obj;
		}

		public static RuleChoiceDef rebirthDefine(EquipmentDef 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.sprite = def.pickupIconSprite;
			obj.tooltipNameToken = def.nameToken;
			obj.tooltipBodyToken = def.descriptionToken;
			obj.equipmentIndex = def.equipmentIndex;
			return obj;
		}
	}
}