Decompiled source of ItemBlacklist v1.3.1

ItemBlacklist.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using HG;
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.ContentManagement;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}"));
		}
	}
	internal static class HookManager
	{
		internal delegate bool ConfigEnabled<T>(T configValue);

		internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly ConfigEnabled<bool> boolConfigEnabled = (bool configValue) => configValue;

		private static ILHookConfig ilHookConfig = new ILHookConfig
		{
			ManualApply = true
		};

		private static HookConfig onHookConfig = new HookConfig
		{
			ManualApply = true
		};

		internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
		{
			HookInternal(methodFrom, ilHook);
		}

		internal static void Hook(Delegate from, Manipulator ilHook)
		{
			HookInternal(from.Method, ilHook);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
		{
			HookInternal(methodFrom, onHook, null);
		}

		internal static void Hook(MethodBase methodFrom, Delegate onHook)
		{
			HookInternal(methodFrom, onHook.Method, onHook.Target);
		}

		internal static void Hook(Delegate from, Delegate onHook)
		{
			HookInternal(from.Method, onHook.Method, onHook.Target);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			HookInternal(methodFrom, onHook, target);
		}

		private static void HookInternal(MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null methodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
				return;
			}
			try
			{
				new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}::{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null methodFrom for hook: " + onHook.Name);
				return;
			}
			try
			{
				new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply Hook: {methodFrom.DeclaringType}::{methodFrom.Name} - {onHook.Name}\n{ex}");
			}
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, (Delegate)(object)ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, onHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfigInternal(enabled, methodFrom, (Delegate)(object)ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), onHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.HookConfigInternal(enabled, methodFrom, onHook);
		}

		private static void HookConfigInternal<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate hook)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			try
			{
				IDetour detour = ManualDetour(methodFrom, hook);
				EventHandler eventHandler = delegate(object sender, EventArgs _)
				{
					UpdateHook(detour, enabled((sender as ConfigEntry<T>).Value));
				};
				configEntry.SettingChanged += eventHandler;
				eventHandler(configEntry, (EventArgs)new SettingChangedEventArgs((ConfigEntryBase)(object)configEntry));
			}
			catch (Exception ex)
			{
				log.error($"Failed to do config hook {methodFrom.DeclaringType}::{methodFrom.Name} - {hook.Method.Name}\n{ex}");
			}
		}

		private static void UpdateHook(IDetour hook, bool enabled)
		{
			if (enabled)
			{
				if (!hook.IsApplied)
				{
					hook.Apply();
				}
			}
			else if (hook.IsApplied)
			{
				hook.Undo();
			}
		}

		internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate hook)
		{
			return ManualDetour(GetMethod(typeFrom, methodFrom), hook);
		}

		internal static IDetour ManualDetour(MethodBase methodFrom, Delegate hook)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			if (methodFrom == null)
			{
				log.error("null methodFrom for detour: " + hook.Method.Name);
			}
			else
			{
				try
				{
					Manipulator val = (Manipulator)(object)((hook is Manipulator) ? hook : null);
					if (val != null)
					{
						return (IDetour)new ILHook(methodFrom, val, ref ilHookConfig);
					}
					return (IDetour)new Hook(methodFrom, hook, ref onHookConfig);
				}
				catch (Exception ex)
				{
					log.error($"Failed to create detour {methodFrom.DeclaringType}::{methodFrom} - {hook.Method.Name}\n{ex}");
				}
			}
			return null;
		}

		internal static MethodInfo GetMethod(Type typeFrom, string methodName)
		{
			if (typeFrom == null || methodName == null)
			{
				log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}");
				return null;
			}
			MethodInfo[] array = (from predicate in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where predicate.Name == methodName
				select predicate).ToArray();
			switch (array.Length)
			{
			case 1:
				return array[0];
			case 0:
				log.error($"Failed to find method: {typeFrom}::{methodName}");
				return null;
			default:
			{
				log.error($"{array.Length} ambiguous matches found for: {typeFrom}::{methodName}");
				MethodInfo[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					log.error(array2[i]);
				}
				return null;
			}
			}
		}

		internal static MethodInfo GetMethod(Type typeFrom, string methodName, params Type[] parameters)
		{
			if (typeFrom == null || methodName == null)
			{
				log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}");
				return null;
			}
			MethodInfo? method = typeFrom.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
			if (method == null)
			{
				log.error($"Failed to find method: {typeFrom}::{methodName}_{parameters.Length}");
			}
			return method;
		}

		internal static void SetPriority(string[] before = null, string[] after = null)
		{
			ilHookConfig.Before = before;
			onHookConfig.Before = before;
			ilHookConfig.After = after;
			onHookConfig.After = after;
		}
	}
	internal static class Utilities
	{
		private static GameObject _prefabParent;

		internal static GameObject CreatePrefab(GameObject gameObject, string name = null)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_prefabParent))
			{
				_prefabParent = new GameObject("DolsoPrefabs");
				Object.DontDestroyOnLoad((Object)(object)_prefabParent);
				((Object)_prefabParent).hideFlags = (HideFlags)61;
				_prefabParent.SetActive(false);
			}
			GameObject val = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
			if (name != null)
			{
				((Object)val).name = name;
			}
			return val;
		}

		internal static Task<Obj> GetAddressableAsync<Obj>(string addressable) where Obj : Object
		{
			//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)
			return Addressables.LoadAssetAsync<Obj>((object)addressable).Task;
		}

		internal static Task<GameObject> GetAddressableAsync(string addressable)
		{
			//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)
			return Addressables.LoadAssetAsync<GameObject>((object)addressable).Task;
		}

		internal static void DoAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<Obj> a)
			{
				callback(a.Result);
			};
		}

		internal static void DoAddressable(string addressable, Action<GameObject> callback)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				callback(a.Result);
			};
		}

		internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
		{
			//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)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				a.Result.AddComponent<Comp>();
			};
		}

		internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : Component
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				callback(a.Result.AddComponent<Comp>());
			};
		}

		internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
		{
			//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)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
				{
					a.Result.AddComponent<Comp>();
				}
			};
		}
	}
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
	internal class HookAttribute : Attribute
	{
		private readonly MethodInfo from;

		internal HookAttribute(Type typeFrom, string methodFrom)
		{
			from = HookManager.GetMethod(typeFrom, methodFrom);
		}

		internal HookAttribute(Type typeFrom, string methodFrom, params Type[] parameters)
		{
			from = HookManager.GetMethod(typeFrom, methodFrom, parameters);
		}

		internal static void ScanAndApply()
		{
			ScanAndApply(Assembly.GetExecutingAssembly().GetTypes());
		}

		internal static void ScanAndApply(params Type[] types)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					foreach (HookAttribute customAttribute in methodInfo.GetCustomAttributes<HookAttribute>(inherit: false))
					{
						if (customAttribute.from == null)
						{
							if (methodInfo.GetParameters().Length == 0)
							{
								methodInfo.Invoke(null, null);
							}
							else
							{
								log.error("null methodFrom for hook: " + methodInfo.Name);
							}
							continue;
						}
						try
						{
							ParameterInfo[] parameters = methodInfo.GetParameters();
							if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext))
							{
								HookManager.Hook(customAttribute.from, (Manipulator)methodInfo.CreateDelegate(typeof(Manipulator)));
							}
							else
							{
								HookManager.Hook(customAttribute.from, methodInfo);
							}
						}
						catch (Exception ex)
						{
							log.error($"Failed to do HookAttribute: {customAttribute.from.DeclaringType}.{customAttribute.from.Name} - {methodInfo.Name}\n\n{ex}");
						}
					}
				}
			}
		}
	}
	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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string fullName = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName;
				Texture2D val = new Texture2D(256, 256);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "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<T>(ConfigEntry<T> entry)
		{
			AddOption<T>(entry, "", "", restartRequired: false);
		}

		internal static void AddOption<T>(ConfigEntry<T> entry, string categoryName = "", string name = "", bool restartRequired = false)
		{
			//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)
			//IL_0156: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_0126: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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)
			//IL_013e: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			object obj;
			if (!(typeof(T) == typeof(float)))
			{
				obj = ((!(typeof(T) == typeof(string))) ? ((!(typeof(T) == typeof(bool))) ? ((!(typeof(T) == typeof(int))) ? ((!(typeof(T) == typeof(Color))) ? ((!(typeof(T) == typeof(KeyboardShortcut))) ? ((object)((!typeof(T).IsEnum) ? ((ChoiceOption)null) : new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig()))) : ((object)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, new KeyBindConfig()))) : ((object)new ColorOption(entry as ConfigEntry<Color>, new ColorOptionConfig()))) : ((object)new IntFieldOption(entry as ConfigEntry<int>, new IntFieldConfig()))) : ((object)new CheckBoxOption(entry as ConfigEntry<bool>, new CheckBoxConfig()))) : ((object)new StringInputFieldOption(entry as ConfigEntry<string>, new InputFieldConfig
				{
					submitOn = (SubmitEnum)6,
					lineType = (LineType)0
				})));
			}
			else
			{
				ConfigEntry<float> obj2 = entry as ConfigEntry<float>;
				FloatFieldConfig val = new FloatFieldConfig();
				((NumericFieldConfig<float>)val).FormatString = "{0:f2}";
				((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault("{0:f2}");
				obj = (object)new FloatFieldOption(obj2, val);
			}
			BaseOption val2 = (BaseOption)obj;
			if (val2 != null)
			{
				BaseOptionConfig config = val2.GetConfig();
				config.category = categoryName;
				config.name = name;
				config.restartRequired = restartRequired;
				if (config.description == "")
				{
					config.description = ((ConfigEntryBase)(object)entry).DescWithDefault();
				}
				ModSettingsManager.AddOption(val2);
			}
		}

		internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
		{
			AddFloatSlider(entry, min, max, format);
		}

		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 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 ItemBlacklist
{
	internal static class Commands
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCWhitelist(ConCommandArgs args)
		{
			//IL_002d: 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)
			//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_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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				Debug.LogError((object)"Must be in a run");
				return;
			}
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)"--- Printing whitelist ---");
				GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
				AllItemsEnumerator enumerator = allItems.GetEnumerator();
				try
				{
					while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
					{
						ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
						if (current.IsDropableTier() && Run.instance.availableItems.Contains(current))
						{
							Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
						}
					}
				}
				finally
				{
					((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
				}
				GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
				AllEquipmentEnumerator enumerator2 = allEquipment.GetEnumerator();
				try
				{
					while (((AllEquipmentEnumerator)(ref enumerator2)).MoveNext())
					{
						EquipmentIndex current2 = ((AllEquipmentEnumerator)(ref enumerator2)).Current;
						if (EquipmentCatalog.GetEquipmentDef(current2).canDrop && Run.instance.availableEquipment.Contains(current2))
						{
							Debug.Log((object)Language.GetString(EquipmentCatalog.GetEquipmentDef(current2).nameToken));
						}
					}
					return;
				}
				finally
				{
					((IDisposable)(AllEquipmentEnumerator)(ref enumerator2)).Dispose();
				}
			}
			string text = "";
			for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
			{
				text += ((ConCommandArgs)(ref args))[i];
			}
			List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
			if (itemDefs.Count > 0)
			{
				foreach (ItemDef item in itemDefs)
				{
					Run.instance.EnableItemDrop(item.itemIndex);
					Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item.nameToken) + "</color>"));
				}
				return;
			}
			List<EquipmentDef> equipDefs = ItemBlacklist.GetEquipDefs(text, englishOnly: false);
			if (equipDefs.Count > 0)
			{
				foreach (EquipmentDef item2 in equipDefs)
				{
					Run.instance.EnableEquipmentDrop(item2.equipmentIndex);
					Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item2.nameToken) + "</color>"));
				}
				return;
			}
			Debug.LogError((object)("Failed to find " + text));
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCBlacklist(ConCommandArgs args)
		{
			//IL_002d: 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)
			//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_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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				Debug.LogError((object)"Must be in a run");
				return;
			}
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)"--- Printing blacklist ---");
				GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
				AllItemsEnumerator enumerator = allItems.GetEnumerator();
				try
				{
					while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
					{
						ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
						if (current.IsDropableTier() && !Run.instance.availableItems.Contains(current))
						{
							Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
						}
					}
				}
				finally
				{
					((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
				}
				GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
				AllEquipmentEnumerator enumerator2 = allEquipment.GetEnumerator();
				try
				{
					while (((AllEquipmentEnumerator)(ref enumerator2)).MoveNext())
					{
						EquipmentIndex current2 = ((AllEquipmentEnumerator)(ref enumerator2)).Current;
						if (EquipmentCatalog.GetEquipmentDef(current2).canDrop && !Run.instance.availableEquipment.Contains(current2))
						{
							Debug.Log((object)Language.GetString(EquipmentCatalog.GetEquipmentDef(current2).nameToken));
						}
					}
					return;
				}
				finally
				{
					((IDisposable)(AllEquipmentEnumerator)(ref enumerator2)).Dispose();
				}
			}
			string text = "";
			for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
			{
				text += ((ConCommandArgs)(ref args))[i];
			}
			List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
			if (itemDefs.Count > 0)
			{
				foreach (ItemDef item in itemDefs)
				{
					Run.instance.DisableItemDrop(item.itemIndex);
					Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item.nameToken) + "</color>"));
				}
				return;
			}
			List<EquipmentDef> equipDefs = ItemBlacklist.GetEquipDefs(text, englishOnly: false);
			if (equipDefs.Count > 0)
			{
				foreach (EquipmentDef item2 in equipDefs)
				{
					Run.instance.DisableEquipmentDrop(item2.equipmentIndex);
					Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item2.nameToken) + "</color>"));
				}
				return;
			}
			Debug.LogError((object)("Failed to find " + text));
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCPrinterWhitelist(ConCommandArgs args)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)"--- Printing whitelist ---");
				GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
				AllItemsEnumerator enumerator = allItems.GetEnumerator();
				try
				{
					while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
					{
						ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
						if (current.IsDropableTier() && !ItemBlacklist.printerBlacklist.Contains(PickupCatalog.FindPickupIndex(current)))
						{
							Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
						}
					}
					return;
				}
				finally
				{
					((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
				}
			}
			string text = "";
			for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
			{
				text += ((ConCommandArgs)(ref args))[i];
			}
			List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
			if (itemDefs.Count == 0)
			{
				Debug.LogError((object)("Failed to find " + text));
				return;
			}
			foreach (ItemDef item2 in itemDefs)
			{
				PickupIndex item = PickupCatalog.FindPickupIndex(item2.itemIndex);
				ItemBlacklist.printerBlacklist.Remove(item);
				Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item2.nameToken) + " for printers</color>"));
			}
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			foreach (PickupDropTable instances in PickupDropTable.instancesList)
			{
				BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
				if (val != null)
				{
					((PickupDropTable)val).Regenerate(Run.instance);
				}
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCPrinterBlacklist(ConCommandArgs args)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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)
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.Log((object)"--- Printing blacklist ---");
				{
					foreach (PickupIndex item2 in ItemBlacklist.printerBlacklist)
					{
						Debug.Log((object)Language.GetString(PickupCatalog.GetPickupDef(item2).nameToken));
					}
					return;
				}
			}
			string text = "";
			for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
			{
				text += ((ConCommandArgs)(ref args))[i];
			}
			List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
			if (itemDefs.Count == 0)
			{
				Debug.LogError((object)("Failed to find " + text));
				return;
			}
			foreach (ItemDef item3 in itemDefs)
			{
				PickupIndex item = PickupCatalog.FindPickupIndex(item3.itemIndex);
				if (!ItemBlacklist.printerBlacklist.Contains(item))
				{
					ItemBlacklist.printerBlacklist.Add(item);
				}
				Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item3.nameToken) + " for printers</color>"));
			}
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			foreach (PickupDropTable instances in PickupDropTable.instancesList)
			{
				BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
				if (val != null)
				{
					((PickupDropTable)val).Regenerate(Run.instance);
				}
			}
		}

		private static bool IsDropableTier(this ItemIndex itemindex)
		{
			//IL_0000: 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)
			ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(ItemCatalog.GetItemDef(itemindex).tier);
			if (Object.op_Implicit((Object)(object)itemTierDef))
			{
				return itemTierDef.isDroppable;
			}
			return false;
		}
	}
	public static class DropRate
	{
		private static readonly Dictionary<PickupIndex, float> pickupChance = new Dictionary<PickupIndex, float>();

		internal static void DropRates_SettingChanged(object sender, EventArgs e)
		{
			ApplyDropRateConfig();
		}

		public static void ApplyDropRateConfig()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			string[] array = ItemBlacklist.CreateStringArray(IBConfig.dropRates.Value);
			pickupChance.Clear();
			bool flag = false;
			for (int i = 0; i < array.Length; i++)
			{
				if (string.IsNullOrEmpty(array[i]))
				{
					continue;
				}
				string[] array2 = array[i].Split('=', StringSplitOptions.RemoveEmptyEntries);
				if (array2.Length != 2 || !float.TryParse(array2[1], NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.InvariantInfo, out var result))
				{
					log.warning("\"" + array[i] + "\" is an invalid format");
					continue;
				}
				string text = array2[0];
				ItemIndex val = ItemCatalog.FindItemIndex(text);
				PickupIndex val2;
				if ((int)val != -1)
				{
					val2 = PickupCatalog.FindPickupIndex(val);
				}
				else
				{
					EquipmentIndex val3 = EquipmentCatalog.FindEquipmentIndex(text);
					if ((int)val3 != -1)
					{
						val2 = PickupCatalog.FindPickupIndex(val3);
					}
					else
					{
						val2 = PickupCatalog.FindPickupIndex(text);
						if (!(val2 != PickupIndex.none))
						{
							foreach (PickupDef allPickup in PickupCatalog.allPickups)
							{
								if (allPickup.nameToken == null || !ItemBlacklist.ContainsString(ItemBlacklist.ReformatString(Language.GetString(allPickup.nameToken, "en")), text))
								{
									continue;
								}
								val2 = allPickup.pickupIndex;
								int num = i;
								string internalName = allPickup.internalName;
								int num2 = allPickup.internalName.IndexOf('.') + 1;
								array[num] = internalName.Substring(num2, internalName.Length - num2) + " = " + array2[1];
								flag = true;
								goto IL_0183;
							}
							log.warning("failed to find a match for " + array[i]);
							continue;
						}
					}
				}
				goto IL_0183;
				IL_0183:
				if (!pickupChance.ContainsKey(val2))
				{
					pickupChance.Add(val2, result);
					log.message($"Found {GetPickupName(val2)} = {result}");
					continue;
				}
				log.warning("duplicate " + GetPickupName(val2) + " from " + array[i] + ", ignoring");
			}
			if (flag)
			{
				IBConfig.dropRates.SettingChanged -= DropRates_SettingChanged;
				IBConfig.dropRates.Value = string.Join(", ", array);
				IBConfig.dropRates.SettingChanged += DropRates_SettingChanged;
			}
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				PickupDropTable.RegenerateAll(Run.instance);
				Debug.Log((object)"Regenerated drop tables");
			}
		}

		private static string GetPickupName(PickupIndex index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Language.GetString(PickupCatalog.GetPickupDef(index).nameToken);
		}

		public static void ModifySelector(WeightedSelection<PickupIndex> selector)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (pickupChance.Count == 0)
			{
				return;
			}
			if (selector == null)
			{
				log.warning("null selector");
				return;
			}
			bool flag = false;
			for (int i = 0; i < selector.Count; i++)
			{
				if (pickupChance.TryGetValue(selector.choices[i].value, out var value))
				{
					selector.choices[i].weight *= value;
					flag = true;
				}
			}
			if (flag)
			{
				selector.RecalculateTotalWeight();
			}
		}

		public static WeightedSelection<PickupIndex> GetSelector(PickupDropTable table)
		{
			BasicPickupDropTable val = (BasicPickupDropTable)(object)((table is BasicPickupDropTable) ? table : null);
			if (val == null)
			{
				ArenaMonsterItemDropTable val2 = (ArenaMonsterItemDropTable)(object)((table is ArenaMonsterItemDropTable) ? table : null);
				if (val2 == null)
				{
					DoppelgangerDropTable val3 = (DoppelgangerDropTable)(object)((table is DoppelgangerDropTable) ? table : null);
					if (val3 == null)
					{
						ExplicitPickupDropTable val4 = (ExplicitPickupDropTable)(object)((table is ExplicitPickupDropTable) ? table : null);
						if (val4 == null)
						{
							return ((FreeChestDropTable)(((table is FreeChestDropTable) ? table : null)?)).selector;
						}
						return val4.weightedSelection;
					}
					return val3.selector;
				}
				return val2.selector;
			}
			return val.selector;
		}
	}
	internal static class Hooks
	{
		static Hooks()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			HookManager.ConfigEnabled<string> enabled = (string configValue) => !string.IsNullOrWhiteSpace(configValue);
			IBConfig.dropRates.HookConfig(enabled, typeof(DoppelgangerDropTable), "GenerateWeightedSelection", (Delegate)new Action<Action<PickupDropTable>, PickupDropTable>(On_PickupDropTable_GenerateWeightedSelection_Modify));
			IBConfig.dropRates.HookConfig(enabled, typeof(ExplicitPickupDropTable), "GenerateWeightedSelection", (Delegate)new Action<Action<PickupDropTable>, PickupDropTable>(On_PickupDropTable_GenerateWeightedSelection_Modify));
			IBConfig.dropRates.HookConfig(enabled, typeof(ArenaMonsterItemDropTable), "GenerateWeightedSelection", (Delegate)new Action<Action<PickupDropTable, Run>, PickupDropTable, Run>(On_PickupDropTable_GenerateWeightedSelection_ModifyRun));
			IBConfig.dropRates.HookConfig(enabled, typeof(BasicPickupDropTable), "GenerateWeightedSelection", (Delegate)new Action<Action<PickupDropTable, Run>, PickupDropTable, Run>(On_PickupDropTable_GenerateWeightedSelection_ModifyRun));
			IBConfig.dropRates.HookConfig(enabled, typeof(FreeChestDropTable), "GenerateDropPreReplacement", new Manipulator(IL_FreeChest_GenerateDropPreReplacement_Modify));
			IBConfig.modifyHalcyoniteDropTables.HookConfig(typeof(HalcyoniteShrineInteractable), "DropRewards", new Manipulator(IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable));
			HookManager.Hook((Delegate)new Func<bool>(RuleCatalog.HiddenTestItemsConvar), (Delegate)(Func<bool>)(() => false));
		}

		[Hook(typeof(LocalUserBallotPersistenceManager), "OnLocalUserSignIn")]
		private static void On_PreGameRuleVoteManager_OnLocalUserSignIn_SignedIn(Action<LocalUser> orig, LocalUser localUser)
		{
			orig(localUser);
			Vote[] array = PreGameRuleVoteController.CreateBallot();
			foreach (string item in ItemBlacklist.BuildItemRules().Concat(ItemBlacklist.BuildEquipRules()))
			{
				RuleDef val = RuleCatalog.FindRuleDef(item);
				if (val != null)
				{
					((Vote)(ref array[val.globalIndex])).choiceValue = 1;
				}
			}
			LocalUserBallotPersistenceManager.votesCache[localUser] = array;
		}

		[Hook(typeof(RuleDef), "FromItem")]
		private static RuleDef On_RuleDef_FromItem_FixItemRules(Func<ItemIndex, RuleDef> orig, ItemIndex itemIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_002d: 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)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got I4
			//IL_0032->IL0032: Incompatible stack types: O vs I4
			//IL_002c->IL0032: Incompatible stack types: I4 vs O
			//IL_002c->IL0032: Incompatible stack types: O vs I4
			object obj = orig(itemIndex);
			ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
			string pickupToken = itemDef.pickupToken;
			ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier);
			int num;
			if ((Object)(object)itemTierDef != (Object)null)
			{
				obj = itemTierDef.darkColorIndex;
				num = (int)obj;
			}
			else
			{
				num = 10;
				obj = num;
				num = (int)obj;
			}
			Color tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)obj));
			RuleChoiceDef obj2 = ((RuleDef)num).FindChoice("On");
			obj2.tooltipBodyToken = pickupToken;
			obj2.tooltipNameColor = tooltipNameColor;
			RuleChoiceDef obj3 = ((RuleDef)num).FindChoice("Off");
			obj3.tooltipBodyToken = pickupToken;
			obj3.tooltipNameColor = tooltipNameColor;
			return (RuleDef)(object)num;
		}

		[Hook(typeof(RuleDef), "FromEquipment")]
		private static RuleDef On_RuleDef_FromEquipment_FixEquipRules(Func<EquipmentIndex, RuleDef> orig, EquipmentIndex equipIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			RuleDef obj = orig(equipIndex);
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipIndex);
			string pickupToken = equipmentDef.pickupToken;
			Color tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(equipmentDef.colorIndex)) * new Color(0.75f, 0.75f, 0.75f);
			RuleChoiceDef obj2 = obj.FindChoice("On");
			obj2.tooltipBodyToken = pickupToken;
			obj2.tooltipNameColor = tooltipNameColor;
			RuleChoiceDef obj3 = obj.FindChoice("Off");
			obj3.spritePath = "Textures/MiscIcons/texUnlockIcon";
			obj3.tooltipBodyToken = pickupToken;
			obj3.tooltipNameColor = tooltipNameColor;
			return obj;
		}

		[Hook(typeof(BasicPickupDropTable), "GenerateWeightedSelection")]
		private static void On_BasicPickupDropTable_GenerateWeightedSelection_FilterPrinters(Action<BasicPickupDropTable, Run> orig, BasicPickupDropTable self, Run run)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			orig(self, run);
			if (ItemBlacklist.printerBlacklist.Count <= 0 || !((Object)self).name.StartsWith("dtDuplicator"))
			{
				return;
			}
			for (int num = self.selector.Count - 1; num >= 0; num--)
			{
				if (ItemBlacklist.printerBlacklist.Contains(self.selector.choices[num].value))
				{
					self.selector.RemoveChoice(num);
				}
			}
		}

		[Hook(typeof(BossGroup), "DropRewards")]
		private static void On_BossGroup_DropRewards_Blacklist(Action<BossGroup> orig, BossGroup self)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				orig(self);
				return;
			}
			if (self.bossDropTables != null)
			{
				int num = 0;
				while (num < self.bossDropTables.Count)
				{
					ExplicitPickupDropTable val = (ExplicitPickupDropTable)self.bossDropTables[num];
					Object pickupDef = val.pickupEntries[0].pickupDef;
					ItemDef val2 = (ItemDef)(object)((pickupDef is ItemDef) ? pickupDef : null);
					if (Object.op_Implicit((Object)(object)val2) && !Run.instance.IsItemAvailable(val2.itemIndex))
					{
						self.bossDropTables.Remove((PickupDropTable)(object)val);
					}
					else
					{
						num++;
					}
				}
			}
			if (self.bossDrops != null)
			{
				int num2 = 0;
				while (num2 < self.bossDrops.Count)
				{
					PickupIndex val3 = self.bossDrops[num2];
					log.info("Removed bossdrop " + Language.GetString(PickupCatalog.GetPickupDef(val3).nameToken));
					if (!Run.instance.IsPickupAvailable(val3))
					{
						self.bossDrops.Remove(val3);
					}
					else
					{
						num2++;
					}
				}
			}
			orig(self);
		}

		[Hook(typeof(EquipmentSlot), "FireBossHunter")]
		private static void IL_EquipmentSlot_FireBossHunter_ReplaceHunterReward(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(a, "GenerateDrop")
			}))
			{
				val.EmitDelegate<Func<PickupIndex, PickupIndex>>((Func<PickupIndex, PickupIndex>)delegate(PickupIndex pickupIndex)
				{
					//IL_0005: 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_0032: 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_0034: 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_0051: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: 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)
					if (Run.instance.IsPickupAvailable(pickupIndex))
					{
						return pickupIndex;
					}
					BasicPickupDropTable obj = LegacyResourcesAPI.Load<BasicPickupDropTable>("DropTables/dtDuplicatorWild");
					log.info("Replacing banned boss drop with a random boss item");
					PickupIndex val2 = ((PickupDropTable)obj).GenerateDrop(Run.instance.treasureRng);
					if (val2 != PickupIndex.none)
					{
						return val2;
					}
					log.info("No pickup found, dropping pearl instead");
					return PickupCatalog.FindPickupIndex(Items.ShinyPearl.itemIndex);
				});
			}
			else
			{
				val.LogErrorCaller("Failed to find GenerateDrop");
			}
		}

		internal static void IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchStfld(a, typeof(CreatePickupInfo), "pickerOptions")
			}))
			{
				ILLabel val2 = val.MarkLabel();
				int num = default(int);
				if (val.TryGotoPrev(new Func<Instruction, bool>[1]
				{
					(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(CreatePickupInfo), "set_pickupIndex")
				}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction a) => ILPatternMatchingExt.MatchLdloca(a, ref num)
				}))
				{
					val.Emit(OpCodes.Ldarg_0);
					val.EmitDelegate<Func<HalcyoniteShrineInteractable, Option[]>>((Func<HalcyoniteShrineInteractable, Option[]>)((HalcyoniteShrineInteractable self) => PickupPickerController.GenerateOptionsFromDropTable(self.rewardOptionCount, (PickupDropTable)(object)self.halcyoniteDropTableTier3, self.rng)));
					val.Emit(OpCodes.Br, (object)val2);
					val.GotoLabel(val2, (MoveType)0, false);
					val.Emit(OpCodes.Pop);
				}
				else
				{
					val.LogErrorCaller("failed find pickupIndex");
				}
			}
			else
			{
				val.LogErrorCaller("failed find pickerOptions");
			}
		}

		[Hook(typeof(Run), "EnableItemDrop")]
		private static void IL_Run_EnableItemDrop_Fix(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int refreshLunarsFlagIndex = 1;
			if (!val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
				(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarItemDropList")
			}))
			{
				val.LogErrorCaller("failed to find lunar");
			}
			val.Emit(OpCodes.Ldc_I4_1);
			val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Add"))
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableItems"));
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Callvirt, (MethodBase)typeof(ItemMask).GetMethod("Add"));
			}
			else
			{
				val.LogErrorCaller("failed to find list.Add");
			}
		}

		[Hook(typeof(Run), "DisableItemDrop")]
		private static void IL_Run_DisableItemDrop_Fix(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int refreshLunarsFlagIndex = 1;
			if (!val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
				(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarItemDropList")
			}))
			{
				val.LogErrorCaller("failed to find lunar");
			}
			val.Emit(OpCodes.Ldc_I4_1);
			val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Remove"))
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableItems"));
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Callvirt, (MethodBase)typeof(ItemMask).GetMethod("Remove"));
				val.Emit(OpCodes.Pop);
			}
			else
			{
				val.LogErrorCaller("failed to find list.remove");
			}
		}

		[Hook(typeof(Run), "EnableEquipmentDrop")]
		private static void IL_Run_EnableEquipmentDrop_Fix(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int refreshLunarsFlagIndex = 1;
			if (!val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
				(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarEquipmentDropList")
			}))
			{
				val.LogErrorCaller("failed to find lunar");
			}
			val.Emit(OpCodes.Ldc_I4_1);
			val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Add"))
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableEquipment"));
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Callvirt, (MethodBase)typeof(EquipmentMask).GetMethod("Add"));
			}
			else
			{
				val.LogErrorCaller("failed to find list.Add");
			}
		}

		[Hook(typeof(RuleCategoryController), "SetData")]
		private static void IL_RuleCategoryController_SetData_ScaleSize(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MethodInfo getc = typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(GridLayoutGroup));
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)getc)
			}))
			{
				val.Emit(OpCodes.Dup);
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Action<GridLayoutGroup, RuleCategoryController>>((Action<GridLayoutGroup, RuleCategoryController>)delegate(GridLayoutGroup grid, RuleCategoryController self)
				{
					//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f6: Expected O, but got Unknown
					//IL_0121: Unknown result type (might be due to invalid IL or missing references)
					//IL_0126: Unknown result type (might be due to invalid IL or missing references)
					//IL_006d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0072: Unknown result type (might be due to invalid IL or missing references)
					//IL_008b: Unknown result type (might be due to invalid IL or missing references)
					int count = self.currentCategory.children.Count;
					if (self.currentCategory != null && (float)count > 144f && grid.constraintCount == 9)
					{
						int num2 = (grid.constraintCount = (int)Math.Sqrt(1.7777778f * (float)count));
						((LayoutGroup)grid).childAlignment = (TextAnchor)1;
						float num3 = 64f * (float)Math.Sqrt(144f / (float)count);
						RectTransform component = ((Component)self.popoutPanelInstance).GetComponent<RectTransform>();
						grid.cellSize = num3 * Vector2.one;
						component.sizeDelta = new Vector2(num3 * ((float)num2 - 9f), 0f);
					}
					if (self.currentCategory != null && self.currentCategory.subtitleToken == "RULE_HEADER_ITEMSANDEQUIPMENT_SUBTITLE")
					{
						GameObject obj = Object.Instantiate<GameObject>(ItemBlacklist.buttonPrefab, ((Component)self.popoutPanelInstance).transform.Find("Canvas/Main"));
						HGButton component2 = obj.GetComponent<HGButton>();
						((UnityEvent)((Button)component2).onClick).AddListener(new UnityAction(ItemBlacklist.SaveFromVotes));
						((MPButton)component2).selectOnPointerEnter = false;
						HGTextMeshProUGUI obj2 = ((Component)obj.transform.Find("Text")).gameObject.AddComponent<HGTextMeshProUGUI>();
						((TMP_Text)obj2).fontSize = 24f;
						((TMP_Text)obj2).outlineColor = Color32.op_Implicit(Color.black);
						((TMP_Text)obj2).enableWordWrapping = false;
						((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
						((TMP_Text)obj2).text = "Save to config";
					}
				});
			}
			else
			{
				val.LogErrorCaller("failed find GridLayoutGroup");
			}
		}

		private static void On_PickupDropTable_GenerateWeightedSelection_Modify(Action<PickupDropTable> orig, PickupDropTable self)
		{
			orig(self);
			DropRate.ModifySelector(DropRate.GetSelector(self));
		}

		private static void On_PickupDropTable_GenerateWeightedSelection_ModifyRun(Action<PickupDropTable, Run> orig, PickupDropTable self, Run run)
		{
			orig(self, run);
			DropRate.ModifySelector(DropRate.GetSelector(self));
		}

		private static void IL_FreeChest_GenerateDropPreReplacement_Modify(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//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_0066: 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(PickupDropTable), "GenerateDropFromWeightedSelection")
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, typeof(FreeChestDropTable).GetField("selector", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
				val.Emit(OpCodes.Call, (MethodBase)typeof(DropRate).GetMethod("ModifySelector", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
			}
			else
			{
				val.LogErrorCaller("");
			}
		}
	}
	internal static class IBConfig
	{
		private static ConfigFile configFile;

		internal static ConfigEntry<string> ibItemDefaults;

		internal static ConfigEntry<string> ibEquipDefaults;

		internal static ConfigEntry<string> ibPrinterBlacklist;

		internal static ConfigEntry<string> dropRates;

		internal static ConfigEntry<bool> modifyHalcyoniteDropTables;

		internal static void DoConfig(ConfigFile bepConfigFile)
		{
			configFile = bepConfigFile;
			ibItemDefaults = configFile.Bind<string>("Default blacklist", "Items", "", "Items listed here will be disabled by default.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list command to view them.\nExample: Old Guillotine, Empathy Cor,gesture, ShieldOnly");
			ibEquipDefaults = configFile.Bind<string>("Default blacklist", "Equipments", "", "Equipments listed here will be disabled by default.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal equip names they must match fully, use the equipment_list command to view them.");
			ibPrinterBlacklist = configFile.Bind<string>("Printer", "Printer Blacklist", "Gasoline, will-o", "Items listed here will only not appear in printers.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list command to view them.");
			dropRates = configFile.Bind<string>("Drop Rates", "Pickups", "", "Pickups listed here will multiply their drop weight by the listed multipier.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list and equipment_list command to view them.\nExample: Fuel Cell = 1.5, Saw = 1.1");
			modifyHalcyoniteDropTables = configFile.Bind<bool>("Fixes", "Modify Halcyonite Drop Tables", true, "SotS's Halcyonite and Geode drop tables force SotS items, which will cause issues if a high number of them are blacklisted. This fix will modify them to ignore the restrictions");
			if (RiskofOptions.enabled)
			{
				DoRiskOfOptions();
			}
		}

		internal static void DoRiskOfOptions()
		{
			RiskofOptions.SetSpriteDefaultIcon();
			RiskofOptions.AddOption<string>(ibPrinterBlacklist, "Game");
			RiskofOptions.AddOption<string>(dropRates, "Game");
			RiskofOptions.AddOption<string>(ibItemDefaults);
			RiskofOptions.AddOption<string>(ibEquipDefaults);
			RiskofOptions.AddOption<bool>(modifyHalcyoniteDropTables);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ReloadConfig(ConCommandArgs args)
		{
			configFile.Reload();
			Debug.Log((object)"ItemBlacklist config reloaded");
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dolso.ItemBlacklist", "ItemBlacklist", "1.3.1")]
	public class ItemBlacklist : BaseUnityPlugin
	{
		internal static HashSet<PickupIndex> printerBlacklist;

		internal static GameObject buttonPrefab;

		private void Awake()
		{
			log.start(((BaseUnityPlugin)this).Logger);
			IBConfig.DoConfig(((BaseUnityPlugin)this).Config);
			IBConfig.ibPrinterBlacklist.SettingChanged += delegate
			{
				ApplyPrinterBlacklistConfig();
			};
			IBConfig.dropRates.SettingChanged += DropRate.DropRates_SettingChanged;
			IBConfig.modifyHalcyoniteDropTables.SettingChanged += delegate
			{
				ModifyHalcyoniteDropTable();
			};
			if (IBConfig.modifyHalcyoniteDropTables.Value)
			{
				ModifyHalcyoniteDropTable();
			}
			HookAttribute.ScanAndApply(typeof(Hooks));
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyConfig));
			AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "savebutton"));
			buttonPrefab = obj.LoadAsset<GameObject>("SaveButton");
			obj.Unload(false);
		}

		private static void ModifyHalcyoniteDropTable()
		{
			Utilities.DoAddressable<BasicPickupDropTable>("RoR2/DLC2/dtShrineHalcyoniteTier1.asset", (Action<BasicPickupDropTable>)delegate(BasicPickupDropTable a)
			{
				a.requiredItemTags = (ItemTag[])(object)(IBConfig.modifyHalcyoniteDropTables.Value ? new ItemTag[0] : new ItemTag[1] { (ItemTag)21 });
				if (Object.op_Implicit((Object)(object)Run.instance))
				{
					((PickupDropTable)a).Regenerate(Run.instance);
				}
			});
			Utilities.DoAddressable<BasicPickupDropTable>("RoR2/DLC2/dtShrineHalcyoniteTier3.asset", (Action<BasicPickupDropTable>)delegate(BasicPickupDropTable a)
			{
				a.bannedItemTags = (ItemTag[])(object)(IBConfig.modifyHalcyoniteDropTables.Value ? new ItemTag[0] : new ItemTag[1] { (ItemTag)21 });
				if (Object.op_Implicit((Object)(object)Run.instance))
				{
					((PickupDropTable)a).Regenerate(Run.instance);
				}
			});
		}

		internal static string[] BuildItemRules()
		{
			List<ItemDef> itemDefs = GetItemDefs(IBConfig.ibItemDefaults.Value, englishOnly: true);
			string[] array = new string[itemDefs.Count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = "Items." + ((Object)itemDefs[i]).name;
			}
			return array;
		}

		internal static string[] BuildEquipRules()
		{
			List<EquipmentDef> equipDefs = GetEquipDefs(IBConfig.ibEquipDefaults.Value, englishOnly: true);
			string[] array = new string[equipDefs.Count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = "Equipment." + ((Object)equipDefs[i]).name;
			}
			return array;
		}

		internal static List<ItemDef> GetItemDefs(string list, bool englishOnly)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			string text = (englishOnly ? "en" : Language.currentLanguageName);
			List<ItemDef> list2 = new List<ItemDef>();
			string[] array = CreateStringArray(list);
			foreach (string text2 in array)
			{
				if (string.IsNullOrEmpty(text2))
				{
					continue;
				}
				if (ItemCatalog.itemNameToIndex.TryGetValue(text2, out var value))
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(value);
					list2.Add(itemDef);
					continue;
				}
				ItemDef[] itemDefs = ContentManager.itemDefs;
				foreach (ItemDef val in itemDefs)
				{
					if (val.nameToken != null && ContainsString(ReformatString(Language.GetString(val.nameToken, text)), text2))
					{
						list2.Add(val);
						break;
					}
				}
			}
			return list2;
		}

		internal static List<EquipmentDef> GetEquipDefs(string list, bool englishOnly)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			string text = (englishOnly ? "en" : Language.currentLanguageName);
			List<EquipmentDef> list2 = new List<EquipmentDef>();
			string[] array = CreateStringArray(list);
			foreach (string text2 in array)
			{
				if (string.IsNullOrEmpty(text2))
				{
					continue;
				}
				if (EquipmentCatalog.equipmentNameToIndex.TryGetValue(text2, out var value))
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(value);
					list2.Add(equipmentDef);
					continue;
				}
				EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
				foreach (EquipmentDef val in equipmentDefs)
				{
					if (val.nameToken != null && ContainsString(ReformatString(Language.GetString(val.nameToken, text)), text2))
					{
						list2.Add(val);
						break;
					}
				}
			}
			return list2;
		}

		internal static void SaveFromVotes()
		{
			if (!LocalUserBallotPersistenceManager.votesCache.TryGetValue(LocalUserManager.GetFirstLocalUser(), out var value) || value == null)
			{
				return;
			}
			StringBuilder stringBuilder = StringBuilderPool.RentStringBuilder();
			StringBuilder stringBuilder2 = StringBuilderPool.RentStringBuilder();
			for (int i = 0; i < value.Length; i++)
			{
				if (((Vote)(ref value[i])).choiceValue == 1)
				{
					RuleDef ruleDef = RuleCatalog.GetRuleDef(i);
					if (ruleDef.globalName.StartsWith("Items."))
					{
						string globalName = ruleDef.globalName;
						stringBuilder.Append(globalName.Substring(6, globalName.Length - 6) + ", ");
					}
					else if (ruleDef.globalName.StartsWith("Equipment."))
					{
						string globalName = ruleDef.globalName;
						stringBuilder2.Append(globalName.Substring(10, globalName.Length - 10) + ", ");
					}
				}
			}
			if (stringBuilder.Length > 2)
			{
				stringBuilder.Length -= 2;
			}
			if (stringBuilder2.Length > 2)
			{
				stringBuilder2.Length -= 2;
			}
			IBConfig.ibItemDefaults.Value = stringBuilder.ToString();
			IBConfig.ibEquipDefaults.Value = stringBuilder2.ToString();
			StringBuilderPool.ReturnStringBuilder(stringBuilder);
			StringBuilderPool.ReturnStringBuilder(stringBuilder2);
		}

		private static void ApplyConfig()
		{
			try
			{
				ApplyPrinterBlacklistConfig();
				DropRate.ApplyDropRateConfig();
			}
			catch (Exception data)
			{
				log.error(data);
			}
		}

		private static void ApplyPrinterBlacklistConfig()
		{
			//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)
			List<ItemDef> itemDefs = GetItemDefs(IBConfig.ibPrinterBlacklist.Value, englishOnly: true);
			printerBlacklist = new HashSet<PickupIndex>(itemDefs.Count);
			foreach (ItemDef item in itemDefs)
			{
				printerBlacklist.Add(PickupCatalog.FindPickupIndex(item.itemIndex));
			}
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			foreach (PickupDropTable instances in PickupDropTable.instancesList)
			{
				BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
				if (val != null)
				{
					((PickupDropTable)val).Regenerate(Run.instance);
				}
			}
			Debug.Log((object)"Regenerated printer drop tables");
		}

		internal static string[] CreateStringArray(string text)
		{
			string[] array = text.Split(new string[2] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = ReformatString(array[i]);
			}
			return array;
		}

		internal static string ReformatString(string input)
		{
			return Regex.Replace(input, "[\n ',-]", string.Empty);
		}

		internal static bool ContainsString(string source, string value)
		{
			return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0;
		}
	}
}