Decompiled source of Virality v1.4.0

BepInEx/plugins/Virality/MaxWasUnavailable.Virality.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DefaultNamespace;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Steamworks;
using UnityEngine;
using Virality.Helpers;
using Virality.State;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Ashley.MeshSplitter")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("Discord")]
[assembly: IgnoresAccessChecksTo("HBAO.Demo.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("MeshSplit")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("pworld")]
[assembly: IgnoresAccessChecksTo("sc.posteffects.runtime")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Tayx.Graphy")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.PlayableGraphVisualizer")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.PhotonUtility")]
[assembly: IgnoresAccessChecksTo("Zorro.Recorder")]
[assembly: IgnoresAccessChecksTo("Zorro.Settings.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.UI.Runtime")]
[assembly: AssemblyCompany("MaxWasUnavailable;Day")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Extends the max number of players that can play in a lobby, adds late joining, and proper Steam rich presence.")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+4e2efb8c67558d18a1a410b0fc0c62ee4f8e2a63")]
[assembly: AssemblyProduct("MaxWasUnavailable.Virality")]
[assembly: AssemblyTitle("MaxWasUnavailable.Virality")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MaxWasUnavailable/Virality")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Virality
{
	[ContentWarningPlugin("MaxWasUnavailable.Virality", "1.4.0", false)]
	[BepInPlugin("MaxWasUnavailable.Virality", "MaxWasUnavailable.Virality", "1.4.0")]
	public class Virality : BaseUnityPlugin
	{
		private bool _isPatched;

		private Harmony? Harmony { get; set; }

		internal static ManualLogSource? Logger { get; private set; }

		internal static ConfigEntry<int>? MaxPlayers { get; private set; }

		internal static ConfigEntry<bool>? AllowLateJoin { get; private set; }

		internal static ConfigEntry<bool>? EnableVoiceFix { get; private set; }

		public static Virality? Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			MaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 12, "The maximum number of players allowed in your lobby.");
			AllowLateJoin = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowLateJoin", true, "Whether or not to allow players to join your lobby after the game has started.");
			EnableVoiceFix = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableVoiceFix", true, "Whether or not to enable the voice fix.");
			PatchAll();
			if (EnableVoiceFix.Value)
			{
				OverrideVoiceServerAppId();
			}
			if (_isPatched)
			{
				Logger.LogInfo((object)"Plugin MaxWasUnavailable.Virality is loaded!");
			}
			else
			{
				Logger.LogError((object)"Plugin MaxWasUnavailable.Virality failed to load correctly!");
			}
		}

		private void PatchAll()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004c: Expected O, but got Unknown
			if (_isPatched)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"Already patched!");
				}
				return;
			}
			ManualLogSource? logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogDebug((object)"Patching...");
			}
			if (Harmony == null)
			{
				Harmony val = new Harmony("MaxWasUnavailable.Virality");
				Harmony val2 = val;
				Harmony = val;
			}
			try
			{
				Harmony.PatchAll();
				_isPatched = true;
				ManualLogSource? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.LogDebug((object)"Patched!");
				}
			}
			catch (Exception arg)
			{
				ManualLogSource? logger4 = Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)$"Failed to patch: {arg}");
				}
			}
		}

		private static void OverrideVoiceServerAppId()
		{
			PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime;
			ManualLogSource? logger = Logger;
			if (logger != null)
			{
				logger.LogDebug((object)("Voice server app id set to realtime server app id (" + PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice + ")"));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MaxWasUnavailable.Virality";

		public const string PLUGIN_NAME = "MaxWasUnavailable.Virality";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace Virality.State
{
	public static class CurrentObjectiveTracker
	{
		public static Objective? CurrentObjective { get; internal set; }
	}
	public static class DoorOpenTracker
	{
		public static bool IsDoorOpen { get; internal set; }
	}
	public static class PhotonLobbyLimitTracker
	{
		public static int? PlayerLimit { get; set; }
	}
}
namespace Virality.Patches
{
	[HarmonyPatch(typeof(BedBoss))]
	[HarmonyPriority(800)]
	internal static class BedBossPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnPlayerJoined")]
		private static bool OnPlayerJoinedPrefix()
		{
			return PlayerHandler.instance.players.Count <= 4;
		}
	}
	[HarmonyPatch(typeof(EscapeMenuMainPage))]
	[HarmonyPriority(800)]
	internal static class EscapeMenuMainPagePatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		private static bool UpdatePrefix(EscapeMenuMainPage __instance)
		{
			bool active = LateJoinHelper.IsLateJoinAllowed || VanillaCheck();
			((Component)__instance.inviteButton).gameObject.SetActive(active);
			return false;
		}

		private static bool VanillaCheck()
		{
			if (MainMenuHandler.SteamLobbyHandler != null && (Object)(object)SurfaceNetworkHandler.Instance != (Object)null)
			{
				return !SurfaceNetworkHandler.HasStarted;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(InviteFriendsTerminal))]
	[HarmonyPriority(800)]
	internal static class InviteFriendsTerminalPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool IsGameFullPrefix(ref bool __result)
		{
			if (SteamLobbyHelper.LobbyHandler == null)
			{
				return true;
			}
			__result = PlayerHandler.instance.players.Count > SteamLobbyHelper.LobbyHandler.m_MaxPlayers;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool IsGameStartedPrefix(ref bool __result)
		{
			if (!Virality.AllowLateJoin.Value)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(MainMenuHandler))]
	[HarmonyPriority(800)]
	internal static class MainMenuHandlerPatches
	{
		[HarmonyTranspiler]
		[HarmonyPatch("OnSteamHosted")]
		private static IEnumerable<CodeInstruction> OnSteamHostedTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_I4_4)).ThrowIfInvalid("Could not find max players constant").SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LobbyHelper), "GetLobbyMaxConfig", (Type[])null, (Type[])null)))
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Modal))]
	[HarmonyPriority(800)]
	internal static class ModalPatches
	{
		private const string PhotonRoomErrorTitle = "failed to create photon room";

		private const string PhotonLobbyLimitBodyPartial = "max players peer room value is too big";

		private static bool IsPhotonLobbyLimitError(string title, string body)
		{
			if (title.ToLower() == "failed to create photon room")
			{
				return body.ToLower().Contains("max players peer room value is too big");
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ShowError")]
		private static void ShowErrorPrefix(string title, ref string body)
		{
			if (IsPhotonLobbyLimitError(title, body))
			{
				int num = int.Parse(body.Split(':').Last());
				ManualLogSource? logger = Virality.Logger;
				if (logger != null)
				{
					logger.LogWarning((object)$"Photon lobby limit error detected. Setting temporary max player override to {num}. You may use a mod such as \"Self Sufficient\" to increase this limit.");
				}
				PhotonLobbyLimitTracker.PlayerLimit = num;
				body += $"\n\nThe lobby player limit will temporarily be set to {num} for the duration of this session.";
				body += "\nYou may use a mod such as \"Self Sufficient\" to host your own Photon server with a higher player limit.";
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Show")]
		private static void ShowPostfix(string title, ref string body, ref ModalOption[] options)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (IsPhotonLobbyLimitError(title, body))
			{
				ModalOption element = new ModalOption("Cancel", (Action)CancelPhotonLobbyLimitOverride);
				options = options.Append(element).ToArray();
			}
		}

		private static void CancelPhotonLobbyLimitOverride()
		{
			PhotonLobbyLimitTracker.PlayerLimit = null;
			ManualLogSource? logger = Virality.Logger;
			if (logger != null)
			{
				logger.LogWarning((object)"Photon lobby limit override cancelled.");
			}
		}
	}
	[HarmonyPatch(typeof(PhotonGameLobbyHandler))]
	[HarmonyPriority(800)]
	internal static class PhotonGameLobbyHandlerPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void StartPostfixHide()
		{
			if (PhotonLobbyHelper.IsMasterClient() && Virality.AllowLateJoin.Value && !PhotonLobbyHelper.IsOnSurface())
			{
				LateJoinHelper.DisableLateJoin();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetCurrentObjective")]
		private static bool SetCurrentObjectivePostfix(ref Objective objective)
		{
			if (!PhotonLobbyHelper.IsMasterClient())
			{
				return true;
			}
			bool flag = objective is LeaveHouseObjective;
			if (flag)
			{
				Objective currentObjective = CurrentObjectiveTracker.CurrentObjective;
				bool flag2 = ((currentObjective is InviteFriendsObjective || currentObjective is LeaveHouseObjective) ? true : false);
				flag = !flag2;
			}
			if (flag)
			{
				return false;
			}
			ManualLogSource? logger = Virality.Logger;
			if (logger != null)
			{
				logger.LogDebug((object)$"Setting current objective to {objective}.");
			}
			CurrentObjectiveTracker.CurrentObjective = objective;
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerHandler))]
	[HarmonyPriority(800)]
	internal static class PlayerHandlerPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("AddPlayer")]
		private static void AddPlayerPostfixOpenDoor(Player player)
		{
			if (PhotonLobbyHelper.IsMasterClient() && !player.IsLocal && Virality.AllowLateJoin.Value && DoorOpenTracker.IsDoorOpen && PhotonLobbyHelper.IsOnSurface())
			{
				SendDoorOpenRPC(player);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("AddPlayer")]
		private static void AddPlayerPostfixSyncObjective(Player player)
		{
			if (PhotonLobbyHelper.IsMasterClient() && Virality.AllowLateJoin.Value)
			{
				SyncObjectiveRPC(player);
			}
		}

		private static void SendDoorOpenRPC(Player player)
		{
			SurfaceNetworkHandler.Instance.m_View.RPC("RPCA_OpenDoor", player.refs.view.Controller, Array.Empty<object>());
		}

		private static void SyncObjectiveRPC(Player player)
		{
			Objective currentObjective = CurrentObjectiveTracker.CurrentObjective;
			if (currentObjective != null)
			{
				((MonoBehaviourPun)PhotonGameLobbyHandler.Instance).photonView.RPC("RPC_SetCurrentObjective", player.refs.view.Controller, new object[1] { ObjectiveDatabase.GetIndex(currentObjective) });
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("AllPlayersInBed")]
		private static void AllPlayersInBedPostfix(PlayerHandler __instance, ref bool __result)
		{
			int num = 0;
			for (int i = 0; i < __instance.playersAlive.Count; i++)
			{
				if ((Object)(object)__instance.playersAlive[i].data.currentBed != (Object)null)
				{
					num++;
				}
			}
			__result = num >= Math.Min(__instance.playersAlive.Count, 4);
		}

		[HarmonyPostfix]
		[HarmonyPatch("AllPlayersAsleep")]
		private static void AllPlayersAsleepPostfix(PlayerHandler __instance, ref bool __result)
		{
			int num = 0;
			for (int i = 0; i < __instance.playersAlive.Count; i++)
			{
				if (__instance.playersAlive[i].data.sleepAmount >= 0.9f)
				{
					num++;
				}
			}
			__result = num >= Math.Min(__instance.playersAlive.Count, 4);
		}
	}
	[HarmonyPatch(typeof(SpawnHandler))]
	[HarmonyPriority(800)]
	internal static class SpawnHandlerPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("FindLocalSpawnIndex")]
		private static void FindLocalSpawnIndexPostfix(ref SpawnHandler __instance)
		{
			if (__instance.m_LocalSpawnIndex != 0)
			{
				int num = Math.Min(Math.Min(__instance.m_HospitalSpawns.Length, __instance.m_HouseSpawns.Length), __instance.m_DiveBellSpawns.Length) - 1;
				SpawnHandler obj = __instance;
				obj.m_LocalSpawnIndex %= num;
				SpawnHandler obj2 = __instance;
				obj2.m_LocalSpawnIndex++;
			}
		}
	}
	[HarmonyPatch(typeof(SteamLobbyHandler))]
	[HarmonyPriority(800)]
	internal static class SteamLobbyHandlerPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("HostMatch")]
		private static void HostMatchPrefix()
		{
			SteamLobbyHelper.SetLobbyMaxToConfig();
		}

		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static IEnumerable<CodeInstruction> ConstructorTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldarg_1)).ThrowIfInvalid("Could not find max players argument").SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LobbyHelper), "GetLobbyMaxConfig", (Type[])null, (Type[])null)))
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(SurfaceNetworkHandler))]
	[HarmonyPriority(800)]
	internal static class SurfaceNetworkHandlerPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("RPCM_StartGame")]
		private static void RPCM_StartGamePostfix()
		{
			if (PhotonLobbyHelper.IsMasterClient() && Virality.AllowLateJoin.Value && PhotonLobbyHelper.IsOnSurface())
			{
				DoorOpenTracker.IsDoorOpen = true;
				LateJoinHelper.EnableLateJoin();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnSlept")]
		private static void OnSleptPostfix()
		{
			if (PhotonLobbyHelper.IsMasterClient() && Virality.AllowLateJoin.Value)
			{
				LateJoinHelper.EnableLateJoin();
			}
		}
	}
}
namespace Virality.Helpers
{
	public static class LateJoinHelper
	{
		public static bool IsLateJoinAllowed { get; private set; }

