Decompiled source of FancyCardBar v1.3.3

FancyCardBar.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using ModdingUtils.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FancyCardBar
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.rsmind.rounds.fancycardbar", "Fancy Card Bar", "1.3.3")]
	[BepInProcess("Rounds.exe")]
	public class FancyCardBar : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c : Object
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__10_0;

			public static UnityAction<bool> <>9__18_0;

			public static UnityAction<bool> <>9__18_1;

			internal void <Start>b__10_0()
			{
			}

			internal void <NewGUI>b__18_0(bool val)
			{
				modActive = val;
			}

			internal void <NewGUI>b__18_1(bool val)
			{
				genIcons = val;
			}
		}

		private const string ModId = "com.rsmind.rounds.fancycardbar";

		private const string ModName = "Fancy Card Bar";

		private const string CompatibilityModName = "FancyCardBar";

		public const string Version = "1.3.3";

		public const string ModInitials = "FCB";

		public static bool Debug;

		internal static AssetBundle assets;

		internal static GameObject blankIcon;

		[field: CompilerGenerated]
		[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
		public static FancyCardBar instance
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		public static bool modActive
		{
			get
			{
				return PlayerPrefs.GetInt(GetConfigKey("modActive"), 1) == 1;
			}
			internal set
			{
				PlayerPrefs.SetInt(GetConfigKey("modActive"), value ? 1 : 0);
			}
		}

		public static bool genIcons
		{
			get
			{
				return PlayerPrefs.GetInt(GetConfigKey("genIcons"), 0) == 1;
			}
			internal set
			{
				PlayerPrefs.SetInt(GetConfigKey("genIcons"), value ? 1 : 0);
			}
		}

		private void Awake()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			Unbound.RegisterClientSideMod("com.rsmind.rounds.fancycardbar");
			assets = AssetUtils.LoadAssetBundleFromResources("fancycardbar", typeof(FancyCardBar).Assembly);
			if ((Object)(object)assets == (Object)null)
			{
				Debug.Log((object)"Failed to load Fancy Card Bar asset bundle");
			}
			Harmony val = new Harmony("com.rsmind.rounds.fancycardbar");
			val.PatchAll();
		}

		private void Start()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			instance = this;
			blankIcon = assets.LoadAsset<GameObject>("I_Template");
			object obj = <>c.<>9__10_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__10_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Fancy Card Bar", (UnityAction)obj, (Action<GameObject>)NewGUI, (GameObject)null, false);
		}

		internal static string GetConfigKey(string name)
		{
			return String.Concat("FancyCardBar_", name.ToLower());
		}

		private static void NewGUI(GameObject menu)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			MenuHandler.CreateText("Fancy Card Bar Options", menu, ref val2, 60, true, default(Nullable<Color>), (TMP_FontAsset)null, (Material)null, default(Nullable<TextAlignmentOptions>));
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, default(Nullable<Color>), (TMP_FontAsset)null, (Material)null, default(Nullable<TextAlignmentOptions>));
			MenuHandler.CreateToggle(modActive, "Use Fancy Icons", menu, (UnityAction<bool>)delegate(bool val)
			{
				modActive = val;
			}, 60, true, default(Nullable<Color>), (TMP_FontAsset)null, (Material)null, default(Nullable<TextAlignmentOptions>));
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, default(Nullable<Color>), (TMP_FontAsset)null, (Material)null, default(Nullable<TextAlignmentOptions>));
			MenuHandler.CreateToggle(genIcons, "Automatically Generate Card Icons", menu, (UnityAction<bool>)delegate(bool val)
			{
				genIcons = val;
			}, 60, true, default(Nullable<Color>), (TMP_FontAsset)null, (Material)null, default(Nullable<TextAlignmentOptions>));
		}
	}
	public class FancyIcon : MonoBehaviour
	{
		public GameObject fancyIcon;
	}
}
namespace FancyCardBar.Patches
{
	internal class FancyIconAdder : Object
	{
		internal static void addIcon(CardBar __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			if (!FancyCardBar.modActive)
			{
				return;
			}
			GameObject gameObject = ((Component)((Component)__instance).transform.GetChild(((Component)__instance).transform.childCount - 1)).gameObject;
			FancyIcon component = ((Component)(CardInfo)ExtensionMethods.GetFieldValue((object)gameObject.GetComponent<CardBarButton>(), "card")).GetComponent<FancyIcon>();
			if (component != null)
			{
				GameObject fancyIcon = component.fancyIcon;
				if (fancyIcon != null)
				{
					GameObject val = Object.Instantiate<GameObject>(fancyIcon, gameObject.transform);
					val.transform.localScale = Vector3.one * (gameObject.GetComponent<RectTransform>().sizeDelta.x / 128f);
					((Behaviour)gameObject.GetComponentInChildren<TextMeshProUGUI>()).enabled = false;
				}
			}
			else
			{
				if (!FancyCardBar.genIcons)
				{
					return;
				}
				GameObject val2 = (GameObject)ExtensionMethods.GetFieldValue(ExtensionMethods.GetFieldValue((object)gameObject.GetComponent<CardBarButton>(), "card"), "cardArt");
				if (val2 != null)
				{
					GameObject val3 = Object.Instantiate<GameObject>(FancyCardBar.blankIcon, gameObject.transform);
					GameObject val4 = Object.Instantiate<GameObject>(val2, val3.transform);
					val4.transform.SetAsFirstSibling();
					val4.transform.localScale = new Vector3(0.15f, 0.15f, 0.15f);
					Animator[] components = val4.GetComponents<Animator>();
					Animator[] array = components;
					foreach (Animator val5 in array)
					{
						Object.Destroy((Object)(object)val5);
					}
					components = val4.GetComponentsInChildren<Animator>();
					Animator[] array2 = components;
					foreach (Animator val6 in array2)
					{
						Object.Destroy((Object)(object)val6);
					}
					val3.transform.localScale = Vector3.one * (gameObject.GetComponent<RectTransform>().sizeDelta.x / 128f);
					((Behaviour)gameObject.GetComponentInChildren<TextMeshProUGUI>()).enabled = false;
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class CardBarPatch : Object
	{
		private static void Postfix(CardBar __instance)
		{
			FancyIconAdder.addIcon(__instance);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class CardBarUtilsPatch : Object
	{
		private static void Postfix(int playerID)
		{
			CardBar _instance = CardBarUtils.instance.PlayersCardBar(playerID);
			FancyIconAdder.addIcon(_instance);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class CardBarUtilsPatch2 : Object
	{
		private static void Postfix(int playerID)
		{
			CardBar _instance = CardBarUtils.instance.PlayersCardBar(playerID);
			FancyIconAdder.addIcon(_instance);
		}
	}
	[Serializable]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class ModdingUtilsPatch : Object
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static bool FixResetPlayersLineColor(int playerID)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)CardBarUtils.instance.PlayersCardBar(playerID)).transform;
			for (int i = 1; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				((Component)child).GetComponent<Graphic>().color = new Color(0.462f, 0.462f, 0.462f, 1f);
				((Component)child.GetChild(1)).GetComponent<Graphic>().color = new Color(0.6509f, 0.6509f, 0.6509f, 1f);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static bool FixChangePlayersLineColor(int playerID, Color color)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)CardBarUtils.instance.PlayersCardBar(playerID)).transform;
			for (int i = 1; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				((Component)child).GetComponent<Graphic>().color = color;
				((Component)child.GetChild(1)).GetComponent<Graphic>().color = color;
			}
			return false;
		}
	}
}