Decompiled source of StatManager v1.0.0

StatManager.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
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;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StatManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StatManager")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("179e1f3b-e093-4adf-9132-f04de1bfb69d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StatManager
{
	[BepInPlugin("Bocon.StatManager", "Stat Manager", "1.0.0")]
	public class StatManager : BaseUnityPlugin
	{
		private const string modGUID = "Bocon.StatManager";

		private const string modeName = "Stat Manager";

		private const string modVersion = "1.0.0";

		private const string ASCII_LOGO = "\n  _____ _        _     __  __                                   \n  / ____| |      | |   |  \\/  |                                  \n | (___ | |_ __ _| |_  | \\  / | __ _ _ __   __ _  __ _  ___ _ __ \n  \\___ \\| __/ _` | __| | |\\/| |/ _` | '_ \\ / _` |/ _` |/ _ \\ '__|\n  ____) | || (_| | |_  | |  | | (_| | | | | (_| | (_| |  __/ |   \n |_____/ \\__\\__,_|\\__| |_|  |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_|   \n                                                  __/ |          \n                                                 |___/           \n";

		private readonly Harmony harmony = new Harmony("Bocon.StatManager");

		private static StatManager Instance;

		internal ManualLogSource mls;

		internal static ConfigEntry<int> HealthBonus;

		internal static ConfigEntry<int> SpeedBonus;

		internal static ConfigEntry<int> MapCountBonus;

		internal static ConfigEntry<int> EnergyBonus;

		internal static ConfigEntry<int> ExtraJumpBonus;

		internal static ConfigEntry<int> GrabRangeBonus;

		internal static ConfigEntry<int> GrabStrengthBonus;

		internal static ConfigEntry<int> GrabThrowBonus;

		internal static ConfigEntry<int> TumbleLaunchBonus;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Bocon.StatManager");
			mls.LogInfo((object)"\n  _____ _        _     __  __                                   \n  / ____| |      | |   |  \\/  |                                  \n | (___ | |_ __ _| |_  | \\  / | __ _ _ __   __ _  __ _  ___ _ __ \n  \\___ \\| __/ _` | __| | |\\/| |/ _` | '_ \\ / _` |/ _` |/ _ \\ '__|\n  ____) | || (_| | |_  | |  | | (_| | | | | (_| | (_| |  __/ |   \n |_____/ \\__\\__,_|\\__| |_|  |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_|   \n                                                  __/ |          \n                                                 |___/           \n");
			HealthBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Health", 10, "Amount of Health upgrades.");
			SpeedBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Sprint Speed", 5, "Amount of Sprint Speed upgrades.");
			MapCountBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Player Map Count", 1, "Amount of Player Map Count upgrades.");
			EnergyBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Energy", 10, "Amount of Energy upgrades.");
			ExtraJumpBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Extra Jump", 1, "Amount of Extra Jump upgrades.");
			GrabRangeBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Grab Range", 5, "Amount of Grab Range upgrades.");
			GrabStrengthBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Grab Strength", 5, "Amount of Grab Strength upgrades.");
			GrabThrowBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Grab Throw", 5, "Amount of Grab Throw upgrades.");
			TumbleLaunchBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Tumble Launch", 5, "Amount of Tumble Launch upgrades.");
			harmony.PatchAll();
		}
	}
}
namespace StatManager.Patches
{
	internal class Patch
	{
		[HarmonyPatch(typeof(GameDirector), "Start")]
		private class GameDirectorPatch
		{
			private static void Postfix()
			{
				Object.FindObjectOfType<MonoBehaviour>().StartCoroutine(WaitForLevel());
			}
		}

		[HarmonyPatch(typeof(RunManager), "ResetProgress")]
		private class RunManagerResetPatch
		{
			private static void Postfix()
			{
				hasAppliedUpgrade = false;
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForLevel>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private List<PlayerAvatar>.Enumerator <>s__1;

			private PlayerAvatar <player>5__2;

			private int <i>5__3;

			private int <i>5__4;

			private int <i>5__5;

			private int <i>5__6;

			private int <i>5__7;

			private int <i>5__8;

			private int <i>5__9;

			private int <i>5__10;

			private int <i>5__11;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = default(List<PlayerAvatar>.Enumerator);
				<player>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!SemiFunc.LevelGenDone())
				{
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				}
				if (!hasAppliedUpgrade && SemiFunc.RunIsLevel())
				{
					<>s__1 = SemiFunc.PlayerGetAll().GetEnumerator();
					try
					{
						while (<>s__1.MoveNext())
						{
							<player>5__2 = <>s__1.Current;
							<i>5__3 = 0;
							while (<i>5__3 < StatManager.HealthBonus.Value)
							{
								PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__3++;
							}
							<i>5__4 = 0;
							while (<i>5__4 < StatManager.SpeedBonus.Value)
							{
								PunManager.instance.UpgradePlayerSprintSpeed(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__4++;
							}
							<i>5__5 = 0;
							while (<i>5__5 < StatManager.MapCountBonus.Value)
							{
								PunManager.instance.UpgradeMapPlayerCount(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__5++;
							}
							<i>5__6 = 0;
							while (<i>5__6 < StatManager.EnergyBonus.Value)
							{
								PunManager.instance.UpgradePlayerEnergy(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__6++;
							}
							<i>5__7 = 0;
							while (<i>5__7 < StatManager.ExtraJumpBonus.Value)
							{
								PunManager.instance.UpgradePlayerExtraJump(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__7++;
							}
							<i>5__8 = 0;
							while (<i>5__8 < StatManager.GrabRangeBonus.Value)
							{
								PunManager.instance.UpgradePlayerGrabRange(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__8++;
							}
							<i>5__9 = 0;
							while (<i>5__9 < StatManager.GrabStrengthBonus.Value)
							{
								PunManager.instance.UpgradePlayerGrabStrength(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__9++;
							}
							<i>5__10 = 0;
							while (<i>5__10 < StatManager.GrabThrowBonus.Value)
							{
								PunManager.instance.UpgradePlayerThrowStrength(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__10++;
							}
							<i>5__11 = 0;
							while (<i>5__11 < StatManager.TumbleLaunchBonus.Value)
							{
								PunManager.instance.UpgradePlayerTumbleLaunch(SemiFunc.PlayerGetSteamID(<player>5__2));
								<i>5__11++;
							}
							<player>5__2 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__1).Dispose();
					}
					<>s__1 = default(List<PlayerAvatar>.Enumerator);
					hasAppliedUpgrade = 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();
			}
		}

		private static bool hasAppliedUpgrade;

		[IteratorStateMachine(typeof(<WaitForLevel>d__2))]
		private static IEnumerator WaitForLevel()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForLevel>d__2(0);
		}
	}
}