Decompiled source of BPHider v1.1.1

Mods/BPHider.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BPHider;
using HarmonyLib;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Social;
using Il2CppRUMBLE.Social.Phone;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using RumbleModdingAPI.RMAPI;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "BPHider", "1.1.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 7, 1, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BPHider")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c3d4ddbce098f7b471aa40f40b54f712baf52875")]
[assembly: AssemblyProduct("BPHider")]
[assembly: AssemblyTitle("BPHider")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
}
namespace BPHider
{
	public static class BuildInfo
	{
		public const string ModName = "BPHider";

		public const string ModVersion = "1.1.1";

		public const string Author = "UlvakSkillz";
	}
	public class Main : MelonMod
	{
		[HarmonyPatch(typeof(PlayerNameTag), "UpdatePlayerBPText", new Type[] { })]
		public static class UpdatePlayerBPText
		{
			private static void Postfix(ref PlayerNameTag __instance)
			{
				UpdateBP(__instance);
			}
		}

		[HarmonyPatch(typeof(PlayerTag), "RefreshFriendIcon", new Type[]
		{
			typeof(UserData),
			typeof(FriendStatus),
			typeof(bool)
		})]
		public static class RefreshFriendIcon
		{
			private static void Postfix(ref PlayerTag __instance, UserData userData, FriendStatus friendStatus, bool sendEvent)
			{
				playerTags.Add(__instance);
				UpdateBP(__instance);
			}
		}

		[HarmonyPatch(typeof(ScrollableList), "PageDown", new Type[] { })]
		public static class PageDown
		{
			private static void Postfix(ref ScrollableList __instance)
			{
				UpdateBPs();
			}
		}

		[HarmonyPatch(typeof(ScrollableList), "PageUp", new Type[] { })]
		public static class PageUp
		{
			private static void Postfix(ref ScrollableList __instance)
			{
				UpdateBPs();
			}
		}

		[HarmonyPatch(typeof(ScrollableList), "ScrollDown", new Type[] { })]
		public static class ScrollDown
		{
			private static void Postfix(ref ScrollableList __instance)
			{
				UpdateBPs();
			}
		}

		[HarmonyPatch(typeof(ScrollableList), "ScrollUp", new Type[] { })]
		public static class ScrollUp
		{
			private static void Postfix(ref ScrollableList __instance)
			{
				UpdateBPs();
			}
		}

		[CompilerGenerated]
		private sealed class <HideMatchInfoBP>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Main <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <HideMatchInfoBP>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (enabledInMatches)
					{
						((TMP_Text)matchInfoPlayer1BP).text = "??????";
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private Mod BPHider = new Mod();

		private static bool hideOwn = true;

		private static bool enabledInMatches = true;

		private static bool enabledInGym = false;

		private static bool enabledInParks = false;

		private bool hasMatchInfo = false;

		private static TextMeshPro matchInfoPlayer1BP;

		private static TextMeshPro matchInfoPlayer2BP;

		private static List<PlayerTag> playerTags = new List<PlayerTag>();

		public override void OnLateInitializeMelon()
		{
			UI.instance.UI_Initialized += UIInit;
			Actions.onMyModsGathered += CheckMods;
			Actions.onMapInitialized += MapInit;
		}

		private void MapInit(string map)
		{
			playerTags.Clear();
			if (hasMatchInfo && (map == "Map0" || map == "Map1"))
			{
				MelonCoroutines.Start(HideMatchInfoBP());
			}
		}

		[IteratorStateMachine(typeof(<HideMatchInfoBP>d__11))]
		private IEnumerator HideMatchInfoBP()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HideMatchInfoBP>d__11(0)
			{
				<>4__this = this
			};
		}

		private void CheckMods()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			Assembly assembly = typeof(int).Assembly;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			foreach (Assembly assembly2 in array)
			{
				if (!(assembly2.GetName().Name == "MatchInfo"))
				{
					continue;
				}
				IEnumerable<PropertyInfo> enumerable = assembly2.GetTypes().SelectMany((Type t) => t.GetProperties());
				foreach (PropertyInfo item in enumerable)
				{
					if (item.Name == "player1BPComponent")
					{
						matchInfoPlayer1BP = (TextMeshPro)item.GetValue(((object)new TextMeshPro()).GetType());
					}
					else if (item.Name == "player2BPComponent")
					{
						matchInfoPlayer2BP = (TextMeshPro)item.GetValue(((object)new TextMeshPro()).GetType());
					}
					if ((Object)(object)matchInfoPlayer1BP != (Object)null && (Object)(object)matchInfoPlayer2BP != (Object)null)
					{
						break;
					}
				}
				hasMatchInfo = true;
				break;
			}
		}

