Decompiled source of SteamLobbyCopier v1.1.0

BepInEx/plugins/SteamLobbyCopier/SteamLobbyCopier.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SteamLobbyCopy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SteamLobbyCopy")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("be484b31-a80a-4689-86a8-860993183e31")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SteamSteamLobbyCopier;

[HarmonyPatch(typeof(IngamePlayerSettings), "Awake")]
internal class PlayerSettingsPatch
{
	private static void Postfix(ref IngamePlayerSettings __instance)
	{
		CopyLobbyManager copyLobbyManager = default(CopyLobbyManager);
		if (!((Component)__instance).gameObject.TryGetComponent<CopyLobbyManager>(ref copyLobbyManager))
		{
			CopyLobbyManager copyLobbyManager2 = ((Component)__instance).gameObject.AddComponent<CopyLobbyManager>();
			copyLobbyManager2.playerSettings = __instance;
		}
	}
}
[HarmonyPatch(typeof(HUDManager), "Awake")]
internal class HUDPatch
{
	public static void OnAwake(HUDManager __instance)
	{
		int i;
		for (i = 0; i < __instance.controlTipLines.Length && ((TMP_Text)__instance.controlTipLines[i]).text != ""; i++)
		{
		}
		if (i < __instance.controlTipLines.Length)
		{
			((TMP_Text)__instance.controlTipLines[i]).text = "Steam Lobby Copier Debug Message";
		}
	}
}
[BepInPlugin("com.ItsMoorbinTime.SteamLobbyCopier", "Steam Lobby Copier", "1.1.0")]
public class SteamLobbyCopierBase : BaseUnityPlugin
{
	private const string modGUID = "com.ItsMoorbinTime.SteamLobbyCopier";

	private const string modName = "Steam Lobby Copier";

	private const string modVersion = "1.1.0";

	private static SteamLobbyCopierBase Instance;

	private readonly Harmony harmony = new Harmony("com.ItsMoorbinTime.SteamLobbyCopier");

	public static ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("com.ItsMoorbinTime.SteamLobbyCopier");
		harmony.PatchAll();
		mls.LogInfo((object)"Steam Lobby Copier wakens...");
	}
}
public class CopyLobbyInputActions : LcInputActions
{
	public static CopyLobbyInputActions Instance = new CopyLobbyInputActions();

	[InputAction(/*Could not decode attribute arguments.*/)]
	public InputAction CopyLobbyKey { get; set; }
}
public class CopyLobbyManager : MonoBehaviour
{
	public IngamePlayerSettings playerSettings;

	public static CopyLobbyManager instance;

	public void Awake()
	{
		instance = this;
		CopyLobbyInputActions.Instance.CopyLobbyKey.performed += OnCopyLobbyKeyPressed;
	}

	public void OnDestroy()
	{
		CopyLobbyInputActions.Instance.CopyLobbyKey.performed -= OnCopyLobbyKeyPressed;
	}

	private void OnCopyLobbyKeyPressed(CallbackContext ctx)
	{
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		if (!Application.isFocused || (Object)(object)GameNetworkManager.Instance == (Object)null)
		{
			return;
		}
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if (!localPlayerController.inTerminalMenu && !localPlayerController.isTypingChat)
		{
			if (!GameNetworkManager.Instance.currentLobby.HasValue)
			{
				SteamLobbyCopierBase.mls.LogInfo((object)"No lobby detected...");
				HUDManager.Instance.DisplayTip("Steam Lobby Copier", "No lobby detected...", false, false, "LC_Tip1");
				return;
			}
			Lobby value = GameNetworkManager.Instance.currentLobby.Value;
			string systemCopyBuffer = $"steam://joinlobby/{SteamClient.AppId}/{((Lobby)(ref value)).Id}/{((Lobby)(ref value)).Owner.Id}";
			GUIUtility.systemCopyBuffer = systemCopyBuffer;
			SteamLobbyCopierBase.mls.LogInfo((object)"Steam lobby link successfully copied to clipboard.");
			HUDManager.Instance.DisplayTip("Steam Lobby Copier", "Steam lobby link successfully copied to clipboard.", false, false, "LC_Tip1");
		}
	}
}