using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[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("LobbyBrowser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Lobby Browser")]
[assembly: AssemblyTitle("LobbyBrowser")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LobbyBrowser
{
[BepInPlugin("LobbyBrowser", "Lobby Browser", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private GameObject canvas;
private Transform hostButton;
private PublicLobbyListUI lobbyBrowser;
private Random random = new Random();
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
Logger = ((BaseUnityPlugin)this).Logger;
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("LobbyBrowser");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
}
logger.LogInfo(val);
SceneManager.sceneLoaded += OnScene;
}
public void OnScene(Scene scene, LoadSceneMode mode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Expected O, but got Unknown
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Expected O, but got Unknown
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "MainMenuScene")
{
return;
}
activeScene = SceneManager.GetActiveScene();
canvas = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name.Contains("Canvas")));
bool flag = default(bool);
if (!Object.op_Implicit((Object)(object)canvas))
{
ManualLogSource logger = Logger;
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Canvas not found - ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<GameObject>(canvas);
}
logger.LogError(val);
return;
}
GameObject obj = canvas;
lobbyBrowser = ((obj != null) ? ((Component)obj.transform.Find("PublicLobbies")).GetComponent<PublicLobbyListUI>() : null);
GameObject obj2 = canvas;
hostButton = ((obj2 != null) ? obj2.transform.Find("UI").Find("Panel").Find("Navbar")
.Find("Host Button") : null);
if (!Object.op_Implicit((Object)(object)lobbyBrowser) || !Object.op_Implicit((Object)(object)hostButton))
{
ManualLogSource logger2 = Logger;
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Browser/Button not found - ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PublicLobbyListUI>(lobbyBrowser);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Transform>(hostButton);
}
logger2.LogError(val);
}
else
{
Transform obj3 = hostButton;
CreateButton("Browse Games", (obj3 != null) ? obj3.parent : null, Vector3.zero, (UnityAction[])(object)new UnityAction[1] { lobbyBrowser.Show });
PublicLobbyListUI obj4 = lobbyBrowser;
CreateButton("Let it ride.", (obj4 != null) ? ((Component)obj4).gameObject.transform : null, new Vector3(-95f, 310f, 0f), (UnityAction[])(object)new UnityAction[1] { LetItRide });
}
}
public void CreateButton(string buttonName, Transform parent, Vector3 position, UnityAction[] actions)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
Transform val = Object.Instantiate<Transform>(hostButton, parent);
((TMP_Text)((Component)val).GetComponentInChildren<TextMeshProUGUI>()).text = buttonName;
((Object)val).name = buttonName;
if (position != Vector3.zero)
{
((Component)val).transform.localPosition = position;
}
val.SetSiblingIndex(1);
SFXGenericUIButtonComponent component = ((Component)val).GetComponent<SFXGenericUIButtonComponent>();
Button component2 = ((Component)val).GetComponent<Button>();
ButtonClickedEvent val2 = new ButtonClickedEvent();
((UnityEventBase)val2).AddListener((object)component, ((object)component).GetType().GetMethod("PlayClick"));
ThreadingExtensions.ForEachParallel<UnityAction>((IList<UnityAction>)actions, (Action<UnityAction>)((UnityEvent)val2).AddListener, -1);
component2.onClick = val2;
}
public void LetItRide()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
List<GameObject> list = ((object)lobbyBrowser).GetType().GetField("_entries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(lobbyBrowser) as List<GameObject>;
if (list == null)
{
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get entries");
}
logger.LogError(val);
}
GameObject obj = list[random.Next(list.Count)];
if (obj != null)
{
obj.GetComponent<PublicLobbyListEntry>().OnClick();
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "LobbyBrowser";
public const string PLUGIN_NAME = "Lobby Browser";
public const string PLUGIN_VERSION = "1.0.0";
}
}