Decompiled source of LootPoolLimiter v1.1.2

ExamplePlugin.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("ExamplePlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+596abb38171c1972d190bdfb1077a7dcd25be4b5")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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 LootPoolLimiter
{
	public static class LootPoolLimiterConfig
	{
		public static ConfigEntry<string> ConfigWhites { get; set; }

		public static ConfigEntry<string> ConfigGreens { get; set; }

		public static ConfigEntry<string> ConfigReds { get; set; }

		public static ConfigEntry<bool> speedCategory { get; set; }

		public static ConfigEntry<string> SpeedIncluded { get; set; }

		public static ConfigEntry<float> categoryVariance { get; set; }

		public static ConfigEntry<float> blacklistWeight { get; set; }

		public static ConfigEntry<bool> affectPrinters { get; set; }

		public static ConfigEntry<bool> affectCradles { get; set; }

		public static ConfigEntry<bool> affectVoidKey { get; set; }

		public static void InitConfig(ConfigFile config)
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			ConfigWhites = config.Bind<string>("General", "White Items", "15-25", "How many white items are in the loot pool. write 2 numbers seperated by \"-\" to limit the pool a random amount in that range (5-10). -1 for no limit");
			ConfigGreens = config.Bind<string>("General", "Green Items", "10-15", "How many green items are in the loot pool. write 2 numbers seperated by \"-\" to limit the pool a random amount in that range (5-10). -1 for no limit");
			ConfigReds = config.Bind<string>("General", "Red Items", "-1", "How many red items are in the loot pool. write 2 numbers seperated by \"-\" to limit the pool a random amount in that range (5-10). -1 for no limit");
			blacklistWeight = config.Bind<float>("General", "blacklistWeight", 0f, "The & chance of getting a blacklisted item. If you don't want to remove items, but want to make them less common instead. (0 to completely remove blacklisted items, 100 disables the mod");
			affectPrinters = config.Bind<bool>("General", "Affect printers", false, "Limits the loot pool of printers and cauldrons as well");
			affectCradles = config.Bind<bool>("General", "Affect cradles", false, "Only allow voided variants of whitelisted items from cradles");
			affectVoidKey = config.Bind<bool>("General", "Affect voidKey", false, "Only allow voided variants of whitelisted items from void keyboxes");
			speedCategory = config.Bind<bool>("Categories", "Speed Category", false, "Add a subcategory for speed items, which in combination with low Category ratio variance will ensure that there are always at least some available");
			SpeedIncluded = config.Bind<string>("Categories", "Speed Category Contents", "SpeedBoostPickup, SprintBonus, AttackSpeedAndMoveSpeed, Hoof, Feather, MoveSpeedOnKill, SprintOutOfCombat, JumpBoost, BoostAllStats", "Items that should belong in the speed category, seperated by \", \" (SpeedBoostPickup, SprintBonus)");
			categoryVariance = config.Bind<float>("Categories", "Category ratio variance", 10f, "Determines how much the ratios can differ from the base game. \nEnsures that you can't get a build with only healing etc.\n Higher values equals more randomness.\n (min:0, max:100)");
			ModSettingsManager.SetModDescription("Randomly remove a set amount of items from the itempool");
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ConfigWhites));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ConfigGreens));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ConfigReds));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(blacklistWeight, new StepSliderConfig
			{
				min = 0f,
				max = 100f,
				increment = 1f
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(speedCategory));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(SpeedIncluded));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(categoryVariance, new StepSliderConfig
			{
				min = 0f,
				max = 100f,
				increment = 1f
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(affectPrinters));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(affectCradles));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(affectVoidKey));
			SetSpriteDefaultIcon();
		}

		private 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);
			}
		}

		public static void printConfig()
		{
			Log.Warning("ConfigWhites: " + (object)ConfigWhites);
			Log.Warning("ConfigGreens: " + (object)ConfigGreens);
			Log.Warning("ConfigReds: " + (object)ConfigReds);
			Log.Warning("speedCategory: " + (object)speedCategory);
			Log.Warning("SpeedIncluded: " + (object)SpeedIncluded);
			Log.Warning("categoryVariance: " + (object)categoryVariance);
			Log.Warning("blacklistWeight: " + (object)blacklistWeight);
			Log.Warning("affectPrinters: " + (object)affectPrinters);
			Log.Warning("affectCradles: " + (object)affectCradles);
			Log.Warning("affectVoidKey: " + (object)affectVoidKey);
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Onyx.LootPoolLimiter", "LootPoolLimiter", "1.1.1")]
	public class LootPoolLimiter : BaseUnityPlugin
	{
		public const string PluginGUID = "Onyx.LootPoolLimiter";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "LootPoolLimiter";

		public const string PluginVersion = "1.1.1";

		public static string[] affectedPools = new string[22]
		{
			"dtChest1", "dtChest2", "dtSonorousEcho", "dtSmallChestDamage", "dtSmallChestHealing", "dtSmallChestUtility", "dtCategoryChest2Damage", "dtCategoryChest2Healing", "dtCategoryChest2Utility", "dtCasinoChest",
			"dtShrineChance", "dtChanceDoll", "dtLockbox", "dtSacrificeArtifact", "dtVoidTriple", "dtTier1Item", "dtTier2Item", "dtTier3Item", "GeodeRewardDropTable", "dtShrineHalcyoniteTier1",
			"dtShrineHalcyoniteTier2", "dtShrineHalcyoniteTier3"
		};

		public static BasicPickupDropTable dtDuplicatorTier1;

		public static BasicPickupDropTable dtDuplicatorTier2;

		public static BasicPickupDropTable dtDuplicatorTier3;

		public static BasicPickupDropTable dtChest1;

		public static int numWhites;

		public static int numGreens;

		public static int numReds;

		public static List<PickupIndex> blockedWhites;

		public static List<PickupIndex> blockedGreens;

		public static List<PickupIndex> blockedReds;

		private Dictionary<ItemDef, ItemDef> voidPairs;

		public static int SotsItemCount;

		public static float[] categoryWeightsWhite = new float[4];

		public static float[] categoryWeightsGreen = new float[4];

		public static float[] categoryWeightsRed = new float[4];

		public static ItemTag[] categoryTags;

		public void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			LootPoolLimiterConfig.InitConfig(((BaseUnityPlugin)this).Config);
			Run.onRunStartGlobal += start_blacklist;
			BasicPickupDropTable.GenerateWeightedSelection += new hook_GenerateWeightedSelection(filter_basic_loot);
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm += new hook_GenerateOptionsFromDropTablePlusForcedStorm(fix_halc_loot);
			PickupTransmutationManager.RebuildAvailablePickupGroups += new hook_RebuildAvailablePickupGroups(filter_printers);
			ShopTerminalBehavior.Start += new hook_Start(fix_soup_always_affected);
			ChestBehavior.BaseItemDrop += new hook_BaseItemDrop(fix_scavbag_droptable);
		}

		private void fix_scavbag_droptable(orig_BaseItemDrop orig, ChestBehavior self)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)self).name.Contains("ScavBackpack"))
			{
				self.dropPickup = self.dropTable.GenerateDrop(self.rng);
			}
			orig.Invoke(self);
		}

		private void start_blacklist(Run run)
		{
			load_config();
			get_category_weights((ItemTier)0, run);
			get_category_weights((ItemTier)1, run);
			get_category_weights((ItemTier)2, run);
			SotsItemCount = 0;
			init_void_relationships();
			blockedWhites = create_blacklist(run.availableTier1DropList, numWhites, categoryWeightsWhite);
			blockedGreens = create_blacklist(run.availableTier2DropList, numGreens, categoryWeightsGreen);
			blockedReds = create_blacklist(run.availableTier3DropList, numReds, categoryWeightsRed);
			PickupDropTable.RegenerateAll(run);
		}

		private void init_void_relationships()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			voidPairs = new Dictionary<ItemDef, ItemDef>();
			Enumerator<Pair> enumerator = ItemCatalog.GetItemPairsForRelationship(Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion()).GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Pair current = enumerator.Current;
					voidPairs.Add(current.itemDef1, current.itemDef2);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		private List<PickupIndex> create_blacklist(List<PickupIndex> itemList, int allowedCount, float[] categoryWeights)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_0104: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			if (allowedCount <= 0)
			{
				return new List<PickupIndex>();
			}
			List<PickupIndex> blockedItems = new List<PickupIndex>(itemList);
			foreach (ItemDef value in voidPairs.Values)
			{
				blockedItems.Add(PickupCatalog.FindPickupIndex(value.itemIndex));
			}
			List<PickupIndex>[] categoryItems = new List<PickupIndex>[4]
			{
				new List<PickupIndex>(),
				new List<PickupIndex>(),
				new List<PickupIndex>(),
				new List<PickupIndex>()
			};
			foreach (PickupIndex item in itemList)
			{
				if (LootPoolLimiterConfig.SpeedIncluded.Value.Split(", ").Contains(PickupCatalog.GetPickupDef(item).internalName.Substring(10)) && LootPoolLimiterConfig.speedCategory.Value)
				{
					categoryItems[3].Add(item);
					continue;
				}
				for (int i = 0; i < categoryTags.Length; i++)
				{
					if (ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(item).itemIndex).ContainsTag(categoryTags[i]))
					{
						categoryItems[i].Add(item);
					}
				}
			}
			blacklistItem(Random.Range(0, 4));
			for (int j = 1; j < allowedCount && j < itemList.Count; j++)
			{
				if (categoryWeights.Max() <= -999f)
				{
					Log.Error("endless loop.\nIf you can see this message, something went wrong. Please report it");
					LootPoolLimiterConfig.printConfig();
					categoryWeights[0] = -999f;
				}
				int num = Array.IndexOf(categoryWeights, categoryWeights.Max());
				if (categoryItems[num].Count <= 0)
				{
					j--;
					categoryWeights[num] = -1000f;
				}
				else
				{
					blacklistItem(num);
				}
			}
			return blockedItems;
			void blacklistItem(int category)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: 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_0068: Unknown result type (might be due to invalid IL or missing references)
				if (categoryItems[category].Count > 0)
				{
					int index = Random.Range(0, categoryItems[category].Count);
					ItemDef itemDef = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(categoryItems[category][index]).itemIndex);
					if (voidPairs.ContainsKey(itemDef))
					{
						blockedItems.Remove(PickupCatalog.FindPickupIndex(voidPairs[itemDef].itemIndex));
					}
					blockedItems.Remove(categoryItems[category][index]);
					if (itemDef.ContainsTag((ItemTag)21))
					{
						SotsItemCount = Math.Min(SotsItemCount + 1, 2);
					}
					categoryItems[category].RemoveAt(index);
					categoryWeights[category] -= Random.Range(1f - LootPoolLimiterConfig.categoryVariance.Value / 100f, 1f);
				}
			}
		}

		private void get_category_weights(ItemTier tier, Run run)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			//IL_005e: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> list;
			int num;
			float[] array;
			switch ((int)tier)
			{
			default:
				return;
			case 0:
				list = run.availableTier1DropList;
				num = numWhites;
				array = categoryWeightsWhite;
				break;
			case 1:
				list = run.availableTier2DropList;
				num = numGreens;
				array = categoryWeightsGreen;
				break;
			case 2:
				list = run.availableTier3DropList;
				num = numReds;
				array = categoryWeightsRed;
				break;
			}
			foreach (PickupIndex item in list)
			{
				PickupIndex current = item;
				if (LootPoolLimiterConfig.SpeedIncluded.Value.Split(", ").Contains(((PickupIndex)(ref current)).pickupDef.internalName.Substring(10)) && LootPoolLimiterConfig.speedCategory.Value)
				{
					array[3] += 1f;
					continue;
				}
				for (int num2 = Random.Range(3, 6); num2 >= 0; num2--)
				{
					if (ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(current).itemIndex).ContainsTag(categoryTags[num2 % 3]))
					{
						array[num2 % 3] += 1f;
						break;
					}
				}
			}
			for (int i = 0; i < categoryTags.Length; i++)
			{
				array[i] = array[i] / (float)list.Count * (float)num;
			}
			array[3] = array[3] / (float)list.Count * (float)num;
		}

		public void fix_soup_always_affected(orig_Start orig, ShopTerminalBehavior self)
		{
			if (!LootPoolLimiterConfig.affectPrinters.Value)
			{
				if (((Object)self).name.Contains("LunarCauldron, WhiteToGreen"))
				{
					self.dropTable = (PickupDropTable)(object)dtDuplicatorTier2;
				}
				if (((Object)self).name.Contains("LunarCauldron, GreenToRed"))
				{
					self.dropTable = (PickupDropTable)(object)dtDuplicatorTier3;
				}
				if (((Object)self).name.Contains("LunarCauldron, RedToWhite"))
				{
					self.dropTable = (PickupDropTable)(object)dtDuplicatorTier1;
				}
			}
			orig.Invoke(self);
		}

		private void load_config()
		{
			((BaseUnityPlugin)this).Config.Reload();
			numWhites = parse_itemnum(LootPoolLimiterConfig.ConfigWhites.Value);
			numGreens = parse_itemnum(LootPoolLimiterConfig.ConfigGreens.Value);
			numReds = parse_itemnum(LootPoolLimiterConfig.ConfigReds.Value);
			static int parse_itemnum(string configString)
			{
				string[] array = configString.Split('-');
				int result;
				int result2;
				if (array.Length > 1)
				{
					if (array[0].Length > 0)
					{
						int.TryParse(array[0], out result);
						int.TryParse(array[1], out result2);
					}
					else
					{
						result = -1;
						result2 = -1;
					}
				}
				else
				{
					int.TryParse(configString, out result);
					result2 = result;
				}
				return Random.Range(result, result2 + 1);
			}
		}

		private void filter_basic_loot(orig_GenerateWeightedSelection orig, BasicPickupDropTable self, Run run)
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, run);
			if (blockedWhites == null || blockedGreens == null || blockedReds == null)
			{
				return;
			}
			if (((Object)self).name.Contains("dtDuplicatorTier1"))
			{
				dtDuplicatorTier1 = self;
			}
			else if (((Object)self).name.Contains("dtDuplicatorTier2"))
			{
				dtDuplicatorTier2 = self;
			}
			else if (((Object)self).name.Contains("dtDuplicatorTier3"))
			{
				dtDuplicatorTier3 = self;
			}
			else if (((Object)self).name.Contains("dtChest1"))
			{
				dtChest1 = self;
			}
			if (!affectedPools.Contains(((Object)self).name) && (!LootPoolLimiterConfig.affectPrinters.Value || !((Object)self).name.Contains("dtDuplicator")) && (!LootPoolLimiterConfig.affectCradles.Value || !((Object)self).name.Contains("dtVoidChest")) && (!LootPoolLimiterConfig.affectVoidKey.Value || !((Object)self).name.Contains("dtVoidLockbox")))
			{
				return;
			}
			Dictionary<ItemTier, float> prevTierAmount = get_tier_weights(self);
			int num = self.selector.Count;
			for (int num2 = self.selector.Count - 1; num2 >= 0; num2--)
			{
				if (blockedWhites.Contains(self.selector.choices[num2].value) || blockedGreens.Contains(self.selector.choices[num2].value) || blockedReds.Contains(self.selector.choices[num2].value))
				{
					num--;
				}
			}
			for (int num3 = self.selector.Count - 1; num3 >= 0; num3--)
			{
				if (LootPoolLimiterConfig.blacklistWeight.Value == 0f)
				{
					if (blockedWhites.Contains(self.selector.choices[num3].value) || blockedGreens.Contains(self.selector.choices[num3].value) || blockedReds.Contains(self.selector.choices[num3].value))
					{
						self.selector.ModifyChoiceWeight(num3, 0f);
					}
				}
				else if (!blockedWhites.Contains(self.selector.choices[num3].value) && !blockedGreens.Contains(self.selector.choices[num3].value) && !blockedReds.Contains(self.selector.choices[num3].value))
				{
					self.selector.ModifyChoiceWeight(num3, self.selector.choices[num3].weight * ((float)((self.selector.Count - num) / num) / (LootPoolLimiterConfig.blacklistWeight.Value / 100f) - (float)((self.selector.Count - num) / num) + 1f));
				}
			}
			balance_item_weight(self, prevTierAmount);
			PickupTransmutationManager.RebuildPickupGroups();
		}

		private void filter_printers(orig_RebuildAvailablePickupGroups orig, Run run)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(run);
			for (int i = 0; i < PickupTransmutationManager.availablePickupGroups.Length; i++)
			{
				PickupIndex[] array = PickupTransmutationManager.pickupGroups[i];
				List<PickupIndex> list = new List<PickupIndex>();
				PickupIndex[] array2 = array;
				foreach (PickupIndex item in array2)
				{
					if (!blockedWhites.Contains(item) && !blockedGreens.Contains(item) && !blockedReds.Contains(item))
					{
						list.Add(item);
					}
				}
				array = list.ToArray();
				PickupTransmutationManager.availablePickupGroups[i] = array;
				for (int k = 0; k < array.Length; k++)
				{
					PickupTransmutationManager.availablePickupGroupMap[array[k].value] = array;
				}
			}
		}

		private Option[] fix_halc_loot(orig_GenerateOptionsFromDropTablePlusForcedStorm orig, int numOptions, PickupDropTable dropTable, PickupDropTable stormDropTable, Xoroshiro128Plus rng)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)stormDropTable == (Object)(object)dropTable)
			{
				dropTable = (PickupDropTable)(object)dtChest1;
			}
			Option[] array = orig.Invoke(numOptions, dropTable, stormDropTable, rng);
			PickupIndex[] array2 = stormDropTable.GenerateUniqueDrops(2, rng);
			PickupIndex[] array3 = dropTable.GenerateUniqueDrops(numOptions, rng);
			int num = 0;
			for (int i = 0; i < numOptions; i++)
			{
				array[i] = new Option
				{
					available = true,
					pickupIndex = array3[i]
				};
				if (ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(array3[i]).itemIndex).ContainsTag((ItemTag)21))
				{
					num++;
					if (array3[i] == array2[1])
					{
						array2[1] = array2[0];
					}
				}
				if (i + SotsItemCount - num >= numOptions)
				{
					array[i].pickupIndex = array2[num];
				}
			}
			PickupPickerController.Shuffle<Option>(new Random(), array);
			return array;
		}

		private Dictionary<ItemTier, float> get_tier_weights(BasicPickupDropTable self)
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_0038: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ItemTier, float> dictionary = new Dictionary<ItemTier, float>();
			ChoiceInfo<PickupIndex>[] choices = self.selector.choices;
			for (int i = 0; i < choices.Length; i++)
			{
				ChoiceInfo<PickupIndex> val = choices[i];
				if ((int)PickupCatalog.GetPickupDef(val.value).itemIndex != -1)
				{
					if (dictionary.ContainsKey(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(val.value).itemIndex).tier))
					{
						dictionary[ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(val.value).itemIndex).tier] += val.weight;
					}
					else
					{
						dictionary.Add(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(val.value).itemIndex).tier, val.weight);
					}
				}
			}
			return dictionary;
		}

		private void balance_item_weight(BasicPickupDropTable self, Dictionary<ItemTier, float> prevTierAmount)
		{
			//IL_001e: 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_0025: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0063: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Invalid comparison between Unknown and I4
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ItemTier, float> dictionary = get_tier_weights(self);
			List<ItemTier> list = new List<ItemTier>();
			foreach (ItemTier key in dictionary.Keys)
			{
				list.Add(key);
			}
			foreach (ItemTier item in list)
			{
				dictionary[item] = prevTierAmount[item] / dictionary[item];
			}
			for (int i = 0; i < self.selector.Count; i++)
			{
				if ((int)PickupCatalog.GetPickupDef(self.selector.choices[i].value).itemIndex != -1)
				{
					self.selector.ModifyChoiceWeight(i, self.selector.choices[i].weight * dictionary[ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(self.selector.choices[i].value).itemIndex).tier]);
				}
			}
		}

		static LootPoolLimiter()
		{
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			categoryTags = (ItemTag[])(object)array;
		}
	}
}