Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Overstaffed v0.1.0
Overstaffed.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Overstaffed.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Overstaffed")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+7ddcc882efe1643a34ace9adbfcc2db68f41cf1a")] [assembly: AssemblyProduct("Overstaffed")] [assembly: AssemblyTitle("Overstaffed")] [assembly: AssemblyVersion("0.1.0.0")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Overstaffed { [BepInPlugin("darkharasho.Overstaffed", "Overstaffed", "0.1.0")] public class Plugin : BaseUnityPlugin { internal const int MaxAllowedPlayers = 20; internal const int MinAllowedPlayers = 1; internal const int DefaultPlayers = 10; internal static ManualLogSource Log; internal static ConfigEntry<int> ConfigMaxPlayers; 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_009f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, new ConfigDescription("The maximum number of players allowed in a server.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); Log.LogInfo((object)string.Format("Overstaffed v{0} loading — MaxPlayers={1}", "0.1.0", ConfigMaxPlayers.Value)); Harmony val = new Harmony("darkharasho.Overstaffed"); TryPatch(val, typeof(GameManagerAwakePatch)); TryPatch(val, typeof(GameManagerSetMaxPlayersPatch)); TryPatch(val, typeof(NetworkConnectOnConnectedToMasterPatch)); Log.LogInfo((object)"Overstaffed loaded."); } private static void TryPatch(Harmony harmony, Type patchType) { try { harmony.CreateClassProcessor(patchType).Patch(); } catch (Exception ex) { Log.LogWarning((object)("[Overstaffed] Failed to apply " + patchType.Name + ": " + ex.GetType().Name + ": " + ex.Message)); } } } public static class PluginInfo { public const string PLUGIN_GUID = "darkharasho.Overstaffed"; public const string PLUGIN_NAME = "Overstaffed"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace Overstaffed.Patches { [HarmonyPatch(typeof(GameManager), "Awake")] internal static class GameManagerAwakePatch { private static void Postfix(GameManager __instance) { int value = Plugin.ConfigMaxPlayers.Value; int maxPlayersPhoton = __instance.maxPlayersPhoton; int maxPlayers = __instance.maxPlayers; if (value > __instance.maxPlayersPhoton) { __instance.maxPlayersPhoton = value; } __instance.maxPlayers = value; Plugin.Log.LogInfo((object)($"[GameManager.Awake] maxPlayers {maxPlayers} -> {__instance.maxPlayers}, " + $"maxPlayersPhoton {maxPlayersPhoton} -> {__instance.maxPlayersPhoton}")); } } [HarmonyPatch(typeof(GameManager), "SetMaxPlayers")] internal static class GameManagerSetMaxPlayersPatch { private static void Prefix(GameManager __instance, ref int _target) { if (_target > __instance.maxPlayersPhoton) { __instance.maxPlayersPhoton = _target; } } } [HarmonyPatch(typeof(NetworkConnect), "OnConnectedToMaster")] internal static class NetworkConnectOnConnectedToMasterPatch { [CompilerGenerated] private sealed class <Transpiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private MethodInfo <helper>5__2; private int <replaced>5__3; private IEnumerator<CodeInstruction> <>7__wrap3; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Transpiler>d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } <helper>5__2 = null; <>7__wrap3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <helper>5__2 = AccessTools.Method(typeof(NetworkConnectOnConnectedToMasterPatch), "GetExpectedMaxPlayers", (Type[])null, (Type[])null); <replaced>5__3 = 0; <>7__wrap3 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; } if (<>7__wrap3.MoveNext()) { CodeInstruction current = <>7__wrap3.Current; if (current.opcode == OpCodes.Ldc_I4_6 && <replaced>5__3 == 0) { <replaced>5__3++; <>2__current = new CodeInstruction(OpCodes.Call, (object)<helper>5__2); <>1__state = 1; return true; } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap3 = null; if (<replaced>5__3 == 0) { Plugin.Log.LogWarning((object)"[NetworkConnect.OnConnectedToMaster] transpiler did NOT find ldc.i4.6 — public matchmaking expectedMaxPlayers will stay at vanilla 6. Private/friends lobbies still respect MaxPlayers via the GameManager patches."); } else { Plugin.Log.LogInfo((object)"[NetworkConnect.OnConnectedToMaster] transpiler replaced ldc.i4.6 with GetExpectedMaxPlayers()"); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap3 != null) { <>7__wrap3.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <Transpiler>d__1 <Transpiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Transpiler>d__ = this; } else { <Transpiler>d__ = new <Transpiler>d__1(0); } <Transpiler>d__.instructions = <>3__instructions; return <Transpiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } public static int GetExpectedMaxPlayers() { int value = Plugin.ConfigMaxPlayers.Value; if (value < 1) { return 1; } if (value > 255) { return 255; } return value; } [IteratorStateMachine(typeof(<Transpiler>d__1))] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Transpiler>d__1(-2) { <>3__instructions = instructions }; } } }