Decompiled source of SBG EZLobbyLink v1.0.1

SBG-EZLobbyLink.dll

Decompiled a month ago
using 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 Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SBG-EZLobbyLink")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+3d61431e4ab753423f25d2524a168bf232231e9e")]
[assembly: AssemblyProduct("EZ Lobby Link")]
[assembly: AssemblyTitle("SBG-EZLobbyLink")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
public enum ButtonAnchor
{
	TopLeft,
	TopRight,
	BottomLeft,
	BottomRight
}
[BepInPlugin("com.kingcox.sbg.ezlobbylink", "SBG EZ Lobby Link", "1.0.1")]
public class LobbyCopierMod : BaseUnityPlugin
{
	private const string AppId = "4069520";

	private string _statusMessage = "";

	private float _messageTimer;

	private ConfigEntry<ButtonAnchor> _anchor;

	private ConfigEntry<float> _offsetX;

	private ConfigEntry<float> _offsetY;

	private ConfigEntry<float> _buttonWidth;

	private ConfigEntry<float> _buttonHeight;

	private void Awake()
	{
		_anchor = ((BaseUnityPlugin)this).Config.Bind<ButtonAnchor>("Button Position", "Anchor", ButtonAnchor.BottomRight, "Screen corner the button is positioned from.");
		_offsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Button Position", "OffsetX", 20f, "Horizontal distance in pixels from the anchor corner.");
		_offsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Button Position", "OffsetY", 60f, "Vertical distance in pixels from the anchor corner.");
		_buttonWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Button Position", "Width", 240f, "Button width in pixels.");
		_buttonHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Button Position", "Height", 40f, "Button height in pixels.");
	}

	private Rect GetButtonRect()
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		float value = _buttonWidth.Value;
		float value2 = _buttonHeight.Value;
		float num = _offsetX.Value;
		float num2 = _offsetY.Value;
		bool num3 = _anchor.Value == ButtonAnchor.TopRight || _anchor.Value == ButtonAnchor.BottomRight;
		bool flag = _anchor.Value == ButtonAnchor.BottomLeft || _anchor.Value == ButtonAnchor.BottomRight;
		if (num3)
		{
			num = (float)Screen.width - value - num;
		}
		if (flag)
		{
			num2 = (float)Screen.height - value2 - num2;
		}
		return new Rect(num, num2, value, value2);
	}

	private void OnGUI()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		if (PauseMenu.IsPaused)
		{
			GUIStyle val = new GUIStyle(GUI.skin.button);
			val.normal.textColor = Color.black;
			val.hover.textColor = Color.black;
			val.fontSize = 16;
			val.fontStyle = (FontStyle)1;
			Rect buttonRect = GetButtonRect();
			if (GUI.Button(buttonRect, "Copy Steam Invite Link", val))
			{
				ExecuteCopy();
			}
			if (_messageTimer > Time.time)
			{
				bool flag = _anchor.Value == ButtonAnchor.TopRight || _anchor.Value == ButtonAnchor.BottomRight;
				bool flag2 = _anchor.Value == ButtonAnchor.BottomLeft || _anchor.Value == ButtonAnchor.BottomRight;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)(flag ? 5 : 3)
				};
				val2.normal.textColor = Color.yellow;
				float num = (flag ? (((Rect)(ref buttonRect)).xMax - 400f) : ((Rect)(ref buttonRect)).x);
				float num2 = (flag2 ? (((Rect)(ref buttonRect)).y - 30f - 5f) : (((Rect)(ref buttonRect)).yMax + 5f));
				GUI.Label(new Rect(num, num2, 400f, 30f), _statusMessage, val2);
			}
		}
	}

	private void ExecuteCopy()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string arg = ((object)SteamClient.SteamId/*cast due to .constrained prefix*/).ToString();
			ulong num = 0uL;
			FieldInfo field = typeof(BNetworkManager).GetField("steamLobby", BindingFlags.Static | BindingFlags.NonPublic);
			if (field != null)
			{
				object value = field.GetValue(null);
				if (value != null)
				{
					PropertyInfo property = value.GetType().GetProperty("Value");
					object obj = ((property != null) ? property.GetValue(value) : value);
					if (obj != null)
					{
						PropertyInfo property2 = obj.GetType().GetProperty("Id");
						if (property2 != null)
						{
							object value2 = property2.GetValue(obj);
							PropertyInfo property3 = value2.GetType().GetProperty("Value");
							num = ((!(property3 != null)) ? ulong.Parse(value2.ToString()) : ((ulong)property3.GetValue(value2)));
						}
					}
				}
			}
			if (num != 0L)
			{
				string text = (GUIUtility.systemCopyBuffer = string.Format("steam://joinlobby/{0}/{1}/{2}", "4069520", num, arg));
				_statusMessage = "Link Copied! ID: " + num;
				_messageTimer = Time.time + 4f;
				Debug.Log((object)("[LobbyCopier] Success! Copied: " + text));
			}
			else
			{
				_statusMessage = "No Active Lobby Found (ID 0)";
				_messageTimer = Time.time + 4f;
			}
		}
		catch (Exception ex)
		{
			_statusMessage = "Reflection Error - Check Log";
			Debug.LogError((object)("[LobbyCopier] Error: " + ex.GetType().Name + " - " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
namespace EZLobbyLink
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SBG-EZLobbyLink";

		public const string PLUGIN_NAME = "EZ Lobby Link";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}