Decompiled source of TabsBuilderApi v1.1.0

TabsBuilder.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Microsoft.CodeAnalysis;
using TMPro;
using TabsBuilderApi.Patches;
using TabsBuilderApi.Utils;
using TabsBuilderApi.backend;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TabsBuilder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Api for tabs in among us")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0-release+def992fc7b6a4f8b51f2240ec418e6217d124b4d")]
[assembly: AssemblyProduct("TabsBuilder")]
[assembly: AssemblyTitle("TabsBuilder")]
[assembly: AssemblyVersion("1.1.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.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
[HarmonyPatch(typeof(ModManager), "LateUpdate")]
internal class ModManagerLateUpdatePatch
{
	public static void Prefix(ModManager __instance)
	{
		__instance.ShowModStamp();
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace TabsBuilderApi
{
	[BepInProcess("Among Us.exe")]
	[BepInPlugin("tabsbuilder.api", "TabsBuilderApi", "1.1.0-release+def992fc7b6a4f8b51f2240ec418e6217d124b4d")]
	public class TabBuilderPlugin : BasePlugin
	{
		public static ManualLogSource mls;

		public const string Id = "tabsbuilder.api";

		internal Harmony Harmony { get; } = new Harmony("tabsbuilder.api");


		public static string Name => "TabsBuilderApi";

		public static string Version => "1.1.0-release+def992fc7b6a4f8b51f2240ec418e6217d124b4d";

		public override void Load()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			mls = Logger.CreateLogSource("tabsbuilder.api");
			ManualLogSource obj = mls;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("tabsbuilder.api");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the api has Awaken");
			}
			obj.LogDebug(val);
			Harmony.PatchAll(typeof(PlayerCustomizationMenuPatched));
			PlayerCustomizationMenuPatched.registerClass();
		}
	}
}
namespace TabsBuilderApi.Utils
{
	public class TabBuilder
	{
		private PlayerCustomizationMenu menu;

		private InventoryTab? tab;

		private Transform? parent;

		private Transform? buttonParent;

		private PassiveButton? topButton;

		private Action<PlayerCustomizationMenu>? action;

		public int? insertIndex;

		public static bool StartCheck(PlayerCustomizationMenu __instance)
		{
			if (Object.op_Implicit((Object)(object)PlayerCustomizationMenu.Instance) && (Object)(object)PlayerCustomizationMenu.Instance != (Object)(object)__instance)
			{
				return true;
			}
			return false;
		}

		public TabBuilder(PlayerCustomizationMenu menu)
		{
			this.menu = menu;
			parent = ((Component)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[0].Tab).transform.parent;
			buttonParent = ((Component)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[0].Button).transform.parent.parent.parent;
		}

		public TabBuilder CreateTab(string tabName)
		{
			tab = ((Il2CppObjectBase)Object.Instantiate<InventoryTab>(((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[2].Tab, parent)).TryCast<InventoryTab>();
			if ((Object)(object)tab == (Object)null)
			{
				return this;
			}
			((Object)tab).name = tabName;
			((Component)tab).gameObject.SetActive(false);
			return this;
		}

		public TabBuilder ReplaceScript(Type type)
		{
			if ((Object)(object)tab == (Object)null)
			{
				return this;
			}
			string name = ((Object)tab).name;
			Scroller scroller = tab.scroller;
			ColorChip colorTabPrefab = tab.ColorTabPrefab;
			PoolablePlayer playerPreview = tab.PlayerPreview;
			GameObject gameObject = ((Component)tab).gameObject;
			Object.Destroy((Object)(object)tab);
			tab = ((Il2CppObjectBase)gameObject.AddComponent(type)).TryCast<InventoryTab>();
			if ((Object)(object)tab == (Object)null)
			{
				return this;
			}
			tab.scroller = scroller;
			tab.PlayerPreview = playerPreview;
			tab.ColorTabPrefab = colorTabPrefab;
			tab.YStart = tab.YStart;
			tab.YOffset = tab.YOffset;
			tab.NumPerRow = tab.NumPerRow;
			tab.XRange = tab.XRange;
			((Object)tab).name = name;
			return this;
		}

		public TabBuilder CreateTop(Sprite assetImage)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			if ((Object)(object)tab == (Object)null)
			{
				return this;
			}
			Transform val = Object.Instantiate<Transform>(((Component)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[1].Button).transform.parent.parent, buttonParent);
			val.position = ((Component)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[1].Button).transform.parent.parent.position;
			val.position = new Vector3(-1E+19f, val.position.y, val.position.z);
			((Object)val).name = ((Object)tab).name;
			Transform child = val.GetChild(0);
			PassiveButton component = ((Component)child.Find("Tab Background")).GetComponent<PassiveButton>();
			component.OnClick = new ButtonClickedEvent();
			Action action = delegate
			{
				OpenTab();
			};
			((UnityEvent)component.OnClick).AddListener(UnityAction.op_Implicit(action));
			topButton = component;
			if (Object.op_Implicit((Object)(object)assetImage))
			{
				((Component)child.Find("Icon")).GetComponent<SpriteRenderer>().sprite = assetImage;
			}
			return this;
		}

		public TabBuilder Before(string existingTabName)
		{
			insertIndex = null;
			for (int i = 0; i < ((Il2CppArrayBase<TabButton>)(object)menu.Tabs).Length; i++)
			{
				if (((Object)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[i].Tab).name == existingTabName)
				{
					insertIndex = i;
					break;
				}
			}
			return this;
		}

		public TabBuilder After(string existingTabName)
		{
			insertIndex = null;
			for (int i = 0; i < ((Il2CppArrayBase<TabButton>)(object)menu.Tabs).Length; i++)
			{
				if (((Object)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[i].Tab).name == existingTabName)
				{
					insertIndex = i + 1;
					break;
				}
			}
			return this;
		}

		public TabBuilder SetAction(Action<PlayerCustomizationMenu> callback)
		{
			action = callback;
			return this;
		}

		public InventoryTab? Build()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			if ((Object)(object)tab == (Object)null)
			{
				return null;
			}
			if ((Object)(object)topButton == (Object)null)
			{
				return null;
			}
			List<TabButton> list = ((IEnumerable<TabButton>)menu.Tabs).ToList();
			GameObject val = new GameObject("viper.cosmella.tabAPI");
			val.transform.parent = ((Component)tab).transform;
			TabButton val2 = new TabButton();
			val2.Tab = tab;
			val2.Button = ((Component)topButton).GetComponent<SpriteRenderer>();
			val2.tabText = ((Component)((Component)tab).transform.Find("Text")).GetComponent<TextMeshPro>();
			if (action != null)
			{
				val.AddComponent<ExpandedTabButton>().action = action;
			}
			if (insertIndex.HasValue)
			{
				list.Insert(insertIndex.Value, val2);
			}
			else
			{
				list.Add(val2);
			}
			menu.Tabs = Il2CppReferenceArray<TabButton>.op_Implicit(list.ToArray());
			RepositionTabs();
			return tab;
		}

		private void OpenTab()
		{
			if ((Object)(object)((Il2CppArrayBase<TabButton>)(object)menu.Tabs)[menu.selectedTab].Tab != (Object)(object)tab)
			{
				menu.OpenTab(tab);
			}
		}

		protected void RepositionTabs()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.width / 1920f;
			List<TabButton> list = ((IEnumerable<TabButton>)menu.Tabs).ToList();
			int count = list.Count;
			for (int i = 0; i < count; i++)
			{
				Transform val = ((Component)list[i].Button).transform.parent.parent;
				if ((Object)(object)val != (Object)null)
				{
					val.position = new Vector3(num * -4.5f + (float)(i + 1), val.position.y, val.position.z);
				}
			}
			GameObject glyphR = menu.glyphR;
			if (Object.op_Implicit((Object)(object)glyphR))
			{
				glyphR.transform.position = new Vector3(num * -4.5f + (float)(count + 1), glyphR.transform.position.y, glyphR.transform.position.z);
			}
		}
	}
	public enum TabBuilderType
	{
		None,
		After,
		Before
	}
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
	public sealed class TabBuilderAttribute : Attribute
	{
		public string TabName { get; }

		public string[] Before { get; }

		public string[] after { get; }

		public Type ScriptType { get; }

		public string TopSpriteResource { get; }

		public Action<PlayerCustomizationMenu> Callback { get; }

		public TabBuilderAttribute(string tabName, string sprite, Type scriptType, TabBuilderType type, params string[] list)
		{
			TabName = tabName;
			ScriptType = scriptType;
			switch (type)
			{
			case TabBuilderType.Before:
				Before = list ?? Array.Empty<string>();
				break;
			default:
				after = list ?? Array.Empty<string>();
				break;
			case TabBuilderType.None:
				break;
			}
			TopSpriteResource = sprite;
		}

		public TabBuilderAttribute(string tabName, string sprite, Action<PlayerCustomizationMenu> callback, TabBuilderType type, params string[] list)
		{
			TabName = tabName;
			switch (type)
			{
			case TabBuilderType.Before:
				Before = list ?? Array.Empty<string>();
				break;
			default:
				after = list ?? Array.Empty<string>();
				break;
			case TabBuilderType.None:
				break;
			}
			Callback = callback;
			TopSpriteResource = sprite;
		}

		public void Build(PlayerCustomizationMenu instance, Assembly asm)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			TabBuilder tabBuilder = new TabBuilder(instance).CreateTab(TabName);
			if (!string.IsNullOrEmpty(TopSpriteResource))
			{
				Sprite assetImage = null;
				using (Stream stream = asm.GetManifestResourceStream(TopSpriteResource ?? ""))
				{
					if (stream != null)
					{
						byte[] array = new byte[stream.Length];
						stream.Read(array, 0, array.Length);
						Texture2D val = new Texture2D(2, 2);
						ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array));
						assetImage = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					}
					else
					{
						string text = TopSpriteResource + " ):";
						string[] manifestResourceNames = asm.GetManifestResourceNames();
						foreach (string value in manifestResourceNames)
						{
							text = $"{text}\n{asm.FullName} has {value}";
						}
						ManualLogSource mls = TabBuilderPlugin.mls;
						bool flag = default(bool);
						BepInExFatalLogInterpolatedStringHandler val2 = new BepInExFatalLogInterpolatedStringHandler(14, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("tabsbuilder.api");
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(asm.FullName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" : ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" | failed");
						}
						mls.LogFatal(val2);
					}
				}
				tabBuilder.CreateTop(assetImage);
			}
			else
			{
				tabBuilder.CreateTop(null);
			}
			if (ScriptType != null)
			{
				tabBuilder.ReplaceScript(Il2CppType.From(ScriptType));
			}
			else if (Callback != null)
			{
				tabBuilder.SetAction(Callback);
			}
			if (Before != null)
			{
				string[] manifestResourceNames = Before;
				foreach (string text2 in manifestResourceNames)
				{
					if (!string.IsNullOrEmpty(text2))
					{
						tabBuilder.Before(text2);
					}
					if (tabBuilder.insertIndex.HasValue)
					{
						break;
					}
				}
			}
			if (after != null)
			{
				string[] manifestResourceNames = after;
				foreach (string text3 in manifestResourceNames)
				{
					if (!string.IsNullOrEmpty(text3))
					{
						tabBuilder.After(text3);
					}
					if (tabBuilder.insertIndex.HasValue)
					{
						break;
					}
				}
			}
			tabBuilder.Build();
		}
	}
}
namespace TabsBuilderApi.Patches
{
	[HarmonyPatch(typeof(PlayerCustomizationMenu))]
	public static class PlayerCustomizationMenuPatched
	{
		public static AnotherScroller anotherScroller;

