Decompiled source of SteamBypass v1.0.0

plugins/SteamBypass-1.0.0.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BOMBANANA.Library.Reflection;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using Steamworks;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SteamBypass-1.0.0")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SteamBypass-1.0.0")]
[assembly: AssemblyTitle("SteamBypass-1.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SteamBypass
{
	[BepInPlugin("steambypass", "Steam Bypass", "1.0.0")]
	public sealed class SteamBypassMod : BasePlugin
	{
		public static ManualLogSource LogSource;

		internal static bool Verbose;

		public override void Load()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			LogSource = ((BasePlugin)this).Log;
			Verbose = Environment.GetEnvironmentVariable("STEAMBYPASS_VERBOSE") == "1";
			ManualLogSource logSource = LogSource;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: loading... verbose=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(Verbose);
			}
			logSource.LogInfo(val);
			Harmony harmony = new Harmony("steambypass");
			int num = 0;
			num += PatchMethod(harmony, "SteamManager", "Awake", 0, "AwakePrefix", "skip SteamClient.Init");
			num += PatchMethod(harmony, "SteamManager", "Update", 0, "UpdatePrefix", "skip RunCallbacks");
			num += PatchMethod(harmony, "SteamManager", "OnApplicationQuit", 0, "OnApplicationQuitPrefix", "skip SteamClient.Cleanup");
			num += PatchMethod(harmony, "GameNetworkManager", "IsSteamClientReady", 0, "IsSteamClientReadyPrefix", "always true");
			num += PatchMethod(harmony, "GameNetworkManager", "IsSteamClientReadyAndOnline", 0, "IsSteamClientReadyAndOnlinePrefix", "always true");
			num += PatchMethod(harmony, "GameNetworkManager", "TryGetLocalSteamId", 1, "TryGetLocalSteamIdPrefix", "force fake local SteamId");
			num += PatchMethod(harmony, "GameNetworkManager", "GetLocalSteamName", 0, "GetLocalSteamNamePrefix", "force fake local Steam name");
			num += PatchMethod(harmony, "LobbyHandler", "CanLobbyBeStarted", 0, "CanLobbyBeStartedPrefix", "always true (host-authoritative)");
			num += PatchMethod(harmony, "LobbyHandler", "CheckPlayersState", 1, "CheckPlayersStatePrefix", "always true (mission-start gate)");
			num += PatchMethod(harmony, "LobbySubUI", "IsLobbyReadyForSetup", 1, "IsLobbyReadyForSetupPrefix", "always true (client UI gate)");
			num += PatchMethod(harmony, "GameNetworkManager", "IsRelayNetworkReady", 0, "IsRelayNetworkReadyPrefix", "true when Steam faked (host/lobby-entry relay gate)");
			num += PatchMethod(harmony, "GameNetworkManager", "IsRelayNetworkUnavailable", 0, "IsRelayNetworkUnavailablePrefix", "false when Steam faked (host/lobby-entry relay gate)");
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "IsRelayNetworkReady", 0, "IsRelayNetworkReadyPostfix", "DEBUG: IsRelayNetworkReady result");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "IsRelayNetworkUnavailable", 0, "IsRelayNetworkUnavailablePostfix", "DEBUG: IsRelayNetworkUnavailable result");
			}
			num += PatchMethod(harmony, "GameNetworkManager", "CleanupFailedHostStartup", 0, "CleanupFailedHostStartupPrefix", "DEBUG: host startup failed marker");
			num += PatchMethod(harmony, "GameNetworkManager", "LogBugOnce", 2, "LogBugOncePrefix", "DEBUG: network error reporter");
			if (Verbose)
			{
				num += PatchMethod(harmony, "MenuSubUI", "Button_HostAsync", 0, "ButtonHostAsyncPrefix", "DEBUG: Play clicked");
				num += PatchMethod(harmony, "GameNetworkManager", "IsSteamClientReadyAndOnline", 0, "IsSteamClientReadyAndOnlinePostfix", "DEBUG: gate result");
			}
			num += PatchMethod(harmony, "GameManager", "HostLobby", 0, "HostLobbyForcePrefix", "DEBUG: force Host() (bypass inlined CanStartHost gate)");
			num += PatchMethod(harmony, "MenuLoadingUI", "ShowLoadingOverlay", 1, "MenuLoadingShowOverlayPostfix", "hide endless loading when offline host live");
			num += PatchMethod(harmony, "GameNetworkManager", "get_CanStartHost", 0, "CanStartHostPrefix", "force true (host gate — property getter, inlined/unused)");
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "IsAlreadyInLobby", 1, "IsAlreadyInLobbyPrefix", "DEBUG: IsAlreadyInLobby gate");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "PrepareForHostAsync", 0, "PrepareForHostAsyncPrefix", "DEBUG: PrepareForHostAsync entered");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "NetworkManager", "StartHost", 0, "StartHostPrefix", "DEBUG: StartHost entered");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "NetworkManager", "StartHost", 0, "StartHostPostfix", "DEBUG: StartHost result");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "NetworkManager", "StartServer", 0, "StartServerPostfix", "DEBUG: StartServer result + transport used");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "UnityTransport", "StartServer", 0, "UnityTransportStartServerPrefix", "NETCODE: UTP.StartServer entered + state DIAG");
				num += PatchMethodPostfix(harmony, "UnityTransport", "StartServer", 0, "UnityTransportStartServerPostfix", "NETCODE: UTP.StartServer result");
				num += PatchMethodFinalizer(harmony, "UnityTransport", "StartServer", 0, "UnityTransportStartServerFinalizer", "NETCODE: UTP.StartServer exception");
				num += PatchMethodPostfix(harmony, "NetworkManager", "CanStart", 1, "CanStartPostfix", "NETCODE: CanStart gate result");
				num += PatchMethod(harmony, "NetworkManager", "Initialize", 1, "InitializePrefix", "NETCODE: Initialize(server) entered + transport");
			}
			num += PatchMethodPostfix(harmony, "NetworkManager", "HostServerInitialize", 0, "HostServerInitializePostfix", "NETCODE: HostServerInitialize done (assign PlayerPrefab)");
			num += PatchMethodPostfix(harmony, "NetworkManager", "Initialize", 1, "InitializePostfix", "NETCODE: Initialize(server) postfix (assign PlayerPrefab)");
			num += PatchMethod(harmony, "NetworkManager", "Shutdown", 0, "ShutdownPrefix", "DIAG21: log every NGO shutdown + stack");
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "Host", 0, "HostPrefix", "DEBUG: Host entered");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "Host", 0, "HostPostfix", "DEBUG: Host finished");
			}
			if (Verbose)
			{
				num += PatchMethod(harmony, "GameNetworkManager", "EnsureRelayNetworkAccessUsableAsync", 1, "EnsureRelayNetworkAccessUsableAsyncPrefix", "DEBUG: relay gate entered");
			}
			num += PatchMethod(harmony, "LobbySubUI", "ApplyLocalPlayerControls", 0, "ApplyLocalPlayerControlsPostfix", "force startButton enabled");
			num += PatchMethod(harmony, "GameNetworkManager", "ConfigureLobbyMetadata", 1, "ConfigureLobbyMetadataPrefix", "no-op (offline local host, no Steam lobby)");
			num += PatchMethod(harmony, "LobbyHandler", "Create", 0, "LobbyHandlerCreatePrefix", "DEBUG: LobbyHandler.Create entered (full chain, builds lobby UI)");
			num += PatchMethod(harmony, "GameNetworkManager", "JoinHostPlayer", 0, "JoinHostPlayerPrefix", "no-op (offline local host, no Steam lobby)");
			num += PatchMethodPostfix(harmony, "LobbySubUI", "ApplyHostOnlyButtonStates", 0, "ApplyHostOnlyButtonStatesPostfix", "LEVELS: raise demo level cap to all 7");
			num += PatchMethod(harmony, "LobbyHandler", "SetSelectedLevelServerRpc", 2, "SetSelectedLevelServerRpcPrefix", "LEVELS: widen level index range 0..6");
			LogSource.LogInfo((object)((num == 0) ? "SteamBypass: no hooks patched" : $"SteamBypass: {num} hooks patched"));
			try
			{
				SteamPatches.EnsurePlayerPrefabAssigned();
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = LogSource;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(49, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("SteamBypass: EnsurePlayerPrefabAssigned() threw: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logSource2.LogWarning(val2);
			}
		}

		private static int PatchMethod(Harmony harmony, string typeName, string methodName, int paramCount, string prefixName, string description)
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve(typeName);
				if (type == null)
				{
					ManualLogSource logSource = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: type '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found — ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped.");
					}
					logSource.LogWarning(val);
					return 0;
				}
				MethodInfo methodInfo = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == methodName && m.GetParameters().Length == paramCount);
				if (methodInfo == null)
				{
					ManualLogSource logSource2 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(paramCount);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" params) not found — skipped.");
					}
					logSource2.LogWarning(val);
					return 0;
				}
				MethodInfo method = typeof(SteamPatches).GetMethod(prefixName, BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					ManualLogSource logSource3 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: prefix method '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prefixName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
					}
					logSource3.LogWarning(val);
					return 0;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				ManualLogSource logSource4 = LogSource;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("SteamBypass: patched ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(description);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
				}
				logSource4.LogInfo(val2);
				return 1;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource5 = LogSource;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(32, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("SteamBypass: failed to patch ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(methodName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logSource5.LogError(val3);
				return 0;
			}
		}

		private static int PatchMethodPostfix(Harmony harmony, string typeName, string methodName, int paramCount, string postfixName, string description)
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve(typeName);
				if (type == null)
				{
					ManualLogSource logSource = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: type '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found — ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" postfix skipped.");
					}
					logSource.LogWarning(val);
					return 0;
				}
				MethodInfo methodInfo = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == methodName && m.GetParameters().Length == paramCount);
				if (methodInfo == null)
				{
					ManualLogSource logSource2 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(paramCount);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" params) not found — postfix skipped.");
					}
					logSource2.LogWarning(val);
					return 0;
				}
				MethodInfo method = typeof(SteamPatches).GetMethod(postfixName, BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					ManualLogSource logSource3 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: postfix method '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(postfixName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
					}
					logSource3.LogWarning(val);
					return 0;
				}
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				ManualLogSource logSource4 = LogSource;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("SteamBypass: patched ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" postfix (");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(description);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
				}
				logSource4.LogInfo(val2);
				return 1;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource5 = LogSource;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(40, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("SteamBypass: failed to patch ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(methodName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" postfix: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logSource5.LogError(val3);
				return 0;
			}
		}

		private static int PatchMethodFinalizer(Harmony harmony, string typeName, string methodName, int paramCount, string finalizerName, string description)
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve(typeName);
				if (type == null)
				{
					ManualLogSource logSource = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: type '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found — ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" finalizer skipped.");
					}
					logSource.LogWarning(val);
					return 0;
				}
				MethodInfo methodInfo = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == methodName && m.GetParameters().Length == paramCount);
				if (methodInfo == null)
				{
					ManualLogSource logSource2 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(paramCount);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" params) not found — finalizer skipped.");
					}
					logSource2.LogWarning(val);
					return 0;
				}
				MethodInfo method = typeof(SteamPatches).GetMethod(finalizerName, BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					ManualLogSource logSource3 = LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(43, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: finalizer method '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(finalizerName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
					}
					logSource3.LogWarning(val);
					return 0;
				}
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null);
				ManualLogSource logSource4 = LogSource;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("SteamBypass: patched ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodInfo.Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" finalizer (");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(description);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
				}
				logSource4.LogInfo(val2);
				return 1;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource5 = LogSource;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(42, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("SteamBypass: failed to patch ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(typeName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(methodName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" finalizer: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logSource5.LogError(val3);
				return 0;
			}
		}
	}
	public static class SteamPatches
	{
		internal static bool _steamSuccessfullyInitialized;

		internal static object _installedTransport;

		internal const ulong FakeSteamId = 76561197960265728uL;

		private static bool _playerPrefabRetryStarted = false;

		private static int _playerPrefabRetryAttemptsLeft = 0;

		private static int _playerPrefabRetryFrameCounter = 0;

		private const int PlayerPrefabRetryFramesBetweenAttempts = 15;

		private static readonly List<(int framesLeft, Action act)> _mainThreadDelayed = new List<(int, Action)>();

		private static bool _uiDrivenThisSession = false;

		private static Type _nmTypeCache;

		private static PropertyInfo _nmSingletonCache;

		private static PropertyInfo _nmListeningCache;

		internal const int MaxLevelIndex = 6;

		public static bool AwakePrefix(object __instance)
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			try
			{
				Type type = __instance.GetType();
				uint num = 0u;
				PropertyInfo property = type.GetProperty("AppId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null)
				{
					num = (uint)property.GetValue(__instance);
				}
				if (InitAndSetup(480u))
				{
					SteamBypassMod.LogSource.LogInfo((object)"SteamBypass: SteamClient.Init(480/Spacewar) succeeded — using real Steam relay.");
					return false;
				}
				if (num != 0 && InitAndSetup(num))
				{
					SteamBypassMod.LogSource.LogInfo((object)"SteamBypass: SteamClient.Init(real appid) succeeded — using real Steam.");
					return false;
				}
				_steamSuccessfullyInitialized = false;
				SetField(type, __instance, "IsSteamReady", true);
				SetField(type, __instance, "hasSteamInitialized", true);
				SetField(type, __instance, "restartThroughSteamPending", false);
				SetField(type, __instance, "restartNotificationShown", true);
				SetField(type, __instance, "steamInitFailedNotificationPending", false);
				SetField(type, __instance, "steamInitFailedNotificationShown", true);
				SetStaticField(type, "_Steam_k__BackingField", __instance);
				FireOnSteamInitialize(type, __instance);
				SteamBypassMod.LogSource.LogInfo((object)"SteamBypass: SteamClient.Init failed (Spacewar + real) — faking ready state.");
				return false;
				bool InitAndSetup(uint id)
				{
					//IL_007b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0081: Expected O, but got Unknown
					try
					{
						SteamClient.Init(id, false);
						_steamSuccessfullyInitialized = true;
						SetField(type, __instance, "IsSteamReady", true);
						SetField(type, __instance, "hasSteamInitialized", true);
						SetStaticField(type, "_Steam_k__BackingField", __instance);
						FireOnSteamInitialize(type, __instance);
						return true;
					}
					catch (Exception ex2)
					{
						ManualLogSource logSource2 = SteamBypassMod.LogSource;
						bool flag2 = default(bool);
						BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(42, 3, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("SteamBypass: SteamClient.Init(");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<uint>(id);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") failed: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.GetType().Name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
						}
						logSource2.LogWarning(val2);
						return false;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: AwakePrefix error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSource.LogError(val);
				return true;
			}
		}

		public static bool UpdatePrefix()
		{
			if (!_steamSuccessfullyInitialized && _mainThreadDelayed.Count == 0 && !_playerPrefabRetryStarted)
			{
				return false;
			}
			try
			{
				ProcessMainThreadScheduledActions();
			}
			catch
			{
			}
			return _steamSuccessfullyInitialized;
		}

		public static bool OnApplicationQuitPrefix()
		{
			return _steamSuccessfullyInitialized;
		}

		public static bool IsSteamClientReadyPrefix(ref bool __result)
		{
			if (_steamSuccessfullyInitialized)
			{
				return true;
			}
			__result = true;
			return false;
		}

		public static bool IsSteamClientReadyAndOnlinePrefix(ref bool __result)
		{
			if (_steamSuccessfullyInitialized)
			{
				return true;
			}
			__result = true;
			return false;
		}

		public static bool EnsurePlayerPrefabAssigned()
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve("NetworkManager");
				if (type == null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] NetworkManager type not found yet.");
					return false;
				}
				object obj = type.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
				if (obj == null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] NetworkManager.Singleton is null (not initialized yet).");
					return false;
				}
				object obj2 = obj.GetType().GetProperty("NetworkConfig", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
				if (obj2 == null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] NetworkConfig is null.");
					return false;
				}
				PropertyInfo property = obj2.GetType().GetProperty("PlayerPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property == null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] PlayerPrefab property not found.");
					return false;
				}
				if (property.GetValue(obj2) != null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] PlayerPrefab already set.");
					return true;
				}
				SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] PlayerPrefab is NULL — attempting to create fallback.");
				Type type2 = Type.GetType("UnityEngine.GameObject, UnityEngine.CoreModule") ?? Type.GetType("UnityEngine.GameObject");
				object obj3 = null;
				if (type2 != null)
				{
					try
					{
						obj3 = Activator.CreateInstance(type2, "PlayerPrefab-Auto");
						MethodInfo methodInfo = type2.GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "AddComponent" && m.IsGenericMethodDefinition);
						Type type3 = TypeResolver.Default.Resolve("NetworkObject");
						if (methodInfo != null && type3 != null && obj3 != null)
						{
							methodInfo.MakeGenericMethod(type3).Invoke(obj3, null);
						}
					}
					catch (Exception ex)
					{
						ManualLogSource logSource = SteamBypassMod.LogSource;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(66, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] fallback GameObject creation failed: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						logSource.LogWarning(val);
					}
				}
				if (obj3 != null)
				{
					try
					{
						property.SetValue(obj2, obj3);
						SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] PlayerPrefab fallback assigned to NetworkConfig.");
						return true;
					}
					catch (Exception ex2)
					{
						ManualLogSource logSource2 = SteamBypassMod.LogSource;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] failed to assign PlayerPrefab: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
						}
						logSource2.LogWarning(val);
					}
				}
				else
				{
					SteamBypassMod.LogSource.LogWarning((object)"[EnsurePlayerPrefabAssigned] Could not create fallback GameObject.");
				}
				return false;
			}
			catch (Exception ex3)
			{
				ManualLogSource logSource3 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[EnsurePlayerPrefabAssigned] error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex3);
				}
				logSource3.LogError(val2);
				return false;
			}
		}

		private static void StartPlayerPrefabRetryBackground()
		{
			if (!_playerPrefabRetryStarted)
			{
				_playerPrefabRetryStarted = true;
				_playerPrefabRetryAttemptsLeft = 20;
				_playerPrefabRetryFrameCounter = 0;
				SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] PlayerPrefab retry scheduled on main thread.");
			}
		}

		internal static void ScheduleOnMainThread(int framesDelay, Action act)
		{
			if (act == null)
			{
				return;
			}
			lock (_mainThreadDelayed)
			{
				_mainThreadDelayed.Add((framesDelay, act));
			}
		}

		internal static string ReadCount(object coll)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			if (coll == null)
			{
				return "NULL";
			}
			try
			{
				if (coll is IEnumerable enumerable && !(coll is string))
				{
					int num = 0;
					foreach (object item in enumerable)
					{
						_ = item;
						num++;
						if (num > 64)
						{
							break;
						}
					}
					return num.ToString();
				}
				Type type = coll.GetType();
				PropertyInfo property = type.GetProperty("Count", BindingFlags.Instance | BindingFlags.Public);
				if (property != null)
				{
					return property.GetValue(coll)?.ToString() ?? "?";
				}
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIAG21] ReadCount: no count member on ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; props=[");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(string.Join(",", (from pp in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
						select pp.Name).Take(12)));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] methods=[");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(string.Join(",", from mm in type.GetMethods(BindingFlags.Instance | BindingFlags.Public)
						where mm.Name.ToLower().Contains("count")
						select mm.Name));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
				}
				logSource.LogWarning(val);
				return "?";
			}
			catch (Exception ex)
			{
				return "err:" + ex.Message;
			}
		}

		internal static void DumpSessionState(string tag)
		{
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				string text = "?";
				string text2 = "?";
				string text3 = "?";
				string text4 = "?";
				string text5 = "?";
				Type type = TypeResolver.Default.Resolve("NetworkManager");
				object obj = type?.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
				if (obj != null)
				{
					flag = ReadBool(type, "IsListening", obj);
					text = flag.ToString();
					flag = ReadBool(type, "IsServer", obj);
					text2 = flag.ToString();
				}
				object lobbyHandler = GetLobbyHandler();
				if (lobbyHandler == null)
				{
					text3 = "NULL";
				}
				else
				{
					text3 = (((Object)((lobbyHandler is Object) ? lobbyHandler : null) == (Object)null) ? "DESTROYED" : "alive");
					try
					{
						text4 = ReadCount(lobbyHandler.GetType().GetField("Players", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(lobbyHandler));
					}
					catch (Exception ex)
					{
						text4 = "err:" + ex.Message;
					}
				}
				try
				{
					Type type2 = TypeResolver.Default.Resolve("GameNetworkManager");
					object obj2 = ResolveStaticMember(type2, "Singleton");
					object obj3 = (type2?.GetField("PlayerStates", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(obj2);
					if (obj3 != null)
					{
						text5 = ReadCount(obj3);
					}
				}
				catch
				{
				}
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(85, 6, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIAG21] session@");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(tag);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": IsListening=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" IsServer=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Handler=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text3);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Players.Count=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text4);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" PlayerStates.Count=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text5);
				}
				logSource.LogInfo(val);
			}
			catch (Exception ex2)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(24, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DIAG21] dump failed @");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(tag);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
				}
				logSource2.LogWarning(val2);
			}
		}

		private static bool ReadBool(Type t, string name, object inst)
		{
			try
			{
				PropertyInfo property = t.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null)
				{
					return Convert.ToBoolean(property.GetValue(inst));
				}
				FieldInfo field = t.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return Convert.ToBoolean(field.GetValue(inst));
				}
			}
			catch
			{
			}
			return false;
		}

		internal static object ResolveStaticMember(Type t, string name)
		{
			try
			{
				return t?.GetProperty(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) ?? t?.GetField(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
			}
			catch
			{
				return null;
			}
		}

		internal static void SessionWatcherTick(string tag)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			if (_uiDrivenThisSession)
			{
				return;
			}
			try
			{
				DumpSessionState("watcher@" + tag);
				if (!IsOfflineHostSessionLive())
				{
					return;
				}
				if (GetLobbyHandler() == null)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[OfflineHost] session live but no Handler — forcing registration now (Create+JoinHostPlayer).");
					LegacyForceRegister();
					if (GetLobbyHandler() == null)
					{
						return;
					}
				}
				_uiDrivenThisSession = true;
				DumpSessionState("at-settle");
				SteamBypassMod.LogSource.LogInfo((object)"[OfflineHost] host session settled — driving UI once (hide overlay + State->Lobby).");
				TryHideLoadingOverlay();
				SwitchGameState("Lobby");
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OfflineHost] watcher tick ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(tag);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		internal static void LegacyForceRegister()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = TypeResolver.Default.Resolve("LobbyHandler")?.GetMethod("Create", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (methodInfo != null && GetLobbyHandler() == null)
				{
					if (methodInfo.IsStatic)
					{
						methodInfo.Invoke(null, null);
					}
					else
					{
						object lobbyHandler = GetLobbyHandler();
						if (lobbyHandler != null)
						{
							methodInfo.Invoke(lobbyHandler, null);
						}
					}
				}
				Type type = TypeResolver.Default.Resolve("GameNetworkManager");
				object obj = ResolveStaticMember(type, "Singleton");
				(type?.GetMethod("JoinHostPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null))?.Invoke(obj, null);
				SteamBypassMod.LogSource.LogWarning((object)"[OfflineHost] LegacyForceRegister done (JoinHostPlayer invoked).");
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OfflineHost] LegacyForceRegister failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		private static void ProcessMainThreadScheduledActions()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			bool flag2 = default(bool);
			try
			{
				if (_mainThreadDelayed.Count > 0)
				{
					lock (_mainThreadDelayed)
					{
						bool flag = default(bool);
						for (int num = _mainThreadDelayed.Count - 1; num >= 0; num--)
						{
							(int, Action) tuple = _mainThreadDelayed[num];
							if (tuple.Item1 > 0)
							{
								_mainThreadDelayed[num] = (tuple.Item1 - 1, tuple.Item2);
							}
							else
							{
								_mainThreadDelayed.RemoveAt(num);
								try
								{
									tuple.Item2();
								}
								catch (Exception ex)
								{
									ManualLogSource logSource = SteamBypassMod.LogSource;
									BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
									if (flag)
									{
										((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MainThreadQueue] action failed: ");
										((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
									}
									logSource.LogWarning(val);
								}
							}
						}
					}
				}
				if (!_playerPrefabRetryStarted)
				{
					return;
				}
				if (_playerPrefabRetryAttemptsLeft <= 0)
				{
					_playerPrefabRetryStarted = false;
					return;
				}
				_playerPrefabRetryFrameCounter++;
				if (_playerPrefabRetryFrameCounter < 15)
				{
					return;
				}
				_playerPrefabRetryFrameCounter = 0;
				try
				{
					if (EnsurePlayerPrefabAssigned())
					{
						SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] assignment succeeded on scheduled attempt.");
						_playerPrefabRetryAttemptsLeft = 0;
						_playerPrefabRetryStarted = false;
						return;
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource logSource2 = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] scheduled attempt threw: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
					}
					logSource2.LogWarning(val);
				}
				_playerPrefabRetryAttemptsLeft--;
				if (_playerPrefabRetryAttemptsLeft <= 0)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[EnsurePlayerPrefabAssigned] scheduled retry attempts exhausted.");
					_playerPrefabRetryStarted = false;
				}
			}
			catch (Exception ex3)
			{
				ManualLogSource logSource3 = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(70, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] ProcessMainThreadScheduledActions error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
				}
				logSource3.LogWarning(val);
				_playerPrefabRetryStarted = false;
			}
		}

		public static bool CanLobbyBeStartedPrefix(ref bool __result)
		{
			__result = true;
			return false;
		}

		public static bool CheckPlayersStatePrefix(object targetState, ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			try
			{
				__result = true;
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: CheckPlayersStatePrefix error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSource.LogError(val);
				return true;
			}
		}

		public static bool IsLobbyReadyForSetupPrefix(ulong localClientId, ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			try
			{
				__result = true;
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteamBypass: IsLobbyReadyForSetupPrefix error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSource.LogError(val);
				return true;
			}
		}

		public static bool IsRelayNetworkReadyPrefix(ref bool __result)
		{
			if (_steamSuccessfullyInitialized)
			{
				return true;
			}
			__result = true;
			return false;
		}

		public static bool IsRelayNetworkUnavailablePrefix(ref bool __result)
		{
			if (_steamSuccessfullyInitialized)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static void IsRelayNetworkReadyPostfix(ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (SteamBypassMod.Verbose)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] IsRelayNetworkReady = ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (steamReal=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_steamSuccessfullyInitialized);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
				}
				logSource.LogInfo(val);
			}
		}

		public static void IsRelayNetworkUnavailablePostfix(ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (SteamBypassMod.Verbose)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] IsRelayNetworkUnavailable = ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (steamReal=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_steamSuccessfullyInitialized);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
				}
				logSource.LogInfo(val);
			}
		}

		public static bool CleanupFailedHostStartupPrefix()
		{
			if (_steamSuccessfullyInitialized)
			{
				SteamBypassMod.LogSource.LogInfo((object)"[STEAM-REAL] CleanupFailedHostStartup — real Steam: original cleanup allowed to run.");
				return true;
			}
			SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] GameNetworkManager.CleanupFailedHostStartup() called — host startup FAILED — ORIGINAL SKIPPED (protecting live offline host session).");
			return false;
		}

		public static void MenuLoadingShowOverlayPostfix(object __instance, bool force)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			if (_steamSuccessfullyInitialized || !force)
			{
				return;
			}
			try
			{
				if (IsOfflineHostSessionLive())
				{
					__instance.GetType().GetMethod("SetOverlaysHidden", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null)?.Invoke(__instance, new object[1] { false });
					SteamBypassMod.LogSource.LogInfo((object)"[OfflineHost] overlays hidden right after ShowLoadingOverlay(true) — offline host session is live.");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[OfflineHost] overlay suppress failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		private static void WarmNetworkManagerCache()
		{
			if (!(_nmTypeCache != null))
			{
				_nmTypeCache = TypeResolver.Default.Resolve("NetworkManager");
				if (!(_nmTypeCache == null))
				{
					_nmSingletonCache = _nmTypeCache.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					_nmListeningCache = _nmTypeCache.GetProperty("IsListening", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
			}
		}

		internal static bool IsOfflineHostSessionLive()
		{
			try
			{
				WarmNetworkManagerCache();
				object obj = _nmSingletonCache?.GetValue(null);
				if (obj == null)
				{
					return false;
				}
				return _nmListeningCache?.GetValue(obj) as bool? == true;
			}
			catch
			{
				return false;
			}
		}

		internal static void TryHideLoadingOverlay()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve("MenuLoadingUI");
				if (type == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[OfflineHost] MenuLoadingUI type not found — cannot hide loading overlay.");
					return;
				}
				Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.From(type), true);
				if (val == null || ((Il2CppArrayBase<Object>)(object)val).Length == 0)
				{
					SteamBypassMod.LogSource.LogInfo((object)"[OfflineHost] no MenuLoadingUI instance in scene — nothing to hide.");
					return;
				}
				Type type2 = ((object)((Il2CppArrayBase<Object>)(object)val)[0]).GetType();
				string[] array = new string[1] { "SetOverlaysHidden" };
				foreach (string text in array)
				{
					MethodInfo method = type2.GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null);
					if (method != null)
					{
						method.Invoke(((Il2CppArrayBase<Object>)(object)val)[0], new object[1] { false });
						ManualLogSource logSource = SteamBypassMod.LogSource;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[OfflineHost] MenuLoadingUI.");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(false) invoked.");
						}
						logSource.LogInfo(val2);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(43, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[OfflineHost] hide loading overlay failed: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				logSource2.LogWarning(val3);
			}
		}

		internal static object GetLobbyHandler()
		{
			try
			{
				Type type = TypeResolver.Default.Resolve("LobbyHandler");
				if (type == null)
				{
					return null;
				}
				FieldInfo field = type.GetField("Handler", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field.GetValue(null);
				}
				return type.GetProperty("Handler", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
			}
			catch
			{
				return null;
			}
		}

		internal static void SwitchGameState(string targetName)
		{
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve("GameManager");
				Type type2 = TypeResolver.Default.Resolve("GameState");
				if (type == null || type2 == null)
				{
					ManualLogSource logSource = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StateSwitch] type resolve failed (GameManager=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(type != null);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", GameState=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(type2 != null);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
					}
					logSource.LogWarning(val);
					return;
				}
				object obj = Resolve(type, null, "Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (obj == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[StateSwitch] GameManager.Singleton not found as property nor field.");
					return;
				}
				object obj2 = Enum.Parse(type2, targetName, ignoreCase: true);
				PropertyInfo property = type.GetProperty("State", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				object obj3 = property?.GetValue(obj);
				if (obj3 == null)
				{
					obj3 = Resolve(type, obj, "_state", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if (object.Equals(obj3, obj2))
				{
					ManualLogSource logSource2 = SteamBypassMod.LogSource;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StateSwitch] already ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj2);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" — no-op.");
					}
					logSource2.LogInfo(val2);
					return;
				}
				if (property != null)
				{
					try
					{
						property.SetValue(obj, obj2);
						object value = property.GetValue(obj);
						if (object.Equals(value, obj2))
						{
							ManualLogSource logSource3 = SteamBypassMod.LogSource;
							BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(77, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StateSwitch] State ");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj3);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> ");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj2);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" via property setter (OnStateChanged fired natively).");
							}
							logSource3.LogInfo(val2);
							return;
						}
						ManualLogSource logSource4 = SteamBypassMod.LogSource;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(76, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StateSwitch] setter ran but State still ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(value);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" — falling back to manual dispatch.");
						}
						logSource4.LogWarning(val);
					}
					catch (Exception ex)
					{
						ManualLogSource logSource5 = SteamBypassMod.LogSource;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StateSwitch] setter threw: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" — falling back to manual dispatch.");
						}
						logSource5.LogWarning(val);
					}
				}
				PropertyInfo property2 = type.GetProperty("_state", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo field = type.GetField("_state", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property2 != null)
				{
					property2.SetValue(obj, obj2);
				}
				else
				{
					if (!(field != null))
					{
						SteamBypassMod.LogSource.LogWarning((object)"[StateSwitch] _state member not found — cannot switch.");
						return;
					}
					field.SetValue(obj, obj2);
				}
				try
				{
					object obj4 = Resolve(type, obj, "OnStateChanged", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (obj4 != null)
					{
						int num = 0;
						if (obj4 is Delegate obj5)
						{
							Delegate[] invocationList = obj5.GetInvocationList();
							foreach (Delegate obj6 in invocationList)
							{
								obj6.Method.Invoke(obj6.Target, new object[2] { obj3, obj2 });
								num++;
							}
						}
						ManualLogSource logSource6 = SteamBypassMod.LogSource;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(83, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StateSwitch] State ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj3);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj2);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" via _state write + manual OnStateChanged (");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" subscriber(s)).");
						}
						logSource6.LogInfo(val2);
					}
					else
					{
						ManualLogSource logSource7 = SteamBypassMod.LogSource;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(70, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[StateSwitch] State ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj3);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj2);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" via _state write (OnStateChanged empty/null).");
						}
						logSource7.LogInfo(val2);
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource logSource8 = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StateSwitch] OnStateChanged manual dispatch failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
					}
					logSource8.LogWarning(val);
				}
			}
			catch (Exception ex3)
			{
				ManualLogSource logSource9 = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[StateSwitch] failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
				}
				logSource9.LogWarning(val);
			}
			static object Resolve(Type t, object inst, string name, BindingFlags bf)
			{
				PropertyInfo property3 = t.GetProperty(name, bf);
				if (property3 != null)
				{
					try
					{
						return (inst == null) ? property3.GetValue(null) : property3.GetValue(inst);
					}
					catch
					{
					}
				}
				FieldInfo field2 = t.GetField(name, bf);
				if (!(field2 == null))
				{
					if (inst != null)
					{
						return field2.GetValue(inst);
					}
					return field2.GetValue(null);
				}
				return null;
			}
		}

		public static void LogBugOncePrefix(string keyword, string detail)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (SteamBypassMod.Verbose)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(59, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] GameNetworkManager.LogBugOnce: keyword='");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(keyword);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' detail='");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(detail);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				}
				logSource.LogInfo(val);
			}
		}

		public static void StartHostPostfix(ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (SteamBypassMod.Verbose)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] NetworkManager.StartHost() returned ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logSource.LogInfo(val);
			}
		}

		public static void ShutdownPrefix()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (!SteamBypassMod.Verbose)
				{
					return;
				}
				StackFrame[] frames = new StackTrace(1, fNeedFileInfo: false).GetFrames();
				List<string> list = new List<string>();
				if (frames != null)
				{
					StackFrame[] array = frames;
					for (int i = 0; i < array.Length; i++)
					{
						MethodBase methodBase = array[i]?.GetMethod();
						if (!(methodBase == null))
						{
							list.Add(methodBase.DeclaringType?.Name + "." + methodBase.Name);
							if (list.Count >= 8)
							{
								break;
							}
						}
					}
				}
				if (SteamBypassMod.Verbose)
				{
					DumpSessionState("at-Shutdown-entry");
				}
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIAG21] NetworkManager.Shutdown() called by: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((list.Count > 0) ? string.Join(" <- ", list) : "<native/il2cpp>");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logSource.LogWarning(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DIAG21] Shutdown diag failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource2.LogWarning(val);
			}
		}

		public static void StartServerPostfix(ref bool __result)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				object obj = (TypeResolver.Default.Resolve("NetworkManager")?.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null);
				object obj2 = obj?.GetType().GetProperty("NetworkConfig")?.GetValue(obj);
				object obj3 = obj2?.GetType().GetProperty("NetworkTransport")?.GetValue(obj2);
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(67, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] NetworkManager.StartServer() returned ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | transport used = ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((obj3 == null) ? "NULL" : obj3.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logSource.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DEBUG] StartServerPostfix error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logSource2.LogError(val2);
			}
		}

		public static void UnityTransportStartServerPrefix(object __instance)
		{
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			SteamBypassMod.LogSource.LogInfo((object)"[NETCODE] UnityTransport.StartServer() entered.");
			bool flag = default(bool);
			try
			{
				Type type = __instance.GetType();
				object obj = type.GetField("ConnectionData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance);
				string text = null;
				object obj2 = null;
				if (obj != null)
				{
					Type type2 = obj.GetType();
					text = (type2.GetField("Address")?.GetValue(obj) as string) ?? (type2.GetProperty("Address")?.GetValue(obj) as string);
					obj2 = type2.GetField("Port")?.GetValue(obj) ?? type2.GetProperty("Port")?.GetValue(obj);
				}
				object obj3 = type.GetField("m_ProtocolType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance);
				object obj4 = type.GetField("m_ServerListenAddresses", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance);
				string text2 = "(none)";
				if (obj4 != null)
				{
					text2 = ((!(obj4 is ICollection collection)) ? obj4.ToString() : $"count={collection.Count}");
				}
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(68, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] UTP state: Address=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Port=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(obj2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Protocol=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(obj3);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ServerListenAddresses=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
				}
				logSource.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NETCODE] UnityTransportStartServerPrefix DIAG error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logSource2.LogError(val2);
			}
		}

		public static void UnityTransportStartServerPostfix(ref bool __result)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logSource = SteamBypassMod.LogSource;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] UnityTransport.StartServer() returned ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			logSource.LogInfo(val);
		}

		public static Exception UnityTransportStartServerFinalizer(Exception __exception)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			if (__exception != null)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] UnityTransport.StartServer() THREW: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__exception.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__exception.Message);
				}
				logSource.LogError(val);
			}
			else
			{
				SteamBypassMod.LogSource.LogInfo((object)"[NETCODE] UnityTransport.StartServer() finished (no exception).");
			}
			return __exception;
		}

		public static void CanStartPostfix(object __instance, object __0, ref bool __result)
		{
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				Type type = __instance.GetType();
				object obj = type.GetProperty("IsListening")?.GetValue(__instance);
				object obj2 = type.GetProperty("NetworkConfig")?.GetValue(__instance);
				Type obj3 = obj2?.GetType();
				object obj4 = obj3?.GetProperty("PlayerPrefab")?.GetValue(obj2);
				object obj5 = obj3?.GetProperty("ConnectionApproval")?.GetValue(obj2);
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(94, 6, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] CanStart(");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(__0);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") returned ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | IsListening=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(obj);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" NetworkConfig=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((obj2 == null) ? "NULL" : "ok");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" PlayerPrefab=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((obj4 == null) ? "NULL" : "set");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ConnectionApproval=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<object>(obj5);
				}
				logSource.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NETCODE] CanStartPostfix error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logSource2.LogError(val2);
			}
		}

		public static void HostServerInitializePrefix()
		{
			SteamBypassMod.LogSource.LogInfo((object)"[NETCODE] NetworkManager.HostServerInitialize() entered.");
		}

		public static void HostServerInitializePostfix()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			SteamBypassMod.LogSource.LogInfo((object)"[NETCODE] NetworkManager.HostServerInitialize() done.");
			try
			{
				SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] HostServerInitializePostfix attempting assignment.");
				if (!EnsurePlayerPrefabAssigned())
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] HostServerInitializePostfix: immediate attempt failed, starting retry background.");
					StartPlayerPrefabRetryBackground();
				}
				else
				{
					SteamBypassMod.LogSource.LogInfo((object)"[EnsurePlayerPrefabAssigned] HostServerInitializePostfix: assignment succeeded.");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] HostServerInitializePostfix error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		public static void InitializePrefix(object __instance, bool server)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				object obj = __instance.GetType().GetProperty("NetworkConfig")?.GetValue(__instance);
				object obj2 = obj?.GetType().GetProperty("NetworkTransport")?.GetValue(obj);
				ManualLogSource logSource = SteamBypassMod.LogSource;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(65, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] NetworkManager.Initialize(server=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(server);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") entered | transport=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((obj2 == null) ? "NULL" : obj2.GetType().Name);
				}
				logSource.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource2 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NETCODE] InitializePrefix error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logSource2.LogError(val2);
			}
		}

		public static void InitializePostfix(object __instance, bool server)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				if (!EnsurePlayerPrefabAssigned())
				{
					StartPlayerPrefabRetryBackground();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = SteamBypassMod.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[EnsurePlayerPrefabAssigned] InitializePostfix failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		public static void ButtonHostAsyncPrefix()
		{
			SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] Play clicked -> MenuSubUI.Button_HostAsync entered.");
		}

		public static void IsSteamClientReadyAndOnlinePostfix(ref bool __result)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logSource = SteamBypassMod.LogSource;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] IsSteamClientReadyAndOnline = ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(__result);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (steamReal=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_steamSuccessfullyInitialized);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
			}
			logSource.LogInfo(val);
		}

		public static bool HostLobbyForcePrefix()
		{
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Expected O, but got Unknown
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Expected O, but got Unknown
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_072d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Expected O, but got Unknown
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Expected O, but got Unknown
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Expected O, but got Unknown
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Expected O, but got Unknown
			if (_steamSuccessfullyInitialized)
			{
				SteamBypassMod.LogSource.LogInfo((object)"[STEAM-REAL] real Steam active — passing through native GameManager.HostLobby() (FacepunchTransport + Steam lobby + invites).");
				return true;
			}
			SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] GameManager.HostLobby() entered — bypassing inlined CanStartHost gate, calling Host() directly.");
			if (IsOfflineHostSessionLive() && GetLobbyHandler() != null)
			{
				SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] HostLobbyForcePrefix: session already live — switching state to Lobby only (no chain re-run).");
				TryHideLoadingOverlay();
				SwitchGameState("Lobby");
				return false;
			}
			bool flag = default(bool);
			try
			{
				Type type = TypeResolver.Default.Resolve("GameNetworkManager");
				if (type == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager type not found.");
					return false;
				}
				object obj = null;
				PropertyInfo property = type.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null)
				{
					obj = property.GetValue(null);
				}
				else
				{
					FieldInfo field = type.GetField("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (field == null)
					{
						SteamBypassMod.LogSource.LogWarning((object)"[DEBUG] HostLobbyForcePrefix: Singleton field/property not found.");
						return false;
					}
					obj = field.GetValue(null);
				}
				if (obj == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager.Singleton is null — cannot start host.");
					return false;
				}
				try
				{
					Type type2 = TypeResolver.Default.Resolve("NetworkManager");
					object obj2 = null;
					if (type2 != null)
					{
						obj2 = type2.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
					}
					if (obj2 == null)
					{
						object obj3 = type.GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
						if (obj3 != null)
						{
							obj2 = obj3.GetType().GetMethod("GetComponent", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(Type) }, null)?.Invoke(obj3, new object[1] { type2 });
						}
					}
					InstallLocalTransport(obj2);
				}
				catch (Exception ex)
				{
					ManualLogSource logSource = SteamBypassMod.LogSource;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] HostLobbyForcePrefix: transport install error: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logSource.LogError(val);
				}
				Type type3 = TypeResolver.Default.Resolve("GameNetworkManager");
				if (type3 == null)
				{
					SteamBypassMod.LogSource.LogError((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager type not found — cannot start host.");
					return false;
				}
				object obj4 = null;
				PropertyInfo property2 = type3.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				obj4 = ((!(property2 != null)) ? type3.GetField("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) : property2.GetValue(null));
				if (obj4 == null)
				{
					SteamBypassMod.LogSource.LogError((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager.Singleton is null — cannot start host.");
					return false;
				}
				MethodInfo method = type3.GetMethod("Host", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (method == null)
				{
					SteamBypassMod.LogSource.LogError((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager.Host() method not found.");
					return false;
				}
				try
				{
					object obj5 = type3.GetProperty("Transport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj4);
					ManualLogSource logSource2 = SteamBypassMod.LogSource;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(140, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DEBUG] HostLobbyForcePrefix: GameNetworkManager.Transport = ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(obj5?.GetType().Name ?? "null");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (typed Facepunch — UTP lives on NetworkConfig, session kept alive explicitly).");
					}
					logSource2.LogInfo(val2);
				}
				catch (Exception ex2)
				{
					ManualLogSource logSource3 = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(53, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DEBUG] HostLobbyForcePrefix: Transport diag failed: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message);
					}
					logSource3.LogWarning(val3);
				}
				try
				{
					Type type4 = TypeResolver.Default.Resolve("NetworkManager");
					object obj6 = ResolveStaticMember(type4, "Singleton");
					if (obj6 == null)
					{
						SteamBypassMod.LogSource.LogWarning((object)"[NETCODE] NetworkManager.Singleton is null — cannot explicitly start server.");
					}
					else
					{
						(type4?.GetMethod("Initialize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null))?.Invoke(obj6, new object[1] { true });
						object obj7 = (type4?.GetMethod("StartServer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null))?.Invoke(obj6, null);
						ManualLogSource logSource4 = SteamBypassMod.LogSource;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(64, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NETCODE] explicit Initialize(true)+StartServer() done, result=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj7);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
						}
						logSource4.LogInfo(val2);
					}
				}
				catch (Exception ex3)
				{
					ManualLogSource logSource5 = SteamBypassMod.LogSource;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NETCODE] explicit server start failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
					}
					logSource5.LogError(val);
				}
				SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] HostLobbyForcePrefix: invoking GameNetworkManager.Singleton.Host() (full chain)...");
				method.Invoke(obj4, null);
				SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] HostLobbyForcePrefix: GameNetworkManager.Singleton.Host() invoked (async chain started).");
				try
				{
					FieldInfo field2 = type3.GetField("hostLobbyCreateSucceeded", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					FieldInfo? field3 = type3.GetField("isJoiningLobby", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					object obj8 = field2?.GetValue(obj4);
					object obj9 = field3?.GetValue(obj4);
					Type type5 = TypeResolver.Default.Resolve("LobbyHandler");
					object obj10 = type5?.GetField("Handler", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) ?? type5?.GetProperty("Handler", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
					Type type6 = TypeResolver.Default.Resolve("NetworkManager");
					object obj11 = (type6?.GetProperty("Singleton", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null);
					object obj12 = (type6?.GetProperty("IsListening", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(obj11);
					ManualLogSource logSource6 = SteamBypassMod.LogSource;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(119, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DEBUG] Post-Join states: hostLobbyCreateSucceeded=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj8);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" isJoiningLobby=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj9);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" LobbyHandler.Handler=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((obj10 == null) ? "NULL" : "live");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" | NetworkManager.IsListening=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj12);
					}
					logSource6.LogInfo(val2);
				}
				catch (Exception ex4)
				{
					ManualLogSource logSource7 = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(59, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DEBUG] HostLobbyForcePrefix: post-join state read failed: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex4.Message);
					}
					logSource7.LogWarning(val3);
				}
				try
				{
					PropertyInfo property3 = type3.GetProperty("IsHost", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					bool? flag2 = property3?.GetValue(obj4) as bool?;
					flag = false;
					if (flag2 == flag)
					{
						SteamBypassMod.LogSource.LogInfo((object)"[DEBUG] HostLobbyForcePrefix: IsHost=false after JoinHostPlayer, attempting to set IsHost=true reflectively.");
						BepInExInfoLogInterpolatedStringHandler val2;
						if (property3 != null && property3.CanWrite)
						{
							property3.SetValue(obj4, true);
						}
						else
						{
							string[] array = new string[4] { "IsHost", "_isHost", "isHost", "<IsHost>k__BackingField" };
							foreach (string text in array)
							{
								FieldInfo field4 = type3.GetField(text, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
								if (field4 != null)
								{
									field4.SetValue(obj4, true);
									ManualLogSource logSource8 = SteamBypassMod.LogSource;
									val2 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
									if (flag)
									{
										((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DEBUG] HostLobbyForcePrefix: wrote field ");
										((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
										((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("=true");
									}
									logSource8.LogInfo(val2);
									break;
								}
							}
						}
						object obj13 = property3?.GetValue(obj4);
						ManualLogSource logSource9 = SteamBypassMod.LogSource;
						val2 = new BepInExInfoLogInterpolatedStringHandler(46, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DEBUG] HostLobbyForcePrefix: Post-fix IsHost=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<object>(obj13);
						}
						logSource9.LogInfo(val2);
					}
				}
				catch (Exception ex5)
				{
					ManualLogSource logSource10 = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(65, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DEBUG] HostLobbyForcePrefix: failed to set IsHost reflectively: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex5.Message);
					}
					logSource10.LogWarning(val3);
				}
			}
			catch (Exception ex6)
			{
				ManualLogSource logSource11 = SteamBypassMod.LogSource;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DEBUG] HostLobbyForcePrefix: exception: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex6);
				}
				logSource11.LogError(val);
			}
			_uiDrivenThisSession = false;
			ScheduleOnMainThread(30, delegate
			{
				SessionWatcherTick("w30");
			});
			ScheduleOnMainThread(60, delegate
			{
				SessionWatcherTick("w60");
			});
			ScheduleOnMainThread(120, delegate
			{
				SessionWatcherTick("w120");
			});
			ScheduleOnMainThread(330, delegate
			{
				DumpSessionState("t+5.5s");
				if (!_uiDrivenThisSession)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[OfflineHost] session did not fully settle by t+5.5s — forcing registration + UI switch as last resort.");
					LegacyForceRegister();
					TryHideLoadingOverlay();
					SwitchGameState("Lobby");
				}
			});
			return false;
		}

		private static void InstallLocalTransport(object networkManager)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Expected O, but got Unknown
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Expected O, but got Unknown
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Expected O, but got Unknown
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected O, but got Unknown
			if (networkManager == null)
			{
				SteamBypassMod.LogSource.LogWarning((object)"[LocalTransport] NetworkManager is null — cannot install local transport.");
				return;
			}
			bool flag = default(bool);
			try
			{
				Type type = networkManager.GetType();
				PropertyInfo property = type.GetProperty("NetworkConfig", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[LocalTransport] NetworkConfig property not found.");
					return;
				}
				object value = property.GetValue(networkManager);
				if (value == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[LocalTransport] NetworkConfig is null.");
					return;
				}
				try
				{
					object obj = value.GetType().GetProperty("NetworkTransport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value);
					if (obj != null)
					{
						obj.GetType().GetMethod("Shutdown", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)?.Invoke(obj, null);
						SteamBypassMod.LogSource.LogInfo((object)"[LocalTransport] Shut down previous NetworkTransport before installing UTP.");
					}
				}
				catch (Exception ex)
				{
					ManualLogSource logSource = SteamBypassMod.LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[LocalTransport] previous transport Shutdown failed (ignored): ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logSource.LogWarning(val);
				}
				object obj2 = type.GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(networkManager);
				if (obj2 == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[LocalTransport] gameObject is null.");
					return;
				}
				Type typeFromHandle = typeof(UnityTransport);
				MethodInfo methodInfo = obj2.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "AddComponent" && m.IsGenericMethodDefinition);
				if (methodInfo == null)
				{
					SteamBypassMod.LogSource.LogWarning((object)"[LocalT