Decompiled source of BetterCounterOfferUI v3.4.1

BetterCounterOffer_Mono_3.4.1.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BetterCounterOffer;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.Economy;
using ScheduleOne.GameTime;
using ScheduleOne.Persistence;
using ScheduleOne.Product;
using ScheduleOne.UI;
using ScheduleOne.UI.Handover;
using ScheduleOne.UI.Phone;
using ScheduleOne.UI.Phone.Messages;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Better Counter Offer UI", "3.4.1", "OverweightUnicorn", "")]
[assembly: MelonColor(255, 191, 0, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ScheduleOne.Core")]
[assembly: AssemblyCompany("BetterCounterOffer_Mono_3.4.1")]
[assembly: AssemblyConfiguration("MONO")]
[assembly: AssemblyFileVersion("3.4.1")]
[assembly: AssemblyInformationalVersion("1.0.0+4dd10420b1e36fdf8455c48f1fa7fc7c4d288203")]
[assembly: AssemblyProduct("BetterCounterOffer_Mono_3.4.1")]
[assembly: AssemblyTitle("BetterCounterOffer_Mono_3.4.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.4.1.0")]
[module: UnverifiableCode]
[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 BetterCounterOffer
{
	public static class BuildInfo
	{
		public const string Name = "Better Counter Offer UI";

		public const string Description = "A mod that improves the Counter Offer UI";

		public const string Author = "OverweightUnicorn";

		public const string Company = "UnicornsCanMod";

		public const string Version = "3.4.1";

		public const string DownloadLink = "";
	}
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__InitOnWake;
		}

		public override void OnInitializeMelon()
		{
			Utility.Log("Initializing Better Counter Offer...Go Make that Money");
			Utility.Log("If you find any bugs,");
			Utility.Log("first check that your game is updated and on the main branch,");
			Utility.Log("Then if the bug persists message me on nexus");
			Utility.Log("- OverweightUnicorn\n");
			CounterOfferConfig.Initialize();
		}

		public override void OnLateInitializeMelon()
		{
			//IL_001b: 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_0026: Expected O, but got Unknown
			UnityEvent onLoadComplete = Singleton<LoadManager>.Instance.onLoadComplete;
			object obj = <>O.<0>__InitOnWake;
			if (obj == null)
			{
				UnityAction val = CounterOfferUI.InitOnWake;
				<>O.<0>__InitOnWake = val;
				obj = (object)val;
			}
			onLoadComplete.AddListener((UnityAction)obj);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName.ToLower() == "main")
			{
				Utility.Log("Main");
				CounterOfferUI.labelCount = 0;
				CounterOfferUI.selectorTabControl = null;
			}
		}
	}
	public static class CounterOfferConfig
	{
		public static MelonPreferences_Category Category { get; private set; }

		public static MelonPreferences_Entry<bool> DisableAllLabels { get; private set; }

		public static MelonPreferences_Entry<bool> DisableSuccessRate { get; private set; }

		public static MelonPreferences_Entry<bool> DisableMaxLimit { get; private set; }

		public static MelonPreferences_Entry<bool> DisableInitialOffer { get; private set; }

		public static MelonPreferences_Entry<bool> EnablePricePerUnit { get; private set; }

		public static void Initialize()
		{
			Category = MelonPreferences.CreateCategory("Better Counter Offer UI");
			DisableAllLabels = Category.CreateEntry<bool>("DisableAllLabels", false, "Disable All Labels", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableSuccessRate = Category.CreateEntry<bool>("DisableSuccessRate", false, "Disable Success Rate", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableMaxLimit = Category.CreateEntry<bool>("DisableMaxLimit", false, "Disable Max Limit", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableInitialOffer = Category.CreateEntry<bool>("DisableInitialOffer", false, "Disable Initial Offer", (string)null, false, false, (ValueValidator)null, (string)null);
			EnablePricePerUnit = Category.CreateEntry<bool>("EnablePricePerUnit", false, "Enable Price Per Unit", (string)null, false, false, (ValueValidator)null, (string)null);
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "Open")]
	internal static class CounterOfferInterfaceOpenPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				CounterOfferUI.offerInterface = __instance;
				CounterOfferUI.OnPopupOpen(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(AmountSelector), "SetAmount")]
	internal static class CounterOfferPriceSelectorSetAmountPatch
	{
		public static void Postfix(AmountSelector __instance)
		{
			CounterofferInterface offerInterface = CounterOfferUI.offerInterface;
			if (!((Object)(object)offerInterface == (Object)null) && !((Object)(object)offerInterface.PriceSelector != (Object)(object)__instance))
			{
				if (!CounterOfferConfig.DisableSuccessRate.Value)
				{
					CounterOfferUI.UpdateSuccessRate(offerInterface);
				}
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					CounterOfferUI.SetFairPriceText(__instance.SelectedAmount / (float)offerInterface.quantity);
				}
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangeQuantity", new Type[] { typeof(float) })]
	internal static class CounterOfferInterfaceChangeQuantityPatch
	{
		public static bool Prefix(CounterofferInterface __instance, ref float change)
		{
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				int quantity = __instance.quantity;
				int num = quantity;
				if (change > 0f)
				{
					num = (quantity / 5 + 1) * 5;
				}
				else
				{
					if (!(change < 0f))
					{
						return true;
					}
					num = ((quantity <= 5) ? 1 : ((quantity - 1) / 5 * 5));
				}
				num = Math.Max(1, Math.Min(9999, num));
				change = num - quantity;
			}
			return true;
		}

		public static void Postfix(CounterofferInterface __instance)
		{
			ProductDefinition selectedProduct = __instance.selectedProduct;
			float amount = (float)__instance.quantity * selectedProduct.Price;
			__instance.PriceSelector.SetAmount(amount);
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "SetProduct")]
	internal static class CounterOfferInterfaceSetProductPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			float amount = (float)__instance.quantity * __instance.selectedProduct.Price;
			__instance.PriceSelector.SetAmount(amount);
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "Open")]
	internal static class CounterOfferProductSelectorOpenPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance)
		{
			if ((Object)(object)CounterOfferUI.selectorInterface == (Object)null)
			{
				CounterOfferUI.selectorInterface = __instance;
			}
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "ChangePage")]
	internal static class CounterOfferProductSelectorChangePageRedirectPatch
	{
		public static bool Prefix(CounterOfferProductSelector __instance, int change)
		{
			CounterOfferProductSelector selectorInterface = CounterOfferUI.selectorInterface;
			if ((Object)(object)selectorInterface != (Object)null && (Object)(object)selectorInterface != (Object)(object)__instance)
			{
				selectorInterface.ChangePage(change);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "GetMatchingProducts")]
	internal static class CounterOfferProductSelectorGetMatchingProductsPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance, ref List<ProductDefinition> __result, string searchTerm)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			string text = searchTerm.ToLower();
			HashSet<EDrugType> hashSet = new HashSet<EDrugType>();
			List<ProductDefinition> list = ((CounterOfferUI.currTab == "Listed") ? ProductManager.ListedProducts : ((!(CounterOfferUI.currTab == "Favorites")) ? ProductManager.DiscoveredProducts : ProductManager.FavouritedProducts));
			List<ProductDefinition> list2 = new List<ProductDefinition>();
			foreach (EDrugType value in Enum.GetValues(typeof(EDrugType)))
			{
				if (text.Contains(((object)value/*cast due to .constrained prefix*/).ToString().ToLower()))
				{
					hashSet.Add(value);
				}
			}
			if (text.Contains("weed"))
			{
				hashSet.Add((EDrugType)0);
			}
			if (text.Contains("coke"))
			{
				hashSet.Add((EDrugType)2);
			}
			if (text.Contains("meth"))
			{
				hashSet.Add((EDrugType)1);
			}
			if (text.Contains("shroom"))
			{
				hashSet.Add((EDrugType)4);
			}
			foreach (ProductDefinition item in list)
			{
				if (hashSet.Contains(item.DrugType) || ((BaseItemDefinition)item).Name.ToLower().Contains(text))
				{
					list2.Add(item);
				}
			}
			__result = list2;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "SetPage")]
	internal static class CounterOfferProductSelectorSetPagePatch
	{
		public const int PageSize = 24;

		public static bool Prefix(CounterOfferProductSelector __instance, int page)
		{
			__instance.pageIndex = Mathf.Clamp(page, 0, Mathf.Max(__instance.pageCount - 1, 0));
			int num = __instance.pageIndex * 24;
			int num2 = Mathf.Min(num + 24, __instance.results.Count);
			List<ProductDefinition> range = __instance.results.GetRange(num, num2 - num);
			foreach (KeyValuePair<ProductDefinition, RectTransform> item in __instance.productEntriesDict)
			{
				RectTransform value = item.Value;
				if (range.Contains(item.Key))
				{
					((Component)value).gameObject.SetActive(true);
					__instance.uiWindowPanel.AddSelectable(((Component)value).GetComponent<UISelectable>());
				}
				else
				{
					((Component)value).gameObject.SetActive(false);
					__instance.uiWindowPanel.RemoveSelectable(((Component)value).GetComponent<UISelectable>(), true);
				}
			}
			for (int i = 0; i < range.Count; i++)
			{
				((Transform)__instance.productEntriesDict[range[i]]).SetSiblingIndex(i);
			}
			__instance.PageLabel.text = $"{__instance.pageIndex + 1} / {__instance.pageCount}";
			return false;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "RebuildResultsList")]
	internal static class CounterOfferProductSelectorRebuildResultsListPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance)
		{
			__instance.pageCount = Mathf.CeilToInt((float)__instance.results.Count / 24f);
			__instance.SetPage(__instance.pageIndex);
		}
	}
	public static class CounterOfferUI
	{
		public static GameObject offerInfoGO = null;

		public static Text initialOfferText = null;

		public static Text successRateText = null;

		public static Text maxCashText = null;

		public static Text fairPriceText = null;

		public static Font gameFont = null;

		public static TabController selectorTabControl;

		public static string currTab = "Favorites";

		public static Gradient colorMap = new Gradient();

		public static CounterOfferProductSelector selectorInterface = null;

		public static CounterofferInterface offerInterface = null;

		public static int labelCount = 0;

		private static Transform contentTransform = null;

		public static void OnPopupOpen(CounterofferInterface instance)
		{
			Customer component = ((Component)instance.conversation.sender).GetComponent<Customer>();
			if ((Object)(object)component == (Object)null)
			{
				component = ((Component)offerInterface.conversation.sender).GetComponent<Customer>();
			}
			if (CounterOfferConfig.DisableAllLabels.Value)
			{
				return;
			}
			if (!CounterOfferConfig.DisableInitialOffer.Value)
			{
				float selectedAmount = instance.PriceSelector.SelectedAmount;
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					SetInitialPriceText(selectedAmount / (float)instance.quantity, ppu: true);
					SetFairPriceText(selectedAmount / (float)instance.quantity);
				}
				else
				{
					SetInitialPriceText(selectedAmount);
				}
			}
			if (!CounterOfferConfig.DisableMaxLimit.Value)
			{
				float num = CalculateSpendingLimits(component);
				SetMaxCashText(num);
			}
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				float num2 = CalculateSuccessProbability(component, instance.selectedProduct, instance.quantity, instance.PriceSelector.SelectedAmount);
				SetSuccessRateText(num2);
			}
		}

		public static void SetSuccessRateText(float success)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)successRateText == (Object)null)
			{
				Utility.Error("successRateText is null??");
				return;
			}
			successRateText.text = $"<b>{Mathf.RoundToInt(success * 100f)}% Chance of Success</b>";
			((Graphic)successRateText).color = colorMap.Evaluate(success);
		}

		public static void SetMaxCashText(float maxSpend)
		{
			if (!((Object)(object)maxCashText == (Object)null))
			{
				maxCashText.text = $"<b>Spend Limit: ${Mathf.RoundToInt(maxSpend)}</b>";
			}
		}

		public static void SetInitialPriceText(float initialPrice, bool ppu = false)
		{
			if (!((Object)(object)initialOfferText == (Object)null))
			{
				if (ppu)
				{
					initialOfferText.text = $"<b>Initial Offer: ${Mathf.RoundToInt(initialPrice)} per Unit</b>";
				}
				else
				{
					initialOfferText.text = $"<b>Initial Offer: ${Mathf.RoundToInt(initialPrice)}</b>";
				}
			}
		}

		public static void SetFairPriceText(float fairPrice)
		{
			if (!((Object)(object)fairPriceText == (Object)null))
			{
				fairPriceText.text = $"<b>Price: ${Mathf.RoundToInt(fairPrice)} per Unit</b>";
			}
		}

		public static float CalculateSpendingLimits(Customer customer)
		{
			CustomerData customerData = customer.CustomerData;
			float adjustedWeeklySpend = customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> list = new List<EDay>();
			customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f, list);
			return adjustedWeeklySpend / (float)list.Count * 3f;
		}

		public static float CalculateSuccessProbability(Customer customer, ProductDefinition product, int quantity, float price)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			float adjustedWeeklySpend = customer.customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> list = new List<EDay>();
			customer.customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f, list);
			float num = adjustedWeeklySpend / (float)list.Count;
			if (price >= num * 3f)
			{
				return 0f;
			}
			float valueProposition = Customer.GetValueProposition(Registry.GetItem<ProductDefinition>(customer.OfferedContractInfo.Products.entries[0].ProductID), customer.OfferedContractInfo.Payment / (float)customer.OfferedContractInfo.Products.entries[0].Quantity);
			float productEnjoyment = customer.GetProductEnjoyment(product, StandardsMethod.GetCorrespondingQuality(customer.customerData.Standards));
			float num2 = Mathf.InverseLerp(-1f, 1f, productEnjoyment);
			float valueProposition2 = Customer.GetValueProposition(product, price / (float)quantity);
			float num3 = Mathf.Pow((float)quantity / (float)customer.OfferedContractInfo.Products.entries[0].Quantity, 0.6f);
			float num4 = Mathf.Lerp(0f, 2f, num3 * 0.5f);
			float num5 = Mathf.Lerp(1f, 0f, Mathf.Abs(num4 - 1f));
			if (valueProposition2 * num5 > valueProposition)
			{
				return 1f;
			}
			if (valueProposition2 < 0.12f)
			{
				return 0f;
			}
			float num6 = productEnjoyment * valueProposition;
			float num7 = num2 * num5 * valueProposition2;
			if (num7 > num6)
			{
				return 1f;
			}
			float num8 = num6 - num7;
			float num9 = Mathf.Lerp(0f, 1f, num8 / 0.2f);
			float num10 = Mathf.Max(customer.CurrentAddiction, customer.NPC.RelationData.NormalizedRelationDelta);
			float num11 = Mathf.Lerp(0f, 0.2f, num10);
			if (num9 <= num11)
			{
				return 1f;
			}
			if (num9 - num11 >= 0.9f)
			{
				return 0f;
			}
			float num12 = (0.9f + num11 - num9) / 0.9f;
			return Mathf.Clamp(num12, 0f, 1f);
		}

		public static void UpdateSuccessRate(CounterofferInterface instance)
		{
			if ((Object)(object)instance == (Object)null)
			{
				Utility.Error("CounterofferInterface Instance was Null!!");
				return;
			}
			if ((Object)(object)successRateText == (Object)null)
			{
				Utility.Error("successRateText Instance was Null!!");
				return;
			}
			float num = CalculateSuccessProbability(((Component)instance.conversation.sender).GetComponent<Customer>(), instance.selectedProduct, instance.quantity, instance.PriceSelector.SelectedAmount);
			SetSuccessRateText(num);
		}

		public static void InitOnWake()
		{
			Utility.Log("Initializing Counter Offer UI");
			GameObject val = GameObject.Find("UI/HandoverScreen");
			if ((Object)(object)val != (Object)null)
			{
				Utility.Log("Found Handover Screen....Maybe Could Just search for the component?");
				HandoverScreen component = val.GetComponent<HandoverScreen>();
				if ((Object)(object)val != (Object)null)
				{
					colorMap = component.SuccessColorMap;
				}
			}
			CounterofferInterface counterofferInterface = PlayerSingleton<MessagesApp>.Instance.CounterofferInterface;
			if (!((Object)(object)counterofferInterface != (Object)null))
			{
				return;
			}
			Transform val2 = ((Component)counterofferInterface).transform.Find("Content");
			GameObject gameObject = ((Component)val2).gameObject;
			if ((Object)(object)gameObject != (Object)null)
			{
				contentTransform = val2;
				CreateLabels(val2);
				GetFairPrice();
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableAllLabels).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableInitialOffer).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableMaxLimit).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableSuccessRate).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.EnablePricePerUnit).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
			}
			UpdateSelectorUI(((Component)counterofferInterface).transform);
			ApplyLabelVisibility();
			if ((Object)(object)selectorInterface != (Object)null)
			{
				selectorInterface.EnsureAllEntriesExist();
			}
		}

		private static void RecalculateLabelCount()
		{
			labelCount = 0;
			if (!CounterOfferConfig.DisableAllLabels.Value)
			{
				if (!CounterOfferConfig.DisableInitialOffer.Value)
				{
					labelCount++;
				}
				if (!CounterOfferConfig.DisableMaxLimit.Value)
				{
					labelCount++;
				}
				if (!CounterOfferConfig.DisableSuccessRate.Value)
				{
					labelCount++;
				}
			}
		}

		public static void ApplyLabelVisibility()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)contentTransform == (Object)null))
			{
				RecalculateLabelCount();
				bool value = CounterOfferConfig.DisableAllLabels.Value;
				bool active = !value && !CounterOfferConfig.DisableInitialOffer.Value;
				bool active2 = !value && !CounterOfferConfig.DisableMaxLimit.Value;
				bool active3 = !value && !CounterOfferConfig.DisableSuccessRate.Value;
				if ((Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).gameObject.SetActive(active);
				}
				if ((Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).gameObject.SetActive(active2);
				}
				if ((Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).gameObject.SetActive(active3);
				}
				if ((Object)(object)selectorInterface != (Object)null)
				{
					((Component)selectorInterface).GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, (float)(-170 - labelCount * 30));
				}
				GetFairPrice();
			}
		}

		private static void GetFairPrice()
		{
			CounterofferInterface counterofferInterface = PlayerSingleton<MessagesApp>.Instance.CounterofferInterface;
			if ((Object)(object)counterofferInterface != (Object)null)
			{
				fairPriceText = counterofferInterface.FairPriceLabel;
			}
		}

		private static void UpdateSelectorUI(Transform parent)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Selection");
			if ((Object)(object)val != (Object)null)
			{
				Utility.Log("The Selector UI now has Tabs....AWESOME");
				selectorInterface = ((Component)val).GetComponent<CounterOfferProductSelector>();
				Transform val2 = val.Find("Container/SearchInput");
				if ((Object)(object)val2 != (Object)null)
				{
					RectTransform component = ((Component)val2).GetComponent<RectTransform>();
					component.anchoredPosition = new Vector2(0f, -83f);
					InputField component2 = ((Component)val2).GetComponent<InputField>();
				}
				Transform val3 = val.Find("Container");
				if ((Object)(object)val3 != (Object)null && selectorTabControl == null)
				{
					selectorTabControl = new TabController(val3);
					selectorTabControl.font = gameFont;
					selectorTabControl.AddTab("Favorites", "<b>Fave</b>");
					selectorTabControl.AddTab("Listed", "<b>Listed</b>");
					selectorTabControl.AddTab("Discovered", "<b>All</b>");
					selectorTabControl.SetSelected(currTab);
				}
			}
			else
			{
				Utility.Error("Selection Couldn't be Found");
			}
		}

		public static void TabSelected(Tab selected)
		{
			currTab = selected.id;
			if ((Object)(object)selectorInterface != (Object)null)
			{
				selectorInterface.RebuildResultsList();
			}
		}

		private static void CreateLabels(Transform parent)
		{
			Transform val = parent.Find("Header/Title");
			if ((Object)(object)val != (Object)null)
			{
				gameFont = ((Component)val).GetComponent<Text>().font;
			}
			initialOfferText = CreateLabel(parent, "InitialCash", "Initial Offer Price: ");
			((Component)initialOfferText).transform.SetSiblingIndex(3);
			maxCashText = CreateLabel(parent, "MaxCash", "$1000 Max");
			((Component)maxCashText).transform.SetSiblingIndex(4);
			successRateText = CreateLabel(parent, "SuccessRate", "100% Success Rate");
			((Component)successRateText).transform.SetSiblingIndex(5);
		}

		public static Text CreateLabel(Transform parent, string title, string text)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(title);
			val.transform.SetParent(parent, false);
			Text val2 = val.AddComponent<Text>();
			val2.text = text;
			val2.font = (((Object)(object)gameFont != (Object)null) ? gameFont : Resources.GetBuiltinResource<Font>("Arial.ttf"));
			val2.fontSize = 30;
			((Graphic)val2).color = Color.gray;
			val2.alignment = (TextAnchor)4;
			RectTransform component = ((Component)val.transform).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(600f, 100f);
			return val2;
		}
	}
	public class Tab
	{
		public string id;

		public Button button;

		public Image background;

		public Text buttonText;

		public void SetColor(Color bgColor, Color textColor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			SetBgColor(bgColor);
			SetTextColor(textColor);
		}

		public void SetBgColor(Color newColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)background).color = newColor;
		}

		public void SetTextColor(Color newColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)buttonText).color = newColor;
		}
	}
	public class TabController
	{
		public Dictionary<string, Tab> allTabs = new Dictionary<string, Tab>();

		public Tab selectedTab = null;

		public float clickBuffer = 0.7f;

		public float prevTime = 0f;

		public GameObject filterbuttons;

		public Transform parent;

		public Font font;

		public Color textActive = new Color(0.961f, 0.961f, 0.961f);

		public Color textDisabled = new Color(0.686f, 0.686f, 0.686f);

		public Color tabIdle = new Color(0.051f, 0.286f, 0.451f);

		public Color tabHover = new Color(0.114f, 0.353f, 0.525f);

		public Color tabActive = new Color(0.204f, 0.522f, 0.737f);

		public TabController(Transform parent)
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			this.parent = parent;
			InitFilterButtons();
		}

		private void InitFilterButtons()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0070: 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_009c: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			filterbuttons = new GameObject("Filter_Buttons");
			if ((Object)(object)parent != (Object)null)
			{
				filterbuttons.transform.SetParent(parent, false);
				filterbuttons.transform.SetSiblingIndex(0);
			}
			filterbuttons.AddComponent<CanvasRenderer>();
			RectTransform val = filterbuttons.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0f, 0.5f);
			val.anchorMax = new Vector2(1f, 0.5f);
			val.anchoredPosition = new Vector2(0f, 200f);
			val.sizeDelta = new Vector2(1f, 60f);
			Image val2 = filterbuttons.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.9608f, 0.9608f, 0.9608f);
			GridLayoutGroup val3 = filterbuttons.AddComponent<GridLayoutGroup>();
			val3.cellSize = new Vector2(100f, 45f);
			val3.spacing = new Vector2(15f, 0f);
			((LayoutGroup)val3).childAlignment = (TextAnchor)4;
			val3.constraint = (Constraint)1;
			val3.constraintCount = 3;
		}

		public void AddTab(string id, string text)
		{
			if (allTabs.ContainsKey(id))
			{
				throw new Exception("The key " + id + " already exists in the tab list");
			}
			if ((Object)(object)filterbuttons == (Object)null)
			{
				throw new Exception("Filter Buttons has not been initialized");
			}
			Tab value = CreateNewTab(filterbuttons.transform, id, text);
			allTabs.Add(id, value);
		}

		public void SetSelected(string key)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!allTabs.ContainsKey(key))
			{
				throw new Exception(key + " Does Not Exist in the TabController Dictionary");
			}
			Tab tab = allTabs[key];
			selectedTab = allTabs[key];
			tab.SetColor(tabActive, textActive);
		}

		public Tab CreateNewTab(Transform parent, string title, string text)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0044: 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_0061: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(title + "_Button");
			val.transform.SetParent(parent, false);
			val.AddComponent<CanvasRenderer>();
			Button button = val.AddComponent<Button>();
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = tabIdle;
			GameObject val3 = new GameObject(title + "_Button_Text");
			val3.transform.SetParent(val.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.text = text;
			val4.font = (((Object)(object)font != (Object)null) ? font : Resources.GetBuiltinResource<Font>("Arial.ttf"));
			val4.fontSize = 30;
			((Graphic)val4).color = textDisabled;
			val4.alignment = (TextAnchor)4;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(60f, 40f);
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.anchoredPosition = new Vector2(0f, 0f);
			Tab newTab = new Tab();
			newTab.id = title;
			newTab.button = button;
			newTab.background = val2;
			newTab.buttonText = val4;
			Entry val5 = new Entry();
			val5.eventID = (EventTriggerType)0;
			((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				HandleButtonEnter(newTab);
			});
			Entry val6 = new Entry();
			val6.eventID = (EventTriggerType)1;
			((UnityEvent<BaseEventData>)(object)val6.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				HandleButtonExit(newTab);
			});
			Entry val7 = new Entry();
			val7.eventID = (EventTriggerType)4;
			((UnityEvent<BaseEventData>)(object)val7.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				HandleButtonClick(newTab);
			});
			EventTrigger val8 = val.AddComponent<EventTrigger>();
			val8.triggers.Add(val5);
			val8.triggers.Add(val6);
			val8.triggers.Add(val7);
			return newTab;
		}

		public void HandleButtonEnter(Tab currTab)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ResetTabs();
			if (selectedTab == null || selectedTab != currTab)
			{
				currTab.SetBgColor(tabHover);
			}
		}

		public void HandleButtonExit(Tab currTab)
		{
			ResetTabs();
		}

		public void HandleButtonClick(Tab currTab)
		{
			//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)
			float time = Time.time;
			if (time - prevTime > clickBuffer)
			{
				CounterOfferUI.TabSelected(currTab);
				selectedTab = currTab;
				ResetTabs();
				currTab.SetColor(tabActive, textActive);
				prevTime = time;
			}
		}

		public void ResetTabs()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, Tab> allTab in allTabs)
			{
				if (selectedTab == null || selectedTab != allTab.Value)
				{
					allTab.Value.SetColor(tabIdle, textDisabled);
				}
			}
		}
	}
	public static class Utility
	{
		public static void PrintException(Exception e)
		{
			MelonLogger.Msg(ConsoleColor.Red, e.Source);
			MelonLogger.Msg(ConsoleColor.DarkRed, e.Message);
		}

		public static void Error(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Red, msg);
		}

		public static void Log(string msg)
		{
			MelonLogger.Msg(ConsoleColor.DarkMagenta, msg);
		}

		public static void Success(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Green, msg);
		}

		public static void ListHierarchy(Transform transform, int depth)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			string text = new string(' ', depth * 2);
			MelonLogger.Msg(text + "- " + ((Object)transform).name);
			foreach (Transform item in transform)
			{
				Transform transform2 = item;
				ListHierarchy(transform2, depth + 1);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BetterCounterOffer_IL2Cpp_3.4.1.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BetterCounterOffer;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Economy;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.Product;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Handover;
using Il2CppScheduleOne.UI.Phone;
using Il2CppScheduleOne.UI.Phone.Messages;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Better Counter Offer UI", "3.4.1", "OverweightUnicorn", "")]
[assembly: MelonColor(255, 191, 0, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("BetterCounterOffer_IL2Cpp_3.4.1")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyFileVersion("3.4.1")]
[assembly: AssemblyInformationalVersion("1.0.0+4dd10420b1e36fdf8455c48f1fa7fc7c4d288203")]
[assembly: AssemblyProduct("BetterCounterOffer_IL2Cpp_3.4.1")]
[assembly: AssemblyTitle("BetterCounterOffer_IL2Cpp_3.4.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.4.1.0")]
[module: UnverifiableCode]
[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 BetterCounterOffer
{
	public static class BuildInfo
	{
		public const string Name = "Better Counter Offer UI";

		public const string Description = "A mod that improves the Counter Offer UI";

		public const string Author = "OverweightUnicorn";

		public const string Company = "UnicornsCanMod";

		public const string Version = "3.4.1";

		public const string DownloadLink = "";
	}
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			Utility.Log("Initializing Better Counter Offer...Go Make that Money");
			Utility.Log("If you find any bugs,");
			Utility.Log("first check that your game is updated and on the main branch,");
			Utility.Log("Then if the bug persists message me on nexus");
			Utility.Log("- OverweightUnicorn\n");
			CounterOfferConfig.Initialize();
		}

		public override void OnLateInitializeMelon()
		{
			Singleton<LoadManager>.Instance.onLoadComplete.AddListener(UnityAction.op_Implicit((Action)CounterOfferUI.InitOnWake));
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName.ToLower() == "main")
			{
				Utility.Log("Main");
				CounterOfferUI.labelCount = 0;
				CounterOfferUI.selectorTabControl = null;
			}
		}
	}
	public static class CounterOfferConfig
	{
		public static MelonPreferences_Category Category { get; private set; }

		public static MelonPreferences_Entry<bool> DisableAllLabels { get; private set; }

		public static MelonPreferences_Entry<bool> DisableSuccessRate { get; private set; }

		public static MelonPreferences_Entry<bool> DisableMaxLimit { get; private set; }

		public static MelonPreferences_Entry<bool> DisableInitialOffer { get; private set; }

		public static MelonPreferences_Entry<bool> EnablePricePerUnit { get; private set; }

		public static void Initialize()
		{
			Category = MelonPreferences.CreateCategory("Better Counter Offer UI");
			DisableAllLabels = Category.CreateEntry<bool>("DisableAllLabels", false, "Disable All Labels", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableSuccessRate = Category.CreateEntry<bool>("DisableSuccessRate", false, "Disable Success Rate", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableMaxLimit = Category.CreateEntry<bool>("DisableMaxLimit", false, "Disable Max Limit", (string)null, false, false, (ValueValidator)null, (string)null);
			DisableInitialOffer = Category.CreateEntry<bool>("DisableInitialOffer", false, "Disable Initial Offer", (string)null, false, false, (ValueValidator)null, (string)null);
			EnablePricePerUnit = Category.CreateEntry<bool>("EnablePricePerUnit", false, "Enable Price Per Unit", (string)null, false, false, (ValueValidator)null, (string)null);
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "Open")]
	internal static class CounterOfferInterfaceOpenPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				CounterOfferUI.offerInterface = __instance;
				CounterOfferUI.OnPopupOpen(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(AmountSelector), "SetAmount")]
	internal static class CounterOfferPriceSelectorSetAmountPatch
	{
		public static void Postfix(AmountSelector __instance)
		{
			CounterofferInterface offerInterface = CounterOfferUI.offerInterface;
			if (!((Object)(object)offerInterface == (Object)null) && !((Object)(object)offerInterface.PriceSelector != (Object)(object)__instance))
			{
				if (!CounterOfferConfig.DisableSuccessRate.Value)
				{
					CounterOfferUI.UpdateSuccessRate(offerInterface);
				}
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					CounterOfferUI.SetFairPriceText(__instance.SelectedAmount / (float)offerInterface.quantity);
				}
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangeQuantity", new Type[] { typeof(float) })]
	internal static class CounterOfferInterfaceChangeQuantityPatch
	{
		public static bool Prefix(CounterofferInterface __instance, ref float change)
		{
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				int quantity = __instance.quantity;
				int num = quantity;
				if (change > 0f)
				{
					num = (quantity / 5 + 1) * 5;
				}
				else
				{
					if (!(change < 0f))
					{
						return true;
					}
					num = ((quantity <= 5) ? 1 : ((quantity - 1) / 5 * 5));
				}
				num = Math.Max(1, Math.Min(9999, num));
				change = num - quantity;
			}
			return true;
		}

		public static void Postfix(CounterofferInterface __instance)
		{
			ProductDefinition selectedProduct = __instance.selectedProduct;
			float amount = (float)__instance.quantity * selectedProduct.Price;
			__instance.PriceSelector.SetAmount(amount);
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "SetProduct")]
	internal static class CounterOfferInterfaceSetProductPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			float amount = (float)__instance.quantity * __instance.selectedProduct.Price;
			__instance.PriceSelector.SetAmount(amount);
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "Open")]
	internal static class CounterOfferProductSelectorOpenPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance)
		{
			if ((Object)(object)CounterOfferUI.selectorInterface == (Object)null)
			{
				CounterOfferUI.selectorInterface = __instance;
			}
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "ChangePage")]
	internal static class CounterOfferProductSelectorChangePageRedirectPatch
	{
		public static bool Prefix(CounterOfferProductSelector __instance, int change)
		{
			CounterOfferProductSelector selectorInterface = CounterOfferUI.selectorInterface;
			if ((Object)(object)selectorInterface != (Object)null && (Object)(object)selectorInterface != (Object)(object)__instance)
			{
				selectorInterface.ChangePage(change);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "GetMatchingProducts")]
	internal static class CounterOfferProductSelectorGetMatchingProductsPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance, ref List<ProductDefinition> __result, string searchTerm)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			string text = searchTerm.ToLower();
			HashSet<EDrugType> hashSet = new HashSet<EDrugType>();
			List<ProductDefinition> val = ((CounterOfferUI.currTab == "Listed") ? ProductManager.ListedProducts : ((!(CounterOfferUI.currTab == "Favorites")) ? ProductManager.DiscoveredProducts : ProductManager.FavouritedProducts));
			List<ProductDefinition> val2 = new List<ProductDefinition>();
			foreach (EDrugType value in Enum.GetValues(typeof(EDrugType)))
			{
				if (text.Contains(((object)value/*cast due to .constrained prefix*/).ToString().ToLower()))
				{
					hashSet.Add(value);
				}
			}
			if (text.Contains("weed"))
			{
				hashSet.Add((EDrugType)0);
			}
			if (text.Contains("coke"))
			{
				hashSet.Add((EDrugType)2);
			}
			if (text.Contains("meth"))
			{
				hashSet.Add((EDrugType)1);
			}
			if (text.Contains("shroom"))
			{
				hashSet.Add((EDrugType)4);
			}
			Enumerator<ProductDefinition> enumerator2 = val.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				ProductDefinition current = enumerator2.Current;
				if (hashSet.Contains(current.DrugType) || ((BaseItemDefinition)current).Name.ToLower().Contains(text))
				{
					val2.Add(current);
				}
			}
			__result = val2;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "SetPage")]
	internal static class CounterOfferProductSelectorSetPagePatch
	{
		public const int PageSize = 24;

		public static bool Prefix(CounterOfferProductSelector __instance, int page)
		{
			__instance.pageIndex = Mathf.Clamp(page, 0, Mathf.Max(__instance.pageCount - 1, 0));
			int num = __instance.pageIndex * 24;
			int num2 = Mathf.Min(num + 24, __instance.results.Count);
			List<ProductDefinition> range = __instance.results.GetRange(num, num2 - num);
			Enumerator<ProductDefinition, RectTransform> enumerator = __instance.productEntriesDict.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<ProductDefinition, RectTransform> current = enumerator.Current;
				RectTransform value = current.Value;
				if (range.Contains(current.Key))
				{
					((Component)value).gameObject.SetActive(true);
					__instance.uiWindowPanel.AddSelectable(((Component)value).GetComponent<UISelectable>());
				}
				else
				{
					((Component)value).gameObject.SetActive(false);
					__instance.uiWindowPanel.RemoveSelectable(((Component)value).GetComponent<UISelectable>(), true);
				}
			}
			for (int i = 0; i < range.Count; i++)
			{
				((Transform)__instance.productEntriesDict[range[i]]).SetSiblingIndex(i);
			}
			__instance.PageLabel.text = $"{__instance.pageIndex + 1} / {__instance.pageCount}";
			return false;
		}
	}
	[HarmonyPatch(typeof(CounterOfferProductSelector), "RebuildResultsList")]
	internal static class CounterOfferProductSelectorRebuildResultsListPatch
	{
		public static void Postfix(CounterOfferProductSelector __instance)
		{
			__instance.pageCount = Mathf.CeilToInt((float)__instance.results.Count / 24f);
			__instance.SetPage(__instance.pageIndex);
		}
	}
	public static class CounterOfferUI
	{
		public static GameObject offerInfoGO = null;

		public static Text initialOfferText = null;

		public static Text successRateText = null;

		public static Text maxCashText = null;

		public static Text fairPriceText = null;

		public static Font gameFont = null;

		public static TabController selectorTabControl;

		public static string currTab = "Favorites";

		public static Gradient colorMap = new Gradient();

		public static CounterOfferProductSelector selectorInterface = null;

		public static CounterofferInterface offerInterface = null;

		public static int labelCount = 0;

		private static Transform contentTransform = null;

		public static void OnPopupOpen(CounterofferInterface instance)
		{
			Customer component = ((Component)instance.conversation.sender).GetComponent<Customer>();
			if ((Object)(object)component == (Object)null)
			{
				component = ((Component)offerInterface.conversation.sender).GetComponent<Customer>();
			}
			if (CounterOfferConfig.DisableAllLabels.Value)
			{
				return;
			}
			if (!CounterOfferConfig.DisableInitialOffer.Value)
			{
				float selectedAmount = instance.PriceSelector.SelectedAmount;
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					SetInitialPriceText(selectedAmount / (float)instance.quantity, ppu: true);
					SetFairPriceText(selectedAmount / (float)instance.quantity);
				}
				else
				{
					SetInitialPriceText(selectedAmount);
				}
			}
			if (!CounterOfferConfig.DisableMaxLimit.Value)
			{
				float num = CalculateSpendingLimits(component);
				SetMaxCashText(num);
			}
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				float num2 = CalculateSuccessProbability(component, instance.selectedProduct, instance.quantity, instance.PriceSelector.SelectedAmount);
				SetSuccessRateText(num2);
			}
		}

		public static void SetSuccessRateText(float success)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)successRateText == (Object)null)
			{
				Utility.Error("successRateText is null??");
				return;
			}
			successRateText.text = $"<b>{Mathf.RoundToInt(success * 100f)}% Chance of Success</b>";
			((Graphic)successRateText).color = colorMap.Evaluate(success);
		}

		public static void SetMaxCashText(float maxSpend)
		{
			if (!((Object)(object)maxCashText == (Object)null))
			{
				maxCashText.text = $"<b>Spend Limit: ${Mathf.RoundToInt(maxSpend)}</b>";
			}
		}

		public static void SetInitialPriceText(float initialPrice, bool ppu = false)
		{
			if (!((Object)(object)initialOfferText == (Object)null))
			{
				if (ppu)
				{
					initialOfferText.text = $"<b>Initial Offer: ${Mathf.RoundToInt(initialPrice)} per Unit</b>";
				}
				else
				{
					initialOfferText.text = $"<b>Initial Offer: ${Mathf.RoundToInt(initialPrice)}</b>";
				}
			}
		}

		public static void SetFairPriceText(float fairPrice)
		{
			if (!((Object)(object)fairPriceText == (Object)null))
			{
				fairPriceText.text = $"<b>Price: ${Mathf.RoundToInt(fairPrice)} per Unit</b>";
			}
		}

		public static float CalculateSpendingLimits(Customer customer)
		{
			CustomerData customerData = customer.CustomerData;
			float adjustedWeeklySpend = customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> val = new List<EDay>();
			customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f, val);
			return adjustedWeeklySpend / (float)val.Count * 3f;
		}

		public static float CalculateSuccessProbability(Customer customer, ProductDefinition product, int quantity, float price)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			float adjustedWeeklySpend = customer.customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> val = new List<EDay>();
			customer.customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f, val);
			float num = adjustedWeeklySpend / (float)val.Count;
			if (price >= num * 3f)
			{
				return 0f;
			}
			float valueProposition = Customer.GetValueProposition(Registry.GetItem<ProductDefinition>(customer.OfferedContractInfo.Products.entries[0].ProductID), customer.OfferedContractInfo.Payment / (float)customer.OfferedContractInfo.Products.entries[0].Quantity);
			float productEnjoyment = customer.GetProductEnjoyment(product, StandardsMethod.GetCorrespondingQuality(customer.customerData.Standards));
			float num2 = Mathf.InverseLerp(-1f, 1f, productEnjoyment);
			float valueProposition2 = Customer.GetValueProposition(product, price / (float)quantity);
			float num3 = Mathf.Pow((float)quantity / (float)customer.OfferedContractInfo.Products.entries[0].Quantity, 0.6f);
			float num4 = Mathf.Lerp(0f, 2f, num3 * 0.5f);
			float num5 = Mathf.Lerp(1f, 0f, Mathf.Abs(num4 - 1f));
			if (valueProposition2 * num5 > valueProposition)
			{
				return 1f;
			}
			if (valueProposition2 < 0.12f)
			{
				return 0f;
			}
			float num6 = productEnjoyment * valueProposition;
			float num7 = num2 * num5 * valueProposition2;
			if (num7 > num6)
			{
				return 1f;
			}
			float num8 = num6 - num7;
			float num9 = Mathf.Lerp(0f, 1f, num8 / 0.2f);
			float num10 = Mathf.Max(customer.CurrentAddiction, customer.NPC.RelationData.NormalizedRelationDelta);
			float num11 = Mathf.Lerp(0f, 0.2f, num10);
			if (num9 <= num11)
			{
				return 1f;
			}
			if (num9 - num11 >= 0.9f)
			{
				return 0f;
			}
			float num12 = (0.9f + num11 - num9) / 0.9f;
			return Mathf.Clamp(num12, 0f, 1f);
		}

		public static void UpdateSuccessRate(CounterofferInterface instance)
		{
			if ((Object)(object)instance == (Object)null)
			{
				Utility.Error("CounterofferInterface Instance was Null!!");
				return;
			}
			if ((Object)(object)successRateText == (Object)null)
			{
				Utility.Error("successRateText Instance was Null!!");
				return;
			}
			float num = CalculateSuccessProbability(((Component)instance.conversation.sender).GetComponent<Customer>(), instance.selectedProduct, instance.quantity, instance.PriceSelector.SelectedAmount);
			SetSuccessRateText(num);
		}

		public static void InitOnWake()
		{
			Utility.Log("Initializing Counter Offer UI");
			GameObject val = GameObject.Find("UI/HandoverScreen");
			if ((Object)(object)val != (Object)null)
			{
				Utility.Log("Found Handover Screen....Maybe Could Just search for the component?");
				HandoverScreen component = val.GetComponent<HandoverScreen>();
				if ((Object)(object)val != (Object)null)
				{
					colorMap = component.SuccessColorMap;
				}
			}
			CounterofferInterface counterofferInterface = PlayerSingleton<MessagesApp>.Instance.CounterofferInterface;
			if (!((Object)(object)counterofferInterface != (Object)null))
			{
				return;
			}
			Transform val2 = ((Component)counterofferInterface).transform.Find("Content");
			GameObject gameObject = ((Component)val2).gameObject;
			if ((Object)(object)gameObject != (Object)null)
			{
				contentTransform = val2;
				CreateLabels(val2);
				GetFairPrice();
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableAllLabels).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableInitialOffer).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableMaxLimit).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.DisableSuccessRate).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
				((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)CounterOfferConfig.EnablePricePerUnit).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate
				{
					ApplyLabelVisibility();
				}, 0, false);
			}
			UpdateSelectorUI(((Component)counterofferInterface).transform);
			ApplyLabelVisibility();
			if ((Object)(object)selectorInterface != (Object)null)
			{
				selectorInterface.EnsureAllEntriesExist();
			}
		}

		private static void RecalculateLabelCount()
		{
			labelCount = 0;
			if (!CounterOfferConfig.DisableAllLabels.Value)
			{
				if (!CounterOfferConfig.DisableInitialOffer.Value)
				{
					labelCount++;
				}
				if (!CounterOfferConfig.DisableMaxLimit.Value)
				{
					labelCount++;
				}
				if (!CounterOfferConfig.DisableSuccessRate.Value)
				{
					labelCount++;
				}
			}
		}

		public static void ApplyLabelVisibility()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)contentTransform == (Object)null))
			{
				RecalculateLabelCount();
				bool value = CounterOfferConfig.DisableAllLabels.Value;
				bool active = !value && !CounterOfferConfig.DisableInitialOffer.Value;
				bool active2 = !value && !CounterOfferConfig.DisableMaxLimit.Value;
				bool active3 = !value && !CounterOfferConfig.DisableSuccessRate.Value;
				if ((Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).gameObject.SetActive(active);
				}
				if ((Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).gameObject.SetActive(active2);
				}
				if ((Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).gameObject.SetActive(active3);
				}
				if ((Object)(object)selectorInterface != (Object)null)
				{
					((Component)selectorInterface).GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, (float)(-170 - labelCount * 30));
				}
				GetFairPrice();
			}
		}

		private static void GetFairPrice()
		{
			CounterofferInterface counterofferInterface = PlayerSingleton<MessagesApp>.Instance.CounterofferInterface;
			if ((Object)(object)counterofferInterface != (Object)null)
			{
				fairPriceText = counterofferInterface.FairPriceLabel;
			}
		}

		private static void UpdateSelectorUI(Transform parent)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Selection");
			if ((Object)(object)val != (Object)null)
			{
				Utility.Log("The Selector UI now has Tabs....AWESOME");
				selectorInterface = ((Component)val).GetComponent<CounterOfferProductSelector>();
				Transform val2 = val.Find("Container/SearchInput");
				if ((Object)(object)val2 != (Object)null)
				{
					RectTransform component = ((Component)val2).GetComponent<RectTransform>();
					component.anchoredPosition = new Vector2(0f, -83f);
					InputField component2 = ((Component)val2).GetComponent<InputField>();
				}
				Transform val3 = val.Find("Container");
				if ((Object)(object)val3 != (Object)null && selectorTabControl == null)
				{
					selectorTabControl = new TabController(val3);
					selectorTabControl.font = gameFont;
					selectorTabControl.AddTab("Favorites", "<b>Fave</b>");
					selectorTabControl.AddTab("Listed", "<b>Listed</b>");
					selectorTabControl.AddTab("Discovered", "<b>All</b>");
					selectorTabControl.SetSelected(currTab);
				}
			}
			else
			{
				Utility.Error("Selection Couldn't be Found");
			}
		}

		public static void TabSelected(Tab selected)
		{
			currTab = selected.id;
			if ((Object)(object)selectorInterface != (Object)null)
			{
				selectorInterface.RebuildResultsList();
			}
		}

		private static void CreateLabels(Transform parent)
		{
			Transform val = parent.Find("Header/Title");
			if ((Object)(object)val != (Object)null)
			{
				gameFont = ((Component)val).GetComponent<Text>().font;
			}
			initialOfferText = CreateLabel(parent, "InitialCash", "Initial Offer Price: ");
			((Component)initialOfferText).transform.SetSiblingIndex(3);
			maxCashText = CreateLabel(parent, "MaxCash", "$1000 Max");
			((Component)maxCashText).transform.SetSiblingIndex(4);
			successRateText = CreateLabel(parent, "SuccessRate", "100% Success Rate");
			((Component)successRateText).transform.SetSiblingIndex(5);
		}

		public static Text CreateLabel(Transform parent, string title, string text)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(title);
			val.transform.SetParent(parent, false);
			Text val2 = val.AddComponent<Text>();
			val2.text = text;
			val2.font = (((Object)(object)gameFont != (Object)null) ? gameFont : Resources.GetBuiltinResource<Font>("Arial.ttf"));
			val2.fontSize = 30;
			((Graphic)val2).color = Color.gray;
			val2.alignment = (TextAnchor)4;
			RectTransform component = ((Component)val.transform).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(600f, 100f);
			return val2;
		}
	}
	public class Tab
	{
		public string id;

		public Button button;

		public Image background;

		public Text buttonText;

		public void SetColor(Color bgColor, Color textColor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			SetBgColor(bgColor);
			SetTextColor(textColor);
		}

		public void SetBgColor(Color newColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)background).color = newColor;
		}

		public void SetTextColor(Color newColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)buttonText).color = newColor;
		}
	}
	public class TabController
	{
		public Dictionary<string, Tab> allTabs = new Dictionary<string, Tab>();

		public Tab selectedTab = null;

		public float clickBuffer = 0.7f;

		public float prevTime = 0f;

		public GameObject filterbuttons;

		public Transform parent;

		public Font font;

		public Color textActive = new Color(0.961f, 0.961f, 0.961f);

		public Color textDisabled = new Color(0.686f, 0.686f, 0.686f);

		public Color tabIdle = new Color(0.051f, 0.286f, 0.451f);

		public Color tabHover = new Color(0.114f, 0.353f, 0.525f);

		public Color tabActive = new Color(0.204f, 0.522f, 0.737f);

		public TabController(Transform parent)
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			this.parent = parent;
			InitFilterButtons();
		}

		private void InitFilterButtons()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0070: 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_009c: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			filterbuttons = new GameObject("Filter_Buttons");
			if ((Object)(object)parent != (Object)null)
			{
				filterbuttons.transform.SetParent(parent, false);
				filterbuttons.transform.SetSiblingIndex(0);
			}
			filterbuttons.AddComponent<CanvasRenderer>();
			RectTransform val = filterbuttons.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0f, 0.5f);
			val.anchorMax = new Vector2(1f, 0.5f);
			val.anchoredPosition = new Vector2(0f, 200f);
			val.sizeDelta = new Vector2(1f, 60f);
			Image val2 = filterbuttons.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.9608f, 0.9608f, 0.9608f);
			GridLayoutGroup val3 = filterbuttons.AddComponent<GridLayoutGroup>();
			val3.cellSize = new Vector2(100f, 45f);
			val3.spacing = new Vector2(15f, 0f);
			((LayoutGroup)val3).childAlignment = (TextAnchor)4;
			val3.constraint = (Constraint)1;
			val3.constraintCount = 3;
		}

		public void AddTab(string id, string text)
		{
			if (allTabs.ContainsKey(id))
			{
				throw new Exception("The key " + id + " already exists in the tab list");
			}
			if ((Object)(object)filterbuttons == (Object)null)
			{
				throw new Exception("Filter Buttons has not been initialized");
			}
			Tab value = CreateNewTab(filterbuttons.transform, id, text);
			allTabs.Add(id, value);
		}

		public void SetSelected(string key)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!allTabs.ContainsKey(key))
			{
				throw new Exception(key + " Does Not Exist in the TabController Dictionary");
			}
			Tab tab = allTabs[key];
			selectedTab = allTabs[key];
			tab.SetColor(tabActive, textActive);
		}

		public Tab CreateNewTab(Transform parent, string title, string text)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0044: 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_0061: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			GameObject val = new GameObject(title + "_Button");
			val.transform.SetParent(parent, false);
			val.AddComponent<CanvasRenderer>();
			Button button = val.AddComponent<Button>();
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = tabIdle;
			GameObject val3 = new GameObject(title + "_Button_Text");
			val3.transform.SetParent(val.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.text = text;
			val4.font = (((Object)(object)font != (Object)null) ? font : Resources.GetBuiltinResource<Font>("Arial.ttf"));
			val4.fontSize = 30;
			((Graphic)val4).color = textDisabled;
			val4.alignment = (TextAnchor)4;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(60f, 40f);
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.anchoredPosition = new Vector2(0f, 0f);
			Tab newTab = new Tab();
			newTab.id = title;
			newTab.button = button;
			newTab.background = val2;
			newTab.buttonText = val4;
			Entry val5 = new Entry();
			val5.eventID = (EventTriggerType)0;
			((UnityEvent<BaseEventData>)(object)val5.callback).AddListener(DelegateSupport.ConvertDelegate<UnityAction<BaseEventData>>((Delegate)(Action<BaseEventData>)delegate
			{
				HandleButtonEnter(newTab);
			}));
			Entry val6 = new Entry();
			val6.eventID = (EventTriggerType)1;
			((UnityEvent<BaseEventData>)(object)val6.callback).AddListener(DelegateSupport.ConvertDelegate<UnityAction<BaseEventData>>((Delegate)(Action<BaseEventData>)delegate
			{
				HandleButtonExit(newTab);
			}));
			Entry val7 = new Entry();
			val7.eventID = (EventTriggerType)4;
			((UnityEvent<BaseEventData>)(object)val7.callback).AddListener(DelegateSupport.ConvertDelegate<UnityAction<BaseEventData>>((Delegate)(Action<BaseEventData>)delegate
			{
				HandleButtonClick(newTab);
			}));
			EventTrigger val8 = val.AddComponent<EventTrigger>();
			val8.triggers.Add(val5);
			val8.triggers.Add(val6);
			val8.triggers.Add(val7);
			return newTab;
		}

		public void HandleButtonEnter(Tab currTab)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ResetTabs();
			if (selectedTab == null || selectedTab != currTab)
			{
				currTab.SetBgColor(tabHover);
			}
		}

		public void HandleButtonExit(Tab currTab)
		{
			ResetTabs();
		}

		public void HandleButtonClick(Tab currTab)
		{
			//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)
			float time = Time.time;
			if (time - prevTime > clickBuffer)
			{
				CounterOfferUI.TabSelected(currTab);
				selectedTab = currTab;
				ResetTabs();
				currTab.SetColor(tabActive, textActive);
				prevTime = time;
			}
		}

		public void ResetTabs()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, Tab> allTab in allTabs)
			{
				if (selectedTab == null || selectedTab != allTab.Value)
				{
					allTab.Value.SetColor(tabIdle, textDisabled);
				}
			}
		}
	}
	public static class Utility
	{
		public static void PrintException(Exception e)
		{
			MelonLogger.Msg(ConsoleColor.Red, e.Source);
			MelonLogger.Msg(ConsoleColor.DarkRed, e.Message);
		}

		public static void Error(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Red, msg);
		}

		public static void Log(string msg)
		{
			MelonLogger.Msg(ConsoleColor.DarkMagenta, msg);
		}

		public static void Success(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Green, msg);
		}

		public static void ListHierarchy(Transform transform, int depth)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			string text = new string(' ', depth * 2);
			MelonLogger.Msg(text + "- " + ((Object)transform).name);
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Transform transform2 = (Transform)enumerator.Current;
					ListHierarchy(transform2, depth + 1);
				}
			}
			finally
			{
				if (enumerator is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}