Decompiled source of ButteredLillysModDisplay v1.0.0

Lillys_Mod_Display.dll

Decompiled 20 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Lillys_Mod_Display;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MelonLoad), "Lillys Mod Display", "1.0.1", "Lilly", null)]
[assembly: MelonGame("KisSoft", "ATLYSS")]
[assembly: MelonOptionalDependencies(new string[] { "BepInEx" })]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Lillys_Mod_Display")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e0f68a0dbd37ac3253779277e215e13a6d6e81b9")]
[assembly: AssemblyProduct("Lillys_Mod_Display")]
[assembly: AssemblyTitle("Lillys_Mod_Display")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 Lillys_Mod_Display
{
	[BepInPlugin("516b9dfb-3ee3-4483-9be3-f685db5717ac", "Lillys Mod Display", "1.0.1")]
	public class Bepin : BaseUnityPlugin
	{
		private ModDisplayCore disCore;

		private void Awake()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			if ((Object)(object)ModDisplayCore.DisplayCoreInstance != (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(GameObject.CreatePrimitive((PrimitiveType)3));
			((Object)val).hideFlags = (HideFlags)61;
			disCore = val.AddComponent<ModDisplayCore>();
			disCore.Logger = logger;
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				try
				{
					disCore.ModList.Add(pluginInfo.Value.Metadata.Name);
				}
				catch (Exception)
				{
				}
			}
			Harmony val2 = new Harmony("Lillys Mod Display");
			val2.PatchAll();
		}

		public bool logger(string mesg)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)(mesg ?? ""));
			return true;
		}
	}
	public class ModDisplayCore : MonoBehaviour
	{
		[HarmonyPatch(typeof(WhoListDataEntry), "Select_Entry")]
		public static class setList
		{
			[HarmonyPrefix]
			private static void Postfix(ref WhoListDataEntry __instance)
			{
				try
				{
					string text = "Mods:\n\n";
					foreach (string item in DisplayCoreInstance.usersMods[__instance._player._steamID])
					{
						text += item;
						text += "\n";
					}
					((TMP_Text)DisplayCoreInstance.modlister).text = text;
				}
				catch (Exception)
				{
					((TMP_Text)DisplayCoreInstance.modlister).text = "No List Found";
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnGameConditionChange")]
		public static class playerLoaded
		{
			[HarmonyPrefix]
			private static void Prefix(ref Player __instance)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Invalid comparison between Unknown and I4
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Invalid comparison between Unknown and I4
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				//IL_00ce: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if ((int)__instance.Network_currentGameCondition == 1)
					{
						byte[] bytes = Encoding.ASCII.GetBytes(DisplayCoreInstance.ModListString);
						CSteamID val = default(CSteamID);
						((CSteamID)(ref val))..ctor(SteamLobby._current._currentLobbyID);
						SteamMatchmaking.SendLobbyChatMsg(val, bytes, bytes.Length);
					}
					if ((int)__instance.Network_currentGameCondition == 1 && (Object)(object)DisplayCoreInstance.modlister == (Object)null)
					{
						DisplayCoreInstance.Logger("adding list");
						DisplayCoreInstance.usersMods = new Dictionary<string, List<string>>();
						GameObject val2 = Object.Instantiate<GameObject>(new GameObject(), GameObject.Find("_GameUI_TabMenu/Canvas_InGameMenu/Dolly_MenuIndex/_cell_whoMenu/_steamworksPanel/").transform);
						DisplayCoreInstance.modlister = val2.AddComponent<TextMeshProUGUI>();
						val2.transform.localPosition = new Vector3(-280f, -25f, 0f);
						val2.transform.localScale = Vector3.one * 0.75f;
						((TMP_Text)DisplayCoreInstance.modlister).text = "";
						((TMP_Text)DisplayCoreInstance.modlister).enableAutoSizing = true;
						((TMP_Text)DisplayCoreInstance.modlister).paragraphSpacing = 55f;
					}
				}
				catch (Exception ex)
				{
					DisplayCoreInstance.Logger(ex.Message);
					DisplayCoreInstance.Logger("missing");
				}
			}
		}

		public static ModDisplayCore DisplayCoreInstance;

		public List<string> ModList = new List<string>();

		public string ModListString = "";

		public Func<string, bool> Logger;

		protected Callback<LobbyChatMsg_t> messageRecived;

		public IDictionary<string, List<string>> usersMods;

		private TextMeshProUGUI modlister;

		private void Start()
		{
			DisplayCoreInstance = this;
			messageRecived = Callback<LobbyChatMsg_t>.Create((DispatchDelegate<LobbyChatMsg_t>)onMessage);
			usersMods = new Dictionary<string, List<string>>();
			ModListString += "MODLIST";
			foreach (string mod in ModList)
			{
				ModListString += ",";
				ModListString += mod;
			}
			Logger("in core: " + ModListString);
		}

		private void onMessage(LobbyChatMsg_t callback)
		{
			//IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = 32000;
				byte[] array = new byte[num];
				CSteamID val = default(CSteamID);
				EChatEntryType val2 = default(EChatEntryType);
				SteamMatchmaking.GetLobbyChatEntry((CSteamID)callback.m_ulSteamIDLobby, (int)callback.m_iChatID, ref val, array, num, ref val2);
				string @string = Encoding.ASCII.GetString(array);
				if (@string.Contains("MODLIST"))
				{
					List<string> list = @string.Split(',').ToList();
					list.Remove("MODLIST");
					findPlayer((CSteamID)callback.m_ulSteamIDUser, list);
				}
			}
			catch (Exception)
			{
			}
		}

		private void findPlayer(CSteamID steamID, List<string> mods)
		{
			try
			{
				usersMods.Add(((object)(CSteamID)(ref steamID)).ToString(), mods);
			}
			catch (Exception)
			{
			}
		}
	}
	public class MelonLoad : MelonMod
	{
		private ModDisplayCore disCore = null;

		public override void OnInitializeMelon()
		{
			if ((Object)(object)ModDisplayCore.DisplayCoreInstance != (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(GameObject.CreatePrimitive((PrimitiveType)3));
			((Object)val).hideFlags = (HideFlags)61;
			disCore = val.AddComponent<ModDisplayCore>();
			foreach (MelonBase registeredMelon in MelonBase.RegisteredMelons)
			{
				try
				{
					disCore.ModList.Add(registeredMelon.Info.Name);
				}
				catch (Exception ex)
				{
					MelonLogger.Msg((object)ex);
				}
			}
			disCore.Logger = logger;
		}

		public bool logger(string mesg)
		{
			MelonLogger.Msg(mesg);
			return true;
		}
	}
}