using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Photon.Pun;
using Steamworks;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace peakReconnect;
[BepInPlugin("peakReconnect", "peakReconnect", "1.0.0")]
public class peakReconnect : BaseUnityPlugin
{
private static ConfigEntry<string> lastServerConfig;
private static ConfigEntry<Key> keyboardConfig;
private static Key keyboardBind;
private static ConfigEntry<GamepadButton> controllerConfig;
private static GamepadButton controllerBind;
private static CSteamID lastServer;
public static peakReconnect Instance { get; private set; }
private void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
keyboardConfig = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "keyboardKey", (Key)25, "keyboard bind to reconnect");
keyboardBind = keyboardConfig.Value;
controllerConfig = ((BaseUnityPlugin)this).Config.Bind<GamepadButton>("Keybinds", "controllerButton", (GamepadButton)32, "controller bind to reconnect");
controllerBind = controllerConfig.Value;
lastServerConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "lastServer", "", "steam join code of the last lobby you were in");
if (!string.IsNullOrEmpty(lastServerConfig.Value) && ulong.TryParse(lastServerConfig.Value, out var result))
{
lastServer = new CSteamID(result);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Last server loaded: " + ((object)(CSteamID)(ref lastServer)).ToString()));
}
else
{
lastServer = CSteamID.Nil;
((BaseUnityPlugin)this).Logger.LogInfo((object)"No last server found, defaulting to Nil");
}
GameObject val = new GameObject("peakReconnect");
val.AddComponent<onConnect>();
Object.DontDestroyOnLoad((Object)val);
}
private static void JoinLobby()
{
//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)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
if (lastServer == CSteamID.Nil)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Last server is Nil, halting join attempt");
return;
}
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("attempting to join steam ID: " + ((object)(CSteamID)(ref lastServer)).ToString()));
SteamLobbyHandler service = GameHandler.GetService<SteamLobbyHandler>();
if (service == null)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"SteamLobbyHandler not found.");
return;
}
MethodInfo method = typeof(SteamLobbyHandler).GetMethod("JoinLobby", BindingFlags.Instance | BindingFlags.NonPublic);
if (method == null)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"JoinLobby method not found.");
return;
}
method.Invoke(service, new object[1] { lastServer });
}
private void Update()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (((Keyboard.current != null && ((ButtonControl)Keyboard.current[keyboardBind]).wasPressedThisFrame) || (Gamepad.current != null && Gamepad.current[controllerBind].wasPressedThisFrame)) && !GameHandler.GetService<SteamLobbyHandler>().InSteamLobby())
{
JoinLobby();
}
}
public void UpdateConfig(CSteamID steamID)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
lastServer = steamID;
lastServerConfig.Value = steamID.m_SteamID.ToString();
((BaseUnityPlugin)this).Config.Save();
}
}
public class onConnect : MonoBehaviourPunCallbacks
{
public override void OnJoinedRoom()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
CSteamID steamID = default(CSteamID);
if (GameHandler.GetService<SteamLobbyHandler>().InSteamLobby(ref steamID))
{
peakReconnect.Instance.UpdateConfig(steamID);
}
((MonoBehaviourPunCallbacks)this).OnJoinedRoom();
}
}