using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Steamworks;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RecentlyPlayedWith")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RecentlyPlayedWith")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c89b5056-b45d-48f1-bdba-0766aca5b4de")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(SteamLobbyHandler), "OnLobbyEnter")]
internal class Patch_OnLobbyEnter
{
private static void Postfix(LobbyEnter_t param)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (param.m_EChatRoomEnterResponse != 1)
{
return;
}
CSteamID val = default(CSteamID);
((CSteamID)(ref val))..ctor(param.m_ulSteamIDLobby);
if (SteamManager.Initialized)
{
int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(val);
RecentlyPlayedWithPeak.DebugLog($"Lobby entered, members: {numLobbyMembers}");
for (int i = 0; i < numLobbyMembers; i++)
{
CSteamID lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(val, i);
RecentlyPlayedWithPeak.MarkPlayedWith(lobbyMemberByIndex.m_SteamID, "LobbyEnter");
}
}
}
}
[HarmonyPatch(typeof(SteamLobbyHandler), "OnLobbyChat")]
internal class Patch_OnLobbyChat
{
private static void Postfix(LobbyChatMsg_t param)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
RecentlyPlayedWithPeak.MarkPlayedWith(param.m_ulSteamIDUser, "LobbyChat");
}
}
[HarmonyPatch(typeof(SteamLobbyHandler), "LeaveLobby")]
internal class Patch_LeaveLobby
{
private static void Prefix()
{
RecentlyPlayedWithPeak.ClearSession();
}
}
[BepInPlugin("com.yourname.peak.recentlyplayedwith", "PEAK Recently Played With", "1.0.0")]
public class RecentlyPlayedWithPeak : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.yourname.peak.recentlyplayedwith";
public const string PLUGIN_NAME = "PEAK Recently Played With";
public const string PLUGIN_VERSION = "1.0.0";
internal static RecentlyPlayedWithPeak Instance;
internal static ConfigEntry<bool> ConfigEnabled;
internal static ConfigEntry<bool> ConfigDebug;
internal static ConfigEntry<bool> ConfigLogNames;
internal Harmony harmony;
internal static HashSet<ulong> SeenPlayers = new HashSet<ulong>();
private void Awake()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
Instance = this;
ConfigEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Recently Played With tracking");
ConfigDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Enable verbose debug logging");
ConfigLogNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "LogUsernames", true, "Log Steam usernames alongside SteamIDs");
harmony = new Harmony("com.yourname.peak.recentlyplayedwith");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PEAK Recently Played With loaded");
}
internal static void Log(string message)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
}
internal static void DebugLog(string message)
{
if (ConfigDebug.Value)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[DEBUG] " + message));
}
}
internal static void ClearSession()
{
SeenPlayers.Clear();
DebugLog("Cleared session player list");
}
internal static void MarkPlayedWith(ulong steamId, string reason)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigEnabled.Value || !SteamManager.Initialized || steamId == 0)
{
return;
}
ulong steamID = SteamUser.GetSteamID().m_SteamID;
if (steamId != steamID && !SeenPlayers.Contains(steamId))
{
SeenPlayers.Add(steamId);
SteamFriends.SetPlayedWith(new CSteamID(steamId));
string arg = "Unknown";
if (ConfigLogNames.Value)
{
arg = SteamFriends.GetFriendPersonaName(new CSteamID(steamId));
}
Log($"[RPW] {arg} ({steamId}) | Reason: {reason}");
}
}
}