Decompiled source of RecentPlayers v1.0.0

RecentPlayersMod.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using RecentPlayersMod.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RecentPlayersMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RecentPlayersMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4201eb57-67ad-4dcd-a766-c0410e7d84f1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RecentPlayersMod
{
	[BepInPlugin("RandomB_oi.RecentlyPlayedWith", "Recent Players", "1.0.0.0")]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "RandomB_oi.RecentlyPlayedWith";

		private const string modName = "Recent Players";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("RandomB_oi.RecentlyPlayedWith");

		internal static ModBase Instance;

		internal static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("RandomB_oi.RecentlyPlayedWith");
			mls.LogInfo((object)"LC RPL is loaded");
			harmony.PatchAll(typeof(ModBase));
			harmony.PatchAll(typeof(MainPatcher));
		}
	}
}
namespace RecentPlayersMod.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class MainPatcher
	{
		public static int UniqueLobbyID;

		public static string[] previousFile;

		public static void LogIds(PlayerControllerB[] allPlayers)
		{
			string[] array = new string[allPlayers.Length + 1];
			array[0] = "Visit their profile by putting their id at the end of this link https://steamcommunity.com/profiles/";
			for (int i = 0; i < allPlayers.Length; i++)
			{
				PlayerControllerB val = allPlayers[i];
				ulong playerSteamId = val.playerSteamId;
				string playerUsername = val.playerUsername;
				array[i + 1] = playerUsername.ToString() + " : " + playerSteamId;
			}
			if (previousFile != null)
			{
				bool flag = true;
				for (int j = 0; j < previousFile.Length; j++)
				{
					if (previousFile[j] != array[j])
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					return;
				}
			}
			previousFile = array;
			string text = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/RecentLCPlayers";
			Directory.CreateDirectory(text);
			using StreamWriter streamWriter = new StreamWriter(Path.Combine(text, "RecentlyPlayedWith" + UniqueLobbyID + ".txt"));
			string[] array2 = array;
			foreach (string value in array2)
			{
				streamWriter.WriteLine(value);
			}
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void logIds(ref PlayerControllerB[] ___allPlayerScripts)
		{
			ModBase.mls.LogMessage((object)"log dem ids");
			UniqueLobbyID = StartOfRound.Instance.randomMapSeed;
			LogIds(___allPlayerScripts);
		}
	}
}