Decompiled source of View Player Perks v1.0.2

ViewPlayerPerks.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
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.Logging;
using ExitGames.Client.Photon;
using Gameplay.Perks;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Realtime;
using ResourceAssets;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ViewPlayerPerks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows players to see other players perk trees. Client Side.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+cf59438c745077af7f402a33cc893b78e53f98a2")]
[assembly: AssemblyProduct("ViewPlayerPerks")]
[assembly: AssemblyTitle("Allows players to see other players perk trees. Client Side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 ViewPlayerPerks
{
	[BepInPlugin("Mest.ViewPlayerPerks", "View Player Perks", "1.0.2")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static BepinPlugin instance;

		internal static ManualLogSource Log;

		private void Awake()
		{
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Mest.ViewPlayerPerks is loaded!");
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "Mest";

		public override string Description => "Allows players to see other players perk trees. Client Side.";

		public override string ThunderstoreID => "";
	}
	internal class PlayerPerkSettings : PlayerSettingsMenu
	{
		private GUISkin _cachedSkin;

		private GUISkin _defaultSkin;

		private int spentPerks;

		private int PerkPoints;

		private int PlayerLevel;

		private List<PerkRef> activePerks;

		private Dictionary<GUIDUnion, int> buffLevels;

		public override void Refresh(Player selectedPlayer)
		{
			if (selectedPlayer != null)
			{
				if (((Dictionary<object, object>)(object)selectedPlayer.CustomProperties).TryGetValue((object)"RP_PR", out object value))
				{
					PerkPoints = (int)value + 1;
				}
				if (((Dictionary<object, object>)(object)selectedPlayer.CustomProperties).TryGetValue((object)"RP_FR", out value))
				{
					PlayerLevel = (int)value;
				}
				activePerks = GetActivePerks(selectedPlayer.CustomProperties);
				PerkRef item = activePerks[0];
				PerkRef item2 = activePerks[3];
				activePerks.RemoveAt(3);
				activePerks.RemoveAt(0);
				activePerks.Insert(2, item);
				activePerks.Insert(3, item2);
				buffLevels = GetPerkBuffLevels(selectedPlayer.CustomProperties);
			}
		}

		public override void Draw(Player selectedPlayer)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Invalid comparison between Unknown and I4
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Invalid comparison between Unknown and I4
			_cachedSkin = Object.Instantiate<GUISkin>(GUI.skin);
			VerticalScope val = new VerticalScope(Array.Empty<GUILayoutOption>());
			try
			{
				VerticalScope val2 = new VerticalScope(Array.Empty<GUILayoutOption>());
				try
				{
					HorizontalScope val3 = new HorizontalScope(Array.Empty<GUILayoutOption>());
					try
					{
						GUILayout.Label($"Perk Points: {PerkPoints - spentPerks}", Array.Empty<GUILayoutOption>());
						GUILayout.Label($"Player Level: {PlayerLevel}", Array.Empty<GUILayoutOption>());
						if (GUILayout.Button("Refresh", Array.Empty<GUILayoutOption>()))
						{
							((PlayerSettingsMenu)this).Refresh(selectedPlayer);
						}
					}
					finally
					{
						((IDisposable)val3)?.Dispose();
					}
					HorizontalScope val4 = new HorizontalScope(Array.Empty<GUILayoutOption>());
					try
					{
						spentPerks = 0;
						foreach (PerkRef activePerk in activePerks)
						{
							VerticalScope val5 = new VerticalScope(Array.Empty<GUILayoutOption>());
							try
							{
								GUILayout.Label(((ResourceAssetRef)activePerk).Filename.Substring(9), Array.Empty<GUILayoutOption>());
								GUI.skin = _defaultSkin;
								GUILayout.HorizontalSlider(0f, 100f, 100f, Array.Empty<GUILayoutOption>());
								GUI.skin = _cachedSkin;
								foreach (PerkBuffRef buff in ((ResourceAssetRef<PerkContainer, Perk, PerkDef>)(object)activePerk).Asset.Buffs)
								{
									PerkBuff asset = ((ResourceAssetRef<PerkBuffContainer, PerkBuff, PerkBuffDef>)(object)buff).Asset;
									if (!((Object)(object)asset != (Object)null) || !(asset.DisplayName != "Coming Soon!"))
									{
										continue;
									}
									int num = 0;
									if (buffLevels.ContainsKey(((ResourceAssetRef)buff).AssetGuid))
									{
										num = buffLevels[((ResourceAssetRef)buff).AssetGuid];
									}
									if (num > 0)
									{
										HorizontalScope val6 = new HorizontalScope(Array.Empty<GUILayoutOption>());
										try
										{
											spentPerks += num;
											GUILayout.Label(((int)asset.DisplayType == 2) ? ("<color=yellow><b>" + asset.DisplayName + "</b></color>") : (((int)asset.DisplayType == 1) ? ("<color=orange>" + asset.DisplayName + "</color>") : asset.DisplayName), Array.Empty<GUILayoutOption>());
											GUILayout.Label(num.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(32f) });
										}
										finally
										{
											((IDisposable)val6)?.Dispose();
										}
									}
								}
							}
							finally
							{
								((IDisposable)val5)?.Dispose();
							}
						}
					}
					finally
					{
						((IDisposable)val4)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val2)?.Dispose();
				}
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}

		public List<PerkRef> GetActivePerks(Hashtable hashtable)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			List<PerkRef> list = new List<PerkRef>();
			if (!((Dictionary<object, object>)(object)hashtable).TryGetValue((object)"ACP", out object value))
			{
				return list;
			}
			int[] array = (int[])value;
			for (int i = 0; i < array.Length / 4; i++)
			{
				list.Add(new PerkRef(new int[4]
				{
					array[i * 4],
					array[i * 4 + 1],
					array[i * 4 + 2],
					array[i * 4 + 3]
				}));
			}
			return list;
		}

		public Dictionary<GUIDUnion, int> GetPerkBuffLevels(Hashtable hashtable)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<GUIDUnion, int> dictionary = new Dictionary<GUIDUnion, int>();
			if (!((Dictionary<object, object>)(object)hashtable).TryGetValue((object)"PBO", out object value) && !((Dictionary<object, object>)(object)hashtable).TryGetValue((object)"PBL", out value))
			{
				return dictionary;
			}
			int[] array = (int[])value;
			for (int i = 0; i < array.Length / 5; i++)
			{
				dictionary.Add(new GUIDUnion(new int[4]
				{
					array[i * 5],
					array[i * 5 + 1],
					array[i * 5 + 2],
					array[i * 5 + 3]
				}), array[i * 5 + 4]);
			}
			return dictionary;
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Mest.ViewPlayerPerks";

		public const string PLUGIN_NAME = "ViewPlayerPerks";

		public const string USERS_PLUGIN_NAME = "View Player Perks";

		public const string PLUGIN_VERSION = "1.0.2";

		public const string PLUGIN_DESCRIPTION = "Allows players to see other players perk trees. Client Side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "Mest";

		public const string PLUGIN_AUTHORS = "Mest";

		public const string PLUGIN_THUNDERSTORE_ID = "";
	}
}