Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of 3D Lobbies v1.0.1
PlayableLobbies.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PlayableLobbies")] [assembly: AssemblyTitle("PlayableLobbies")] [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 RepoMods.PlayableLobbies { [BepInPlugin("repo.playable.lobbies", "Playable Lobbies", "1.0.0")] public sealed class PlayableLobbiesPlugin : BaseUnityPlugin { private Harmony? _harmony; private ConfigEntry<bool> _enabledConfig = null; private ConfigEntry<bool> _autoEnableConfig = null; private ConfigEntry<KeyCode> _toggleKeyConfig = null; private ConfigEntry<KeyCode> _interactionHoldKeyConfig = null; private bool _immersiveEnabled; private bool _captureActive; private bool _lobbyHintLogged; internal static PlayableLobbiesPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static bool WantsImmersiveView => (Object)(object)Instance != (Object)null && Instance.ShouldUseImmersiveView(); internal static bool WantsCapturedMouse => (Object)(object)Instance != (Object)null && Instance.ShouldCaptureMouse(); private void Awake() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown Instance = this; ((Object)this).hideFlags = (HideFlags)61; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Log = ((BaseUnityPlugin)this).Logger; _enabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Playable Lobbies."); _autoEnableConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoEnableInLobbyMenu", true, "Automatically enable immersive lobby view when entering the waiting room."); _toggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "ToggleImmersiveKey", (KeyCode)289, "Toggle the immersive lobby view on or off."); _interactionHoldKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "HoldForMenuCursor", (KeyCode)308, "Hold this key to use the lobby cursor and buttons without leaving the first-person view."); _immersiveEnabled = _autoEnableConfig.Value; try { _harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); _harmony.PatchAll(typeof(PlayableLobbiesPlugin).Assembly); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Playable Lobbies failed to patch: {arg}"); } } private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(_toggleKeyConfig.Value) && SemiFunc.RunIsLobbyMenu()) { _immersiveEnabled = !_immersiveEnabled; ((BaseUnityPlugin)this).Logger.LogInfo((object)(_immersiveEnabled ? "Playable Lobbies enabled for this waiting room." : "Playable Lobbies disabled for this waiting room.")); } bool flag = ShouldUseImmersiveView(); bool flag2 = ShouldCaptureMouse(); if (flag && !_lobbyHintLogged) { _lobbyHintLogged = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Playable Lobbies active. Move the mouse to look around. Hold {_interactionHoldKeyConfig.Value} to use the lobby cursor. Press {_toggleKeyConfig.Value} to toggle."); } else if (!flag) { _lobbyHintLogged = false; } if (_captureActive != flag2) { if (flag2) { ApplyCapturedCursorState(); } else { ReleaseCapturedCursorState(SemiFunc.RunIsLobbyMenu()); } _captureActive = flag2; } if (_captureActive) { ApplyCapturedCursorState(); } else if (flag) { FreezeAim(); RestoreMenuCursorComponent(); } } private void OnDestroy() { ReleaseCapturedCursorState(restoreLobbyCursor: false); Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private bool ShouldUseImmersiveView() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 if (!_enabledConfig.Value || !_immersiveEnabled) { return false; } if (!SemiFunc.RunIsLobbyMenu()) { return false; } if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { return false; } if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState < 2) { return false; } if ((Object)(object)PlayerAvatar.instance == (Object)null || (Object)(object)CameraAim.Instance == (Object)null || (Object)(object)CameraPosition.instance == (Object)null) { return false; } return true; } private bool ShouldCaptureMouse() { if (!ShouldUseImmersiveView()) { return false; } return !IsInteractionRequested(); } private bool IsInteractionRequested() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKey(_interactionHoldKeyConfig.Value)) { return true; } if ((Object)(object)ChatManager.instance != (Object)null && ChatManager.instance.chatActive) { return true; } if ((Object)(object)MenuManager.instance != (Object)null && MenuManager.instance.textInputActive) { return true; } return false; } private static void FreezeAim() { if (!((Object)(object)CameraAim.Instance == (Object)null)) { CameraAim.Instance.overrideAimStop = true; CameraAim.Instance.overrideAimStopTimer = 0.2f; } } private static void ApplyCapturedCursorState() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)CursorManager.instance != (Object)null) { CursorManager.instance.unlockTimer = -1234f; } Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0); FreezeAimStopRelease(); HideMenuCursor(); } private static void ReleaseCapturedCursorState(bool restoreLobbyCursor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0); RestoreMenuCursorComponent(); if (restoreLobbyCursor && SemiFunc.RunIsLobbyMenu()) { if ((Object)(object)CursorManager.instance != (Object)null) { CursorManager.instance.Unlock(0.1f); } else { Cursor.lockState = (CursorLockMode)0; } Cursor.visible = false; } } private static void FreezeAimStopRelease() { if (!((Object)(object)CameraAim.Instance == (Object)null)) { CameraAim.Instance.overrideAimStop = false; CameraAim.Instance.overrideAimStopTimer = 0f; } } private static void HideMenuCursor() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MenuCursor.instance == (Object)null)) { ((Behaviour)MenuCursor.instance).enabled = false; MenuCursor.instance.showTimer = 0f; MenuCursor.instance.overridePosTimer = 0f; if ((Object)(object)MenuCursor.instance.mesh != (Object)null) { MenuCursor.instance.mesh.SetActive(false); } ((Component)MenuCursor.instance).transform.localScale = Vector3.zero; } } private static void RestoreMenuCursorComponent() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MenuCursor.instance == (Object)null)) { ((Behaviour)MenuCursor.instance).enabled = true; MenuCursor.instance.showTimer = 0f; MenuCursor.instance.overridePosTimer = 0f; if ((Object)(object)MenuCursor.instance.mesh != (Object)null) { MenuCursor.instance.mesh.SetActive(false); } ((Component)MenuCursor.instance).transform.localScale = Vector3.zero; } } } [HarmonyPatch(typeof(CursorManager), "Unlock")] internal static class PlayableLobbiesCursorUnlockPatch { private static bool Prefix() { return !PlayableLobbiesPlugin.WantsCapturedMouse; } } [HarmonyPatch(typeof(MenuCursor), "Show")] internal static class PlayableLobbiesMenuCursorShowPatch { private static bool Prefix() { return !PlayableLobbiesPlugin.WantsCapturedMouse; } } [HarmonyPatch(typeof(CameraAim), "Update")] internal static class PlayableLobbiesCameraAimPatch { private static void Postfix(CameraAim __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (PlayableLobbiesPlugin.WantsImmersiveView) { ((Component)__instance).transform.localRotation = __instance.playerAim; } } } [HarmonyPatch(typeof(CameraPosition), "Update")] internal static class PlayableLobbiesCameraPositionPatch { private static void Postfix(CameraPosition __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (PlayableLobbiesPlugin.WantsImmersiveView && !((Object)(object)__instance.playerTransform == (Object)null)) { ((Component)__instance).transform.localPosition = __instance.playerTransform.localPosition + __instance.playerOffset; ((Component)__instance).transform.localRotation = Quaternion.identity; } } } [HarmonyPatch(typeof(CameraZoom), "Update")] internal static class PlayableLobbiesCameraZoomPatch { private static void Postfix(CameraZoom __instance) { if (!PlayableLobbiesPlugin.WantsImmersiveView) { return; } float num = (__instance.zoomCurrent = ((__instance.OverrideZoomCurve == null) ? __instance.zoomNew : Mathf.LerpUnclamped(__instance.zoomPrev, __instance.zoomNew, __instance.OverrideZoomCurve.Evaluate(__instance.zoomLerp)))); foreach (Camera cam in __instance.cams) { if (!((Object)(object)cam == (Object)null)) { cam.fieldOfView = Mathf.Clamp(num + __instance.SprintZoomCurrent + __instance.TumbleVelocityZoom, __instance.MinimumZoom, __instance.MaximumZoom); } } } } }