		public static void registerClass()
		{
			ClassInjector.RegisterTypeInIl2Cpp<ExpandedTabButton>();
			ClassInjector.RegisterTypeInIl2Cpp<AnotherScroller>();
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static bool Start_Prefix(PlayerCustomizationMenu __instance)
		{
			if (TabBuilder.StartCheck(__instance))
			{
				return true;
			}
			TabRegistry.BuildAll(__instance);
			return true;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start_Postfix(PlayerCustomizationMenu __instance)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			if (TabBuilder.StartCheck(__instance))
			{
				return;
			}
			Transform val = ((Component)__instance).transform.FindChild("Header");
			if (Object.op_Implicit((Object)(object)val))
			{
				val = val.FindChild("Tabs");
			}
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)((Il2CppArrayBase<TabButton>)(object)__instance.Tabs)[1].Button).transform.parent.parent;
			}
			if ((Object)(object)val == (Object)null)
			{
				TabBuilderPlugin.mls.LogFatal((object)"unable to find tabs? 3:");
				return;
			}
			AspectSpacer component = ((Component)val).gameObject.GetComponent<AspectSpacer>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Object.Destroy((Object)(object)component);
			}
			AspectSize component2 = ((Component)val).gameObject.GetComponent<AspectSize>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Object.Destroy((Object)(object)component2);
			}
			GameObject gameObject = ((Component)val.parent).gameObject;
			BoxCollider2D val2 = gameObject.GetComponent<BoxCollider2D>();
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = gameObject.AddComponent<BoxCollider2D>();
			}
			val2.size = new Vector2(30f, 1f);
			((Collider2D)val2).offset = Vector2.zero;
			anotherScroller = gameObject.AddComponent<AnotherScroller>();
			float num = (float)Screen.width / 1920f;
			anotherScroller.allowX = true;
			anotherScroller.allowY = false;
			anotherScroller.DragScrollSpeed = 1f;
			((PassiveUiElement)anotherScroller).Colliders = new Il2CppReferenceArray<Collider2D>((Collider2D[])(object)new Collider2D[1] { (Collider2D)val2 });
			anotherScroller.Inner = val;
			((Component)__instance.BackButton).transform.SetParent(val);
			__instance.glyphL.gameObject.transform.position = new Vector3(num * -4.5f, __instance.glyphL.gameObject.transform.position.y, __instance.glyphL.gameObject.transform.position.z);
			((Component)__instance.BackButton).transform.position = new Vector3(__instance.glyphL.gameObject.transform.position.x, ((Component)__instance.BackButton).transform.position.y, ((Component)__instance.BackButton).transform.position.z);
			anotherScroller.ScrollPostX(num * -2f);
			anotherScroller.SetBoundsMax(0f, 5f);
			anotherScroller.SetBoundsMin(0f, num * -2f);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void Update_Postfix(PlayerCustomizationMenu __instance)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)anotherScroller))
			{
				float num = (float)Screen.width / 1920f;
				anotherScroller.SetBoundsMax(0f, num * 4f + (float)(((Il2CppArrayBase<TabButton>)(object)__instance.Tabs).Count - 3));
				((Component)__instance.BackButton).transform.position = new Vector3(__instance.glyphL.gameObject.transform.position.x, ((Component)__instance.BackButton).transform.position.y, ((Component)__instance.BackButton).transform.position.z);
			}
		}

		[HarmonyPatch("OpenTab")]
		[HarmonyPostfix]
		public static void OpenTab_Postfix(PlayerCustomizationMenu __instance, InventoryTab tab)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)tab))
			{
				return;
			}
			Transform val = ((Component)tab).transform.Find("viper.cosmella.tabAPI");
			if (Object.op_Implicit((Object)(object)((Component)anotherScroller).gameObject) && (int)ActiveInputManager.currentControlType == 0)
			{
				anotherScroller.ScrollPostX((float)Screen.width / 1920f + (float)(__instance.selectedTab - 2));
			}
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			ExpandedTabButton component = ((Component)val).GetComponent<ExpandedTabButton>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			IEnumerator enumerator = tab.scroller.Inner.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Transform val2 = ((Il2CppObjectBase)enumerator.Current).TryCast<Transform>();
					if ((Object)(object)val2 != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)val2).gameObject);
					}
				}
			}
			finally
			{
				if (enumerator is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
			tab.ColorChips.Clear();
			component.InvokeAction(__instance);
		}
	}
}
namespace TabsBuilderApi.backend
{
	public class AnotherScroller : PassiveUiElement
	{
		public delegate void ScrollHandler(float value);

