Decompiled source of AutoBanish v1.0.0

AutoBanish.dll

Decompiled 19 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 Assets.Scripts.Saves___Serialization.Progression.Achievements;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
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("AutoBanish")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a73cba9e8ffaf545b392d3c77d960bd157664528")]
[assembly: AssemblyProduct("AutoBanish")]
[assembly: AssemblyTitle("AutoBanish")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 AutoBanish
{
	public class Menu : MonoBehaviour
	{
		private sealed class Tab
		{
			public readonly string Category;

			public readonly string Title;

			public readonly string Hint;

			public readonly Color Frame;

			public Tab(string category, string title, Color frame, string hint)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: 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_001f: Unknown result type (might be due to invalid IL or missing references)
				Category = category;
				Title = title;
				Frame = frame;
				Hint = hint;
			}
		}

		private static readonly Color Accent = new Color(1f, 0.8f, 0.32f);

		private static readonly Color PanelBg = new Color(0.075f, 0.075f, 0.1f, 0.98f);

		private static readonly Color CardBg = new Color(0.2f, 0.2f, 0.26f);

		private static readonly Color CardMarked = new Color(0.6f, 0.11f, 0.14f);

		private static readonly Color TabIdle = new Color(0.22f, 0.22f, 0.28f);

		private static readonly Color Muted = new Color(0.72f, 0.72f, 0.78f);

		private static readonly Vector2 Zero = Vector2.zero;

		private static readonly Vector2 One = Vector2.one;

		private static readonly Vector2 Half = new Vector2(0.5f, 0.5f);

		private static readonly Vector2 Top = new Vector2(0.5f, 1f);

		private static readonly Tab[] Tabs = new Tab[3]
		{
			new Tab("Items", "Items", Color.clear, "Click a card to mark it. Marked items are banished automatically when they drop from a chest."),
			new Tab("Weapons", "Weapons", new Color(0.5f, 0.62f, 0.78f), "Marked weapons are banished automatically when a level-up offers them. That level-up is spent on the banish, same as banishing by hand."),
			new Tab("Tomes", "Tomes", new Color(0.62f, 0.48f, 0.82f), "Marked tomes are banished automatically when a level-up offers them. That level-up is spent on the banish, same as banishing by hand.")
		};

		private GameObject root;

		private TMP_FontAsset font;

		private TextMeshProUGUI hint;

		private ScrollRect scroll;

		private readonly RectTransform[] contents = (RectTransform[])(object)new RectTransform[Tabs.Length];

		private readonly Image[] tabBgs = (Image[])(object)new Image[Tabs.Length];

		private readonly TextMeshProUGUI[] tabTexts = (TextMeshProUGUI[])(object)new TextMeshProUGUI[Tabs.Length];

		private int tab;

		private int cards;

		public Menu(IntPtr ptr)
			: base(ptr)
		{
		}

		private void OnGUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//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)
			Event current = Event.current;
			if ((int)current.type == 4 && current.keyCode == Plugin.MenuKey.Value)
			{
				current.Use();
				if ((Object)(object)root == (Object)null || cards == 0)
				{
					Build();
				}
				root.SetActive(!root.activeSelf);
			}
		}

		private void Build()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)root);
			}
			font = FindFont();
			root = new GameObject("AutoBanishMenu");
			Object.DontDestroyOnLoad((Object)(object)root);
			Canvas obj = root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32000;
			CanvasScaler obj2 = root.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			root.AddComponent<GraphicRaycaster>();
			RectTransform parent = Box("Backdrop", root.transform, Zero, One, Zero, Zero, new Color(0f, 0f, 0f, 0.72f));
			RectTransform parent2 = Box("Border", (Transform)(object)parent, Half, Half, new Vector2(-520f, -400f), new Vector2(520f, 400f), Accent);
			RectTransform parent3 = Box("Panel", (Transform)(object)parent2, Zero, One, new Vector2(2f, 2f), new Vector2(-2f, -2f), PanelBg);
			((TMP_Text)Label(Node("Title", (Transform)(object)parent3, new Vector2(0f, 1f), One, new Vector2(28f, -66f), new Vector2(-260f, -18f)), "AutoBanish", 38f, (TextAlignmentOptions)513, Accent)).fontStyle = (FontStyles)1;
			hint = Label(Node("Hint", (Transform)(object)parent3, new Vector2(0f, 1f), One, new Vector2(28f, -122f), new Vector2(-28f, -70f)), "", 19f, (TextAlignmentOptions)257, Muted);
			((TMP_Text)hint).enableAutoSizing = true;
			((TMP_Text)hint).fontSizeMin = 14f;
			((TMP_Text)hint).fontSizeMax = 19f;
			RectTransform val = Box("Close", (Transform)(object)parent3, One, One, new Vector2(-224f, -64f), new Vector2(-28f, -20f), new Color(0.3f, 0.3f, 0.36f));
			Label(Node("Text", (Transform)(object)val, Zero, One, Zero, Zero), $"Close  [{Plugin.MenuKey.Value}]", 20f, (TextAlignmentOptions)514, Color.white);
			AddButton(val, (Graphic)(object)((Component)val).GetComponent<Image>(), delegate
			{
				root.SetActive(false);
			});
			Box("Divider", (Transform)(object)parent3, new Vector2(0f, 1f), One, new Vector2(28f, -188f), new Vector2(-28f, -186f), new Color(1f, 1f, 1f, 0.08f));
			RectTransform val2 = Node("Scroll", (Transform)(object)parent3, Zero, One, new Vector2(28f, 24f), new Vector2(-28f, -200f));
			RectTransform val3 = Box("Viewport", (Transform)(object)val2, Zero, One, Zero, new Vector2(-16f, 0f), new Color(0f, 0f, 0f, 0.25f));
			((Component)val3).gameObject.AddComponent<RectMask2D>();
			RectTransform val4 = Box("Scrollbar", (Transform)(object)val2, new Vector2(1f, 0f), One, new Vector2(-8f, 0f), Zero, new Color(1f, 1f, 1f, 0.06f));
			RectTransform val5 = Box("Handle", (Transform)(object)val4, Zero, One, Zero, Zero, new Color(Accent.r, Accent.g, Accent.b, 0.85f));
			Scrollbar val6 = ((Component)val4).gameObject.AddComponent<Scrollbar>();
			val6.handleRect = val5;
			((Selectable)val6).targetGraphic = (Graphic)(object)((Component)val5).GetComponent<Image>();
			val6.direction = (Direction)2;
			scroll = ((Component)val2).gameObject.AddComponent<ScrollRect>();
			scroll.viewport = val3;
			scroll.horizontal = false;
			scroll.movementType = (MovementType)2;
			scroll.scrollSensitivity = 40f;
			scroll.verticalScrollbar = val6;
			cards = 0;
			DataManager instance = DataManager.Instance;
			bool flag = (Object)(object)instance != (Object)null && instance.unsortedItems != null;
			if (!flag)
			{
				Plugin.Logger.LogError((object)"Game data is not loaded yet, menu is empty");
			}
			for (int num = 0; num < Tabs.Length; num++)
			{
				int index = num;
				RectTransform val7 = Box("Tab", (Transform)(object)parent3, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2((float)(28 + num * 232), -176f), new Vector2((float)(250 + num * 232), -132f), TabIdle);
				tabBgs[num] = ((Component)val7).GetComponent<Image>();
				tabTexts[num] = Label(Node("Text", (Transform)(object)val7, Zero, One, Zero, Zero), "", 21f, (TextAlignmentOptions)514, Color.white);
				((TMP_Text)tabTexts[num]).fontStyle = (FontStyles)1;
				AddButton(val7, (Graphic)(object)tabBgs[num], delegate
				{
					SelectTab(index);
				});
				contents[num] = Grid((Transform)(object)val3);
				if (flag)
				{
					foreach (var item in Entries(instance, Tabs[num]))
					{
						Card((Transform)(object)contents[num], Tabs[num], item.id, item.name, item.icon, item.frame);
					}
				}
				UpdateTabText(num);
			}
			SelectTab(tab);
			root.SetActive(false);
		}

		private static IEnumerable<(string id, string name, Texture icon, Color frame)> Entries(DataManager data, Tab t)
		{
			if (t.Category == "Items")
			{
				List<ItemData> items = data.unsortedItems;
				return from i in Enumerable.Range(0, items.Count)
					select items[i] into it
					where (int)it.rarity != 5
					orderby it.rarity, ((UnlockableBase)it).GetName()
					select (((object)it.eItem/*cast due to .constrained prefix*/).ToString(), ((UnlockableBase)it).GetName(), ((UnlockableBase)it).GetIcon(), it.GetColor());
			}
			if (t.Category == "Weapons")
			{
				List<WeaponData> weapons = data.unsortedWeapons;
				return from i in Enumerable.Range(0, weapons.Count)
					select weapons[i] into w
					select (((object)w.eWeapon/*cast due to .constrained prefix*/).ToString(), ((UnlockableBase)w).GetName(), ((UnlockableBase)w).GetIcon(), Frame: t.Frame) into x
					orderby x.Item2
					select x;
			}
			List<TomeData> tomes = data.unsortedTomes;
			return from i in Enumerable.Range(0, tomes.Count)
				select tomes[i] into x
				select (((object)x.eTome/*cast due to .constrained prefix*/).ToString(), ((UnlockableBase)x).GetName(), ((UnlockableBase)x).GetIcon(), Frame: t.Frame) into x
				orderby x.Item2
				select x;
		}

		private void SelectTab(int i)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			tab = i;
			for (int j = 0; j < Tabs.Length; j++)
			{
				((Component)contents[j]).gameObject.SetActive(j == i);
				((Graphic)tabBgs[j]).color = ((j == i) ? Accent : TabIdle);
				((Graphic)tabTexts[j]).color = ((j == i) ? PanelBg : Color.white);
			}
			((TMP_Text)hint).text = Tabs[i].Hint;
			scroll.content = contents[i];
			scroll.verticalNormalizedPosition = 1f;
		}

		private void UpdateTabText(int i)
		{
			((TMP_Text)tabTexts[i]).text = $"{Tabs[i].Title} ({Plugin.Marked[Tabs[i].Category].Count})";
		}

		private static RectTransform Grid(Transform viewport)
		{
			//IL_0010: 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_001a: 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_002a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Node("Content", viewport, new Vector2(0f, 1f), One, Zero, Zero);
			obj.pivot = Top;
			GridLayoutGroup val = ((Component)obj).gameObject.AddComponent<GridLayoutGroup>();
			val.cellSize = new Vector2(108f, 140f);
			val.spacing = new Vector2(10f, 10f);
			RectOffset padding = ((LayoutGroup)val).padding;
			int top = (((LayoutGroup)val).padding.bottom = 10);
			padding.top = top;
			val.constraint = (Constraint)1;
			val.constraintCount = 8;
			((LayoutGroup)val).childAlignment = (TextAnchor)1;
			((Component)obj).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			return obj;
		}

		private void Card(Transform parent, Tab t, string id, string title, Texture iconTexture, Color frame)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			frame.a = 1f;
			RectTransform val = Box("Card", parent, Zero, Zero, Zero, Zero, frame);
			RectTransform val2 = Box("Inner", (Transform)(object)val, Zero, One, new Vector2(3f, 3f), new Vector2(-3f, -3f), CardBg);
			Image bg = ((Component)val2).GetComponent<Image>();
			RawImage icon = ((Component)Node("Icon", (Transform)(object)val2, Top, Top, new Vector2(-30f, -86f), new Vector2(30f, -26f))).gameObject.AddComponent<RawImage>();
			icon.texture = iconTexture;
			((Graphic)icon).raycastTarget = false;
			TextMeshProUGUI obj = Label(Node("Name", (Transform)(object)val2, Zero, new Vector2(1f, 0f), new Vector2(4f, 4f), new Vector2(-4f, 50f)), title, 15f, (TextAlignmentOptions)514, Color.white);
			((TMP_Text)obj).enableAutoSizing = true;
			((TMP_Text)obj).fontSizeMin = 10f;
			((TMP_Text)obj).fontSizeMax = 15f;
			RectTransform badge = Box("Badge", (Transform)(object)val2, new Vector2(0f, 1f), One, new Vector2(0f, -22f), Zero, new Color(0.86f, 0.14f, 0.17f));
			((Graphic)((Component)badge).GetComponent<Image>()).raycastTarget = false;
			((TMP_Text)Label(Node("Text", (Transform)(object)badge, Zero, One, Zero, Zero), "BANISH", 13f, (TextAlignmentOptions)514, Color.white)).fontStyle = (FontStyles)1;
			Paint();
			AddButton(val, (Graphic)(object)bg, delegate
			{
				Plugin.Toggle(t.Category, id);
				Paint();
				UpdateTabText(Array.IndexOf(Tabs, t));
			});
			cards++;
			void Paint()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: 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)
				bool flag = Plugin.Marked[t.Category].Contains(id);
				((Graphic)bg).color = (flag ? CardMarked : CardBg);
				((Graphic)icon).color = (Color)(flag ? new Color(1f, 1f, 1f, 0.45f) : Color.white);
				((Component)badge).gameObject.SetActive(flag);
			}
		}

		private static void AddButton(RectTransform rect, Graphic target, Action onClick)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Button obj = ((Component)rect).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = target;
			ColorBlock colors = ((Selectable)obj).colors;
			Color val = default(Color);
			((Color)(ref val))..ctor(0.82f, 0.82f, 0.82f);
			((ColorBlock)(ref colors)).selectedColor = val;
			((ColorBlock)(ref colors)).normalColor = val;
			((ColorBlock)(ref colors)).highlightedColor = Color.white;
			((ColorBlock)(ref colors)).pressedColor = new Color(0.62f, 0.62f, 0.62f);
			((ColorBlock)(ref colors)).fadeDuration = 0.08f;
			((Selectable)obj).colors = colors;
			((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit(onClick));
		}

		private static RectTransform Node(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = new GameObject(name).AddComponent<RectTransform>();
			((Transform)obj).SetParent(parent, false);
			obj.anchorMin = anchorMin;
			obj.anchorMax = anchorMax;
			obj.offsetMin = offsetMin;
			obj.offsetMax = offsetMax;
			return obj;
		}

		private static RectTransform Box(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Node(name, parent, anchorMin, anchorMax, offsetMin, offsetMax);
			((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = color;
			return obj;
		}

		private TextMeshProUGUI Label(RectTransform rect, string text, float size, TextAlignmentOptions align, Color color)
		{
			//IL_0035: 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)
			TextMeshProUGUI val = ((Component)rect).gameObject.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val).font = font;
			}
			((TMP_Text)val).text = text;
			((TMP_Text)val).fontSize = size;
			((TMP_Text)val).alignment = align;
			((Graphic)val).color = color;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
			((Graphic)val).raycastTarget = false;
			return val;
		}

		private static TMP_FontAsset FindFont()
		{
			foreach (Object item in (Il2CppArrayBase<Object>)(object)Object.FindObjectsOfType(Il2CppType.Of<TextMeshProUGUI>()))
			{
				TMP_FontAsset val = ((TMP_Text)((Il2CppObjectBase)item).Cast<TextMeshProUGUI>()).font;
				if ((Object)(object)val != (Object)null && val.HasCharacter('Ж', true, false))
				{
					return val;
				}
			}
			Plugin.Logger.LogWarning((object)"No game font with Cyrillic glyphs found, using the TMP default");
			return TMP_Settings.defaultFontAsset;
		}
	}
	[BepInPlugin("megabonk.autobanish", "AutoBanish", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal const string Items = "Items";

		internal const string Weapons = "Weapons";

		internal const string Tomes = "Tomes";

		internal static ManualLogSource Logger;

		internal static ConfigEntry<KeyCode> MenuKey;

		internal static MonoBehaviour Host;

		internal static readonly Dictionary<string, HashSet<string>> Marked = new Dictionary<string, HashSet<string>>();

		private static readonly Dictionary<string, ConfigEntry<string>> lists = new Dictionary<string, ConfigEntry<string>>();

		public override void Load()
		{
			Logger = ((BasePlugin)this).Log;
			Bind("Items", "Items banished when they drop from a chest (EItem names, comma separated)");
			Bind("Weapons", "Weapons banished when offered on level-up (EWeapon names, comma separated)");
			Bind("Tomes", "Tomes banished when offered on level-up (ETome names, comma separated)");
			MenuKey = ((BasePlugin)this).Config.Bind<KeyCode>("General", "MenuKey", (KeyCode)287, "Opens and closes the menu");
			Host = (MonoBehaviour)(object)((BasePlugin)this).AddComponent<Menu>();
			Harmony.CreateAndPatchAll(typeof(BanishPatches), (string)null);
		}

		private void Bind(string category, string description)
		{
			ConfigEntry<string> val = ((BasePlugin)this).Config.Bind<string>("General", category, "", description);
			lists[category] = val;
			Marked[category] = val.Value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToHashSet();
		}

		internal static void Toggle(string category, string id)
		{
			HashSet<string> hashSet = Marked[category];
			if (!hashSet.Remove(id))
			{
				hashSet.Add(id);
			}
			lists[category].Value = string.Join(",", hashSet);
		}
	}
	internal static class BanishPatches
	{
		private static bool chestPending;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ChestWindowUi), "Open")]
		private static void ChestOpen()
		{
			chestPending = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ChestWindowUi), "OpeningFinished")]
		private static void ChestOpened(ChestWindowUi __instance)
		{
			//IL_002e: 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)
			if (chestPending)
			{
				chestPending = false;
				ItemData itemData = __instance.itemData;
				if (!((Object)(object)itemData == (Object)null) && Plugin.Marked["Items"].Contains(((object)itemData.eItem/*cast due to .constrained prefix*/).ToString()))
				{
					MonoBehaviourExtensions.StartCoroutine(Plugin.Host, ChestBanish(__instance, itemData));
				}
			}
		}

		private static IEnumerator ChestBanish(ChestWindowUi window, ItemData item)
		{
			string name = ((UnlockableBase)item).GetName();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if ((Object)(object)window.levelupScreen != (Object)null && window.levelupScreen.GetBanishes() <= 0)
			{
				ManualLogSource logger = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": no banishes left");
				}
				logger.LogInfo(val);
				yield break;
			}
			MyButtonOffersUtility button = window.b_banish;
			float deadline = Time.unscaledTime + 5f;
			while (!Clickable(button))
			{
				if (Time.unscaledTime > deadline || (Object)(object)window.itemData != (Object)(object)item)
				{
					ManualLogSource logger2 = Plugin.Logger;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(67, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": banish button not clickable (active=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((Component)button).gameObject.activeInHierarchy);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", interactable=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(((Selectable)((MyButton)button).button).interactable);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", cantAfford=");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(button.cantAfford);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
					}
					logger2.LogWarning(val2);
					yield break;
				}
				yield return null;
			}
			((UnityEvent)((MyButton)button).button.onClick).Invoke();
			ManualLogSource logger3 = Plugin.Logger;
			val = new BepInExInfoLogInterpolatedStringHandler(9, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Banished ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
			}
			logger3.LogInfo(val);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UpgradePicker), "ShuffleUpgrades")]
		private static void LevelupShuffled(UpgradePicker __instance)
		{
			MonoBehaviourExtensions.StartCoroutine(Plugin.Host, LevelupBanish(__instance));
		}

		private static IEnumerator LevelupBanish(UpgradePicker picker)
		{
			LevelupScreen screen = picker.levelupScreen;
			float deadline = Time.unscaledTime + 5f;
			string name;
			bool flag = default(bool);
			while (true)
			{
				yield return null;
				UpgradeButton val = ((IEnumerable<Object>)Object.FindObjectsOfType(Il2CppType.Of<UpgradeButton>())).Select((Object o) => ((Il2CppObjectBase)o).Cast<UpgradeButton>()).FirstOrDefault((Func<UpgradeButton, bool>)IsMarked);
				if ((Object)(object)val == (Object)null)
				{
					yield break;
				}
				name = val.upgradable.GetName();
				if (screen.GetBanishes() <= 0)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": no banishes left");
					}
					logger.LogInfo(val2);
					yield break;
				}
				if (Time.unscaledTime > deadline)
				{
					break;
				}
				if (picker.banishMode)
				{
					((UnityEvent)((MyButton)val).button.onClick).Invoke();
					if (!((Component)val).gameObject.activeSelf)
					{
						ManualLogSource logger2 = Plugin.Logger;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Banished ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" on level-up");
						}
						logger2.LogInfo(val2);
					}
				}
				else if (Clickable(screen.b_banish))
				{
					((UnityEvent)((MyButton)screen.b_banish).button.onClick).Invoke();
				}
			}
			MyButtonOffersUtility b_banish = screen.b_banish;
			ManualLogSource logger3 = Plugin.Logger;
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(75, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(name);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": level-up banish failed (banishMode=");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(picker.banishMode);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", active=");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(((Component)b_banish).gameObject.activeInHierarchy);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", interactable=");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(((Selectable)((MyButton)b_banish).button).interactable);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", cantAfford=");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(b_banish.cantAfford);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
			}
			logger3.LogWarning(val3);
		}

		private static bool IsMarked(UpgradeButton button)
		{
			//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)
			//IL_0075: 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)
			if (button.isItem || button.upgradable == null)
			{
				return false;
			}
			WeaponData val = ((Il2CppObjectBase)button.upgradable).TryCast<WeaponData>();
			if ((Object)(object)val != (Object)null)
			{
				return Plugin.Marked["Weapons"].Contains(((object)val.eWeapon/*cast due to .constrained prefix*/).ToString());
			}
			TomeData val2 = ((Il2CppObjectBase)button.upgradable).TryCast<TomeData>();
			if ((Object)(object)val2 != (Object)null)
			{
				return Plugin.Marked["Tomes"].Contains(((object)val2.eTome/*cast due to .constrained prefix*/).ToString());
			}
			return false;
		}

		private static bool Clickable(MyButtonOffersUtility button)
		{
			if (((Component)button).gameObject.activeInHierarchy && ((Selectable)((MyButton)button).button).interactable)
			{
				return !button.cantAfford;
			}
			return false;
		}
	}
}