Decompiled source of EnigmaBlacklist v1.0.4

EnigmaBlacklist.dll

Decompiled 4 months 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 On.RoR2;
using On.RoR2.Artifacts;
using RoR2;
using RoR2.Artifacts;

[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("EnigmaBlacklist")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1c24f7fb9154ae2fd7e5ac981a3f4674313269d6")]
[assembly: AssemblyProduct("EnigmaBlacklist")]
[assembly: AssemblyTitle("EnigmaBlacklist")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EnigmaBlacklist
{
	[BepInPlugin("com.Moffein.EnigmaBlacklist", "Enigma Blacklist", "1.0.4")]
	public class EnigmaBlacklist : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<char, bool> <>9__7_2;

			public static Func<char, bool> <>9__7_3;

			public static hook_Init <>9__7_0;

			public static hook_OnRunStartGlobal <>9__7_1;

			internal void <Awake>b__7_0(orig_Init orig)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Invalid comparison between Unknown and I4
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Invalid comparison between Unknown and I4
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke();
				blacklistString = new string((from c in blacklistString.ToCharArray()
					where !char.IsWhiteSpace(c)
					select c).ToArray());
				string[] array = blacklistString.Split(',');
				string[] array2 = array;
				foreach (string text in array2)
				{
					EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(text);
					if ((int)val != -1)
					{
						blacklist.Add(val);
					}
				}
				whitelistString = new string((from c in whitelistString.ToCharArray()
					where !char.IsWhiteSpace(c)
					select c).ToArray());
				string[] array3 = whitelistString.Split(',');
				string[] array4 = array3;
				foreach (string text2 in array4)
				{
					EquipmentIndex val2 = EquipmentCatalog.FindEquipmentIndex(text2);
					if ((int)val2 != -1)
					{
						whitelist.Add(val2);
					}
				}
			}

			internal bool <Awake>b__7_2(char c)
			{
				return !char.IsWhiteSpace(c);
			}

			internal bool <Awake>b__7_3(char c)
			{
				return !char.IsWhiteSpace(c);
			}

			internal void <Awake>b__7_1(orig_OnRunStartGlobal orig, Run run)
			{
				//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_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: 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_0086: 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)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: 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)
				orig.Invoke(run);
				List<EquipmentIndex> list = new List<EquipmentIndex>();
				foreach (EquipmentIndex item in EnigmaArtifactManager.validEquipment)
				{
					if (!Run.instance.availableEquipment.Contains(item) || (useWhitelist && !whitelist.Contains(item)) || (!useWhitelist && blacklist.Contains(item)))
					{
						list.Add(item);
					}
					else if (blacklistLunars)
					{
						EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(item);
						if (equipmentDef.isLunar)
						{
							list.Add(item);
						}
					}
				}
				foreach (EquipmentIndex item2 in list)
				{
					EnigmaArtifactManager.validEquipment.Remove(item2);
				}
				if (!useWhitelist)
				{
					return;
				}
				foreach (EquipmentIndex item3 in whitelist)
				{
					if (!EnigmaArtifactManager.validEquipment.Contains(item3))
					{
						EnigmaArtifactManager.validEquipment.Add(item3);
					}
				}
			}
		}

		public static bool blacklistLunars = true;

		public static bool useWhitelist = false;

		public static HashSet<EquipmentIndex> blacklist = new HashSet<EquipmentIndex>();

		public static HashSet<EquipmentIndex> whitelist = new HashSet<EquipmentIndex>();

		public static string blacklistString = "";

		public static string whitelistString = "";

		private void ReadConfig()
		{
			blacklistLunars = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Blacklist Lunars", true, "Prevent Lunars from being rolled.").Value;
			blacklistString = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Blacklist String", "Recycle, Tonic, BossHunter, BossHunterConsumed, GoldGat", "Equipments to blacklist. Separated by comma, case-sensitive. Full list can be found at https://github.com/risk-of-thunder/R2Wiki/wiki/Item-&-Equipment-IDs-and-Names").Value;
			useWhitelist = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Use Whitelist", false, "Use a whitelist instead of a blacklist. Disables Blacklist String setting.").Value;
			whitelistString = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Whitelist String", "", "Equipments to whitelist. Separated by comma, case-sensitive. Full list can be found at https://github.com/risk-of-thunder/R2Wiki/wiki/Item-&-Equipment-IDs-and-Names").Value;
		}

		public void Awake()
		{
			//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)
			//IL_0027: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			ReadConfig();
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				hook_Init val = delegate(orig_Init orig)
				{
					//IL_0062: Unknown result type (might be due to invalid IL or missing references)
					//IL_0067: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Invalid comparison between Unknown and I4
					//IL_007d: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f9: Invalid comparison between Unknown and I4
					//IL_010a: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke();
					blacklistString = new string((from c in blacklistString.ToCharArray()
						where !char.IsWhiteSpace(c)
						select c).ToArray());
					string[] array = blacklistString.Split(',');
					string[] array2 = array;
					foreach (string text in array2)
					{
						EquipmentIndex val3 = EquipmentCatalog.FindEquipmentIndex(text);
						if ((int)val3 != -1)
						{
							blacklist.Add(val3);
						}
					}
					whitelistString = new string((from c in whitelistString.ToCharArray()
						where !char.IsWhiteSpace(c)
						select c).ToArray());
					string[] array3 = whitelistString.Split(',');
					string[] array4 = array3;
					foreach (string text2 in array4)
					{
						EquipmentIndex val4 = EquipmentCatalog.FindEquipmentIndex(text2);
						if ((int)val4 != -1)
						{
							whitelist.Add(val4);
						}
					}
				};
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			EquipmentCatalog.Init += (hook_Init)obj;
			object obj2 = <>c.<>9__7_1;
			if (obj2 == null)
			{
				hook_OnRunStartGlobal val2 = delegate(orig_OnRunStartGlobal orig, Run run)
				{
					//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_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_0070: 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_0086: 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)
					//IL_00de: Unknown result type (might be due to invalid IL or missing references)
					//IL_009d: Unknown result type (might be due to invalid IL or missing references)
					//IL_011e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0123: Unknown result type (might be due to invalid IL or missing references)
					//IL_012b: 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)
					orig.Invoke(run);
					List<EquipmentIndex> list = new List<EquipmentIndex>();
					foreach (EquipmentIndex item in EnigmaArtifactManager.validEquipment)
					{
						if (!Run.instance.availableEquipment.Contains(item) || (useWhitelist && !whitelist.Contains(item)) || (!useWhitelist && blacklist.Contains(item)))
						{
							list.Add(item);
						}
						else if (blacklistLunars)
						{
							EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(item);
							if (equipmentDef.isLunar)
							{
								list.Add(item);
							}
						}
					}
					foreach (EquipmentIndex item2 in list)
					{
						EnigmaArtifactManager.validEquipment.Remove(item2);
					}
					if (useWhitelist)
					{
						foreach (EquipmentIndex item3 in whitelist)
						{
							if (!EnigmaArtifactManager.validEquipment.Contains(item3))
							{
								EnigmaArtifactManager.validEquipment.Add(item3);
							}
						}
					}
				};
				<>c.<>9__7_1 = val2;
				obj2 = (object)val2;
			}
			EnigmaArtifactManager.OnRunStartGlobal += (hook_OnRunStartGlobal)obj2;
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}