Decompiled source of MoreUpgrades v1.6.5

MoreUpgrades.dll

Decompiled a day ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using KeybindLib.Classes;
using MoreUpgrades.Classes;
using MoreUpgrades.Compatibility;
using MoreUpgrades.Patches;
using MoreUpgrades.Properties;
using Photon.Pun;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreUpgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreUpgrades")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e12a72d-c200-488d-940a-653d1003d96e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreUpgrades
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("bulletbot.moreupgrades", "MoreUpgrades", "1.6.5")]
	internal class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "bulletbot.moreupgrades";

		private const string modName = "MoreUpgrades";

		private const string modVer = "1.6.5";

		internal static Plugin instance;

		public ManualLogSource logger;

		private readonly Harmony harmony = new Harmony("bulletbot.moreupgrades");

		public ConfigEntry<bool> importUpgrades;

		public ConfigEntry<string> excludeUpgradeIds;

		public AssetBundle assetBundle;

		public List<UpgradeItem> upgradeItems;

		public bool updateTracker;

		internal void PatchAll(string name)
		{
			(from x in Assembly.GetExecutingAssembly().GetTypes()
				where x.Namespace == typeof(Plugin).Namespace + "." + name
				select x).ToList().ForEach(delegate(Type x)
			{
				harmony.PatchAll(x);
			});
		}

		private GameObject GetVisualsFromComponent(Component component)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			GameObject val = null;
			if (component is EnemyParent)
			{
				EnemyParent val2 = (EnemyParent)(object)((component is EnemyParent) ? component : null);
				Enemy val3 = (Enemy)AccessTools.Field(typeof(EnemyParent), "Enemy").GetValue(component);
				if (val2.enemyName != "Bella")
				{
					try
					{
						val = ((Component)((Component)val2).GetComponentInChildren<EnemyVision>().VisionTransform).gameObject;
					}
					catch
					{
					}
					if ((Object)(object)val == (Object)null)
					{
						try
						{
							val = ((Component)val2.EnableObject.GetComponentInChildren<Animator>()).gameObject;
						}
						catch
						{
						}
					}
				}
				else
				{
					val = ((Component)((Component)val3).GetComponentInChildren<EnemyTricycle>().followTargetTransform).gameObject;
				}
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)val3).gameObject;
				}
			}
			else if (component is PlayerAvatar)
			{
				PlayerAvatar val4 = (PlayerAvatar)(object)((component is PlayerAvatar) ? component : null);
				val = ((Component)val4.playerAvatarVisuals).gameObject;
			}
			return val;
		}

		internal void RegisterToMap(Component component)
		{
			if ((Object)(object)Map.Instance == (Object)null)
			{
				return;
			}
			GameObject visualsFromComponent = GetVisualsFromComponent(component);
			if ((Object)(object)visualsFromComponent == (Object)null)
			{
				return;
			}
			string upgradeItemName = null;
			if (component is EnemyParent)
			{
				upgradeItemName = "Map Enemy Tracker";
			}
			else
			{
				if (!(component is PlayerAvatar))
				{
					return;
				}
				upgradeItemName = "Map Player Tracker";
			}
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == upgradeItemName);
			if (upgradeItem != null)
			{
				List<MapInfo> variable = upgradeItem.GetVariable<List<MapInfo>>("Map Infos");
				if (!variable.Any((MapInfo x) => (Object)(object)x.component == (Object)(object)component))
				{
					GameObject val = Object.Instantiate<GameObject>(Map.Instance.CustomObject, Map.Instance.OverLayerParent);
					((Object)val).name = ((Object)visualsFromComponent).name;
					MapCustomEntity component2 = val.GetComponent<MapCustomEntity>();
					component2.Parent = visualsFromComponent.transform;
					variable.Add(new MapInfo
					{
						component = component,
						mapCustomEntity = component2
					});
					updateTracker = true;
				}
			}
		}

		internal void ShowToMap(Component component)
		{
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker");
			UpgradeItem upgradeItem2 = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker");
			if (upgradeItem == null && upgradeItem2 == null)
			{
				return;
			}
			List<MapInfo> list = upgradeItem?.GetVariable<List<MapInfo>>("Map Infos");
			List<MapInfo> list2 = upgradeItem2?.GetVariable<List<MapInfo>>("Map Infos");
			if (list == null && list2 == null)
			{
				return;
			}
			MapInfo mapInfo = list?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? list2?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component);
			if (mapInfo == null)
			{
				return;
			}
			bool flag = component is EnemyParent;
			bool flag2 = component is PlayerAvatar;
			if (!flag && !flag2)
			{
				return;
			}
			if (flag)
			{
				Component obj = component;
				EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null);
				if ((from x in upgradeItem.GetConfig<string>("Exclude Enemies").Split(new char[1] { ',' })
					select x.Trim() into x
					where !string.IsNullOrEmpty(x)
					select x).Contains(val.enemyName))
				{
					return;
				}
			}
			mapInfo.visible = true;
			updateTracker = true;
		}

		internal void HideFromMap(Component component)
		{
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker");
			UpgradeItem upgradeItem2 = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker");
			if (upgradeItem == null && upgradeItem2 == null)
			{
				return;
			}
			List<MapInfo> list = upgradeItem?.GetVariable<List<MapInfo>>("Map Infos");
			List<MapInfo> list2 = upgradeItem2?.GetVariable<List<MapInfo>>("Map Infos");
			if (list == null && list2 == null)
			{
				return;
			}
			MapInfo mapInfo = list?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? list2?.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component);
			if (mapInfo == null)
			{
				return;
			}
			bool flag = component is EnemyParent;
			bool flag2 = component is PlayerAvatar;
			if (!flag && !flag2)
			{
				return;
			}
			if (flag)
			{
				Component obj = component;
				EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null);
				if ((from x in upgradeItem.GetConfig<string>("Exclude Enemies").Split(new char[1] { ',' })
					select x.Trim() into x
					where !string.IsNullOrEmpty(x)
					select x).Contains(val.enemyName))
				{
					return;
				}
			}
			mapInfo.visible = false;
			updateTracker = true;
		}

		internal void SwapOnMap(Component component, Component fromComponent)
		{
			UpgradeItem mapEnemyTracker = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Enemy Tracker");
			UpgradeItem upgradeItem = upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Map Player Tracker");
			if (mapEnemyTracker == null || upgradeItem == null)
			{
				return;
			}
			List<MapInfo> variable = mapEnemyTracker.GetVariable<List<MapInfo>>("Map Infos");
			List<MapInfo> variable2 = upgradeItem.GetVariable<List<MapInfo>>("Map Infos");
			if (variable == null || variable2 == null)
			{
				return;
			}
			MapInfo mapInfo = variable.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component) ?? variable2.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)component);
			MapInfo mapInfo2 = variable.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)fromComponent) ?? variable2.FirstOrDefault((MapInfo x) => (Object)(object)x.component == (Object)(object)fromComponent);
			if (mapInfo == null || mapInfo2 == null)
			{
				return;
			}
			bool flag = component is PlayerAvatar || component is EnemyParent;
			bool flag2 = fromComponent is PlayerAvatar || fromComponent is EnemyParent;
			if (!flag || !flag2)
			{
				return;
			}
			if (component is EnemyParent || fromComponent is EnemyParent)
			{
				List<string> list = new List<string>();
				Component obj = component;
				EnemyParent val = (EnemyParent)(object)((obj is EnemyParent) ? obj : null);
				if (val != null)
				{
					list.Add(val.enemyName);
				}
				Component obj2 = fromComponent;
				EnemyParent val2 = (EnemyParent)(object)((obj2 is EnemyParent) ? obj2 : null);
				if (val2 != null)
				{
					list.Add(val2.enemyName);
				}
				if (list.Any((string x) => (from y in mapEnemyTracker.GetConfig<string>("Exclude Enemies").Split(new char[1] { ',' })
					select y.Trim() into y
					where !string.IsNullOrEmpty(y)
					select y).Contains(x)))
				{
					return;
				}
			}
			if (variable.Contains(mapInfo) && variable2.Contains(mapInfo2))
			{
				variable.Remove(mapInfo);
				variable.Add(mapInfo2);
				variable2.Remove(mapInfo2);
				variable2.Add(mapInfo);
			}
			else if (variable.Contains(mapInfo2) && variable2.Contains(mapInfo))
			{
				variable.Remove(mapInfo2);
				variable.Add(mapInfo);
				variable2.Remove(mapInfo);
				variable2.Add(mapInfo2);
			}
			updateTracker = true;
		}

		private void Awake()
		{
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			logger = Logger.CreateLogSource("MoreUpgrades");
			assetBundle = AssetBundle.LoadFromMemory(Resources.moreupgrades);
			if ((Object)(object)assetBundle == (Object)null)
			{
				logger.LogError((object)"Something went wrong when loading the asset bundle.");
				return;
			}
			importUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("! REPOLib Configuration !", "Import Upgrades", false, "Whether to import the upgrades from REPOLib.");
			excludeUpgradeIds = ((BaseUnityPlugin)this).Config.Bind<string>("! REPOLib Configuration !", "Exclude Upgrade IDs", "", "Exclude specific REPOLib upgrades by listing their IDs, seperated by commas.\nThis setting only has an effect if 'Import Upgrades' is enabled.");
			upgradeItems = new List<UpgradeItem>();
			UpgradeItem.Base @base = new UpgradeItem.Base
			{
				name = "Sprint Usage",
				maxAmount = 10,
				maxAmountInShop = 2,
				minPrice = 9000f,
				maxPrice = 14000f
			};
			UpgradeItem sprintUsage = null;
			@base.onStart = (Action<PlayerAvatar, int>)Delegate.Combine(@base.onStart, new Action<PlayerAvatar, int>(UpdateSprintUsage));
			@base.onUpgrade = (Action<PlayerAvatar, int>)Delegate.Combine(@base.onUpgrade, new Action<PlayerAvatar, int>(UpdateSprintUsage));
			sprintUsage = new UpgradeItem(@base);
			sprintUsage.AddConfig("Scaling Factor", 0.9f, "Formula: energySprintDrain * (scalingFactor ^ upgradeLevel))");
			upgradeItems.Add(sprintUsage);
			UpgradeItem.Base base2 = new UpgradeItem.Base
			{
				name = "Valuable Count",
				minPrice = 30000f,
				maxPrice = 40000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			};
			UpgradeItem valuableCount = null;
			base2.onVariablesStart = (Action)Delegate.Combine(base2.onVariablesStart, (Action)delegate
			{
				valuableCount.AddVariable("Current Valuables", new List<ValuableObject>());
				valuableCount.AddVariable("Changed", value: false);
				valuableCount.AddVariable("Previous Count", 0);
				valuableCount.AddVariable("Previous Value", 0);
				valuableCount.AddVariable("Text Length", 0);
			});
			base2.onUpdate = (Action)Delegate.Combine(base2.onUpdate, (Action)delegate
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop())
				{
					PlayerAvatar playerAvatarScript3 = PlayerController.instance.playerAvatarScript;
					if ((Object)(object)MissionUI.instance != (Object)null && (Object)(object)playerAvatarScript3 != (Object)null && valuableCount.playerUpgrade.GetLevel(playerAvatarScript3) > 0)
					{
						TextMeshProUGUI val2 = (TextMeshProUGUI)AccessTools.Field(typeof(MissionUI), "Text").GetValue(MissionUI.instance);
						string text = (string)AccessTools.Field(typeof(MissionUI), "messagePrev").GetValue(MissionUI.instance);
						List<ValuableObject> variable2 = valuableCount.GetVariable<List<ValuableObject>>("Current Valuables");
						bool variable3 = valuableCount.GetVariable<bool>("Changed");
						int variable4 = valuableCount.GetVariable<int>("Previous Count");
						int variable5 = valuableCount.GetVariable<int>("Previous Value");
						int variable6 = valuableCount.GetVariable<int>("Text Length");
						int count = variable2.Count;
						bool config = valuableCount.GetConfig<bool>("Display Total Value");
						int num = (config ? variable2.Select((ValuableObject x) => (int)(float)AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent").GetValue(x)).Sum() : 0);
						if (!string.IsNullOrEmpty(((TMP_Text)val2).text) && (variable3 || variable4 != count || variable5 != num))
						{
							string text2 = ((TMP_Text)val2).text;
							if (!variable3 && (variable4 != count || variable5 != num))
							{
								text2 = text2.Substring(0, text2.Length - variable6);
							}
							string text3 = $"\nValuables: <b>{count}</b>" + (config ? (" (<color=#558B2F>$</color><b>" + SemiFunc.DollarGetString(num) + "</b>)") : "");
							text2 += text3;
							valuableCount.SetVariable("Previous Count", count);
							valuableCount.SetVariable("Previous Value", num);
							valuableCount.SetVariable("Text Length", text3.Length);
							((TMP_Text)val2).text = text2;
							AccessTools.Field(typeof(MissionUI), "messagePrev").SetValue(MissionUI.instance, text2);
							if (variable3)
							{
								valuableCount.SetVariable("Changed", value: false);
							}
						}
					}
				}
			});
			valuableCount = new UpgradeItem(base2);
			valuableCount.AddConfig("Display Total Value", defaultValue: true, "Whether to display the total value next to the valuable counter.");
			valuableCount.AddConfig("Ignore Money Bags", defaultValue: false, "Whether to ignore the money bags from the extraction points.");
			upgradeItems.Add(valuableCount);
			Sprite mapTracker = assetBundle.LoadAsset<Sprite>("Map Tracker");
			float trackerDelay = 0.2f;
			UpgradeItem.Base base3 = new UpgradeItem.Base
			{
				name = "Map Enemy Tracker",
				minPrice = 50000f,
				maxPrice = 60000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			};
			UpgradeItem mapEnemyTracker = null;
			base3.onVariablesStart = (Action)Delegate.Combine(base3.onVariablesStart, (Action)delegate
			{
				mapEnemyTracker.AddVariable("Map Infos", new List<MapInfo>());
			});
			base3.onUpdate = (Action)Delegate.Combine(base3.onUpdate, (Action)delegate
			{
				if (updateTracker || Time.time % trackerDelay < Time.deltaTime)
				{
					UpdateTracker(mapEnemyTracker);
				}
			});
			mapEnemyTracker = new UpgradeItem(base3);
			mapEnemyTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot.");
			mapEnemyTracker.AddConfig<Color>("Color", Color.red, "The color of the icon.");
			mapEnemyTracker.AddConfig("Exclude Enemies", "", "Exclude specific enemies from displaying their icon by listing their names.\nExample: 'Gnome, Clown', seperated by commas.");
			upgradeItems.Add(mapEnemyTracker);
			UpgradeItem.Base base4 = new UpgradeItem.Base
			{
				name = "Map Player Tracker",
				minPrice = 30000f,
				maxPrice = 40000f,
				maxPurchaseAmount = 1,
				priceIncreaseScaling = 0f
			};
			UpgradeItem mapPlayerTracker = null;
			base4.onVariablesStart = (Action)Delegate.Combine(base4.onVariablesStart, (Action)delegate
			{
				mapPlayerTracker.AddVariable("Map Infos", new List<MapInfo>());
			});
			base4.onUpdate = (Action)Delegate.Combine(base4.onUpdate, (Action)delegate
			{
				if (updateTracker || Time.time % trackerDelay < Time.deltaTime)
				{
					UpdateTracker(mapPlayerTracker);
				}
			});
			mapPlayerTracker = new UpgradeItem(base4);
			mapPlayerTracker.AddConfig("Arrow Icon", defaultValue: true, "Whether the icon should appear as an arrow showing direction instead of a dot.");
			mapPlayerTracker.AddConfig("Player Color", defaultValue: false, "Whether the icon should be colored as the player.");
			mapPlayerTracker.AddConfig<Color>("Color", Color.blue, "The color of the icon.");
			upgradeItems.Add(mapPlayerTracker);
			UpgradeItem.Base base5 = new UpgradeItem.Base
			{
				name = "Item Resist",
				maxAmount = 10,
				maxAmountInShop = 2,
				minPrice = 4000f,
				maxPrice = 6000f
			};
			UpgradeItem itemResist = null;
			base5.onVariablesStart = (Action)Delegate.Combine(base5.onVariablesStart, (Action)delegate
			{
				itemResist.AddVariable("Last Player Grabbed", new Dictionary<PhysGrabObject, PlayerAvatar>());
			});
			itemResist = new UpgradeItem(base5);
			itemResist.AddConfig("Scaling Factor", 0.9f, "Formula: valueLost * (scalingFactor ^ upgradeLevel)");
			upgradeItems.Add(itemResist);
			UpgradeItem.Base base6 = new UpgradeItem.Base
			{
				name = "Map Zoom",
				maxAmount = 2,
				maxAmountInShop = 1,
				minPrice = 20000f,
				maxPrice = 35000f,
				maxPurchaseAmount = 2
			};
			UpgradeItem mapZoom = null;
			base6.onStart = (Action<PlayerAvatar, int>)Delegate.Combine(base6.onStart, new Action<PlayerAvatar, int>(UpdateMapZoom));
			base6.onUpgrade = (Action<PlayerAvatar, int>)Delegate.Combine(base6.onUpgrade, new Action<PlayerAvatar, int>(UpdateMapZoom));
			mapZoom = new UpgradeItem(base6);
			mapZoom.AddConfig("Scaling Factor", 0.75f, "Formula: defaultMapZoom + upgradeLevel * scalingFactor");
			upgradeItems.Add(mapZoom);
			UpgradeItem upgradeItem2 = new UpgradeItem(new UpgradeItem.Base
			{
				name = "Autoscan",
				maxAmount = 3,
				maxAmountInShop = 1,
				minPrice = 45000f,
				maxPrice = 50000f,
				maxPurchaseAmount = 3
			});
			upgradeItem2.AddConfig("Silent Scanning", defaultValue: false, "Whether the scanned items should be silent or not.");
			upgradeItem2.AddConfig("Scaling Factor", 5f, "Formula: upgradeLevel * scalingFactor");
			upgradeItems.Add(upgradeItem2);
			UpgradeItem upgradeItem3 = new UpgradeItem(new UpgradeItem.Base
			{
				name = "Item Value",
				maxAmount = 10,
				maxAmountInShop = 2,
				minPrice = 75000f,
				maxPrice = 82500f
			});
			upgradeItem3.AddConfig("Scaling Factor", 0.05f, "This variable is based on the host!\nFormula: itemValue * (1 + upgradeLevel * scalingFactor)");
			upgradeItems.Add(upgradeItem3);
			UpgradeItem.Base base7 = new UpgradeItem.Base
			{
				name = "Extra Life",
				maxAmount = 10,
				maxAmountInShop = 2,
				minPrice = 150000f,
				maxPrice = 225000f
			};
			Keybind reviveKeybind = Keybinds.Bind("Revive", "<Keyboard>/r");
			base7.onUpdate = (Action)Delegate.Combine(base7.onUpdate, (Action)delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				PlayerAvatar playerAvatarScript2 = PlayerController.instance.playerAvatarScript;
				if (!((Object)(object)playerAvatarScript2 == (Object)null) && SemiFunc.NoTextInputsActive() && InputManager.instance.KeyUp(reviveKeybind.inputKey))
				{
					MoreUpgradesManager.instance.Revive(playerAvatarScript2);
				}
			});
			UpgradeItem upgradeItem4 = new UpgradeItem(base7);
			upgradeItem4.AddConfig("Singleplayer Invincibility Timer", 3f, "This variable is based on the host! After reviving, you will be given a short invincibility period.");
			upgradeItem4.AddConfig("Multiplayer Invincibility Timer", 0f, "This variable is based on the host! After reviving, you will be given a short invincibility period.");
			upgradeItems.Add(upgradeItem4);
			SceneManager.activeSceneChanged += delegate
			{
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				if (!((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelSplashScreen))
				{
					GameObject val = new GameObject("More Upgrades Manager");
					val.AddComponent<MoreUpgradesManager>();
				}
			};
			logger.LogMessage((object)"MoreUpgrades has started.");
			PatchAll("Patches");
			if (REPOLib.IsLoaded())
			{
				REPOLib.OnAwake();
			}
			void UpdateMapZoom(PlayerAvatar playerAvatar, int level)
			{
				if (!((Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)playerAvatar))
				{
					MapPatch.mapCamera.orthographicSize = MapPatch.defaultMapZoom + (float)level * mapZoom.GetConfig<float>("Scaling Factor");
				}
			}
			void UpdateSprintUsage(PlayerAvatar playerAvatar, int level)
			{
				if (!((Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)playerAvatar))
				{
					string key = "Energy Sprint Drain";
					if (!sprintUsage.HasVariable(key))
					{
						sprintUsage.AddVariable(key, PlayerController.instance.EnergySprintDrain);
					}
					PlayerController.instance.EnergySprintDrain = sprintUsage.GetVariable<float>(key) * Mathf.Pow(sprintUsage.GetConfig<float>("Scaling Factor"), (float)level);
				}
			}
			void UpdateTracker(UpgradeItem upgradeItem)
			{
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				PlayerAvatar playerAvatarScript = PlayerController.instance.playerAvatarScript;
				if ((Object)(object)playerAvatarScript != (Object)null)
				{
					bool flag = upgradeItem.playerUpgrade.GetLevel(playerAvatarScript) > 0;
					List<MapInfo> variable = upgradeItem.GetVariable<List<MapInfo>>("Map Infos");
					foreach (MapInfo item in variable)
					{
						MapCustomEntity mapCustomEntity = item.mapCustomEntity;
						SpriteRenderer spriteRenderer = mapCustomEntity.spriteRenderer;
						if (flag)
						{
							Transform parent = mapCustomEntity.Parent;
							if (Map.Instance.Active)
							{
								Map.Instance.CustomPositionSet(((Component)mapCustomEntity).transform, parent);
							}
							spriteRenderer.sprite = (upgradeItem.GetConfig<bool>("Arrow Icon") ? mapTracker : playerAvatarScript.playerDeathHead.mapCustom.sprite);
							Color color = upgradeItem.GetConfig<Color>("Color");
							if (upgradeItem.upgradeBase.name == "Map Player Tracker" && upgradeItem.GetConfig<bool>("Player Color"))
							{
								color = (Color)AccessTools.Field(typeof(PlayerAvatarVisuals), "color").GetValue(playerAvatarScript.playerAvatarVisuals);
							}
							MapLayer layerParent = Map.Instance.GetLayerParent(parent.position.y + 1f);
							if (layerParent.layer == Map.Instance.PlayerLayer)
							{
								color.a = 1f;
							}
							else
							{
								color.a = 0.3f;
							}
							spriteRenderer.color = color;
						}
						((Renderer)spriteRenderer).enabled = flag && item.visible;
					}
				}
				updateTracker = false;
			}
		}
	}
}
namespace MoreUpgrades.REPOLibPatches
{
	[HarmonyPatch(typeof(REPOLibItemUpgrade))]
	internal class REPOLibItemUpgradePatch
	{
		[HarmonyPatch("Upgrade")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> UpgradeTranspiler(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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlayerUpgrade), "AddLevel", new Type[2]
				{
					typeof(PlayerAvatar),
					typeof(int)
				}, (Type[])null), (string)null)
			});
			val.RemoveInstructions(2);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(REPOLibItemUpgradePatch), "Upgrade", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static void Upgrade(PlayerUpgrade playerUpgrade, PlayerAvatar playerAvatar, int amount)
		{
			if ((Object)(object)MoreUpgradesManager.instance != (Object)null)
			{
				UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)playerUpgrade.Item);
				if (upgradeItem != null && upgradeItem.GetConfig<bool>("Allow Team Upgrades"))
				{
					foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
					{
						playerUpgrade.AddLevel(item, amount);
					}
					return;
				}
			}
			playerUpgrade.AddLevel(playerAvatar, amount);
		}
	}
	[HarmonyPatch(typeof(Upgrades))]
	internal class UpgradesPatch
	{
		[HarmonyPatch("RegisterUpgrades")]
		[HarmonyPostfix]
		private static void RegisterUpgrades(Dictionary<string, PlayerUpgrade> ____playerUpgrades)
		{
			if ((Object)(object)Plugin.instance.assetBundle == (Object)null || (Object)(object)StatsManager.instance == (Object)null)
			{
				return;
			}
			foreach (KeyValuePair<string, PlayerUpgrade> pair in ____playerUpgrades)
			{
				UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)pair.Value.Item);
				if (upgradeItem != null)
				{
					string key = "appliedPlayerUpgrade" + pair.Key;
					Dictionary<string, int> appliedPlayerDictionary = upgradeItem.appliedPlayerDictionary;
					if (StatsManager.instance.dictionaryOfDictionaries.TryGetValue(key, out var value))
					{
						appliedPlayerDictionary = value;
						continue;
					}
					appliedPlayerDictionary.Clear();
					StatsManager.instance.dictionaryOfDictionaries.Add(key, appliedPlayerDictionary);
				}
			}
		}

		[HarmonyPatch("RegisterUpgrade")]
		[HarmonyPostfix]
		private static void RegisterUpgrade(ref PlayerUpgrade __result)
		{
			if (!((Object)(object)Plugin.instance.assetBundle == (Object)null) && __result != null && Plugin.instance.importUpgrades.Value && !(from x in Plugin.instance.excludeUpgradeIds.Value.Split(new char[1] { ',' })
				select x.Trim() into x
				where !string.IsNullOrEmpty(x)
				select x).Contains(__result.UpgradeId))
			{
				Plugin.instance.upgradeItems.Add(new UpgradeItem(__result));
			}
		}
	}
}
namespace MoreUpgrades.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("MoreUpgrades.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] moreupgrades
		{
			get
			{
				object @object = ResourceManager.GetObject("moreupgrades", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace MoreUpgrades.Patches
{
	[HarmonyPatch(typeof(ItemAttributes))]
	internal class ItemAttributesPatch
	{
		[HarmonyPatch("GetValue")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> GetValueTranspiler(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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(ShopManager), "instance"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null)
			};
			val.MatchForward(false, array);
			val.RemoveInstructions(array.Length);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "item")),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "ItemValueMultiplier", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Map))]
	internal class MapPatch
	{
		public static Camera mapCamera;

		public static float defaultMapZoom;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Awake(ref Transform ___playerTransformTarget)
		{
			mapCamera = ((Component)___playerTransformTarget).GetComponentInChildren<Camera>();
			defaultMapZoom = mapCamera.orthographicSize;
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
	internal class PhysGrabObjectImpactDetectorPatch
	{
		[HarmonyPatch("Break")]
		[HarmonyPrefix]
		private static void Break(PhysGrabObjectImpactDetector __instance, PhysGrabObject ___physGrabObject, bool ___isValuable, ref float valueLost)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null || !___isValuable)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Resist");
			if (upgradeItem == null)
			{
				return;
			}
			List<PhysGrabber> playerGrabbing = ___physGrabObject.playerGrabbing;
			if (playerGrabbing != null && playerGrabbing.Count > 0)
			{
				List<PlayerAvatar> list = playerGrabbing.Select((PhysGrabber player) => player.playerAvatar).ToList();
				int num = 0;
				foreach (PlayerAvatar item in list)
				{
					num += upgradeItem.playerUpgrade.GetLevel(item);
				}
				valueLost = ReduceValueLost(upgradeItem, valueLost, num);
			}
			else
			{
				Dictionary<PhysGrabObject, PlayerAvatar> variable = upgradeItem.GetVariable<Dictionary<PhysGrabObject, PlayerAvatar>>("Last Player Grabbed");
				if (variable.TryGetValue(___physGrabObject, out var value))
				{
					valueLost = ReduceValueLost(upgradeItem, valueLost, upgradeItem.playerUpgrade.GetLevel(value));
				}
			}
		}

		private static float ReduceValueLost(UpgradeItem upgradeItem, float valueLost, int level)
		{
			return valueLost * Mathf.Pow(upgradeItem.GetConfig<float>("Scaling Factor"), (float)level);
		}
	}
	[HarmonyPatch(typeof(PhysGrabber))]
	internal class PhysGrabberPatch
	{
		[HarmonyPatch("RayCheck")]
		[HarmonyPostfix]
		private static void RayCheck(PlayerAvatar ___playerAvatar, LayerMask ___mask)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null || (Object)(object)PlayerController.instance.playerAvatarScript != (Object)(object)___playerAvatar || (bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(___playerAvatar) || (bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(___playerAvatar))
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Autoscan");
			if (upgradeItem == null)
			{
				return;
			}
			int level = upgradeItem.playerUpgrade.GetLevel(___playerAvatar);
			if (level <= 0)
			{
				return;
			}
			Vector3 position = ___playerAvatar.playerTransform.position;
			Collider[] array = Physics.OverlapSphere(position, (float)level * upgradeItem.GetConfig<float>("Scaling Factor"), LayerMask.op_Implicit(___mask), (QueryTriggerInteraction)2);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				ValuableObject componentInParent = ((Component)((Component)val).transform).GetComponentInParent<ValuableObject>();
				if ((Object)(object)componentInParent == (Object)null || (bool)AccessTools.Field(typeof(ValuableObject), "discovered").GetValue(componentInParent))
				{
					continue;
				}
				if (upgradeItem.GetConfig<bool>("Silent Scanning"))
				{
					if (!GameManager.Multiplayer())
					{
						AccessTools.Method(typeof(ValuableObject), "DiscoverRPC", (Type[])null, (Type[])null).Invoke(componentInParent, null);
					}
					else
					{
						((PhotonView)AccessTools.Field(typeof(ValuableObject), "photonView").GetValue(componentInParent)).RPC("DiscoverRPC", (RpcTarget)0, Array.Empty<object>());
					}
				}
				else
				{
					componentInParent.Discover((State)0);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	internal class PlayerAvatarPatch
	{
		[HarmonyPatch("LateStart")]
		[HarmonyPostfix]
		private static void LateStart(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)__instance == (Object)(object)PlayerController.instance.playerAvatarScript))
			{
				Plugin.instance.RegisterToMap((Component)(object)__instance);
				Plugin.instance.ShowToMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("ReviveRPC")]
		[HarmonyPostfix]
		private static void ReviveRPC(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.ShowToMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("PlayerDeathRPC")]
		[HarmonyPostfix]
		private static void PlayerDeathRPC(PlayerAvatar __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.HideFromMap((Component)(object)__instance);
			}
		}
	}
	[HarmonyPatch(typeof(EnemySlowMouth))]
	internal class EnemySlowMouthPatch
	{
		[HarmonyPatch("UpdateStateRPC")]
		[HarmonyPostfix]
		private static void UpdateStateRPC(EnemySlowMouth __instance, Enemy ___enemy)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null) && !((Object)(object)___enemy == (Object)null))
			{
				PlayerAvatar val = (PlayerAvatar)AccessTools.Field(typeof(EnemySlowMouth), "playerTarget").GetValue(__instance);
				EnemyParent val2 = (EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy);
				State currentState = __instance.currentState;
				if ((int)currentState == 9)
				{
					Plugin.instance.HideFromMap((Component)(object)val2);
					Plugin.instance.SwapOnMap((Component)(object)val2, (Component)(object)val);
				}
				else if ((int)currentState == 11)
				{
					Plugin.instance.SwapOnMap((Component)(object)val, (Component)(object)val2);
					Plugin.instance.ShowToMap((Component)(object)val2);
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyParent))]
	internal class EnemyParentPatch
	{
		[HarmonyPatch("Setup")]
		[HarmonyPostfix]
		private static void Setup(EnemyParent __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.RegisterToMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("SpawnRPC")]
		[HarmonyPostfix]
		private static void SpawnRPC(EnemyParent __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.ShowToMap((Component)(object)__instance);
			}
		}

		[HarmonyPatch("DespawnRPC")]
		[HarmonyPostfix]
		private static void DespawnRPC(EnemyParent __instance)
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.HideFromMap((Component)(object)__instance);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	internal class EnemyHealthPatch
	{
		[HarmonyPatch("DeathRPC")]
		[HarmonyPostfix]
		private static void DeathRPC(EnemyHealth __instance, Enemy ___enemy)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.HideFromMap((Component)(EnemyParent)AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(___enemy));
			}
		}
	}
	[HarmonyPatch(typeof(MissionUI))]
	internal class MissionUIPatch
	{
		[HarmonyPatch("MissionText")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> MissionTextTranspiler(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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(MissionUI), "messagePrev"), (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MissionUIPatch), "MissionText", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static void MissionText()
		{
			if (!((Object)(object)MoreUpgradesManager.instance == (Object)null))
			{
				Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count")?.SetVariable("Changed", value: true);
			}
		}
	}
	[HarmonyPatch(typeof(ValuableObject))]
	internal class ValuableObjectPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ValuableObject __instance)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count");
			if (upgradeItem != null && (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<SurplusValuable>()) || !upgradeItem.GetConfig<bool>("Ignore Money Bags")))
			{
				List<ValuableObject> variable = upgradeItem.GetVariable<List<ValuableObject>>("Current Valuables");
				if (!variable.Contains(__instance))
				{
					variable.Add(__instance);
				}
			}
		}

		[HarmonyPatch("DollarValueSetLogic")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DollarValueSetLogicTranspiler(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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ValuableObject), "dollarValueOriginal"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"), (string)null)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableObjectPatch), "DollarValueSetLogic", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static float DollarValueSetLogic(float dollarValueCurrent)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return dollarValueCurrent;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Value");
			if (upgradeItem == null)
			{
				return dollarValueCurrent;
			}
			int num = 0;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				num = upgradeItem.playerUpgrade.GetLevel(player);
			}
			return dollarValueCurrent * (1f + (float)num * upgradeItem.GetConfig<float>("Scaling Factor"));
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject))]
	internal class PhysGrabObjectPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update(PhysGrabObject __instance, bool ___isValuable, PlayerAvatar ___lastPlayerGrabbing)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null || !___isValuable)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Item Resist");
			if (upgradeItem == null || !((Object)(object)___lastPlayerGrabbing != (Object)null))
			{
				return;
			}
			Dictionary<PhysGrabObject, PlayerAvatar> variable = upgradeItem.GetVariable<Dictionary<PhysGrabObject, PlayerAvatar>>("Last Player Grabbed");
			if (!variable.TryGetValue(__instance, out var value) || !((Object)(object)value == (Object)(object)___lastPlayerGrabbing))
			{
				if (variable.ContainsKey(__instance))
				{
					variable.Remove(__instance);
				}
				variable.Add(__instance, ___lastPlayerGrabbing);
			}
		}

		[HarmonyPatch("OnDestroy")]
		[HarmonyPostfix]
		private static void OnDestroy(PhysGrabObject __instance)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return;
			}
			ValuableObject component = ((Component)__instance).gameObject.GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Valuable Count");
			if (upgradeItem != null && (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<SurplusValuable>()) || !upgradeItem.GetConfig<bool>("Ignore Money Bags")))
			{
				List<ValuableObject> variable = upgradeItem.GetVariable<List<ValuableObject>>("Current Valuables");
				if (variable.Contains(component))
				{
					variable.Remove(component);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal class ShopManagerPatch
	{
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> GetAllItemsFromStatsManagerTranspiler(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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary<string, Item>.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null)
			});
			object operand = val.Operand;
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Dictionary<string, Item>.ValueCollection.Enumerator), "get_Current", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null)
			});
			val.Advance(1);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ShopManagerPatch), "GetAllItemsFromStatsManager", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Brtrue, operand)
			});
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier"), (string)null)
			});
			val.RemoveInstructions(2);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "ItemValueMultiplier", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static bool GetAllItemsFromStatsManager(Item item)
		{
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return false;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item);
			return upgradeItem != null && !upgradeItem.GetConfig<bool>("Enabled");
		}

		[HarmonyPatch("UpgradeValueGet")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> UpgradeValueGetTranspiler(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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease"), (string)null)
			};
			val.MatchForward(false, array);
			val.RemoveInstructions(array.Length);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_2, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MoreUpgradesAPI), "UpgradeValueIncrease", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}
	}
}
namespace MoreUpgrades.Compatibility
{
	internal static class KeybindLib
	{
		internal const string modGUID = "bulletbot.keybindlib";
	}
	internal static class REPOLib
	{
		internal const string modGUID = "REPOLib";

