Decompiled source of ItemBundles v1.3.0

ItemBundles.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreUpgrades.Classes;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("SeroRonin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("ItemBundles")]
[assembly: AssemblyTitle("ItemBundles")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ItemBundles
{
	public static class BundleHelper
	{
		public static int GetItemBundleChance(Item item)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			int chanceInShop = ItemBundles.Instance.itemTypeBundleInfo[item.itemType].chanceInShop;
			if (ItemBundles.Instance.itemBundleInfo[item.itemAssetName].chanceInShop >= 0)
			{
				chanceInShop = ItemBundles.Instance.itemBundleInfo[item.itemAssetName].chanceInShop;
			}
			return chanceInShop;
		}

		public static int GetItemBundleMax(Item item)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			int maxInShop = ItemBundles.Instance.itemTypeBundleInfo[item.itemType].maxInShop;
			if (ItemBundles.Instance.itemBundleInfo[item.itemAssetName].maxInShop >= 0)
			{
				maxInShop = ItemBundles.Instance.itemBundleInfo[item.itemAssetName].maxInShop;
			}
			return maxInShop;
		}

		public static int GetItemBundleMinItem(Item item)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			int value = ItemBundles.Instance.config_minConsumablePerBundle.Value;
			if (ItemBundles.Instance.itemTypeBundleInfo[item.itemType].config_minPerBundle.Value >= 0)
			{
				value = ItemBundles.Instance.itemTypeBundleInfo[item.itemType].config_minPerBundle.Value;
			}
			if (ItemBundles.Instance.itemBundleInfo[item.itemAssetName].config_minPerBundle.Value >= 0)
			{
				value = ItemBundles.Instance.itemBundleInfo[item.itemAssetName].config_minPerBundle.Value;
			}
			return value;
		}

		public static int GetItemBundleMinItem(string itemString, itemType itemType)
		{
			//IL_001b: 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)
			int value = ItemBundles.Instance.config_minConsumablePerBundle.Value;
			if (ItemBundles.Instance.itemTypeBundleInfo[itemType].config_minPerBundle.Value >= 0)
			{
				value = ItemBundles.Instance.itemTypeBundleInfo[itemType].config_minPerBundle.Value;
			}
			if (ItemBundles.Instance.itemBundleInfo[itemString].config_minPerBundle.Value >= 0)
			{
				value = ItemBundles.Instance.itemBundleInfo[itemString].config_minPerBundle.Value;
			}
			return value;
		}

		public static float GetItemBundlePriceMult(string itemString, itemType itemType)
		{
			//IL_001b: 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)
			float value = ItemBundles.Instance.config_priceMultiplier.Value;
			if (ItemBundles.Instance.itemTypeBundleInfo[itemType].config_priceMultiplier.Value >= 0f)
			{
				value = ItemBundles.Instance.itemTypeBundleInfo[itemType].config_priceMultiplier.Value;
			}
			if (ItemBundles.Instance.itemBundleInfo[itemString].config_priceMultiplier.Value >= 0f)
			{
				value = ItemBundles.Instance.itemBundleInfo[itemString].config_priceMultiplier.Value;
			}
			return value;
		}

		public static string GetItemStringFromBundle(Item bundleItem)
		{
			string itemAssetName = bundleItem.itemAssetName;
			return GetItemStringFromBundle(itemAssetName);
		}

		public static string GetItemStringFromBundle(string bundleItemString)
		{
			string removeString = " Bundle";
			return RemoveString(bundleItemString, removeString);
		}

		public static string RemoveString(string baseString, string removeString)
		{
			int num = baseString.IndexOf(removeString);
			return (num < 0) ? baseString : baseString.Remove(num, removeString.Length);
		}

		public static List<PlayerAvatar> PlayerGetAllAlive()
		{
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (item.playerHealth.health > 0)
				{
					list.Add(item);
				}
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	internal static class BundlePatch_StatsManager
	{
		[HarmonyPostfix]
		[HarmonyPatch("AddItemsUpgradesPurchased")]
		private static void AddItemsUpgradesPurchased_Postfix(StatsManager __instance, ref string itemName)
		{
			string value = " Bundle";
			if (itemName.Contains(value))
			{
				string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(itemName);
				__instance.itemsUpgradesPurchased[itemStringFromBundle]++;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start_Postfix(StatsManager __instance)
		{
			ItemBundles.Instance.InitializeItemBundles();
		}
	}
	[HarmonyPatch(typeof(ItemAttributes))]
	internal static class BundlePatch_ItemAttributes
	{
		[HarmonyPrefix]
		[HarmonyPatch("GetValue")]
		private static void GetValue_Prefix(ItemAttributes __instance)
		{
			if (!ItemBundles.Instance.moreUpgradesLoaded)
			{
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetValue")]
		private static void GetValue_Postfix(ItemAttributes __instance)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Invalid comparison between Unknown and I4
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Invalid comparison between Unknown and I4
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			string value = "Bundle";
			string itemAssetName = __instance.itemAssetName;
			if (!itemAssetName.Contains(value))
			{
				return;
			}
			int value2 = __instance.value;
			int count = SemiFunc.PlayerGetAll().Count;
			count += ItemBundles.Instance.config_debugFakePlayers.Value;
			if ((int)__instance.itemType == 3)
			{
				float num = Random.Range(__instance.itemValueMin, __instance.itemValueMax) * ShopManager.instance.itemValueMultiplier;
				if (num < 1000f)
				{
					num = 1000f;
				}
				if (num >= 1000f)
				{
					num = Mathf.Ceil(num / 1000f);
				}
				num += num * ShopManager.instance.upgradeValueIncrease * (float)StatsManager.instance.GetItemsUpgradesPurchased(BundleHelper.GetItemStringFromBundle(__instance.itemAssetName));
				__instance.value = (int)num;
			}
			if ((int)__instance.itemType == 6 || (int)__instance.itemType == 11)
			{
				count = Mathf.Max(count, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType));
			}
			if (count > 1)
			{
				float num2 = BundleHelper.GetItemBundlePriceMult(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType) / 100f;
				float num3 = (float)count * num2;
				value2 = Mathf.RoundToInt((float)value2 * num3);
				ItemBundlesLogger.LogWarning($"---- ITEM VALUE INCREASED: {value2}");
				__instance.value = value2;
				if (GameManager.Multiplayer())
				{
					__instance.photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { __instance.value });
				}
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("ShowingInfo")]
		private static IEnumerable<CodeInstruction> ShowingInfo_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_3, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Beq, (object)null, (string)null)
			}).ThrowIfInvalid("ShowingInfo(): Couldn't find matching code");
			object operand = val.Operand;
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[5]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "itemAssetName")),
				new CodeInstruction(OpCodes.Ldstr, (object)"Bundle"),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(string), "Contains", new Type[1] { typeof(string) }, (Type[])null)),
				new CodeInstruction(OpCodes.Brtrue, operand)
			});
			ItemBundlesLogger.LogInfo("--- ShowingInfo(): ADDING NEW INSTRUCTIONS", debugOnly: true);
			return val.InstructionEnumeration();
		}

		[HarmonyPostfix]
		[HarmonyPatch("ShowingInfo")]
		private static void ShowingInfo_Postfix(ItemAttributes __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			string promptName = __instance.promptName;
			string value = "Bundle";
			if (__instance.itemAssetName.Contains(value))
			{
				string text = "";
				int count = SemiFunc.PlayerGetAll().Count;
				if ((int)__instance.itemType == 8)
				{
					int healAmount = ((Component)__instance).GetComponent<ItemHealthPackBundle>().healAmount;
					text = BundleHelper.PlayerGetAllAlive().Count * healAmount + "hp";
				}
				else if ((int)__instance.itemType == 6 || (int)__instance.itemType == 11)
				{
					text = Mathf.Max(count, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType)).ToString();
				}
				else if ((int)__instance.itemType == 3)
				{
					text = count.ToString();
				}
				promptName = promptName + "\n[Bundle of " + text + "]";
				__instance.promptName = promptName;
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	[HarmonyPriority(0)]
	internal static class BundlePatch_ShopManager
	{
		[HarmonyPrefix]
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		private static void GetAllItemsFromStatsManager_Prefix(ShopManager __instance)
		{
			if (SemiFunc.IsNotMasterClient())
			{
				return;
			}
			ItemBundlesLogger.LogInfo("------ Overriding Shop List", debugOnly: true);
			ItemBundles.Instance.itemDictionaryShop.Clear();
			foreach (KeyValuePair<string, Item> item in StatsManager.instance.itemDictionary)
			{
				List<string> list = ItemBundles.Instance.itemDictionaryShopBlacklist.Keys.ToList();
				List<Item> list2 = ItemBundles.Instance.itemDictionaryShopBlacklist.Values.ToList();
				if (list.Contains(item.Key) || list2.Contains(item.Value))
				{
					ItemBundlesLogger.LogInfo($"------ Blacklisting {item.Key} or {item.Value} from shop list", debugOnly: true);
					continue;
				}
				ItemBundlesLogger.LogInfo($"------ Adding {item.Key} or {item.Value} to shop list", debugOnly: true);
				ItemBundles.Instance.itemDictionaryShop.Add(item.Key, item.Value);
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		private static IEnumerable<CodeInstruction> GetAllItemsFromStatsManager_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
			}).ThrowIfInvalid("GetAllItemsFromStatsManager(): Couldn't find matching code");
			ItemBundlesLogger.LogInfo("--- GetAllItemsFromStatsManager(): ADDING NEW INSTRUCTIONS", debugOnly: true);
			val.Opcode = OpCodes.Call;
			val.Operand = AccessTools.PropertyGetter(typeof(ItemBundles), "Instance");
			val.Advance(1);
			val.Operand = AccessTools.Field(typeof(ItemBundles), "itemDictionaryShop");
			return val.InstructionEnumeration();
		}

		[HarmonyPostfix]
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		private static void GetAllItemsFromStatsManager_Postfix(ShopManager __instance)
		{
			foreach (KeyValuePair<itemType, ItemBundles.BundleShopInfo> item in ItemBundles.Instance.itemTypeBundleInfo)
			{
				item.Value.chanceInShop = ((item.Value.config_chanceInShop.Value == -1) ? ItemBundles.Instance.config_chanceBundlesInShop.Value : item.Value.config_chanceInShop.Value);
				item.Value.maxInShop = ((item.Value.config_maxInShop.Value == -1) ? ItemBundles.Instance.config_maxBundlesInShop.Value : item.Value.config_maxInShop.Value);
			}
			foreach (KeyValuePair<string, ItemBundles.BundleShopInfo> item2 in ItemBundles.Instance.itemBundleInfo)
			{
				item2.Value.chanceInShop = item2.Value.config_chanceInShop.Value;
				item2.Value.maxInShop = item2.Value.config_maxInShop.Value;
			}
			ItemBundlesLogger.LogInfo("------ Bundling Lists", debugOnly: true);
			if (SemiFunc.IsMultiplayer() || !ItemBundles.Instance.config_disableBundlesSP.Value)
			{
				AttemptBundlesFromList(ref __instance.potentialItems);
				AttemptBundlesFromList(ref __instance.potentialItemConsumables);
				AttemptBundlesFromList(ref __instance.potentialItemUpgrades);
				AttemptBundlesFromList(ref __instance.potentialItemHealthPacks);
			}
		}

		private static void AttemptBundlesFromList(ref List<Item> itemList)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			List<Item> list = new List<Item>(itemList);
			for (int num = list.Count - 1; num >= 0; num--)
			{
				Item val = list[num];
				if (ItemBundles.Instance.itemBundleInfo.ContainsKey(val.itemAssetName))
				{
					ItemBundlesLogger.LogInfo($"-{num}- Found {val.itemAssetName} entry", debugOnly: true);
					ItemBundles.BundleShopInfo bundleShopInfo = ItemBundles.Instance.itemTypeBundleInfo[val.itemType];
					ItemBundles.BundleShopInfo bundleShopInfo2 = ItemBundles.Instance.itemBundleInfo[val.itemAssetName];
					float num2 = BundleHelper.GetItemBundleChance(val);
					num2 /= 100f;
					if (BundleHelper.GetItemBundleMax(val) == 0)
					{
						ItemBundlesLogger.LogWarning($"-{num}- Already have max bundles for {val.itemAssetName}!", debugOnly: true);
					}
					else
					{
						float num3 = Random.Range(0f, 1f);
						if (num3 <= num2)
						{
							ItemBundlesLogger.LogWarning($"-{num}- Passed with {num3} {num3 <= num2}, Replacing item {list[num]} with {bundleShopInfo2.bundleItem}!", debugOnly: true);
							list[num] = bundleShopInfo2.bundleItem;
							if (bundleShopInfo.maxInShop > 0)
							{
								bundleShopInfo.maxInShop--;
							}
							if (bundleShopInfo2.maxInShop > 0)
							{
								bundleShopInfo2.maxInShop--;
							}
						}
						else
						{
							ItemBundlesLogger.LogError($"-{num}- Failed with {num3} {num3 <= num2}, keeping item {list[num]}!", debugOnly: true);
						}
					}
				}
			}
			ListExtension.Shuffle<Item>((IList<Item>)list);
			itemList = list;
		}
	}
	[BepInPlugin("SeroRonin.ItemBundles", "ItemBundles", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ItemBundles : BaseUnityPlugin
	{
		public class BundleShopInfo
		{
			public Item bundleItem;

			public int chanceInShop;

			public int maxInShop;

			public ConfigEntry<int> config_chanceInShop;

			public ConfigEntry<int> config_maxInShop;

			public ConfigEntry<int> config_minPerBundle;

			public ConfigEntry<float> config_priceMultiplier;
		}

		public AssetBundle assetBundle;

		public Dictionary<string, Item> itemDictionaryShop = new Dictionary<string, Item>();

		public Dictionary<string, Item> itemDictionaryShopBlacklist = new Dictionary<string, Item>();

		public Dictionary<itemType, BundleShopInfo> itemTypeBundleInfo = new Dictionary<itemType, BundleShopInfo>();

		public Dictionary<string, BundleShopInfo> itemBundleInfo = new Dictionary<string, BundleShopInfo>();

		public bool moreUpgradesLoaded;

		public static ItemBundles Instance { get; private set; }

		internal Harmony? Harmony { get; set; }

		public ConfigEntry<bool> config_disableBundlesSP { get; private set; }

		public ConfigEntry<int> config_chanceBundlesInShop { get; private set; }

		public ConfigEntry<int> config_maxBundlesInShop { get; private set; }

		public ConfigEntry<int> config_minConsumablePerBundle { get; private set; }

		public ConfigEntry<float> config_priceMultiplier { get; private set; }

		public ConfigEntry<int> config_debugFakePlayers { get; private set; }

		public ConfigEntry<bool> config_debugLogging { get; private set; }

		public ConfigEntry<bool> enableMoreUpgradesCompat { get; private set; }

		private void Awake()
		{
			if (!Object.op_Implicit((Object)(object)Instance))
			{
				Instance = this;
				ItemBundlesLogger.Init(((BaseUnityPlugin)this).Logger);
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, "itembundles");
				assetBundle = AssetBundle.LoadFromFile(text);
				((Component)this).gameObject.transform.parent = null;
				((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
				if (Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades"))
				{
					moreUpgradesLoaded = true;
				}
				CreateConfigs();
				Patch();
				RegisterItemBundles();
				if (moreUpgradesLoaded)
				{
					MoreUpgradesCompat.InitCompat();
				}
				ItemBundlesLogger.LogInfo($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
			}
		}

		public void RegisterItemBundles()
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				ItemBundlesLogger.LogError("Assetbundle \"itembundles\" not found! Please make sure that it exists in the same folder as the mod DLL");
				ItemBundlesLogger.LogError("ItemBundles has run into a fatal error! The mod will not work correctly and may cause issues elsewhere!");
				return;
			}
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Map Player Count Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Energy Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Extra Jump Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Grab Range Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Grab Strength Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Health Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Sprint Speed Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Tumble Launch Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Small Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Medium Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Large Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Grenade Explosive Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Grenade Shockwave Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Grenade Stun Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Mine Explosive Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Mine Shockwave Bundle");
			RegisterBundleItemRepoLib(assetBundle, "Item Mine Stun Bundle");
		}

		public void InitializeItemBundles()
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				ItemBundlesLogger.LogError("Assetbundle \"itembundles\" not found! Please make sure that it exists in the same folder as the mod DLL");
				ItemBundlesLogger.LogError("ItemBundles has run into a fatal error! The mod will not work correctly and may cause issues elsewhere!");
				return;
			}
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Map Player Count Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Energy Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Extra Jump Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Grab Range Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Grab Strength Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Health Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Sprint Speed Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Upgrade Player Tumble Launch Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Health Pack Small Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Health Pack Medium Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Health Pack Large Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Grenade Explosive Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Grenade Shockwave Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Grenade Stun Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Mine Explosive Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Mine Shockwave Bundle");
			RegisterBundleItemCustom(assetBundle, "Item Mine Stun Bundle");
			if (moreUpgradesLoaded)
			{
				MoreUpgradesCompat.RegisterBundleItem_MoreUpgrades(assetBundle, "Modded Item Upgrade Player Map Enemy Tracker Bundle");
				MoreUpgradesCompat.RegisterBundleItem_MoreUpgrades(assetBundle, "Modded Item Upgrade Player Map Player Tracker Bundle");
				MoreUpgradesCompat.RegisterBundleItem_MoreUpgrades(assetBundle, "Modded Item Upgrade Player Sprint Usage Bundle");
				MoreUpgradesCompat.RegisterBundleItem_MoreUpgrades(assetBundle, "Modded Item Upgrade Player Valuable Count Bundle");
			}
		}

		public void CreateConfigs()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Expected O, but got Unknown
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Expected O, but got Unknown
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Expected O, but got Unknown
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Expected O, but got Unknown
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Expected O, but got Unknown
			config_disableBundlesSP = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Bundles in Singleplayer", true, new ConfigDescription("Whether bundles are disabled when doing a singleplayer run", (AcceptableValueBase)null, Array.Empty<object>()));
			config_chanceBundlesInShop = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Bundle Chance", 20, new ConfigDescription("Percent chance that an item will be replaced with a bundle variant", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			config_maxBundlesInShop = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Maximum Bundles In Shop", -1, new ConfigDescription("Maximum number of bundles that can appear of ANY one type. Setting to -1 makes shop ignore this entry", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>()));
			config_minConsumablePerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Mininum consumables per bundle", 0, new ConfigDescription("Minimum amount of items in consumable bundles. Price still scales. Default: 0", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Bundle Price Multiplier", 66.66f, new ConfigDescription("Multiplier of total item costs that bundles have", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			string text = "";
			if (!moreUpgradesLoaded)
			{
				text = "HideFromREPOConfig";
			}
			enableMoreUpgradesCompat = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod Compatibility", "Enable More Upgrades Compatability", false, new ConfigDescription("[EXPERIMENTAL, Requires Restart] More Upgrades support is only partially done. See mod page for more info and expect issues!", (AcceptableValueBase)null, new object[1] { text }));
			string text2 = "Has Priority over General entry. Ignored if set below 0";
			itemTypeBundleInfo[(itemType)11] = new BundleShopInfo
			{
				config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Mines: Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
				config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Mines: Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Mines: Mininum per bundle", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles: Item Type", "Mines: Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
			};
			itemTypeBundleInfo[(itemType)6] = new BundleShopInfo
			{
				config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Grenades: Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
				config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Grenades: Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Grenades: Mininum per bundle", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles: Item Type", "Grenades: Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
			};
			itemTypeBundleInfo[(itemType)8] = new BundleShopInfo
			{
				config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Health Packs: Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
				config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Health Packs: Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles: Item Type", "Health Packs: Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
			};
			itemTypeBundleInfo[(itemType)3] = new BundleShopInfo
			{
				config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Upgrades: Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
				config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles: Item Type", "Upgrades: Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles: Item Type", "Upgrades: Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
			};
			config_debugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Dev", "Debug Logging", false, new ConfigDescription("Enables debug logging", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
			config_debugFakePlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Dev", "Number of Fake Players", 0, new ConfigDescription("Adds fake players to bundle player calculations", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), new object[1] { "HideFromREPOConfig" }));
		}

		internal void RegisterBundleItemRepoLib(AssetBundle assetBundle, string itemString)
		{
			Item val = assetBundle.LoadAsset<Item>(itemString);
			if ((Object)(object)val == (Object)null)
			{
				ItemBundlesLogger.LogError("Item " + itemString + " not found!");
			}
			else
			{
				Items.RegisterItem(val);
			}
		}

		internal void RegisterBundleItemCustom(AssetBundle assetBundle, string bundleItemString, string configSectionPrefix = "")
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Invalid comparison between Unknown and I4
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Invalid comparison between Unknown and I4
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			Item val = assetBundle.LoadAsset<Item>(bundleItemString);
			if ((Object)(object)val == (Object)null)
			{
				ItemBundlesLogger.LogError("--- Bundle Item \"" + bundleItemString + "\" not found!");
				return;
			}
			string text = " Bundle";
			if (!bundleItemString.Contains(text))
			{
				ItemBundlesLogger.LogError("--- Item " + bundleItemString + " is not a bundle! Add \" Bundle\" to item name (WITH THE SPACE)");
				return;
			}
			string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(val);
			Item val2 = StatsManager.instance.itemDictionary[itemStringFromBundle];
			if (!Object.op_Implicit((Object)(object)val2))
			{
				ItemBundlesLogger.LogError("--- Didn't find " + itemStringFromBundle + "! Make sure itemAssetName of bundle Item and bundle Prefab is " + itemStringFromBundle + text);
				return;
			}
			if (itemBundleInfo.ContainsKey(itemStringFromBundle))
			{
				ItemBundlesLogger.LogWarning($"--- bundleStringPairs {itemStringFromBundle} already has an entry {itemBundleInfo[itemStringFromBundle]}, we are overriding something!");
			}
			itemDictionaryShopBlacklist.Add(val.itemAssetName, val);
			string text2 = "Has Priority over Item Type entry. Ignored if set below 0";
			BundleShopInfo bundleShopInfo = new BundleShopInfo
			{
				bundleItem = val,
				config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
				config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
				config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
			};
			if ((int)val.itemType == 6 || (int)val.itemType == 11)
			{
				bundleShopInfo.config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Mininum per bundle", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>()));
			}
			if (configSectionPrefix == "MoreUpgrades " && !enableMoreUpgradesCompat.Value)
			{
				ItemBundlesLogger.LogInfo("--- MoreUpgrades Compatibility not enabled, voiding bundleInfo { " + itemStringFromBundle + " | " + val.itemAssetName + " }", debugOnly: true);
			}
			else
			{
				itemBundleInfo[itemStringFromBundle] = bundleShopInfo;
				ItemBundlesLogger.LogInfo("--- Added bundleInfo { " + itemStringFromBundle + " | " + val.itemAssetName + " }", debugOnly: true);
			}
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	internal static class ItemBundlesLogger
	{
		public static ManualLogSource ManualLogSource { get; private set; }

		public static void Init(ManualLogSource manualLogSource)
		{
			ManualLogSource = manualLogSource;
		}

		public static void Log(LogLevel level, object data, bool debugOnly = false)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!debugOnly || ItemBundles.Instance.config_debugLogging.Value)
			{
				ManualLogSource.Log(level, data);
			}
		}

		public static void LogFatal(object data, bool debugOnly = false)
		{
			Log((LogLevel)1, data, debugOnly);
		}

		public static void LogError(object data, bool debugOnly = false)
		{
			Log((LogLevel)2, data, debugOnly);
		}

		public static void LogWarning(object data, bool debugOnly = false)
		{
			Log((LogLevel)4, data, debugOnly);
		}

		public static void LogMessage(object data, bool debugOnly = false)
		{
			Log((LogLevel)8, data, debugOnly);
		}

		public static void LogInfo(object data, bool debugOnly = false)
		{
			Log((LogLevel)16, data, debugOnly);
		}

		public static void LogDebug(object data, bool debugOnly = false)
		{
			Log((LogLevel)32, data, debugOnly);
		}
	}
	public static class MoreUpgradesCompat
	{
		public static string modName = "MoreUpgrades";

		public static Assembly moreUpgradesAssembly;

		public static Type plugin_type;

		public static BaseUnityPlugin plugin_instance;

		public static Type upgradesMananger_type;

		public static object upgradesMananger_instance;

		public static MethodInfo upgradesMananger_upgradeMethod;

		public static BindingFlags bindingFlags;

		public static void InitCompat()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(Chainloader.PluginInfos["bulletbot." + modName.ToLower()].Location);
			moreUpgradesAssembly = Assembly.LoadFrom(directoryName + "\\" + modName + ".dll");
			plugin_type = moreUpgradesAssembly.GetType(modName + ".Plugin");
			bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic;
			plugin_instance = (BaseUnityPlugin)plugin_type.GetField("instance", bindingFlags).GetValue(null);
			GetUpgradeItemsList(out List<UpgradeItem> upgradeItems);
			foreach (UpgradeItem item in upgradeItems)
			{
				string text = item.fullName + " Bundle";
				Item val = ItemBundles.Instance.assetBundle.LoadAsset<Item>(item.fullName + " Bundle");
				if (Object.op_Implicit((Object)(object)val))
				{
					Items.RegisterItem(val);
					ItemBundlesLogger.LogInfo($"-- {modName}Compat found bundle item: {val}", debugOnly: true);
					val.prefab.GetComponent<MoreUpgradesCompat_Bundle>().upgradeItemName = item.name;
					val.prefab.GetComponent<MoreUpgradesCompat_Bundle>().FixMaterial();
					val.prefab.GetComponent<MoreUpgradesCompat_Bundle>().FixLight();
				}
				else
				{
					ItemBundlesLogger.LogError("-- " + modName + " did not find bundle item", debugOnly: true);
				}
			}
		}

		public static void GetUpgradeItemsList(out List<UpgradeItem> upgradeItems)
		{
			List<UpgradeItem> list = (List<UpgradeItem>)plugin_type.GetField("upgradeItems", bindingFlags).GetValue(plugin_instance);
			if (list != null)
			{
				upgradeItems = list;
				return;
			}
			ItemBundlesLogger.LogError("- " + modName + "Compat: " + modName + ".Plugin.instance.upgradeItems was not found, generating empty list to prevent NRE!", debugOnly: true);
			upgradeItems = new List<UpgradeItem>();
		}

		public static void CallUpgrade(string upgradeItemName, string steamId, int amount = 1)
		{
			object[] parameters = new object[3] { upgradeItemName, steamId, amount };
			if (upgradesMananger_type == null)
			{
				upgradesMananger_type = moreUpgradesAssembly.GetType(modName + ".Classes.MoreUpgradesManager");
			}
			if (upgradesMananger_type == null)
			{
				return;
			}
			if (upgradesMananger_instance == null)
			{
				upgradesMananger_instance = upgradesMananger_type.GetField("instance", bindingFlags).GetValue(null);
			}
			if (upgradesMananger_instance != null)
			{
				if (upgradesMananger_upgradeMethod == null)
				{
					upgradesMananger_upgradeMethod = upgradesMananger_type.GetMethod("Upgrade", bindingFlags);
				}
				if (!(upgradesMananger_upgradeMethod == null))
				{
					upgradesMananger_upgradeMethod.Invoke(upgradesMananger_instance, parameters);
				}
			}
		}

		public static Material? GetBoxMat(string upgradeItemName)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			AssetBundle val = (AssetBundle)plugin_type.GetField("assetBundle", bindingFlags).GetValue(plugin_instance);
			Item val2 = val.LoadAsset<Item>(upgradeItemName);
			if ((Object)(object)val2 == (Object)null)
			{
				ItemBundlesLogger.LogError("- GetBoxMat " + upgradeItemName + " failed", debugOnly: true);
				return null;
			}
			Material result = ((Renderer)val2.prefab.GetComponentInChildren<MeshRenderer>()).materials[0];
			MeshFilter[] componentsInChildren = val2.prefab.GetComponentsInChildren<MeshFilter>();
			MeshFilter[] array = componentsInChildren;
			foreach (MeshFilter val3 in array)
			{
				MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null && ((Object)((Renderer)component).materials[0]).name.Contains("upgrade"))
				{
					result = ((Renderer)component).materials[0];
				}
			}
			return result;
		}

		public static Light? GetLight(string upgradeItemName)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			AssetBundle val = (AssetBundle)plugin_type.GetField("assetBundle", bindingFlags).GetValue(plugin_instance);
			Item val2 = val.LoadAsset<Item>(upgradeItemName);
			if ((Object)(object)val2 == (Object)null)
			{
				ItemBundlesLogger.LogError("- GetLight " + upgradeItemName + " failed", debugOnly: true);
				return null;
			}
			Transform val3 = val2.prefab.transform.Find("Light - Small Lamp");
			if ((Object)(object)val3 == (Object)null)
			{
				return null;
			}
			return ((Component)val3).GetComponent<Light>();
		}

		public static void RegisterBundleItem_MoreUpgrades(AssetBundle assetBundle, string bundleItemString)
		{
			ItemBundles.Instance.RegisterBundleItemCustom(assetBundle, bundleItemString, "MoreUpgrades ");
			UpdateItemInfo(bundleItemString);
		}

		public static void UpdateItemInfo(string bundleItemString)
		{
			Item val = StatsManager.instance.itemDictionary[bundleItemString];
			string key = BundleHelper.RemoveString(bundleItemString, " Bundle");
			Item val2 = StatsManager.instance.itemDictionary[key];
			val.value = ScriptableObject.CreateInstance<Value>();
			val.value.valueMin = val2.value.valueMin / 4f;
			val.value.valueMax = val2.value.valueMax / 4f;
		}
	}
	public class ItemConsumableBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private PhotonView photonView;

		private PhysGrabObjectImpactDetector impactDetector;

		public GameObject itemPrefab;

		private bool used;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
		}

		private void Update()
		{
			if (!SemiFunc.RunIsShop() && SemiFunc.IsMasterClientOrSingleplayer() && itemToggle.toggleState && !used && !used && itemToggle.toggleState)
			{
				SpawnItems();
				StatsManager.instance.ItemRemove(((Component)this).GetComponent<ItemAttributes>().instanceName);
				impactDetector.destroyDisable = false;
				impactDetector.DestroyObject(false);
				used = true;
			}
		}

		public void SpawnItems()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_003b: 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_0063: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			int num = SemiFunc.PlayerGetAll().Count;
			Item item = ((Component)this).GetComponent<ItemAttributes>().item;
			if ((int)item.itemType == 6 || (int)item.itemType == 11)
			{
				num = Mathf.Max(num, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(item), item.itemType));
			}
			itemType itemType = item.itemType;
			itemType val = itemType;
			float num2 = (((int)val == 6) ? 0.25f : (((int)val != 11) ? 0f : 0.5f));
			if (!SemiFunc.IsMultiplayer())
			{
				for (int i = 0; i < num + ItemBundles.Instance.config_debugFakePlayers.Value; i++)
				{
					Vector3 val2 = Vector3.zero;
					if (i != 0)
					{
						val2 = Random.insideUnitSphere * num2;
					}
					GameObject val3 = Object.Instantiate<GameObject>(itemPrefab, ((Component)this).transform.position + val2, Quaternion.identity);
					StatsManager.instance.ItemPurchase(val3.GetComponent<ItemAttributes>().item.itemAssetName);
				}
			}
			else
			{
				if (!SemiFunc.IsMasterClient())
				{
					return;
				}
				for (int j = 0; j < num + ItemBundles.Instance.config_debugFakePlayers.Value; j++)
				{
					Vector3 val4 = Vector3.zero;
					if (j != 0)
					{
						val4 = Random.insideUnitSphere * num2;
					}
					GameObject val5 = PhotonNetwork.Instantiate("Items/" + ((Object)itemPrefab).name, ((Component)this).transform.position + val4, Quaternion.identity, (byte)0, (object[])null);
					StatsManager.instance.ItemPurchase(val5.GetComponent<ItemAttributes>().item.itemAssetName);
				}
			}
		}
	}
	public class ItemHealthPackBundle : MonoBehaviour
	{
		public int healAmount;

		private int healingBank;

		private ItemToggle itemToggle;

		private ItemEquippable itemEquippable;

		private ItemAttributes itemAttributes;

		private PhotonView photonView;

		private PhysGrabObject physGrabObject;

		private List<PlayerAvatar> playersToHeal;

		[Space]
		public ParticleSystem[] particles;

		public ParticleSystem[] rejectParticles;

		[Space]
		public PropLight propLight;

		public AnimationCurve lightIntensityCurve;

		private float lightIntensityLerp;

		public MeshRenderer mesh;

		private Material material;

		private Color materialEmissionOriginal;

		private int materialPropertyEmission = Shader.PropertyToID("_EmissionColor");

		[Space]
		public Sound soundUse;

		public Sound soundReject;

		private bool used;

		private void Start()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
			itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
			itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			playersToHeal = new List<PlayerAvatar>();
			material = ((Renderer)mesh).material;
			materialEmissionOriginal = material.GetColor(materialPropertyEmission);
		}

		private void Update()
		{
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsShop())
			{
				return;
			}
			LightLogic();
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !itemToggle.toggleState || used)
			{
				return;
			}
			playersToHeal.Clear();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (item.playerHealth.health < item.playerHealth.maxHealth && item.playerHealth.health > 0)
				{
					healingBank += healAmount;
					playersToHeal.Add(item);
				}
			}
			healingBank += healAmount * ItemBundles.Instance.config_debugFakePlayers.Value;
			if (playersToHeal.Count <= 0)
			{
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("RejectRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					RejectRPC();
				}
				itemToggle.ToggleItem(false, -1);
				physGrabObject.rb.AddForce(Vector3.up * 2f, (ForceMode)1);
				physGrabObject.rb.AddTorque(-((Component)physGrabObject).transform.right * 0.05f, (ForceMode)1);
				return;
			}
			Dictionary<PlayerAvatar, int> dictionary = new Dictionary<PlayerAvatar, int>();
			foreach (PlayerAvatar item2 in playersToHeal)
			{
				dictionary[item2] = 0;
			}
			while (healingBank > 0 && playersToHeal.Count > 0)
			{
				List<PlayerAvatar> list = new List<PlayerAvatar>(playersToHeal);
				foreach (PlayerAvatar item3 in playersToHeal)
				{
					int num = item3.playerHealth.maxHealth - (item3.playerHealth.health + dictionary[item3]);
					int num2 = Mathf.Min(healingBank, healAmount);
					int num3 = Mathf.Min(num, num2);
					if (num <= num2)
					{
						list.Remove(item3);
					}
					healingBank = Mathf.Max(healingBank - num3, 0);
					dictionary[item3] += num3;
				}
				playersToHeal = list;
			}
			foreach (KeyValuePair<PlayerAvatar, int> item4 in dictionary)
			{
				ItemBundlesLogger.LogInfo($"{item4.Key.playerName} missing {item4.Key.playerHealth.maxHealth - item4.Key.playerHealth.health} health, healing for {healAmount} base + {item4.Value - healAmount} excess!", debugOnly: true);
				item4.Key.playerHealth.HealOther(item4.Value, true);
			}
			_ = StatsManager.instance.itemsPurchased[itemAttributes.item.itemAssetName];
			StatsManager.instance.ItemRemove(itemAttributes.instanceName);
			physGrabObject.impactDetector.destroyDisable = false;
			physGrabObject.impactDetector.indestructibleBreakEffects = true;
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("UsedRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				UsedRPC();
			}
		}

		private void LightLogic()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			if (used && lightIntensityLerp < 1f)
			{
				lightIntensityLerp += 1f * Time.deltaTime;
				propLight.lightComponent.intensity = lightIntensityCurve.Evaluate(lightIntensityLerp);
				propLight.originalIntensity = propLight.lightComponent.intensity;
				material.SetColor(materialPropertyEmission, Color.Lerp(Color.black, materialEmissionOriginal, lightIntensityCurve.Evaluate(lightIntensityLerp)));
			}
		}

		[PunRPC]
		private void UsedRPC()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			itemToggle.ToggleDisable(true);
			itemAttributes.DisableUI(true);
			Object.Destroy((Object)(object)itemEquippable);
			ParticleSystem[] array = particles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			soundUse.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			used = true;
		}

		[PunRPC]
		private void RejectRPC()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
			if (val.isLocal)
			{
				val.physGrabber.ReleaseObjectRPC(false, 1f);
			}
			ParticleSystem[] array = rejectParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
			soundReject.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}

		public void OnDestroy()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem[] array = particles;
			ParticleSystem[] array2 = array;
			foreach (ParticleSystem val in array2)
			{
				if (Object.op_Implicit((Object)(object)val) && val.isPlaying)
				{
					((Component)val).transform.SetParent((Transform)null);
					MainModule main = val.main;
					((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2;
				}
			}
			array = rejectParticles;
			ParticleSystem[] array3 = array;
			foreach (ParticleSystem val2 in array3)
			{
				if (Object.op_Implicit((Object)(object)val2) && val2.isPlaying)
				{
					((Component)val2).transform.SetParent((Transform)null);
					MainModule main2 = val2.main;
					((MainModule)(ref main2)).stopAction = (ParticleSystemStopAction)2;
				}
			}
		}
	}
	public class ItemUpgradeMapPlayerCountBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradeMapPlayerCount(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerEnergyBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerEnergy(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerExtraJumpBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerExtraJump(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerGrabRangeBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerGrabRange(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerGrabStrengthBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerGrabStrength(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerGrabThrowBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerThrowStrength(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerHealthBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerSprintSpeedBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerSprintSpeed(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class ItemUpgradePlayerTumbleLaunchBundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				PunManager.instance.UpgradePlayerTumbleLaunch(SemiFunc.PlayerGetSteamID(item));
			}
		}
	}
	public class MoreUpgradesCompat_Bundle : MonoBehaviour
	{
		private ItemToggle itemToggle;

		public string upgradeItemName;

		private void Start()
		{
			itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public void FixMaterial()
		{
			Material boxMat = MoreUpgradesCompat.GetBoxMat(upgradeItemName);
			if (!((Object)(object)boxMat != (Object)null))
			{
				return;
			}
			MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>();
			MeshFilter[] array = componentsInChildren;
			foreach (MeshFilter val in array)
			{
				MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null && ((Object)((Renderer)component).materials[0]).name.Contains("upgrade"))
				{
					Material[] materials = (Material[])(object)new Material[2]
					{
						boxMat,
						((Renderer)component).materials[1]
					};
					((Renderer)component).materials = materials;
				}
			}
		}

		public void FixLight()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Light component = ((Component)((Component)this).gameObject.transform.Find("Light - Small Lamp")).GetComponent<Light>();
			Light light = MoreUpgradesCompat.GetLight(upgradeItemName);
			if ((Object)(object)component != (Object)null && (Object)(object)light != (Object)null)
			{
				component.color = light.color;
			}
		}

		public void Upgrade()
		{
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			foreach (PlayerAvatar item in list)
			{
				string steamId = SemiFunc.PlayerGetSteamID(item);
				MoreUpgradesCompat.CallUpgrade(upgradeItemName, steamId);
			}
		}
	}
	public static class VanillaUpgradesCompat
	{
		public static string modName = "VanillaUpgrades";

		public static Assembly vanillaUpgradesAssembly;

		public static Type plugin_type;

		public static BaseUnityPlugin plugin_instance;

		public static List<object> plugin_upgradeItems;

		public static Type upgradesMananger_type;

		public static object upgradesMananger_instance;

		public static MethodInfo upgradesMananger_upgradeMethod;

		public static Type upgradeItem_type;

		public static BindingFlags bindingFlags;

		public static void InitCompat()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(Chainloader.PluginInfos["bulletbot." + modName.ToLower()].Location);
			vanillaUpgradesAssembly = Assembly.LoadFrom(directoryName + "\\" + modName + ".dll");
			plugin_type = vanillaUpgradesAssembly.GetType(modName + ".Plugin");
			bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic;
			plugin_instance = (BaseUnityPlugin)plugin_type.GetField("instance", bindingFlags).GetValue(null);
			upgradeItem_type = vanillaUpgradesAssembly.GetType(modName + ".Classes.UpgradeItem");
			ItemBundlesLogger.LogWarning($"- {modName} instance: {plugin_instance}", debugOnly: true);
			GetUpgradeItemsList(out plugin_upgradeItems);
		}

		public static void GetUpgradeItemsList(out List<object> upgradeItems)
		{
			List<object> list = (List<object>)plugin_type.GetField("upgradeItems", bindingFlags).GetValue(plugin_instance);
			ItemBundlesLogger.LogWarning($"- {modName} upgradeItems test: {list}", debugOnly: true);
			Type typeFromHandle = typeof(List<>);
			Type type = typeFromHandle.MakeGenericType(upgradeItem_type);
			object obj = Activator.CreateInstance(type);
			if (list != null)
			{
				IList list2 = (IList)obj;
				foreach (object item in list)
				{
					if ((Type)item == upgradeItem_type)
					{
						string text = (string)upgradeItem_type.GetField("name", bindingFlags).GetValue(item);
						ItemBundlesLogger.LogWarning("- " + modName + " upgradeItems list item: " + text, debugOnly: true);
						list2.Add(item);
					}
				}
				upgradeItems = list2 as List<object>;
			}
			else
			{
				ItemBundlesLogger.LogError("- " + modName + "s.Plugin.instance.upgradeItems was not found, generating empty list to prevent NRE!", debugOnly: true);
				upgradeItems = new List<object>();
			}
		}

		public static void CallUpgrade(string upgradeItemName, string steamId, int amount = 1)
		{
			object[] parameters = new object[3] { upgradeItemName, steamId, amount };
			if (upgradesMananger_type == null)
			{
				upgradesMananger_type = vanillaUpgradesAssembly.GetType(modName + ".Classes." + modName + "Manager");
			}
			if (upgradesMananger_type == null)
			{
				return;
			}
			if (upgradesMananger_instance == null)
			{
				upgradesMananger_instance = upgradesMananger_type.GetField("instance", bindingFlags).GetValue(null);
			}
			if (upgradesMananger_instance != null)
			{
				if (upgradesMananger_upgradeMethod == null)
				{
					upgradesMananger_upgradeMethod = upgradesMananger_type.GetMethod("Upgrade", bindingFlags);
				}
				if (!(upgradesMananger_upgradeMethod == null))
				{
					upgradesMananger_upgradeMethod.Invoke(upgradesMananger_instance, parameters);
				}
			}
		}
	}
}