		private void UIInit()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			BPHider.ModName = "BPHider";
			BPHider.ModVersion = "1.1.1";
			BPHider.SetFolder("BPHider");
			BPHider.AddToList("Hide Your BP", true, 0, "Toggles Your BPs On/Off", new Tags());
			BPHider.AddToList("Hide in Gym", true, 0, "Toggles BPs On/Off in the Gym", new Tags());
			BPHider.AddToList("Hide in Matches", true, 0, "Toggles BPs On/Off in Matches", new Tags());
			BPHider.AddToList("Hide in Parks", true, 0, "Toggles BPs On/Off in Parks", new Tags());
			BPHider.GetFromFile();
			BPHider.ModSaved += Save;
			UI.instance.AddMod(BPHider);
			hideOwn = (bool)BPHider.Settings[0].SavedValue;
			enabledInGym = (bool)BPHider.Settings[1].SavedValue;
			enabledInMatches = (bool)BPHider.Settings[2].SavedValue;
			enabledInParks = (bool)BPHider.Settings[3].SavedValue;
		}

		public void Save()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			bool flag = enabledInMatches;
			bool flag2 = enabledInMatches;
			bool flag3 = enabledInGym;
			bool flag4 = enabledInParks;
			hideOwn = (bool)BPHider.Settings[0].SavedValue;
			enabledInGym = (bool)BPHider.Settings[1].SavedValue;
			enabledInMatches = (bool)BPHider.Settings[2].SavedValue;
			enabledInParks = (bool)BPHider.Settings[3].SavedValue;
			if ((flag != hideOwn && (name == "Gym" || name == "Park")) || (enabledInGym != flag3 && name == "Gym") || (enabledInParks != flag4 && name == "Park"))
			{
				UpdateBPs();
			}
			else
			{
				if (enabledInMatches == flag2 || (!(name == "Map0") && !(name == "Map1")))
				{
					return;
				}
				for (int i = 1; i < Singleton<PlayerManager>.instance.AllPlayers.Count; i++)
				{
					UpdateBP(Singleton<PlayerManager>.instance.AllPlayers[i].Controller.PlayerNameTag);
				}
				if (hasMatchInfo)
				{
					try
					{
						((TMP_Text)matchInfoPlayer1BP).text = (enabledInMatches ? "????? BP" : Singleton<PlayerManager>.instance.AllPlayers[0].Data.GeneralData.BattlePoints.ToString());
					}
					catch
					{
						return;
					}
					try
					{
						((TMP_Text)matchInfoPlayer2BP).text = (enabledInMatches ? "????? BP" : Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.BattlePoints.ToString());
					}
					catch
					{
					}
				}
			}
		}

		private static void UpdateBPs()
		{
			foreach (PlayerTag playerTag in playerTags)
			{
				UpdateBP(playerTag);
			}
		}

		private static void UpdateBP(PlayerNameTag nameTag)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (Singleton<PlayerManager>.instance.localPlayer.Data.GeneralData.PublicUsername == nameTag.playerNameText.text)
			{
				nameTag.playerBPAmountText.text = (hideOwn ? "??????" : ((PlayerControllerSubsystem)nameTag).parentController.assignedPlayer.Data.GeneralData.BattlePoints.ToString());
				return;
			}
			switch (name)
			{
			case "Gym":
				nameTag.playerBPAmountText.text = (enabledInGym ? "??????" : ((PlayerControllerSubsystem)nameTag).parentController.assignedPlayer.Data.GeneralData.BattlePoints.ToString());
				break;
			case "Park":
				nameTag.playerBPAmountText.text = (enabledInParks ? "??????" : ((PlayerControllerSubsystem)nameTag).parentController.assignedPlayer.Data.GeneralData.BattlePoints.ToString());
				break;
			case "Map0":
			case "Map1":
				nameTag.playerBPAmountText.text = (enabledInMatches ? "??????" : ((PlayerControllerSubsystem)nameTag).parentController.assignedPlayer.Data.GeneralData.BattlePoints.ToString());
				break;
			}
		}

		private static void UpdateBP(PlayerTag playerTag)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (playerTag.UserData.publicName == Singleton<PlayerManager>.instance.localPlayer.Data.GeneralData.PublicUsername)
			{
				playerTag.battlePoints.text = (hideOwn ? "??????" : playerTag.UserData.battlePoints.ToString());
				return;
			}
			switch (name)
			{
			case "Gym":
				playerTag.battlePoints.text = (enabledInGym ? "??????" : playerTag.UserData.battlePoints.ToString());
				break;
			case "Park":
				playerTag.battlePoints.text = (enabledInParks ? "??????" : playerTag.UserData.battlePoints.ToString());
				break;
			case "Map0":
			case "Map1":
				playerTag.battlePoints.text = (enabledInMatches ? "??????" : playerTag.UserData.battlePoints.ToString());
				break;
			}
		}
	}
}