		public Vector3 currentScroll = new Vector3(0f, 0f, 0f);

		public Transform Inner;

		public bool allowY;

		public bool showY = true;

		public FloatRange ContentYBounds = new FloatRange(-10f, 10f);

		public FloatRange ScrollbarYBounds;

		public Scrollbar ScrollbarY;

		public bool allowX;

		public bool showX = true;

		public FloatRange ContentXBounds = new FloatRange(-10f, 10f);

		public FloatRange ScrollbarXBounds;

		public Scrollbar ScrollbarX;

		public float DragScrollSpeed = 1f;

		public float ScrollWheelSpeed = 0.25f;

		public bool MouseMustBeOverToScroll;

		public Vector2 velocity;

		public bool active;

		public bool mouseOver;

		public ScrollHandler OnScrollXEvent;

		public ScrollHandler OnScrollYEvent;

		public override bool HandleUp => true;

		public override bool HandleDown => true;

		public override bool HandleDrag => true;

		public override bool HandleOverOut => MouseMustBeOverToScroll;

		public bool AtTop => Inner.localPosition.y <= ContentYBounds.min + 0.25f;

		public bool AtBottom => Inner.localPosition.y >= ContentYBounds.max - 0.25f;

		public bool AtLeft => Inner.localPosition.x <= ContentXBounds.min + 0.25f;

