Decompiled source of LateJoinSharedUpgradesByNastyPablo v1.1.2

LateJoinAbilityUpgrade.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LateJoinSharedUpgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LateJoinSharedUpgrades")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("094ae07c-aa38-4a28-8336-7af75e3b4ff3")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace LateJoinShared;

[BepInPlugin("NastyPabloDLL.LateJoinSharedUpgrades", "LateJoinSharedUpgrades", "1.1.0")]
[BepInProcess("REPO.exe")]
public class LateJoinSharedUpgrades : BaseUnityPlugin
{
	[HarmonyPatch(typeof(LevelGenerator), "PlayerSpawn")]
	private class UpdatePlayersUpgradesAtSpawn
	{
		[HarmonyPostfix]
		private static void UpdateUpgradesForEveryone()
		{
			if ((!healthUpgradeSync.Value && !energyUpgradeSync.Value && !sprintSpeedSync.Value && !tumbleLaunchSync.Value && !extraJumpSync.Value && !grabRangeSync.Value && !grabStrengthSync.Value && !mapPlayerCountSync.Value) || (!SemiFunc.RunIsLevel() && !SemiFunc.RunIsLobby()) || !SemiFunc.IsMasterClient())
			{
				return;
			}
			HealthUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Health");
			EnergyUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Energy");
			SprintSpeedUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Sprint Speed");
			TumbleLaunchUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Tumble Launch");
			ExtraJumpUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Extra Jump");
			GrabRangeUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Grab Range");
			GrabStrengthUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Player Grab Strength");
			MapPlayerCountUpgrade = GeneralExtensions.GetValueSafe<string, int>(StatsManager.instance.itemsUpgradesPurchased, "Item Upgrade Map Player Count");
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				steamID = SemiFunc.PlayerGetSteamID(item);
				if (healthUpgradeSync.Value)
				{
					for (int i = StatsManager.instance.playerUpgradeHealth[steamID]; i < HealthUpgrade; i++)
					{
						PunManager.instance.UpgradePlayerHealth(steamID);
					}
				}
				if (energyUpgradeSync.Value)
				{
					for (int j = StatsManager.instance.playerUpgradeStamina[steamID]; j < EnergyUpgrade; j++)
					{
						PunManager.instance.UpgradePlayerEnergy(steamID);
					}
				}
				if (sprintSpeedSync.Value)
				{
					for (int k = StatsManager.instance.playerUpgradeSpeed[steamID]; k < SprintSpeedUpgrade; k++)
					{
						PunManager.instance.UpgradePlayerSprintSpeed(steamID);
					}
				}
				if (tumbleLaunchSync.Value)
				{
					for (int l = StatsManager.instance.playerUpgradeLaunch[steamID]; l < TumbleLaunchUpgrade; l++)
					{
						PunManager.instance.UpgradePlayerTumbleLaunch(steamID);
					}
				}
				if (extraJumpSync.Value)
				{
					for (int m = StatsManager.instance.playerUpgradeExtraJump[steamID]; m < ExtraJumpUpgrade; m++)
					{
						PunManager.instance.UpgradePlayerExtraJump(steamID);
					}
				}
				if (grabRangeSync.Value)
				{
					for (int n = StatsManager.instance.playerUpgradeRange[steamID]; n < GrabRangeUpgrade; n++)
					{
						PunManager.instance.UpgradePlayerGrabRange(steamID);
					}
				}
				if (grabStrengthSync.Value)
				{
					for (int num = StatsManager.instance.playerUpgradeStrength[steamID]; num < GrabStrengthUpgrade; num++)
					{
						PunManager.instance.UpgradePlayerGrabStrength(steamID);
					}
				}
				if (mapPlayerCountSync.Value)
				{
					for (int num2 = StatsManager.instance.playerUpgradeMapPlayerCount[steamID]; num2 < MapPlayerCountUpgrade; num2++)
					{
						PunManager.instance.UpgradeMapPlayerCount(steamID);
					}
				}
			}
		}
	}

	private const string modGUID = "NastyPabloDLL.LateJoinSharedUpgrades";

	private const string modName = "LateJoinSharedUpgrades";

	private const string modVersion = "1.1.0";

	private readonly Harmony harmony = new Harmony("NastyPabloDLL.LateJoinSharedUpgrades");

	private static readonly ManualLogSource logger = Logger.CreateLogSource("Late Join Shared Upgrades");

	private static int HealthUpgrade = 0;

	private static int EnergyUpgrade = 0;

	private static int SprintSpeedUpgrade = 0;

	private static int TumbleLaunchUpgrade = 0;

	private static int ExtraJumpUpgrade = 0;

	private static int GrabRangeUpgrade = 0;

	private static int GrabStrengthUpgrade = 0;

	private static int MapPlayerCountUpgrade = 0;

	private static ConfigEntry<bool> healthUpgradeSync;

	private static ConfigEntry<bool> energyUpgradeSync;

	private static ConfigEntry<bool> sprintSpeedSync;

	private static ConfigEntry<bool> tumbleLaunchSync;

	private static ConfigEntry<bool> extraJumpSync;

	private static ConfigEntry<bool> grabRangeSync;

	private static ConfigEntry<bool> grabStrengthSync;

	private static ConfigEntry<bool> mapPlayerCountSync;

	private static string steamID;

	private void Awake()
	{
		ConfigurationInit(((BaseUnityPlugin)this).Config);
		harmony.PatchAll();
	}

	private static void ConfigurationInit(ConfigFile configFile)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Expected O, but got Unknown
		healthUpgradeSync = configFile.Bind<bool>("General", "Health Upgrade Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		energyUpgradeSync = configFile.Bind<bool>("General", "Energy Upgrade Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		sprintSpeedSync = configFile.Bind<bool>("General", "Sprint Speed Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		tumbleLaunchSync = configFile.Bind<bool>("General", "Tumble Launch Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		extraJumpSync = configFile.Bind<bool>("General", "Extra Jump Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		grabRangeSync = configFile.Bind<bool>("General", "Grab Range Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		grabStrengthSync = configFile.Bind<bool>("General", "Grab Strength Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
		mapPlayerCountSync = configFile.Bind<bool>("General", "Map Player Count Sync", true, new ConfigDescription("Enable", (AcceptableValueBase)null, Array.Empty<object>()));
	}
}