		public static void EnableLateJoin()
		{
			ManualLogSource? logger = Virality.Logger;
			if (logger != null)
			{
				logger.LogDebug((object)"Enabling late join.");
			}
			SteamLobbyHelper.LobbyHandler.OpenLobby();
			PhotonNetwork.CurrentRoom.IsOpen = true;
			PhotonNetwork.CurrentRoom.IsVisible = true;
			IsLateJoinAllowed = true;
		}

		public static void DisableLateJoin()
		{
			ManualLogSource? logger = Virality.Logger;
			if (logger != null)
			{
				logger.LogDebug((object)"Disabling late join.");
			}
			SteamLobbyHelper.LobbyHandler.HideLobby();
			PhotonNetwork.CurrentRoom.IsOpen = false;
			PhotonNetwork.CurrentRoom.IsVisible = false;
			IsLateJoinAllowed = false;
		}
	}
	public static class LobbyHelper
	{
		public static int GetLobbyMaxConfig()
		{
			return PhotonLobbyLimitTracker.PlayerLimit ?? Virality.MaxPlayers.Value;
		}
	}
	public static class PhotonLobbyHelper
	{
		public static bool IsOnSurface()
		{
			return PhotonGameLobbyHandler.IsSurface;
		}

		public static void SetLobbyMaxPlayers(int maxPlayers)
		{
			PhotonNetwork.CurrentRoom.MaxPlayers = maxPlayers;
		}

		public static void SetLobbyMaxToConfig()
		{
			SetLobbyMaxPlayers(LobbyHelper.GetLobbyMaxConfig());
		}

		public static bool IsMasterClient()
		{
			return PhotonNetwork.IsMasterClient;
		}
	}
	public static class SteamLobbyHelper
	{
		public static SteamLobbyHandler? LobbyHandler => MainMenuHandler.SteamLobbyHandler;

		public static AppId_t GetAppId()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return SteamUtils.GetAppID();
		}

		public static CSteamID GetUserId()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return SteamUser.GetSteamID();
		}

		public static CSteamID GetLobbyId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return LobbyHandler.m_CurrentLobby;
		}

		public static void SetLobbyMaxPlayers(int maxPlayers)
		{
			ManualLogSource? logger = Virality.Logger;
			if (logger != null)
			{
				logger.LogInfo((object)$"Setting lobby max players to {maxPlayers}.");
			}
			LobbyHandler.m_MaxPlayers = maxPlayers;
		}

		public static void SetLobbyMaxToConfig()
		{
			SetLobbyMaxPlayers(LobbyHelper.GetLobbyMaxConfig());
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}