Decompiled source of CC APGU v1.0.0

plugins/AllPlayersGetUpgrades.dll

Decompiled 2 weeks 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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("AllPlayersGetUpgrades")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("All Players Get Upgrades")]
[assembly: AssemblyTitle("AllPlayersGetUpgrades")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CacklingCoon.AllPlayersGetUpgrades
{
	[BepInPlugin("REPO_CacklingCoon_AllPlayersGetUpgrades", "CC_APGU", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "REPO_CacklingCoon_AllPlayersGetUpgrades";

		public const string PluginName = "CC_APGU";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Logger;

		internal void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin REPO_CacklingCoon_AllPlayersGetUpgrades is loaded!");
			Dictionary<Type, string> patches = ListMethodsToPatch();
			PatchAll(patches);
		}

		private static void PatchAll(Dictionary<Type, string> patches)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			Harmony val = new Harmony("REPO_CacklingCoon_AllPlayersGetUpgrades");
			foreach (KeyValuePair<Type, string> patch in patches)
			{
				val.Patch((MethodBase)AccessTools.Method(patch.Key, "Upgrade", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), patch.Value, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static Dictionary<Type, string> ListMethodsToPatch()
		{
			Dictionary<Type, string> dictionary = new Dictionary<Type, string>();
			Type typeFromHandle = typeof(ItemUpgradeMapPlayerCount);
			dictionary[typeFromHandle] = "UpgradeMapPlayerCount";
			Type typeFromHandle2 = typeof(ItemUpgradePlayerTumbleLaunch);
			dictionary[typeFromHandle2] = "UpgradePlayerTumbleLaunch";
			Type typeFromHandle3 = typeof(ItemUpgradePlayerEnergy);
			dictionary[typeFromHandle3] = "UpgradePlayerEnergy";
			Type typeFromHandle4 = typeof(ItemUpgradePlayerExtraJump);
			dictionary[typeFromHandle4] = "UpgradePlayerExtraJump";
			Type typeFromHandle5 = typeof(ItemUpgradePlayerGrabRange);
			dictionary[typeFromHandle5] = "UpgradePlayerGrabRange";
			Type typeFromHandle6 = typeof(ItemUpgradePlayerGrabStrength);
			dictionary[typeFromHandle6] = "UpgradePlayerGrabStrength";
			Type typeFromHandle7 = typeof(ItemUpgradePlayerHealth);
			dictionary[typeFromHandle7] = "UpgradePlayerHealth";
			Type typeFromHandle8 = typeof(ItemUpgradePlayerSprintSpeed);
			dictionary[typeFromHandle8] = "UpgradePlayerSprintSpeed";
			return dictionary;
		}

		private static bool UpgradeAll(Func<string, int> upgradeFunction)
		{
			Logger.LogDebug((object)"Upgrade method is being patched.");
			foreach (string item in from player in SemiFunc.PlayerGetAll()
				select SemiFunc.PlayerGetSteamID(player))
			{
				upgradeFunction(item);
			}
			return false;
		}

		private static bool UpgradeMapPlayerCount()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradeMapPlayerCount);
		}

		private static bool UpgradePlayerTumbleLaunch()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerTumbleLaunch);
		}

		private static bool UpgradePlayerEnergy()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerEnergy);
		}

		private static bool UpgradePlayerExtraJump()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerExtraJump);
		}

		private static bool UpgradePlayerGrabRange()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerGrabRange);
		}

		private static bool UpgradePlayerGrabStrength()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerGrabStrength);
		}

		private static bool UpgradePlayerHealth()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerHealth);
		}

		private static bool UpgradePlayerSprintSpeed()
		{
			return UpgradeAll((Func<string, int>)PunManager.instance.UpgradePlayerSprintSpeed);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AllPlayersGetUpgrades";

		public const string PLUGIN_NAME = "All Players Get Upgrades";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}