		public bool AtRight => Inner.localPosition.x >= ContentXBounds.max - 0.25f;

		public Collider2D Hitbox => ((Il2CppArrayBase<Collider2D>)(object)((PassiveUiElement)this).Colliders)[0];

		public void SetBounds(FloatRange yBounds, FloatRange xBounds)
		{
			if (yBounds != null)
			{
				ContentYBounds = yBounds;
			}
			if (xBounds != null)
			{
				ContentXBounds = xBounds;
			}
			UpdateScrollBars();
		}

		public void CalculateAndSetYBounds(float amount, float numPerRow, float numRowsVisible, float spacing)
		{
			ContentYBounds.max = Mathf.Max(0f, (float)Mathf.CeilToInt((amount - numPerRow * numRowsVisible) / numPerRow) * spacing);
			UpdateScrollBars();
		}

		public void SetBoundsMax(float yMax, float xMax)
		{
			ContentYBounds.max = yMax;
			ContentXBounds.max = xMax;
			UpdateScrollBars();
		}

		public void SetYBoundsMax(float yMax)
		{
			ContentYBounds.max = yMax;
			UpdateScrollBars();
		}

		public void SetBoundsMin(float yMin, float xMin)
		{
			ContentYBounds.min = yMin;
			ContentXBounds.min = xMin;
			UpdateScrollBars();
		}