		public static bool IsLoaded()
		{
			return Chainloader.PluginInfos.ContainsKey("REPOLib");
		}

		public static void OnAwake()
		{
			Plugin.instance.PatchAll("REPOLibPatches");
		}
	}
}
namespace MoreUpgrades.Classes
{
	internal class MapInfo
	{
		public Component component;

		public MapCustomEntity mapCustomEntity;

		public bool visible;
	}
	public static class MoreUpgradesAPI
	{
		public static float ItemValueMultiplier(Item item)
		{
			float num = (float)AccessTools.Field(typeof(ShopManager), "itemValueMultiplier").GetValue(ShopManager.instance);
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return num;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item);
			if (upgradeItem == null)
			{
				return num;
			}
			float num2 = upgradeItem.GetConfig<float>("Price Multiplier");
			if (num2 < 0f)
			{
				num2 = num;
			}
			return num2;
		}

		public static float UpgradeValueIncrease(Item item)
		{
			float num = (float)AccessTools.Field(typeof(ShopManager), "upgradeValueIncrease").GetValue(ShopManager.instance);
			if ((Object)(object)MoreUpgradesManager.instance == (Object)null)
			{
				return num;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => (Object)(object)x.playerUpgrade.Item == (Object)(object)item);
			if (upgradeItem == null)
			{
				return num;
			}
			float num2 = upgradeItem.GetConfig<float>("Price Increase Scaling");
			if (num2 < 0f)
			{
				num2 = num;
			}
			return num2;
		}
	}
	internal class MoreUpgradesManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <WaitUntilLevel>d__7 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public MoreUpgradesManager <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitUntilLevel>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => SemiFunc.LevelGenDone()));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.checkPlayerUpgrades = true;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static MoreUpgradesManager instance;

		private PhotonView photonView;

		private bool checkPlayerUpgrades;

		private void Awake()
		{
			instance = this;
			photonView = ((Component)this).gameObject.AddComponent<PhotonView>();
			photonView.ViewID = 876842;
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.variables?.Clear();
				upgradeItem.upgradeBase.onVariablesStart?.Invoke();
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				((MonoBehaviour)this).StartCoroutine("WaitUntilLevel");
			}
		}

		private void Update()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.upgradeBase.onUpdate?.Invoke();
			}
		}

		private void LateUpdate()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				upgradeItem.upgradeBase.onLateUpdate?.Invoke();
			}
		}

		private void FixedUpdate()
		{
			foreach (UpgradeItem upgradeItem in Plugin.instance.upgradeItems)
			{
				if (checkPlayerUpgrades)
				{
					int config = upgradeItem.GetConfig<int>("Starting Amount");
					if (config >= 0)
					{
						foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
						{
							string key = SemiFunc.PlayerGetSteamID(item);
							if (!upgradeItem.appliedPlayerDictionary.ContainsKey(key))
							{
								upgradeItem.appliedPlayerDictionary[key] = 0;
							}
							if (upgradeItem.appliedPlayerDictionary[key] != config)
							{
								upgradeItem.playerUpgrade.SetLevel(item, config);
								upgradeItem.appliedPlayerDictionary[key] = config;
							}
						}
					}
					if (upgradeItem.GetConfig<bool>("Sync Host Upgrades"))
					{
						PlayerAvatar localPlayerAvatar = SemiFunc.PlayerAvatarLocal();
						int level = upgradeItem.playerUpgrade.GetLevel(localPlayerAvatar);
						foreach (PlayerAvatar item2 in from x in SemiFunc.PlayerGetAll()
							where (Object)(object)x != (Object)(object)localPlayerAvatar
							select x)
						{
							if (level != upgradeItem.playerUpgrade.GetLevel(item2))
							{
								upgradeItem.playerUpgrade.SetLevel(item2, level);
							}
						}
					}
				}
				upgradeItem.upgradeBase.onFixedUpdate?.Invoke();
			}
		}

		[IteratorStateMachine(typeof(<WaitUntilLevel>d__7))]
		private IEnumerator WaitUntilLevel()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitUntilLevel>d__7(0)
			{
				<>4__this = this
			};
		}

		public void Revive(PlayerAvatar playerAvatar)
		{
			string text = SemiFunc.PlayerGetSteamID(playerAvatar);
			if (text != null)
			{
				if (!SemiFunc.IsMultiplayer())
				{
					ReviveRPC(text);
					return;
				}
				photonView.RPC("ReviveRPC", (RpcTarget)2, new object[1] { text });
			}
		}

		[PunRPC]
		private void ReviveRPC(string steamId)
		{
			if (SemiFunc.RunIsShop() || SemiFunc.RunIsArena())
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId);
			if ((Object)(object)val == (Object)null || !(bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(val) || !(bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(val))
			{
				return;
			}
			UpgradeItem upgradeItem = Plugin.instance.upgradeItems.FirstOrDefault((UpgradeItem x) => x.upgradeBase.name == "Extra Life");
			if (upgradeItem != null && upgradeItem.playerUpgrade.GetLevel(steamId) > 0)
			{
				upgradeItem.playerUpgrade.RemoveLevel(val, 1);
				val.Revive(false);
				PlayerHealth playerHealth = val.playerHealth;
				playerHealth.HealOther((int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(playerHealth) - 1, false);
				bool flag = SemiFunc.IsMultiplayer();
				float config = upgradeItem.GetConfig<float>((flag ? "Multiplayer" : "Singleplayer") + " Invincibility Timer");
				if (!flag)
				{
					SetInvincibleRPC(steamId, config);
					return;
				}
				photonView.RPC("SetInvincibleRPC", (RpcTarget)0, new object[2] { steamId, config });
			}
		}

		[PunRPC]
		private void SetInvincibleRPC(string steamId, float duration)
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId);
			if (!((Object)(object)val == (Object)null) && (bool)AccessTools.Field(typeof(PlayerAvatar), "isDisabled").GetValue(val) && (bool)AccessTools.Field(typeof(PlayerAvatar), "deadSet").GetValue(val))
			{
				val.playerHealth.InvincibleSet(duration);
			}
		}
	}
	internal class UpgradeItem
	{
		internal class Base
		{
			public string name = null;

			public int maxAmount = 1;

			public int maxAmountInShop = 1;

			public float minPrice = 1000f;

			public float maxPrice = 1000f;

			public int maxPurchaseAmount = 0;

			public float priceIncreaseScaling = -1f;

			public Action<PlayerAvatar, int> onStart;

			public Action<PlayerAvatar, int> onUpgrade;

			public Action onVariablesStart;

			public Action onUpdate;

			public Action onLateUpdate;

			public Action onFixedUpdate;

			public List<string> excludeConfigs = new List<string>();
		}

		public bool isRepoLibImported;

		private string sectionName;

		internal Base upgradeBase;

		internal PlayerUpgrade playerUpgrade;

		private Dictionary<string, ConfigEntryBase> configEntries;

		internal Dictionary<string, int> appliedPlayerDictionary;

		internal Dictionary<string, object> variables;

		public bool AddConfig<T>(string key, T defaultValue, string description = "")
		{
			if (configEntries.ContainsKey(key))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			if (upgradeBase.excludeConfigs.Contains(key))
			{
				return false;
			}
			configEntries.Add(key, (ConfigEntryBase)(object)((BaseUnityPlugin)Plugin.instance).Config.Bind<T>(sectionName, key, defaultValue, description));
			return true;
		}

		public bool SetConfig<T>(string key, T value)
		{
			if (!configEntries.TryGetValue(key, out var value2))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value."));
				return false;
			}
			if (value2 is ConfigEntry<T> val)
			{
				val.Value = value;
				return true;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value2.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return false;
		}

		public T GetConfig<T>(string key)
		{
			if (!configEntries.TryGetValue(key, out var value))
			{
				Plugin.instance.logger.LogWarning((object)("A config entry with the key '" + key + "' does not exist. Returning default value."));
				return default(T);
			}
			if (value is ConfigEntry<T> val)
			{
				return val.Value;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for config entry '" + key + "'. Expected: " + value.SettingType.FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return default(T);
		}

		public bool HasVariable(string key)
		{
			object value;
			return variables.TryGetValue(key, out value);
		}

		public bool AddVariable<T>(string key, T value)
		{
			if (HasVariable(key))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' already exists. Duplicates are not allowed."));
				return false;
			}
			variables.Add(key, value);
			return true;
		}

		public bool SetVariable<T>(string key, T value)
		{
			if (!variables.TryGetValue(key, out var value2))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist."));
				return false;
			}
			if (value2 is T)
			{
				variables[key] = value;
				return true;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value2.GetType().FullName + ", but got: " + typeof(T).FullName + "."));
			return false;
		}

		public T GetVariable<T>(string key)
		{
			if (!variables.TryGetValue(key, out var value))
			{
				Plugin.instance.logger.LogWarning((object)("A variable with the key '" + key + "' does not exist. Returning default value."));
				return default(T);
			}
			if (value is T result)
			{
				return result;
			}
			Plugin.instance.logger.LogWarning((object)("Type mismatch for variable '" + key + "'. Expected: " + value.GetType().FullName + ", but got: " + typeof(T).FullName + ". Returning default value."));
			return default(T);
		}

		private void SetupConfig()
		{
			configEntries = new Dictionary<string, ConfigEntryBase>();
			AddConfig("Enabled", defaultValue: true, "Whether the upgrade item can be spawned to the shop.");
			AddConfig("Max Amount", upgradeBase.maxAmount, "The maximum number of times the upgrade item can appear in the truck.");
			AddConfig("Max Amount In Shop", upgradeBase.maxAmountInShop, "The maximum number of times the upgrade item can appear in the shop.");
			AddConfig("Minimum Price", upgradeBase.minPrice, "The minimum cost to purchase the upgrade item.");
			AddConfig("Maximum Price", upgradeBase.maxPrice, "The maximum cost to purchase the upgrade item.");
			AddConfig("Price Increase Scaling", upgradeBase.priceIncreaseScaling, "The scale of the price increase based on the total number of upgrade item purchased.\nSet this value under 0 to use the default scaling.");
			AddConfig("Price Multiplier", isRepoLibImported ? (-1f) : 1f, "The multiplier of the price.\nSet this value under 0 to use the default multiplier.");
			AddConfig("Max Purchase Amount", upgradeBase.maxPurchaseAmount, "The maximum number of times the upgrade item can be purchased before it is no longer available in the shop.\nSet to 0 to disable the limit.");
			AddConfig("Allow Team Upgrades", defaultValue: false, "Whether the upgrade item applies to the entire team instead of just one player.");
			AddConfig("Sync Host Upgrades", defaultValue: false, "Whether the host should sync the item upgrade for the entire team.");
			AddConfig("Starting Amount", 0, "The number of times the upgrade item is applied at the start of the game.");
		}

		internal UpgradeItem(Base upgradeBase)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			sectionName = upgradeBase.name;
			this.upgradeBase = upgradeBase;
			appliedPlayerDictionary = new Dictionary<string, int>();
			variables = new Dictionary<string, object>();
			SetupConfig();
			Item val = ScriptableObject.CreateInstance<Item>();
			val.itemType = (itemType)3;
			val.emojiIcon = (emojiIcon)11;
			val.itemVolume = (itemVolume)6;
			string name = (((Object)val).name = "Modded Item Upgrade Player " + upgradeBase.name);
			val.itemName = upgradeBase.name + " Upgrade";
			val.maxAmount = GetConfig<int>("Max Amount");
			val.maxAmountInShop = GetConfig<int>("Max Amount In Shop");
			val.maxPurchaseAmount = GetConfig<int>("Max Purchase Amount");
			val.maxPurchase = val.maxPurchaseAmount > 0;
			Value val2 = ScriptableObject.CreateInstance<Value>();
			val2.valueMin = GetConfig<float>("Minimum Price");
			val2.valueMax = GetConfig<float>("Maximum Price");
			val.value = val2;
			GameObject val3 = Plugin.instance.assetBundle.LoadAsset<GameObject>(upgradeBase.name);
			((Object)val3).name = name;
			REPOLibItemUpgrade component = val3.GetComponent<REPOLibItemUpgrade>();
			AccessTools.Field(typeof(REPOLibItemUpgrade), "_upgradeId").SetValue(component, upgradeBase.name);
			ItemAttributes component2 = val3.GetComponent<ItemAttributes>();
			component2.item = val;
			Items.RegisterItem(component2);
			playerUpgrade = Upgrades.RegisterUpgrade(upgradeBase.name, val, upgradeBase.onStart, upgradeBase.onUpgrade);
		}

		internal UpgradeItem(PlayerUpgrade playerUpgrade)
		{
			isRepoLibImported = true;
			Item item = playerUpgrade.Item;
			upgradeBase = new Base
			{
				name = playerUpgrade.UpgradeId,
				maxAmount = item.maxAmount,
				maxAmountInShop = item.maxAmountInShop,
				maxPurchaseAmount = item.maxPurchaseAmount,
				minPrice = item.value.valueMin,
				maxPrice = item.value.valueMax
			};
			sectionName = upgradeBase.name + " (REPOLib)";
			appliedPlayerDictionary = new Dictionary<string, int>();
			SetupConfig();
			item.maxAmount = GetConfig<int>("Max Amount");
			item.maxAmountInShop = GetConfig<int>("Max Amount In Shop");
			item.maxPurchaseAmount = GetConfig<int>("Max Purchase Amount");
			item.maxPurchase = item.maxPurchaseAmount > 0;
			item.value.valueMin = GetConfig<float>("Minimum Price");
			item.value.valueMax = GetConfig<float>("Maximum Price");
			this.playerUpgrade = playerUpgrade;
		}
	}
}