Decompiled source of AlwaysCountPlayers v1.0.1

AlwaysCountPlayers.dll

Decompiled 8 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.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("AlwaysCountPlayers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AlwaysCountPlayers")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("675bcb71-4621-44a0-9fa8-40213fe56d70")]
[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 AlwaysCountPlayers
{
	[BepInPlugin("Bocon.AlwaysCountPlayers", "God Mode", "1.3.0")]
	public class AlwaysCountPlayers : BaseUnityPlugin
	{
		private const string modGUID = "Bocon.AlwaysCountPlayers";

		private const string modeName = "God Mode";

		private const string modVersion = "1.3.0";

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

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

		private static AlwaysCountPlayers Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Bocon.AlwaysCountPlayers");
			mls.LogInfo((object)"\n            _                                _____                      _     _____   _                                \n     /\\    | |                              / ____|                    | |   |  __ \\ | |                               \n    /  \\   | |__      __ __ _  _   _  ___  | |      ___   _   _  _ __  | |_  | |__) || |  __ _  _   _   ___  _ __  ___ \n   / /\\ \\  | |\\ \\ /\\ / // _` || | | |/ __| | |     / _ \\ | | | || '_ \\ | __| |  ___/ | | / _` || | | | / _ \\| '__|/ __|\n  / ____ \\ | | \\ V  V /| (_| || |_| |\\__ \\ | |____| (_) || |_| || | | || |_  | |     | || (_| || |_| ||  __/| |   \\__ \\\n /_/    \\_\\|_|  \\_/\\_/  \\__,_| \\__, ||___/  \\_____|\\___/  \\__,_||_| |_| \\__| |_|     |_| \\__,_| \\__, | \\___||_|   |___/\n                                __/ |                                                            __/ |                 \n                               |___/                                                            |___/                  ");
			harmony.PatchAll();
		}
	}
}
namespace AlwaysCountPlayers.Patches
{
	internal class AlwaysCountPlayersPatch
	{
		[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;

			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;
							PunManager.instance.UpgradeMapPlayerCount(SemiFunc.PlayerGetSteamID(<player>5__2));
							<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);
		}
	}
}