		public void SetYBoundsMin(float yMin)
		{
			ContentYBounds.min = yMin;
			UpdateScrollBars();
		}

		public FloatRange GetYBounds()
		{
			return ContentYBounds;
		}

		public FloatRange GetXBounds()
		{
			return ContentXBounds;
		}

		public override void Update()
		{
			//IL_001c: 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)
			//IL_003d: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if (!active && ((Vector2)(ref velocity)).sqrMagnitude > 0.01f)
			{
				velocity = Vector2.ClampMagnitude(velocity, ((Vector2)(ref velocity)).magnitude - 10f * Time.deltaTime);
				ScrollRelative(velocity * Time.deltaTime);
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)Inner))
				{
					return;
				}
				if (MouseMustBeOverToScroll && Object.op_Implicit((Object)(object)((PassiveUiElement)this).ClickMask))
				{
					Vector2 position = DestroyableSingleton<PassiveButtonManager>.Instance.controller.GetTouch(0).Position;
					mouseOver = ((PassiveUiElement)this).ClickMask.OverlapPoint(position);
				}
				if (!MouseMustBeOverToScroll || mouseOver)
				{
					Vector2 val = Input.mouseScrollDelta * ScrollWheelSpeed;
					if (val.y != 0f)
					{
						val.y = 0f - val.y;
						ScrollRelative(val);
					}
					if (val.x != 0f)
					{
						val.x = 0f - val.x;
						ScrollRelative(val);
					}
				}
			}
		}

		public void ScrollDown()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Collider2D val = ((IEnumerable<Collider2D>)((PassiveUiElement)this).Colliders).First();
			Bounds bounds = val.bounds;
			float y = ((Bounds)(ref bounds)).max.y;
			bounds = val.bounds;
			float num = y - ((Bounds)(ref bounds)).min.y;
			ScrollRelative(new Vector2(0f, num * 0.75f));
		}

		public void ScrollUp()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Collider2D val = ((IEnumerable<Collider2D>)((PassiveUiElement)this).Colliders).First();
			Bounds bounds = val.bounds;
			float y = ((Bounds)(ref bounds)).max.y;
			bounds = val.bounds;
			float num = y - ((Bounds)(ref bounds)).min.y;
			ScrollRelative(new Vector2(0f, num * -0.75f));
		}

		public float GetScrollPercY()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (ContentYBounds.Width < 0.0001f)
			{
				return 1f;
			}
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			return ContentYBounds.ReverseLerp(localPosition.y);
		}

		public float GetScrollPercX()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (ContentXBounds.Width < 0.0001f)
			{
				return 1f;
			}
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			return ContentXBounds.ReverseLerp(localPosition.x);
		}

		public void ScrollPercentY(float p)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			localPosition.y = ContentYBounds.Lerp(p);
			((Component)Inner).transform.localPosition = localPosition;
			UpdateScrollBars();
		}

		public void ScrollPercentX(float p)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			localPosition.x = ContentXBounds.Lerp(p);
			currentScroll = localPosition;
			((Component)Inner).transform.localPosition = -currentScroll;
			UpdateScrollBars();
		}

		public void ScrollPostX(float p)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			localPosition.x = p;
			currentScroll = localPosition;
			((Component)Inner).transform.localPosition = -currentScroll;
			UpdateScrollBars();
		}

		public override void ReceiveClickDown()
		{
			active = true;
		}

		public override void ReceiveClickUp()
		{
			active = false;
		}

		public override void ReceiveClickDrag(Vector2 dragDelta)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			velocity = dragDelta / Time.deltaTime * 0.9f;
			ScrollRelative(dragDelta);
		}

		public void ScrollToScrollbarPositionY(Vector3 newScrollbarPosition)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			newScrollbarPosition.y = ScrollbarYBounds.Clamp(newScrollbarPosition.y);
			float p = 1f - ScrollbarYBounds.ReverseLerp(newScrollbarPosition.y);
			ScrollPercentY(p);
		}

		public void ScrollToScrollbarPositionX(Vector3 newScrollbarPosition)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			newScrollbarPosition.x = ScrollbarXBounds.Clamp(newScrollbarPosition.x);
			float p = 1f - ScrollbarXBounds.ReverseLerp(newScrollbarPosition.x);
			ScrollPercentX(p);
		}

		public void ScrollRelative(Vector2 dragDelta)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			dragDelta *= DragScrollSpeed;
			if (!allowX)
			{
				dragDelta.x = 0f;
			}
			if (!allowY)
			{
				dragDelta.y = 0f;
			}
			dragDelta.x = 0f - dragDelta.x;
			Vector3 val = currentScroll + Vector2.op_Implicit(dragDelta);
			float num = Mathf.Max(ContentYBounds.min, ContentYBounds.max);
			val.y = Mathf.Clamp(val.y, ContentYBounds.min, num);
			float num2 = Mathf.Max(ContentXBounds.min, ContentXBounds.max);
			val.x = Mathf.Clamp(val.x, ContentXBounds.min, num2);
			currentScroll = val;
			((Component)Inner).transform.localPosition = -currentScroll;
			UpdateScrollBars();
		}

		public void UpdateScrollBars()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)ScrollbarY))
			{
				if (!showY || ContentYBounds.min >= ContentYBounds.max)
				{
					ScrollbarY.Toggle(false);
				}
				else
				{
					ScrollbarY.Toggle(true);
					float num = ContentYBounds.Lerp(((Component)Inner).transform.localPosition.y);
					Vector3 localPosition = ((Component)ScrollbarY).transform.localPosition;
					localPosition.y = ScrollbarYBounds.ReverseLerp(1f - num);
					ScrollbarY.UpdatePosition(localPosition);
				}
				ScrollHandler onScrollYEvent = OnScrollYEvent;
				if ((Delegate)(object)onScrollYEvent != (Delegate)null)
				{
					onScrollYEvent.Invoke(GetScrollPercY());
				}
			}
			if (Object.op_Implicit((Object)(object)ScrollbarX))
			{
				if (!showX || ContentXBounds.min >= ContentXBounds.max)
				{
					ScrollbarX.Toggle(false);
				}
				else
				{
					ScrollbarX.Toggle(true);
					float num2 = ContentXBounds.Lerp(((Component)Inner).transform.localPosition.x);
					Vector3 localPosition2 = ((Component)ScrollbarX).transform.localPosition;
					localPosition2.x = ScrollbarXBounds.ReverseLerp(1f - num2);
					ScrollbarX.UpdatePosition(localPosition2);
				}
				ScrollHandler onScrollXEvent = OnScrollXEvent;
				if (!((Delegate)(object)onScrollXEvent == (Delegate)null))
				{
					onScrollXEvent.Invoke(GetScrollPercX());
				}
			}
		}

		public void ScrollToTop()
		{
			//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)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			velocity = Vector2.zero;
			Vector3 localPosition = ((Component)Inner).transform.localPosition;
			localPosition.y = ContentYBounds.min;
			currentScroll = localPosition;
			((Component)Inner).transform.localPosition = -currentScroll;
			UpdateScrollBars();
		}
	}
	public class ExpandedTabButton : MonoBehaviour
	{
		public Action<PlayerCustomizationMenu>? action;

		public void InvokeAction(PlayerCustomizationMenu menu)
		{
			action?.Invoke(menu);
		}
	}
	public static class TabRegistry
	{
		public static void BuildAll(PlayerCustomizationMenu instance)
		{
			foreach (Type item in (from t in AppDomain.CurrentDomain.GetAssemblies().SelectMany(delegate(Assembly assembly)
				{
					try
					{
						return assembly.GetTypes();
					}
					catch (ReflectionTypeLoadException ex)
					{
						return ex.Types.Where((Type t) => t != null);
					}
					catch
					{
						return Enumerable.Empty<Type>();
					}
				})
				where t.IsDefined(typeof(TabBuilderAttribute), inherit: false)
				select t).ToList())
			{
				Assembly assembly2 = item.Assembly;
				TabBuilderAttribute[] array = (TabBuilderAttribute[])Attribute.GetCustomAttributes(item, typeof(TabBuilderAttribute));
				for (int i = 0; i < array.Length; i++)
				{
					array[i]?.Build(instance, assembly2);
				}
			}
		}
	}
}