Decompiled source of UpgraderEveryRound v1.1.2

UpgraderEveryRound.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UpgraderEveryRound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.7")]
[assembly: AssemblyInformationalVersion("1.1.1+a4fd454339ce0574a936cf9060e309254e526555")]
[assembly: AssemblyProduct("UpgraderEveryRound")]
[assembly: AssemblyTitle("UpgraderEveryRound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UpgraderEveryRound
{
	[BepInPlugin("dev.abpor.repo.upgradereveryround", "Upgrader Every Round", "1.1.1")]
	[BepInDependency("nickklmao.menulib", "2.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "dev.abpor.repo.upgradereveryround";

		public const string modName = "Upgrader Every Round";

		public const string modVersion = "1.1.1";

		public static bool isOpen;

		public static ConfigEntry<int> upgradesPerRound;

		public static ConfigEntry<bool> limitedChoices;

		public static ConfigEntry<int> numChoices;

		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("dev.abpor.repo.upgradereveryround");

		private void Awake()
		{
			//IL_002f: 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_0064: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			upgradesPerRound = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrades", "Upgrades Per Round", 1, new ConfigDescription("Number of upgrades per round", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			limitedChoices = ((BaseUnityPlugin)this).Config.Bind<bool>("Upgrades", "Limited random choices", false, new ConfigDescription("Only presents a fixed number of random options", (AcceptableValueBase)null, Array.Empty<object>()));
			numChoices = ((BaseUnityPlugin)this).Config.Bind<int>("Upgrades", "Number of choices", 3, new ConfigDescription("Number of options to choose from per upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			harmony.PatchAll(typeof(PlayerSpawnPatch));
			harmony.PatchAll(typeof(RunManagerChangeLevelPatch));
			harmony.PatchAll(typeof(RunManagerMainMenuPatch));
			harmony.PatchAll(typeof(StatsManagerPatch));
			harmony.PatchAll(typeof(UpgradePlayerEnergyPatch));
			harmony.PatchAll(typeof(UpgradePlayerExtraJumpPatch));
			harmony.PatchAll(typeof(UpgradePlayerGrabRangePatch));
			harmony.PatchAll(typeof(UpgradePlayerGrabStrengthPatch));
			harmony.PatchAll(typeof(UpgradePlayerHealthPatch));
			harmony.PatchAll(typeof(UpgradePlayerSprintSpeedPatch));
			harmony.PatchAll(typeof(UpgradePlayerTumbleLaunchPatch));
			Logger.LogInfo((object)"Plugin UpgraderEveryRound is loaded!");
		}

		public static void ApplyUpgrade(string _steamID, REPOPopupPage popupPage)
		{
			StatsUI.instance.Fetch();
			StatsUI.instance.ShowStats();
			CameraGlitch.Instance.PlayUpgrade();
			int num = ++StatsManager.instance.dictionaryOfDictionaries["playerUpgradesUsed"][_steamID];
			if (GameManager.Multiplayer())
			{
				PhotonView component = ((Component)PunManager.instance).GetComponent<PhotonView>();
				component.RPC("UpdateStatRPC", (RpcTarget)1, new object[3] { "playerUpgradesUsed", _steamID, num });
			}
			int num2 = RunManager.instance.levelsCompleted * upgradesPerRound.Value;
			if (num >= num2)
			{
				isOpen = false;
				popupPage.ClosePage(true);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	[HarmonyPatch("SpawnRPC")]
	public static class PlayerSpawnPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <Prefix>b__0_0()
			{
				Plugin.isOpen = false;
			}
		}

		private static void Prefix(PhotonView ___photonView)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0210: Expected O, but got Unknown
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_0242: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_0274: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02a6: Expected O, but got Unknown
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Expected O, but got Unknown
			//IL_02d8: Expected O, but got Unknown
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Expected O, but got Unknown
			//IL_0307: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0336: Expected O, but got Unknown
			Level[] source = (Level[])(object)new Level[3]
			{
				RunManager.instance.levelMainMenu,
				RunManager.instance.levelLobbyMenu,
				RunManager.instance.levelTutorial
			};
			if (source.Contains(RunManager.instance.levelCurrent))
			{
				return;
			}
			string _steamID = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(SemiFunc.PhotonViewIDPlayerAvatarLocal()));
			int num = RunManager.instance.levelsCompleted * Plugin.upgradesPerRound.Value;
			num++;
			if (StatsManager.instance.dictionaryOfDictionaries["playerUpgradesUsed"][_steamID] >= num || (GameManager.Multiplayer() && !___photonView.IsMine))
			{
				return;
			}
			MenuManager.instance.PageCloseAll();
			REPOPopupPage repoPopupPage = MenuAPI.CreateREPOPopupPage("Choose an upgrade", (PresetSide)0, false, true, 1.5f);
			UnityEvent onPageEnd = repoPopupPage.menuPage.onPageEnd;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					Plugin.isOpen = false;
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			onPageEnd.AddListener((UnityAction)obj);
			int num2 = (Plugin.limitedChoices.Value ? Plugin.numChoices.Value : 7);
			List<int> list = new List<int>(7) { 0, 1, 2, 3, 4, 5, 6 };
			BuilderDelegate val5 = default(BuilderDelegate);
			BuilderDelegate val11 = default(BuilderDelegate);
			BuilderDelegate val7 = default(BuilderDelegate);
			BuilderDelegate val13 = default(BuilderDelegate);
			BuilderDelegate val15 = default(BuilderDelegate);
			BuilderDelegate val9 = default(BuilderDelegate);
			BuilderDelegate val2 = default(BuilderDelegate);
			for (int i = 0; i < num2; i++)
			{
				int index = (Plugin.limitedChoices.Value ? Random.Range(0, list.Count) : 0);
				int num3 = list[index];
				list.RemoveAt(index);
				switch (num3)
				{
				case 0:
				{
					REPOPopupPage obj4 = repoPopupPage;
					BuilderDelegate obj5 = val5;
					if (obj5 == null)
					{
						BuilderDelegate val6 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Stamina", (Action)delegate
							{
								PunManager.instance.UpgradePlayerEnergy(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(46f, 18f));
						};
						BuilderDelegate val4 = val6;
						val5 = val6;
						obj5 = val4;
					}
					obj4.AddElement(obj5);
					break;
				}
				case 1:
				{
					REPOPopupPage obj10 = repoPopupPage;
					BuilderDelegate obj11 = val11;
					if (obj11 == null)
					{
						BuilderDelegate val12 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Extra Jump", (Action)delegate
							{
								PunManager.instance.UpgradePlayerExtraJump(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(186f, 18f));
						};
						BuilderDelegate val4 = val12;
						val11 = val12;
						obj11 = val4;
					}
					obj10.AddElement(obj11);
					break;
				}
				case 2:
				{
					REPOPopupPage obj6 = repoPopupPage;
					BuilderDelegate obj7 = val7;
					if (obj7 == null)
					{
						BuilderDelegate val8 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Range", (Action)delegate
							{
								PunManager.instance.UpgradePlayerGrabRange(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(46f, 60f));
						};
						BuilderDelegate val4 = val8;
						val7 = val8;
						obj7 = val4;
					}
					obj6.AddElement(obj7);
					break;
				}
				case 3:
				{
					REPOPopupPage obj12 = repoPopupPage;
					BuilderDelegate obj13 = val13;
					if (obj13 == null)
					{
						BuilderDelegate val14 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Strength", (Action)delegate
							{
								PunManager.instance.UpgradePlayerGrabStrength(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(186f, 60f));
						};
						BuilderDelegate val4 = val14;
						val13 = val14;
						obj13 = val4;
					}
					obj12.AddElement(obj13);
					break;
				}
				case 4:
				{
					REPOPopupPage obj14 = repoPopupPage;
					BuilderDelegate obj15 = val15;
					if (obj15 == null)
					{
						BuilderDelegate val16 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Health", (Action)delegate
							{
								PunManager.instance.UpgradePlayerHealth(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(46f, 102f));
						};
						BuilderDelegate val4 = val16;
						val15 = val16;
						obj15 = val4;
					}
					obj14.AddElement(obj15);
					break;
				}
				case 5:
				{
					REPOPopupPage obj8 = repoPopupPage;
					BuilderDelegate obj9 = val9;
					if (obj9 == null)
					{
						BuilderDelegate val10 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Sprint speed", (Action)delegate
							{
								PunManager.instance.UpgradePlayerSprintSpeed(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(186f, 102f));
						};
						BuilderDelegate val4 = val10;
						val9 = val10;
						obj9 = val4;
					}
					obj8.AddElement(obj9);
					break;
				}
				case 6:
				{
					REPOPopupPage obj2 = repoPopupPage;
					BuilderDelegate obj3 = val2;
					if (obj3 == null)
					{
						BuilderDelegate val3 = delegate(Transform parent)
						{
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							MenuAPI.CreateREPOButton("Tumble Launch", (Action)delegate
							{
								PunManager.instance.UpgradePlayerTumbleLaunch(_steamID);
								Plugin.ApplyUpgrade(_steamID, repoPopupPage);
							}, parent, new Vector2(46f, 144f));
						};
						BuilderDelegate val4 = val3;
						val2 = val3;
						obj3 = val4;
					}
					obj2.AddElement(obj3);
					break;
				}
				}
			}
			repoPopupPage.OpenPage(false);
			Plugin.isOpen = true;
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	[HarmonyPatch("Start")]
	public static class StatsManagerPatch
	{
		private static void Prefix(StatsManager __instance)
		{
			__instance.dictionaryOfDictionaries.Add("playerUpgradesUsed", new Dictionary<string, int>());
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerEnergy")]
	public static class UpgradePlayerEnergyPatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerEnergyCountRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeStamina[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerExtraJump")]
	public static class UpgradePlayerExtraJumpPatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerExtraJumpRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeExtraJump[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerGrabRange")]
	public static class UpgradePlayerGrabRangePatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerGrabRangeRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeRange[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerGrabStrength")]
	public static class UpgradePlayerGrabStrengthPatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerGrabStrengthRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeStrength[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerHealth")]
	public static class UpgradePlayerHealthPatch
	{
		private static void Postfix(string playerName, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerHealthRPC", (RpcTarget)1, new object[2]
				{
					playerName,
					___statsManager.playerUpgradeHealth[playerName]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerSprintSpeed")]
	public static class UpgradePlayerSprintSpeedPatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerSprintSpeedRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeSpeed[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("UpgradePlayerTumbleLaunch")]
	public static class UpgradePlayerTumbleLaunchPatch
	{
		private static void Postfix(string _steamID, PhotonView ___photonView, StatsManager ___statsManager)
		{
			if (!SemiFunc.IsMasterClient() && GameManager.Multiplayer() && Plugin.isOpen)
			{
				___photonView.RPC("UpgradePlayerTumbleLaunchRPC", (RpcTarget)1, new object[2]
				{
					_steamID,
					___statsManager.playerUpgradeLaunch[_steamID]
				});
			}
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	[HarmonyPatch("ChangeLevel")]
	public static class RunManagerChangeLevelPatch
	{
		private static void Prefix()
		{
			Plugin.isOpen = false;
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	[HarmonyPatch("LeaveToMainMenu")]
	public static class RunManagerMainMenuPatch
	{
		private static void Prefix()
		{
			Plugin.isOpen = false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UpgraderEveryRound";

		public const string PLUGIN_NAME = "UpgraderEveryRound";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}