using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using REPO_ServerList.Properties;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
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: AssemblyTitle("REPO_ServerList")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO_ServerList")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fafcfe35-5a1d-4819-aebc-c1669943e8c0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace REPO_ServerList
{
[HarmonyPatch]
[BepInPlugin("com.github.qert2002.REPO_ServerList", "REPO_ServerList", "1.0")]
public class REPO_ServerList : BaseUnityPlugin
{
public static REPO_ServerList PluginInstance;
public static ManualLogSource Log;
public static Harmony HarmonyInstance;
public static TMP_FontAsset newFontTextMeshPro;
public static GameObject MainGameObject;
public static GameObject ServerListCanvasObject;
public static GameObject LobbyObj;
public static bool OneTimeInit;
public static GameObject TempServerScreenObject;
public static Lobby[] currentLobbyList;
public static List<Lobby> currentLobbyListWithData;
public static bool IsServerListMenuOpened = false;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
PluginInstance = this;
Log = ((BaseUnityPlugin)this).Logger;
HarmonyInstance = new Harmony("REPO_ServerList");
HarmonyInstance.PatchAll();
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
Log.LogInfo((object)"Loaded!");
}
public static string GetGameObjectPath(GameObject obj)
{
string text = "/" + ((Object)obj).name;
while ((Object)(object)obj.transform.parent != (Object)null)
{
obj = ((Component)obj.transform.parent).gameObject;
text = "/" + ((Object)obj).name + text;
}
return text;
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
if (OneTimeInit)
{
return;
}
OneTimeInit = true;
AssetBundle val = AssetBundle.LoadFromMemory(Resources.ServerList1);
Font[] array = val.LoadAllAssets<Font>();
foreach (Font val2 in array)
{
if (((Object)val2).name == "Teko")
{
newFontTextMeshPro = TMP_FontAsset.CreateFontAsset(val2);
break;
}
}
GameObject[] array2 = val.LoadAllAssets<GameObject>();
foreach (GameObject val3 in array2)
{
if (((Object)val3).name == "Canvas")
{
ServerListCanvasObject = val3;
Log.LogInfo((object)"Canvas founded!");
}
}
val.Unload(false);
if ((Object)(object)MainGameObject == (Object)null)
{
MainGameObject = new GameObject("REPO_ServerList");
Object.DontDestroyOnLoad((Object)(object)MainGameObject);
Log.LogInfo((object)"Loaded!");
}
if ((Object)(object)ServerListCanvasObject != (Object)null)
{
LobbyObj = ((Component)ServerListCanvasObject.transform.Find("Image/Scroll View/Viewport/Content/Lobby_{0}")).gameObject;
}
currentLobbyListWithData = new List<Lobby>();
}
public static async Task JoinLobby(Lobby lobby)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if ((int)(await ((Lobby)(ref lobby)).Join()) == 1)
{
currentLobbyListWithData.Add(lobby);
((Lobby)(ref lobby)).Leave();
}
else
{
((Lobby)(ref lobby)).Leave();
}
}
public static async void RefreshLobbies()
{
currentLobbyList = null;
Log.LogInfo((object)"Requested server list");
for (int i = 0; i < 50; i++)
{
if ((Object)(object)TempServerScreenObject != (Object)null)
{
Transform currLobby = TempServerScreenObject.transform.Find($"Image/Scroll View/Viewport/Content/Lobby_{i}");
if ((Object)(object)currLobby != (Object)null)
{
Object.Destroy((Object)(object)((Component)currLobby).gameObject);
}
}
}
LobbyQuery lobbyQuery = SteamMatchmaking.LobbyList;
LobbyQuery lobbyList = SteamMatchmaking.LobbyList;
lobbyQuery = ((LobbyQuery)(ref lobbyList)).FilterDistanceWorldwide();
currentLobbyList = await ((LobbyQuery)(ref lobbyQuery)).RequestAsync();
if (currentLobbyList != null)
{
Log.LogInfo((object)$"Lobbies getted: {currentLobbyList.Length}");
currentLobbyListWithData.Clear();
Lobby[] array = currentLobbyList;
foreach (Lobby lobbyCool in array)
{
await JoinLobby(lobbyCool);
}
Transform contentLobbyList = TempServerScreenObject.transform.Find("Image/Scroll View/Viewport/Content");
int lobbyNumber = 0;
foreach (Lobby currentLobbyListWithDatum in currentLobbyListWithData)
{
Lobby filledLobby = currentLobbyListWithDatum;
if ((Object)(object)TempServerScreenObject != (Object)null && (Object)(object)contentLobbyList != (Object)null)
{
GameObject newLobbyAboba = Object.Instantiate<GameObject>(LobbyObj, contentLobbyList);
((Object)newLobbyAboba).name = $"Lobby_{lobbyNumber}";
TextMeshProUGUI component = ((Component)newLobbyAboba.transform.Find("LobbyName")).GetComponent<TextMeshProUGUI>();
Friend owner = ((Lobby)(ref filledLobby)).Owner;
((TMP_Text)component).text = "Lobby of " + ((Friend)(ref owner)).Name;
((TMP_Text)((Component)newLobbyAboba.transform.Find("LobbyPlayerCount")).GetComponent<TextMeshProUGUI>()).text = $"{((Lobby)(ref filledLobby)).MemberCount}/{((Lobby)(ref filledLobby)).MaxMembers}";
owner = ((Lobby)(ref filledLobby)).Owner;
Image? ownerImg = await ((Friend)(ref owner)).GetMediumAvatarAsync();
if (ownerImg.HasValue)
{
Texture2D texture2D = new Texture2D((int)ownerImg.Value.Width, (int)ownerImg.Value.Height, (TextureFormat)4, false, true);
texture2D.LoadRawTextureData(ownerImg.Value.Data);
texture2D.Apply();
((Component)newLobbyAboba.transform.Find("LobbyImg")).GetComponent<Image>().sprite = ConvertToSprite(texture2D);
((Transform)((Component)newLobbyAboba.transform.Find("LobbyImg")).GetComponent<RectTransform>()).localRotation = Quaternion.Euler(0f, 0f, -180f);
}
((UnityEvent)((Component)newLobbyAboba.transform.Find("Button")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
SteamId id = ((Lobby)(ref filledLobby)).Id;
Join_Lobby_Btn(((object)(SteamId)(ref id)).ToString());
});
newLobbyAboba.SetActive(true);
lobbyNumber++;
}
}
}
else
{
Log.LogInfo((object)"Something not work");
}
}
public static async void Join_Lobby_Btn(string LobbyId)
{
await TryToJoinInLobby(LobbyId);
}
public static async Task TryToJoinInLobby(string lobbyId)
{
if (!ulong.TryParse(lobbyId, out var lobbyIdUlong))
{
return;
}
SteamId lobbyId2 = SteamId.op_Implicit(lobbyIdUlong);
Debug.Log((object)("[TryToJoinInLobby]SteamId lobby: " + ((object)(SteamId)(ref lobbyId2)).ToString()));
await SteamMatchmaking.JoinLobbyAsync(lobbyId2);
MenuManager.instance.PageCloseAll();
MenuManager.instance.PageOpen((MenuPageIndex)0, false);
if ((Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu)
{
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
player.OutroStartRPC();
}
typeof(RunManager).GetField("lobbyJoin", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(RunManager.instance, true);
RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)3);
}
typeof(SteamManager).GetField("joinLobby", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(SteamManager.instance, true);
lobbyId2 = default(SteamId);
}
public static Sprite ConvertToSprite(Texture2D texture)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.zero);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MenuPageMain), "ButtonEventJoinGame")]
public static bool OV_MenuPageMain_ButtonEventJoinGame(MenuPageMain __instance)
{
if ((Object)(object)__instance != (Object)null)
{
SemiFunc.MainMenuSetSingleplayer();
MenuManager.instance.PageCloseAll();
IsServerListMenuOpened = true;
MenuManager.instance.PageOpen((MenuPageIndex)11, false);
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MenuManager), "PageOpen")]
public static void OV_MenuManager_PageOpen(MenuManager __instance, MenuPage __result)
{
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Expected O, but got Unknown
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance != (Object)null) || !((Object)(object)__result != (Object)null) || !IsServerListMenuOpened)
{
return;
}
IsServerListMenuOpened = false;
Log.LogInfo((object)"Opened server list menu!");
GameObject gameObject = ((Component)__result).gameObject;
if (!((Object)(object)gameObject == (Object)null))
{
string text = "THIS IS FUCKING FIX OF ERRORS IN GAMEDEV, the guys wrote all the interaction with the UI from scratch, because due to these errors below, the vanilla EVENTSYSTEM interaction did not work, I FIX THIS 6 HOURS";
((Graphic)GameObject.Find("UI/HUD/HUD Canvas/Fade").gameObject.GetComponent<Image>()).raycastTarget = false;
((Graphic)GameObject.Find("UI/HUD/HUD Canvas/Render Texture Video").gameObject.GetComponent<RawImage>()).raycastTarget = false;
GraphicRaycaster component = GameObject.Find("UI/UI/Canvas").gameObject.GetComponent<GraphicRaycaster>();
Object.Destroy((Object)(object)component);
GameObject val = GameObject.Find("UI/HUD/Camera Overlay");
Camera component2 = val.GetComponent<Camera>();
GameObject val2 = GameObject.Find("UI/HUD/clearCameraRay");
if ((Object)(object)val2 == (Object)null)
{
val.SetActive(false);
val2 = Object.Instantiate<GameObject>(val, GameObject.Find("UI/HUD/").transform);
Object.Destroy((Object)(object)val2.GetComponent<CameraOverlay>());
((Object)val2).name = "clearCameraRay";
val2.transform.position = val.transform.position;
val.SetActive(true);
val2.SetActive(true);
}
Camera component3 = val2.GetComponent<Camera>();
component3.targetTexture = null;
GameObject val3 = GameObject.Find("UI/HUD/HUD Canvas");
Canvas component4 = val3.GetComponent<Canvas>();
component4.worldCamera = component3;
string text2 = "THIS IS FUCKING FIX OF ERRORS IN GAMEDEV, the guys wrote all the interaction with the UI from scratch, because due to these errors below, the vanilla EVENTSYSTEM interaction did not work, I FIX THIS 6 HOURS";
((Component)gameObject.transform.Find("Mode Header")).gameObject.SetActive(false);
((Component)gameObject.transform.Find("Save File Info")).gameObject.SetActive(false);
((TMP_Text)((Component)gameObject.transform.Find("Header").Find("Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = "SERVER LIST";
((Component)gameObject.transform.Find("Menu Scroll Box")).gameObject.SetActive(false);
TempServerScreenObject = Object.Instantiate<GameObject>(ServerListCanvasObject);
TempServerScreenObject.transform.SetParent(gameObject.transform);
TempServerScreenObject.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
TempServerScreenObject.transform.position = new Vector3(350f, 170f, 0f);
Button component5 = ((Component)TempServerScreenObject.transform.Find("Image/RefreshLobbiesButton")).GetComponent<Button>();
((UnityEvent)component5.onClick).AddListener(new UnityAction(RefreshLobbies));
Button component6 = ((Component)TempServerScreenObject.transform.Find("Image/ConnectToFriendButton")).GetComponent<Button>();
((UnityEvent)component6.onClick).AddListener(new UnityAction(ConnectToFriend));
}
}
public static void ConnectToFriend()
{
MenuManager.instance.PageCloseAll();
MenuManager.instance.PageOpen((MenuPageIndex)0, false);
SteamManager.instance.OpenSteamOverlayToLobby();
}
public static void OV_MenuPageSaves_Start(MenuPageSaves __instance)
{
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance != (Object)null && IsServerListMenuOpened)
{
Log.LogInfo((object)"Opened server list menu!");
GameObject gameObject = ((Component)__instance).gameObject;
if (!((Object)(object)gameObject == (Object)null))
{
((Component)gameObject.transform.Find("Mode Header")).gameObject.SetActive(false);
((Component)gameObject.transform.Find("Save File Info")).gameObject.SetActive(false);
((TMP_Text)((Component)gameObject.transform.Find("Header").Find("Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = "SERVER LIST";
((Component)gameObject.transform.Find("Menu Scroll Box")).gameObject.SetActive(false);
((Component)EventSystem.current).gameObject.SetActive(false);
GameObject val = Object.Instantiate<GameObject>(ServerListCanvasObject);
val.transform.SetParent(gameObject.transform);
val.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
val.transform.position = new Vector3(350f, 170f, 0f);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MenuPageSaves), "OnGoBack")]
public static void OnGoBack()
{
if (IsServerListMenuOpened)
{
Log.LogInfo((object)"Closed server list menu!");
IsServerListMenuOpened = false;
}
}
}
}
namespace REPO_ServerList.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
public class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("REPO_ServerList.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
public static string ServerList => ResourceManager.GetString("ServerList", resourceCulture);
public static byte[] ServerList1
{
get
{
object @object = ResourceManager.GetObject("ServerList1", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}