Decompiled source of AnotherProfileViewer v1.0.0

AnotherProfileViewer.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Death__123")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7e5eda7a51f16028bcf75b99bf9902e63eecb94d")]
[assembly: AssemblyProduct("AnotherProfileViewer")]
[assembly: AssemblyTitle("AnotherProfileViewer")]
[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 AnotherProfileViewer
{
	[BepInPlugin("me.Death.Plugin.REPO.AnotherProfileViewer", "AnotherProfileViewer", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private bool ShowGUI;

		private static ConfigEntry<KeyboardShortcut> OpenMenuKey;

		private Vector2 PlayerListScrollView;

		private Rect WindowRect;

		private bool FirstSet;

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin me.Death.Plugin.REPO.AnotherProfileViewer is loaded!");
			OpenMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "OpenListKey", new KeyboardShortcut((KeyCode)105, Array.Empty<KeyCode>()), "打开列表\nOpen menu");
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = OpenMenuKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				if (!FirstSet)
				{
					FirstSet = true;
					WindowRect = new Rect((float)Screen.width * 0.6f, (float)Screen.height * 0.2f, (float)Screen.width * 0.2f, (float)Screen.height * 0.7f);
				}
				ShowGUI = !ShowGUI;
			}
		}

		private void OnGUI()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (ShowGUI)
			{
				WindowRect = GUILayout.Window(0, WindowRect, new WindowFunction(ListGui), "Another Profile Viewer", GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			}
		}

		private void ListGui(int id)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			GUI.DragWindow(new Rect(0f, 0f, (float)Screen.width * 0.2f, 30f));
			PlayerListScrollView = GUILayout.BeginScrollView(PlayerListScrollView, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("", Array.Empty<GUILayoutOption>());
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				string text = SemiFunc.PlayerGetName(player);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label(text, Array.Empty<GUILayoutOption>());
				GUILayout.FlexibleSpace();
				if (GUILayout.Button("Add Friend", Array.Empty<GUILayoutOption>()))
				{
					OpenProfile(player, friendadd: true);
				}
				if (GUILayout.Button("Open profile", Array.Empty<GUILayoutOption>()))
				{
					OpenProfile(player, friendadd: false);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			GUILayout.EndScrollView();
		}

		public static void OpenProfile(PlayerAvatar player, bool friendadd)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			string text = SemiFunc.PlayerGetSteamID(player);
			if (text == null || !ulong.TryParse(text, out var result))
			{
				Logger.LogWarning((object)"Cannot find or parse steamID for player!");
				return;
			}
			SteamId val = default(SteamId);
			val.Value = result;
			SteamFriends.OpenUserOverlay(val, friendadd ? "friendadd" : "steamid");
			Logger.LogInfo((object)(friendadd ? "Add friend for " : ("Open profile for " + val.Value)));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "me.Death.Plugin.REPO.AnotherProfileViewer";

		public const string PLUGIN_NAME = "AnotherProfileViewer";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}