Decompiled source of Tabholic v1.0.1

plugins/Tabholic.dll

Decompiled 5 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 BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using TabInfo.Utils;
using Tabholic.UI;
using Tabholic.Utils;
using UIManager;
using UIManager.Menus;
using UIManager.Properties;
using UIManager.UI;
using UIManager.UI.ContextPanels;
using UIManager.UI.ContextPanels.SimplePanels;
using UIManager.UI.Layouts;
using UIManager.Utils.Configs;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 Tabholic
{
	[BepInIncompatibility("AALUND13.ROUNDS.Tabholic")]
	[BepInPlugin("com.penial.rounds.Infoholic", "Infoholioc Disabler", "9999.9999.9999")]
	[BepInProcess("Rounds.exe")]
	internal class InfoholiocDisabler : BaseUnityPlugin
	{
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("AALUND13.ROUNDS.Tabholic", "Tabholic", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class Tabholic : BaseUnityPlugin
	{
		internal const string ModId = "AALUND13.ROUNDS.Tabholic";

		internal const string ModName = "Tabholic";

		internal const string Version = "1.0.0";

		private static Harmony Harmony;

		public static Tabholic Instance { get; private set; }

		public static AssetBundle Assets { get; private set; }

		public static UIPanelInfo PanelInfo { get; internal set; }

		private void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			Instance = this;
			Unbound.RegisterClientSideMod("AALUND13.ROUNDS.Tabholic");
			Assets = AssetUtils.LoadAssetBundleFromResources("tabholic_assets", typeof(Tabholic).Assembly);
			Harmony = new Harmony("AALUND13.ROUNDS.Tabholic");
			Harmony.PatchAll();
		}

		private void Start()
		{
			UIPanelRegistrar component = Assets.LoadAsset<GameObject>("Tabholic UI Regsiter").GetComponent<UIPanelRegistrar>();
			component.Register();
			PanelInfo = component.UIPanelsPrefabs.First();
			OptionPanelRegistry.RegisterOptionMenu<TabholicOptionPanel>(PanelInfo);
			((Component)this).gameObject.AddComponent<TabholicManager>();
			TabholicOptionMenu.RegisterMenu();
		}

		private void Update()
		{
			TabholicOptionMenu.OnUpdate();
		}
	}
	public static class TabholicOptionMenu
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__5_0;

			public static UnityAction <>9__6_0;

			public static UnityAction <>9__6_1;

			public static UnityAction<bool> <>9__6_2;

			public static UnityAction <>9__6_3;

			public static Func<IBaseStat, StatWrapper> <>9__8_1;

			internal void <RegisterMenu>b__5_0()
			{
			}

			internal void <NewGui>b__6_0()
			{
				UILayoutMenu.Instance.Open(Tabholic.PanelInfo);
			}

			internal void <NewGui>b__6_1()
			{
				DetectKey = true;
				UpdateKeyText();
			}

			internal void <NewGui>b__6_2(bool value)
			{
				((GlobalConfig<bool>)(object)SimplisticMode).Value = value;
			}

			internal void <NewGui>b__6_3()
			{
			}

			internal StatWrapper <CreateCategoryGUI>b__8_1(IBaseStat s)
			{
				return (StatWrapper)s;
			}
		}

		public static EnumGlobleConfig<KeyCode> ToggleKeyBind = new EnumGlobleConfig<KeyCode>("show_tabholic_keybind", (KeyCode)111);

		public static BoolGlobleConfig SimplisticMode = new BoolGlobleConfig("tabholic_simplistic_mode", true);

		private static TextMeshProUGUI KeyText;

		private static GameObject KeybindButton;

		private static bool DetectKey;

		internal static void RegisterMenu()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Tabholic", (UnityAction)obj, (Action<GameObject>)NewGui, (GameObject)null, false);
		}

		private static void NewGui(GameObject menu)
		{
			//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)
			//IL_0060: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			if (!TabholicManager.Instance.InitializedCategories)
			{
				TabholicManager.Instance.InitCategories();
			}
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText("Tabholic", menu, ref val, 90, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					UILayoutMenu.Instance.Open(Tabholic.PanelInfo);
				};
				<>c.<>9__6_0 = val2;
				obj = (object)val2;
			}
			MenuHandler.CreateButton("Manage Tabholic Panel", menu, (UnityAction)obj, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 60, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Keybinds", menu, ref val, 75, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			object obj2 = <>c.<>9__6_1;
			if (obj2 == null)
			{
				UnityAction val3 = delegate
				{
					DetectKey = true;
					UpdateKeyText();
				};
				<>c.<>9__6_1 = val3;
				obj2 = (object)val3;
			}
			KeybindButton = MenuHandler.CreateButton("Set Toggle Keybind", menu, (UnityAction)obj2, 35, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			KeyCode value2 = ((GlobalConfig<KeyCode>)(object)ToggleKeyBind).Value;
			MenuHandler.CreateText("Current Toggle Keybind: " + ((object)(KeyCode)(ref value2)).ToString(), menu, ref KeyText, 40, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 60, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Toggles", menu, ref val, 75, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateToggle(((GlobalConfig<bool>)(object)SimplisticMode).Value, "Simplistic Mode", menu, (UnityAction<bool>)delegate(bool value)
			{
				((GlobalConfig<bool>)(object)SimplisticMode).Value = value;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("<#7A7A7A><i>\"Simplistic Mode\" Only Show Category/Stats That is Enable in The \"Categories\" Section", menu, ref val, 35, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 60, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Categories", menu, ref val, 75, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			foreach (StatCategoryWrapper categoryWrapper in TabholicManager.categoryWrappers)
			{
				string name = categoryWrapper.WrappingCategory.name;
				object obj3 = <>c.<>9__6_3;
				if (obj3 == null)
				{
					UnityAction val4 = delegate
					{
					};
					<>c.<>9__6_3 = val4;
					obj3 = (object)val4;
				}
				CreateCategoryGUI(MenuHandler.CreateMenu(name, (UnityAction)obj3, menu, 60, true, true, ((Component)menu.transform.parent).gameObject, true, -1), categoryWrapper);
			}
		}

		private static void UpdateKeyText()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (DetectKey)
			{
				((TMP_Text)KeyText).text = "Current Toggle Keybind: Press Any Key...";
				return;
			}
			TextMeshProUGUI keyText = KeyText;
			KeyCode value = ((GlobalConfig<KeyCode>)(object)ToggleKeyBind).Value;
			((TMP_Text)keyText).text = "Current Toggle Keybind: " + ((object)(KeyCode)(ref value)).ToString();
		}

		private static void CreateCategoryGUI(GameObject menu, StatCategoryWrapper categoryWrapper)
		{
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText(categoryWrapper.WrappingCategory.name.ToUpper(), menu, ref val, 90, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 30, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Toggle Category", menu, ref val, 60, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 30, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			Toggle componentInChildren = MenuHandler.CreateToggle(((GlobalConfig<bool>)(object)categoryWrapper.Enabled).Value, categoryWrapper.WrappingCategory.name ?? "", menu, (UnityAction<bool>)delegate(bool value)
			{
				((GlobalConfig<bool>)(object)categoryWrapper.Enabled).Value = value;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null).GetComponentInChildren<Toggle>();
			MenuHandler.CreateText(" ", menu, ref val, 30, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Toggle Stats ", menu, ref val, 60, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 30, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			foreach (StatWrapper item in categoryWrapper.Stats.Select((IBaseStat s) => (StatWrapper)s))
			{
				CreateCategoryGUI(menu, componentInChildren, categoryWrapper, item);
			}
		}

		private static void CreateCategoryGUI(GameObject menu, Toggle categoryToggle, StatCategoryWrapper categoryWrapper, StatWrapper statWrapper)
		{
			MenuHandler.CreateToggle(((GlobalConfig<bool>)(object)statWrapper.Enabled).Value, categoryWrapper.WrappingCategory.name + " " + statWrapper.WrappingStat.name, menu, (UnityAction<bool>)delegate(bool value)
			{
				if (value)
				{
					categoryToggle.isOn = true;
				}
				((GlobalConfig<bool>)(object)statWrapper.Enabled).Value = value;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}

		internal static void OnUpdate()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)KeybindButton == (Object)null || (Object)(object)KeyText == (Object)null || !DetectKey)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				DetectKey = false;
				UpdateKeyText();
				return;
			}
			foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
			{
				if (Input.GetKeyDown(value))
				{
					DetectKey = false;
					((GlobalConfig<KeyCode>)(object)ToggleKeyBind).Value = value;
					UpdateKeyText();
				}
			}
		}
	}
}
namespace Tabholic.Utils
{
	public static class AllowedCategories
	{
		private static List<string> AllowedCatgories = new List<string> { "Basic Stats", "Advanced Character Stats", "Armor Stats", "CCM Stats", "null" };

		private static Dictionary<string, List<string>> AllowStats = new Dictionary<string, List<string>>
		{
			{
				"AA Stats",
				new List<string> { "Damage Per Seconds", "Bullets Per Seconds" }
			},
			{
				"Advanced Gun Stats",
				new List<string> { "Bullet Gravity", "Bullet Size", "Bullet Speed", "Damage Growth", "Even Gun Spread", "Gun Spread" }
			},
			{
				"Useful Stats",
				new List<string> { "Ghost Bullets", "Unblockable" }
			},
			{
				"JARL Stats",
				new List<string> { "Total Armor" }
			}
		};

		public static bool IsAllowed(string category)
		{
			if (!AllowedCatgories.Any((string allowedCategory) => allowedCategory.Equals(category, StringComparison.OrdinalIgnoreCase)))
			{
				return AllowStats.Any((KeyValuePair<string, List<string>> allowedStat) => allowedStat.Key.Equals(category, StringComparison.OrdinalIgnoreCase));
			}
			return true;
		}

		public static bool IsAllowed(string category, string stat)
		{
			if (!AllowedCatgories.Any((string allowedCategory) => allowedCategory.Equals(category, StringComparison.OrdinalIgnoreCase)))
			{
				return AllowStats.Any((KeyValuePair<string, List<string>> allowedStat) => allowedStat.Key.Equals(category, StringComparison.OrdinalIgnoreCase) && allowedStat.Value.Contains(stat));
			}
			return true;
		}

		public static void AddAllowCategory(string category)
		{
			AllowedCatgories.Add(category);
		}

		public static void AddAllowStats(string category, string stat)
		{
			if (AllowStats.TryGetValue(category, out var value))
			{
				value.Add(stat);
				return;
			}
			AllowStats.Add(category, new List<string> { stat });
		}
	}
	public static class StatsAlias
	{
		private static Dictionary<string, Dictionary<string, string>> statsAlias = new Dictionary<string, Dictionary<string, string>> { 
		{
			"AA Stats",
			new Dictionary<string, string>
			{
				{ "Damage Per Seconds", "DPS" },
				{ "Bullets Per Seconds", "SPS" }
			}
		} };

		public static void AddAlias(string category, string statName, string statAlias)
		{
			if (statsAlias.TryGetValue(category, out var value))
			{
				value.Add(statName, statAlias);
				return;
			}
			statsAlias.Add(category, new Dictionary<string, string> { { statName, statAlias } });
		}

		public static string GetStatAlias(string category, string statName)
		{
			if (statsAlias.TryGetValue(category, out var value) && value.ContainsKey(statName))
			{
				return value[statName];
			}
			return statName;
		}
	}
	public interface IBaseStatCategory
	{
		int Priority { get; }

		IBaseStat[] Stats { get; }

		bool CanDisplay(Player player);

		string Display();
	}
	public interface IBaseStat
	{
		bool CanDisplay(Player player);

		string Display(Player player);
	}
	public class StatCategoryWrapper : IBaseStatCategory
	{
		public readonly StatCategory WrappingCategory;

		public readonly BoolGlobleConfig Enabled;

		private readonly IBaseStat[] stats;

		public IBaseStat[] Stats => stats;

		public int Priority => WrappingCategory.priority;

		public StatCategoryWrapper(StatCategory category)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			WrappingCategory = category;
			Enabled = new BoolGlobleConfig("enable_" + category.name.ToLower(), AllowedCategories.IsAllowed(category.name));
			IBaseStat[] array = (from stat in category.Stats
				select new StatWrapper(category, stat.Value) into s
				orderby s.WrappingStat.name
				select s).ToArray();
			stats = array;
		}

		public bool CanDisplay(Player player)
		{
			if ((((GlobalConfig<bool>)(object)Enabled).Value || !((GlobalConfig<bool>)(object)TabholicOptionMenu.SimplisticMode).Value) && (bool)ExtensionMethods.InvokeMethod((object)WrappingCategory, "DisplayCondition", new object[1] { player }))
			{
				return Stats.Any((IBaseStat s) => s.CanDisplay(player));
			}
			return false;
		}

		public string Display()
		{
			return WrappingCategory.name;
		}
	}
	public class StatWrapper : IBaseStat
	{
		public readonly Stat WrappingStat;

		public readonly StatCategory WrappingCategory;

		public readonly BoolGlobleConfig Enabled;

		public StatWrapper(StatCategory category, Stat stat)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			WrappingCategory = category;
			WrappingStat = stat;
			Enabled = new BoolGlobleConfig("enable_" + category.name.ToLower() + "_" + stat.name.ToLower(), AllowedCategories.IsAllowed(category.name, stat.name));
		}

		public bool CanDisplay(Player player)
		{
			if (((GlobalConfig<bool>)(object)Enabled).Value || !((GlobalConfig<bool>)(object)TabholicOptionMenu.SimplisticMode).Value)
			{
				return (bool)ExtensionMethods.InvokeMethod((object)WrappingStat, "DisplayCondition", new object[1] { player });
			}
			return false;
		}

		public string Display(Player player)
		{
			return StatsAlias.GetStatAlias(WrappingCategory.name, WrappingStat.name) + ": " + (string)ExtensionMethods.InvokeMethod((object)WrappingStat, "DisplayValue", new object[1] { player });
		}
	}
	public class PreviewStatCategoryWrapper : IBaseStatCategory
	{
		private readonly PreviewStatWrapper[] previewStatWrapper;

		public readonly string Name;

		public IBaseStat[] Stats => previewStatWrapper;

		public int Priority => -1;

		public PreviewStatCategoryWrapper(string name, PreviewStatWrapper[] stats)
		{
			Name = name;
			previewStatWrapper = stats.OrderBy((PreviewStatWrapper s) => s.Name).ToArray();
		}

		public bool CanDisplay(Player player)
		{
			return true;
		}

		public string Display()
		{
			return Name;
		}
	}
	public class PreviewStatWrapper : IBaseStat
	{
		public readonly string Name;

		public readonly string Amount;

		public PreviewStatWrapper(string name, string amount)
		{
			Name = name;
			Amount = amount;
		}

		public bool CanDisplay(Player player)
		{
			return true;
		}

		public string Display(Player player)
		{
			return Name + ": " + Amount;
		}
	}
}
namespace Tabholic.UI
{
	public class DestroyAction : MonoBehaviour
	{
		public Action OnDestroyAction;

		public void Destroy()
		{
			OnDestroyAction?.Invoke();
		}
	}
	public class TabholicManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <GameEnd>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TabholicManager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				TabholicManager tabholicManager = <>4__this;
				if (num != 0)
				{
					return false;
				}
				<>1__state = -1;
				tabholicManager.ClearPlayer();
				tabholicManager.InGame = false;
				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();
			}
		}

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

			private object <>2__current;

			public TabholicManager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				TabholicManager tabholicManager = <>4__this;
				if (num != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (!tabholicManager.InitializedCategories)
				{
					tabholicManager.InitCategories();
				}
				tabholicManager.SetLocalPlayer();
				tabholicManager.InGame = true;
				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();
			}
		}

		public static List<StatCategoryWrapper> categoryWrappers = new List<StatCategoryWrapper>();

		public static List<PreviewStatCategoryWrapper> previewCategoryWrappers = new List<PreviewStatCategoryWrapper>
		{
			new PreviewStatCategoryWrapper("Basic Stats", new PreviewStatWrapper[6]
			{
				new PreviewStatWrapper("HP", "100/100"),
				new PreviewStatWrapper("Damage", "55"),
				new PreviewStatWrapper("Block Cooldown", "4.00s"),
				new PreviewStatWrapper("Reload Time", "2.00s"),
				new PreviewStatWrapper("Ammo", "3"),
				new PreviewStatWrapper("Movement Speed", "1.00")
			}),
			new PreviewStatCategoryWrapper("Advanced Character Stats", new PreviewStatWrapper[7]
			{
				new PreviewStatWrapper("Phoenix Revives", "0"),
				new PreviewStatWrapper("Decay", "0"),
				new PreviewStatWrapper("Regeneration", "0HP/s"),
				new PreviewStatWrapper("Size", "1"),
				new PreviewStatWrapper("Jumps", "1"),
				new PreviewStatWrapper("Jump Height", "1"),
				new PreviewStatWrapper("Gravity", "1")
			})
		};

		private bool InGame;

		public static TabholicManager Instance { get; private set; }

		public static UILayoutPanel LayoutPanel => UIRegistry.Instance.GetLayoutPanel(Tabholic.PanelInfo.PanelID);

		public Player Player { get; private set; }

		public bool InitializedCategories { get; private set; }

		private void Awake()
		{
			Instance = this;
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart);
			GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)GameEnd);
		}

		private void Update()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (InGame && Input.GetKeyDown(((GlobalConfig<KeyCode>)(object)TabholicOptionMenu.ToggleKeyBind).Value) && (Object)(object)Player != (Object)null)
			{
				LayoutPanel.Info.DisplayMode = (DisplayMode)((int)LayoutPanel.Info.DisplayMode != 1);
			}
		}

		internal void InitCategories()
		{
			categoryWrappers = (from c in TabInfoManager.Categories.Values
				select new StatCategoryWrapper(c) into c
				orderby c.Priority
				select c).ToList();
			InitializedCategories = true;
		}

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

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

		public void SetLocalPlayer()
		{
			Player val = PlayerManager.instance.players.Find((Player p) => p.data.view.IsMine && !((Behaviour)((Component)p).GetComponent<PlayerAPI>()).enabled && GameModeManager.CurrentHandlerID != "Sandbox");
			if ((Object)(object)val != (Object)null)
			{
				DispalyPlayer(val);
			}
			else
			{
				ClearPlayer();
			}
		}

		public void DispalyPlayer(Player player)
		{
			if (!((Object)(object)Player != (Object)null) && !((Object)(object)player == (Object)null))
			{
				Player = player;
				DestroyAction orAddComponent = ExtensionMethods.GetOrAddComponent<DestroyAction>(((Component)Player).gameObject, false);
				orAddComponent.OnDestroyAction = (Action)Delegate.Combine(orAddComponent.OnDestroyAction, new Action(ClearPlayer));
				LayoutPanel.Info.DisplayMode = (DisplayMode)1;
			}
		}

		public void ClearPlayer()
		{
			if (!((Object)(object)Player == (Object)null))
			{
				DestroyAction orAddComponent = ExtensionMethods.GetOrAddComponent<DestroyAction>(((Component)Player).gameObject, false);
				orAddComponent.OnDestroyAction = (Action)Delegate.Remove(orAddComponent.OnDestroyAction, new Action(ClearPlayer));
				Player = null;
				LayoutPanel.Info.DisplayMode = (DisplayMode)0;
			}
		}
	}
	public class StatCategoryFrame : MonoBehaviour
	{
		public GameObject StatPrefab;

		public GameObject StatsHolder;

		public TextMeshProUGUI Text;

		public VerticalLayoutGroup StatHolderLayoutGroup;

		public VerticalLayoutGroup CategoryHolderLayoutGroup;

		private TabholicFrame TabholicFrame;

		internal IBaseStatCategory StatCategoryWrapper;

		private bool InitializeOptionControl;

		private void OnEnable()
		{
			Display();
		}

		private void Update()
		{
			Display();
		}

		public void Initialize(TabholicFrame frame, IBaseStatCategory statCategoryWrapper)
		{
			StatCategoryWrapper = statCategoryWrapper;
			TabholicFrame = frame;
			IBaseStat[] stats = StatCategoryWrapper.Stats;
			foreach (IBaseStat statCategoryWrapper2 in stats)
			{
				Object.Instantiate<GameObject>(StatPrefab, StatsHolder.transform).GetComponent<StatObject>().Initialize(frame, statCategoryWrapper2);
			}
			if ((Object)(object)TabholicManager.Instance.Player != (Object)null)
			{
				bool flag = StatCategoryWrapper.CanDisplay(TabholicManager.Instance.Player);
				((Component)this).gameObject.SetActive(flag);
				if (!flag)
				{
					TabholicFrame.DisableStatsCategoriesDisplayers.Add(this);
				}
			}
			((TMP_Text)Text).text = StatCategoryWrapper.Display();
		}

		public void Display()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!StatCategoryWrapper.CanDisplay(TabholicManager.Instance.Player))
			{
				TabholicFrame.DisableStatsCategoriesDisplayers.Add(this);
				((Component)this).gameObject.SetActive(false);
			}
			if (!InitializeOptionControl && (Object)(object)TabholicOptionPanel.Instance != (Object)null)
			{
				RectTransform textRect = ((Component)Text).GetComponent<RectTransform>();
				((Component)Text).gameObject.SetActive(((PropertyField<bool>)(object)TabholicOptionPanel.Instance.CategoryHeader).Value);
				((Graphic)Text).color = ((PropertyField<Color>)(object)TabholicOptionPanel.Instance.CategoryColor).Value;
				textRect.SetSizeWithCurrentAnchors((Axis)1, ((PropertyValueField<float>)(object)TabholicOptionPanel.Instance.CategoryTextSize).Value);
				((HorizontalOrVerticalLayoutGroup)StatHolderLayoutGroup).spacing = ((PropertyValueField<float>)(object)TabholicOptionPanel.Instance.StatGap).Value;
				((HorizontalOrVerticalLayoutGroup)CategoryHolderLayoutGroup).spacing = ((PropertyValueField<float>)(object)TabholicOptionPanel.Instance.CategoryTextGap).Value;
				BoolPropertyField categoryHeader = TabholicOptionPanel.Instance.CategoryHeader;
				((PropertyField<bool>)(object)categoryHeader).OnValueChanged = (Action<bool>)Delegate.Combine(((PropertyField<bool>)(object)categoryHeader).OnValueChanged, (Action<bool>)delegate(bool value)
				{
					((Component)Text).gameObject.SetActive(value);
				});
				ColorPropertyField categoryColor = TabholicOptionPanel.Instance.CategoryColor;
				((PropertyField<Color>)(object)categoryColor).OnValueChanged = (Action<Color>)Delegate.Combine(((PropertyField<Color>)(object)categoryColor).OnValueChanged, (Action<Color>)delegate(Color value)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)Text).color = value;
				});
				FloatPropertyField statGap = TabholicOptionPanel.Instance.StatGap;
				((PropertyValueField<float>)(object)statGap).OnValueChanged = (Action<float>)Delegate.Combine(((PropertyValueField<float>)(object)statGap).OnValueChanged, (Action<float>)delegate(float value)
				{
					((HorizontalOrVerticalLayoutGroup)StatHolderLayoutGroup).spacing = value;
				});
				FloatPropertyField categoryTextGap = TabholicOptionPanel.Instance.CategoryTextGap;
				((PropertyValueField<float>)(object)categoryTextGap).OnValueChanged = (Action<float>)Delegate.Combine(((PropertyValueField<float>)(object)categoryTextGap).OnValueChanged, (Action<float>)delegate(float value)
				{
					((HorizontalOrVerticalLayoutGroup)CategoryHolderLayoutGroup).spacing = value;
				});
				FloatPropertyField categoryTextSize = TabholicOptionPanel.Instance.CategoryTextSize;
				((PropertyValueField<float>)(object)categoryTextSize).OnValueChanged = (Action<float>)Delegate.Combine(((PropertyValueField<float>)(object)categoryTextSize).OnValueChanged, (Action<float>)delegate(float value)
				{
					textRect.SetSizeWithCurrentAnchors((Axis)1, value);
				});
				InitializeOptionControl = true;
			}
		}
	}
	public class StatObject : MonoBehaviour
	{
		public TextMeshProUGUI Text;

		private TabholicFrame TabholicFrame;

		internal IBaseStat StatWrapper;

		private bool InitializeOptionControl;

		private void Awake()
		{
			TabholicFrame = ((Component)this).GetComponentInParent<TabholicFrame>();
		}

		private void OnEnable()
		{
			Display();
			VerticalLayoutGroup[] componentsInParent = ((Component)this).GetComponentsInParent<VerticalLayoutGroup>();
			for (int i = 0; i < componentsInParent.Length; i++)
			{
				Transform transform = ((Component)componentsInParent[i]).transform;
				LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null));
			}
		}

		private void Update()
		{
			Display();
		}

		public void Initialize(TabholicFrame frame, IBaseStat statCategoryWrapper)
		{
			StatWrapper = statCategoryWrapper;
			TabholicFrame = frame;
			if ((Object)(object)TabholicManager.Instance.Player != (Object)null)
			{
				bool flag = StatWrapper.CanDisplay(TabholicManager.Instance.Player);
				((Component)this).gameObject.SetActive(flag);
				if (!flag)
				{
					TabholicFrame.DisableStatsDisplayers.Add(this);
				}
			}
		}

		public void Display()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (!StatWrapper.CanDisplay(TabholicManager.Instance.Player))
			{
				TabholicFrame.DisableStatsDisplayers.Add(this);
				((Component)this).gameObject.SetActive(false);
				VerticalLayoutGroup[] componentsInParent = ((Component)this).GetComponentsInParent<VerticalLayoutGroup>();
				for (int i = 0; i < componentsInParent.Length; i++)
				{
					Transform transform = ((Component)componentsInParent[i]).transform;
					LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null));
				}
			}
			else
			{
				((TMP_Text)Text).text = StatWrapper.Display(TabholicManager.Instance.Player);
			}
			if (!InitializeOptionControl && (Object)(object)TabholicOptionPanel.Instance != (Object)null)
			{
				((Graphic)Text).color = ((PropertyField<Color>)(object)TabholicOptionPanel.Instance.StatColor).Value;
				ColorPropertyField statColor = TabholicOptionPanel.Instance.StatColor;
				((PropertyField<Color>)(object)statColor).OnValueChanged = (Action<Color>)Delegate.Combine(((PropertyField<Color>)(object)statColor).OnValueChanged, (Action<Color>)delegate(Color value)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					((Graphic)Text).color = value;
				});
				InitializeOptionControl = true;
			}
		}
	}
	public class TabholicFrame : MonoBehaviour
	{
		public GameObject CategoryPrefeb;

		public List<StatCategoryFrame> Frames = new List<StatCategoryFrame>();

		public List<StatObject> DisableStatsDisplayers = new List<StatObject>();

		public List<StatCategoryFrame> DisableStatsCategoriesDisplayers = new List<StatCategoryFrame>();

		public VerticalLayoutGroup CategoryLayoutGroup;

		private bool first = true;

		private bool initializeOptionControl;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			UIPanelInfo componentInParent = ((Component)this).GetComponentInParent<UIPanelInfo>();
			if (!first)
			{
				return;
			}
			componentInParent.OnDisplayModeChnaged = (Action<DisplayMode>)Delegate.Combine(componentInParent.OnDisplayModeChnaged, (Action<DisplayMode>)delegate(DisplayMode display)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Invalid comparison between Unknown and I4
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Invalid comparison between Unknown and I4
				if ((int)display == 1)
				{
					CreatePlayerStats();
				}
				else if ((int)display == 2)
				{
					CreatePreviewStats();
				}
			});
			if ((int)componentInParent.DisplayMode == 1)
			{
				CreatePlayerStats();
			}
			else if ((int)componentInParent.DisplayMode == 2)
			{
				CreatePreviewStats();
			}
			first = false;
		}

		private void Update()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			foreach (StatObject item in new List<StatObject>(DisableStatsDisplayers))
			{
				if (item.StatWrapper.CanDisplay(TabholicManager.Instance.Player))
				{
					DisableStatsDisplayers.Remove(item);
					((Component)item).gameObject.SetActive(true);
				}
			}
			foreach (StatCategoryFrame item2 in new List<StatCategoryFrame>(DisableStatsCategoriesDisplayers))
			{
				if (item2.StatCategoryWrapper.CanDisplay(TabholicManager.Instance.Player))
				{
					DisableStatsCategoriesDisplayers.Remove(item2);
					((Component)item2).gameObject.SetActive(true);
				}
			}
			if (!initializeOptionControl && (Object)(object)TabholicOptionPanel.Instance != (Object)null)
			{
				((Component)this).transform.localScale = Vector3.one * ((PropertyValueField<float>)(object)TabholicOptionPanel.Instance.PanelScale).Value;
				((HorizontalOrVerticalLayoutGroup)CategoryLayoutGroup).spacing = ((PropertyValueField<float>)(object)TabholicOptionPanel.Instance.CategoryGap).Value;
				FloatPropertyField panelScale = TabholicOptionPanel.Instance.PanelScale;
				((PropertyValueField<float>)(object)panelScale).OnValueChanged = (Action<float>)Delegate.Combine(((PropertyValueField<float>)(object)panelScale).OnValueChanged, (Action<float>)delegate(float value)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					((Component)this).transform.localScale = Vector3.one * value;
				});
				FloatPropertyField categoryGap = TabholicOptionPanel.Instance.CategoryGap;
				((PropertyValueField<float>)(object)categoryGap).OnValueChanged = (Action<float>)Delegate.Combine(((PropertyValueField<float>)(object)categoryGap).OnValueChanged, (Action<float>)delegate(float value)
				{
					((HorizontalOrVerticalLayoutGroup)CategoryLayoutGroup).spacing = value;
				});
			}
		}

		private void CreatePreviewStats()
		{
			foreach (StatCategoryFrame frame in Frames)
			{
				Object.Destroy((Object)(object)((Component)frame).gameObject);
			}
			Frames.Clear();
			DisableStatsCategoriesDisplayers.Clear();
			DisableStatsDisplayers.Clear();
			foreach (PreviewStatCategoryWrapper previewCategoryWrapper in TabholicManager.previewCategoryWrappers)
			{
				StatCategoryFrame component = Object.Instantiate<GameObject>(CategoryPrefeb, ((Component)this).transform).GetComponent<StatCategoryFrame>();
				component.Initialize(this, previewCategoryWrapper);
				if ((Object)(object)TabholicManager.Instance.Player != (Object)null)
				{
					((Component)component).gameObject.SetActive(component.StatCategoryWrapper.CanDisplay(TabholicManager.Instance.Player));
				}
				Frames.Add(component);
			}
		}

		private void CreatePlayerStats()
		{
			foreach (StatCategoryFrame frame in Frames)
			{
				Object.Destroy((Object)(object)((Component)frame).gameObject);
			}
			Frames.Clear();
			DisableStatsCategoriesDisplayers.Clear();
			DisableStatsDisplayers.Clear();
			foreach (StatCategoryWrapper categoryWrapper in TabholicManager.categoryWrappers)
			{
				StatCategoryFrame component = Object.Instantiate<GameObject>(CategoryPrefeb, ((Component)this).transform).GetComponent<StatCategoryFrame>();
				component.Initialize(this, categoryWrapper);
				Frames.Add(component);
			}
		}
	}
	public class TabholicOptionPanel : SimpleContextPanel
	{
		[Header("Enable/Disable Options")]
		public BoolPropertyField CategoryHeader = new BoolPropertyField(true);

		[Header("Spacing")]
		public FloatPropertyField CategoryGap = new FloatPropertyField(10f, 20f, 0f);

		public FloatPropertyField CategoryTextGap = new FloatPropertyField(2f, 10f, 0f);

		public FloatPropertyField StatGap = new FloatPropertyField(1f, 10f, 0f);

		[Header("Color")]
		public ColorPropertyField CategoryColor = new ColorPropertyField(new Color(0.72f, 0.72f, 0.72f, 1f));

		public ColorPropertyField StatColor = new ColorPropertyField(new Color(0.72f, 0.72f, 0.72f, 1f));

		[Header("Scaling")]
		public FloatPropertyField PanelScale = new FloatPropertyField(1f, 2f, 0.75f);

		public FloatPropertyField CategoryTextSize = new FloatPropertyField(20f, 20f, 10f);

		public static TabholicOptionPanel Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}
	}
}
namespace Tabholic.UI.Tests
{
	public class EditorContextPanelRegister : MonoBehaviour
	{
		public UIPanelInfo PrefabPanelInfo;

		private void Awake()
		{
			OptionPanelRegistry.RegisterOptionMenu<TabholicOptionPanel>(PrefabPanelInfo);
		}
	}
}