Decompiled source of BetterCounterOfferUI v3.4.0

BetterCounterOffer_IL2Cpp_3.4.0.dll

Decompiled 2 months 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.Handover;
using Il2CppScheduleOne.UI.Phone;
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.0", "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.0")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyFileVersion("3.4.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4dd10420b1e36fdf8455c48f1fa7fc7c4d288203")]
[assembly: AssemblyProduct("BetterCounterOffer_IL2Cpp_3.4.0")]
[assembly: AssemblyTitle("BetterCounterOffer_IL2Cpp_3.4.0")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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.0";

		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.OnPopupOpen(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangePrice")]
	internal static class CounterOfferInterfaceChangePricePatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
			if (CounterOfferConfig.EnablePricePerUnit.Value)
			{
				CounterOfferUI.SetFairPriceText(__instance.price / (float)__instance.quantity);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangeQuantity")]
	internal static class CounterOfferInterfaceChangeQuantityPatch
	{
		public static bool Prefix(CounterofferInterface __instance, ref int change)
		{
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				int quantity = __instance.quantity;
				int num = quantity;
				if (change > 0)
				{
					num = (quantity / 5 + 1) * 5;
				}
				else
				{
					if (change >= 0)
					{
						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 num = (float)__instance.quantity * selectedProduct.Price - __instance.price;
			__instance.ChangePrice(num);
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "SetProduct")]
	internal static class CounterOfferInterfaceSetProductPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			float num = (float)__instance.quantity * __instance.selectedProduct.Price - __instance.price;
			__instance.ChangePrice(num);
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "UpdateFairPrice")]
	internal static class CounterofferInterface_UpdateFairPrice_Patch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if (CounterOfferConfig.EnablePricePerUnit.Value)
			{
				CounterOfferUI.SetFairPriceText(__instance.price);
			}
		}
	}
	[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), "GetMatchingProducts")]
	internal static class CounterOfferProductSelectorGetMatchingProductsPatch
	{
		public static void Postfix(CounterofferInterface __instance, ref List<ProductDefinition> __result, ref string searchTerm)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			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>();
			if (searchTerm.ToLower().Contains("weed"))
			{
				hashSet.Add((EDrugType)0);
			}
			if (searchTerm.ToLower().Contains("coke"))
			{
				hashSet.Add((EDrugType)2);
			}
			if (searchTerm.ToLower().Contains("meth"))
			{
				hashSet.Add((EDrugType)1);
			}
			Enumerator<ProductDefinition> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ProductDefinition current = enumerator.Current;
				if (hashSet.Contains(current.DrugType) || ((BaseItemDefinition)current).Name.ToLower().Contains(searchTerm))
				{
					val2.Add(current);
				}
			}
			__result = val2;
		}
	}
	public static class CounterOfferUI
	{
		public static GameObject PlayerRef = null;

		public static GameObject popupRef = null;

		public static GameObject productSelectorRef = null;

		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 Text btnText = null;

		public static Image btnBg = null;

		public static Font gameFont = null;

		public static TabController selectorTabControl;

		public static bool displayAll = false;

		public static string currTab = "Favorites";

		public static float prevTime = 0f;

		public static Gradient colorMap = new Gradient();

		public static List<ProductDefinition> currList = null;

		public static CounterOfferProductSelector selectorInterface = null;

		public static CounterofferInterface offerInterface = null;

		public static int labelCount = 0;

		public static Dictionary<string, Vector2[]> uiPositions = new Dictionary<string, Vector2[]>
		{
			{
				"Shade/Content",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(-160f, -160f),
					new Vector2(-160f, -180f),
					new Vector2(-160f, -140f),
					new Vector2(-160f, -90f)
				}
			},
			{
				"Selection",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -182f),
					new Vector2(0f, -230f),
					new Vector2(0f, -250f),
					new Vector2(0f, -250f)
				}
			},
			{
				"Subtitle",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -117f),
					new Vector2(0f, -150f),
					new Vector2(0f, -190f),
					new Vector2(0f, -220f)
				}
			},
			{
				"Remove",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(-210f, 74f),
					new Vector2(-210f, 30f),
					new Vector2(-210f, 10f),
					new Vector2(-210f, 10f)
				}
			},
			{
				"Add",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(210f, 74f),
					new Vector2(210f, 30f),
					new Vector2(210f, 10f),
					new Vector2(210f, 10f)
				}
			},
			{
				"Product",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, 74f),
					new Vector2(0f, 30f),
					new Vector2(0f, 10f),
					new Vector2(0f, 10f)
				}
			},
			{
				"Subtitle (1)",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -258.12f),
					new Vector2(0f, -260f),
					new Vector2(0f, -300f),
					new Vector2(0f, -335f)
				}
			},
			{
				"Price",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -313.12f),
					new Vector2(0f, -310f),
					new Vector2(0f, -350f),
					new Vector2(0f, -390f)
				}
			},
			{
				"Fair price",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -362f),
					new Vector2(0f, -370f),
					new Vector2(0f, -405f),
					new Vector2(0f, -450f)
				}
			}
		};

		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)offerInterface.conversation.sender).GetComponent<Customer>();
			}
			prevTime = 0f;
			if (CounterOfferConfig.DisableAllLabels.Value)
			{
				return;
			}
			if (!CounterOfferConfig.DisableInitialOffer.Value)
			{
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					SetInitialPriceText(instance.price / (float)instance.quantity, ppu: true);
					SetFairPriceText(instance.price / (float)instance.quantity);
				}
				else
				{
					SetInitialPriceText(instance.price);
				}
			}
			if (!CounterOfferConfig.DisableMaxLimit.Value)
			{
				float num = CalculateSpendingLimits(component);
				SetMaxCashText(num);
			}
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				float num2 = CalculateSuccessProbability(component, instance.selectedProduct, instance.quantity, instance.price);
				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)
			{
				MelonLogger.Msg("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> orderDays = customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f);
			return adjustedWeeklySpend / (float)orderDays.Count * 3f;
		}

		public static float CalculateSuccessProbability(Customer customer, ProductDefinition product, int quantity, float price)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			float adjustedWeeklySpend = customer.customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> orderDays = customer.customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f);
			float num = adjustedWeeklySpend / (float)orderDays.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)
			{
				MelonLogger.Msg(ConsoleColor.Red, "CounterofferInterface Instance was Null!!");
				return;
			}
			if ((Object)(object)successRateText == (Object)null)
			{
				MelonLogger.Msg(ConsoleColor.Red, "successRateText Instance was Null!!");
				return;
			}
			float num = CalculateSuccessProbability(((Component)instance.conversation.sender).GetComponent<Customer>(), instance.selectedProduct, instance.quantity, instance.price);
			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;
				}
			}
			GameObject val2 = GameObject.Find("Player_Local");
			if (!((Object)(object)val2 != (Object)null))
			{
				return;
			}
			Utility.Log("Found player?");
			PlayerRef = val2;
			Transform val3 = PlayerRef.transform.Find("CameraContainer/Camera/OverlayCamera/GameplayMenu/Phone/phone/AppsCanvas/Messages/Container/CounterofferInterface/Shade/Content");
			GameObject val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				contentTransform = val3;
				CreateLabels(val3);
				GetAndShiftFairPrice(val3);
				ApplyLabelVisibility();
				UpdateSelectorUI(val3);
				((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);
			}
		}

		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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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 flag = !value && !CounterOfferConfig.DisableInitialOffer.Value;
				bool flag2 = !value && !CounterOfferConfig.DisableMaxLimit.Value;
				bool flag3 = !value && !CounterOfferConfig.DisableSuccessRate.Value;
				if ((Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).gameObject.SetActive(flag);
				}
				if ((Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).gameObject.SetActive(flag2);
				}
				if ((Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).gameObject.SetActive(flag3);
				}
				float num = 40f;
				if (flag && (Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				if (flag2 && (Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				if (flag3 && (Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				GrowPopUpWindow(contentTransform);
				ShiftOfferElements(contentTransform);
				GetAndShiftFairPrice(contentTransform);
			}
		}

		private static void GrowPopUpWindow(Transform transform)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)transform != (Object)null)
			{
				Vector2 sizeDelta = uiPositions["Shade/Content"][labelCount];
				RectTransform component = ((Component)transform).GetComponent<RectTransform>();
				component.sizeDelta = sizeDelta;
			}
		}

		private static void AdjustUiElements(Transform parent, string searchStr)
		{
			//IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(searchStr);
			if ((Object)(object)val != (Object)null)
			{
				Vector2 anchoredPosition = uiPositions[searchStr][labelCount];
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition = anchoredPosition;
			}
			else
			{
				MelonLogger.Msg(ConsoleColor.Red, searchStr + " Couldn't be Found");
			}
		}

		private static void ShiftOfferElements(Transform parent)
		{
			AdjustUiElements(parent, "Price");
			AdjustUiElements(parent, "Subtitle (1)");
			AdjustUiElements(parent, "Product");
			AdjustUiElements(parent, "Add");
			AdjustUiElements(parent, "Remove");
			AdjustUiElements(parent, "Subtitle");
			AdjustUiElements(parent, "Selection");
		}

		private static void GetAndShiftFairPrice(Transform parent)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Fair price");
			if ((Object)(object)val != (Object)null)
			{
				Vector2 anchoredPosition = uiPositions["Fair price"][labelCount];
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition = anchoredPosition;
				fairPriceText = ((Component)val).GetComponent<Text>();
			}
		}

		private static void UpdateSelectorUI(Transform parent)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Selection");
			if ((Object)(object)val != (Object)null)
			{
				MelonLogger.Msg(ConsoleColor.Magenta, "The Selector UI now has Tabs....AWESOME");
				selectorInterface = ((Component)val).GetComponent<CounterOfferProductSelector>();
				Transform val2 = val.Find("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("Window");
				if ((Object)(object)val3 != (Object)null)
				{
					RectTransform component3 = ((Component)val3).GetComponent<RectTransform>();
					component3.anchoredPosition = new Vector2(0f, -87f);
					if (selectorTabControl == null)
					{
						selectorTabControl = new TabController(val);
						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
			{
				MelonLogger.Msg(ConsoleColor.Red, "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)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00fc: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Title");
			if ((Object)(object)val != (Object)null)
			{
				gameFont = ((Component)val).GetComponent<Text>().font;
			}
			if (!((Object)(object)offerInfoGO != (Object)null))
			{
				offerInfoGO = new GameObject("OfferInformation");
				offerInfoGO.transform.SetParent(parent, false);
				offerInfoGO.transform.localPosition = new Vector3(181.5444f, 1.175f, -9.2547f);
				offerInfoGO.AddComponent<CanvasRenderer>();
				RectTransform val2 = offerInfoGO.AddComponent<RectTransform>();
				val2.anchoredPosition = new Vector2(-270.0037f, -150f);
				val2.anchorMin = new Vector2(1f, 1f);
				val2.anchorMax = new Vector2(1f, 1f);
				val2.pivot = new Vector2(0.5f, 0.5f);
				val2.sizeDelta = new Vector2(300f, 100f);
				initialOfferText = CreateLabel(offerInfoGO.transform, "InitialCash", "Initial Offer Price: ", new Vector3(0f, 40f, 0f));
				maxCashText = CreateLabel(offerInfoGO.transform, "MaxCash", "$1000 Max", new Vector3(0f, 5f, 0f));
				successRateText = CreateLabel(offerInfoGO.transform, "SuccessRate", "100% Success Rate", new Vector3(0f, -30f, 0f));
			}
		}

		public static Text CreateLabel(Transform parent, string title, string text, Vector3 localPosition)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			GameObject val = new GameObject(title);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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.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)
		{
		}
	}
}

BetterCounterOffer_Mono_3.4.0.dll

Decompiled 2 months 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.Handover;
using ScheduleOne.UI.Phone;
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.0", "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.0")]
[assembly: AssemblyConfiguration("MONO")]
[assembly: AssemblyFileVersion("3.4.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4dd10420b1e36fdf8455c48f1fa7fc7c4d288203")]
[assembly: AssemblyProduct("BetterCounterOffer_Mono_3.4.0")]
[assembly: AssemblyTitle("BetterCounterOffer_Mono_3.4.0")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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.0";

		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.OnPopupOpen(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangePrice")]
	internal static class CounterOfferInterfaceChangePricePatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
			if (CounterOfferConfig.EnablePricePerUnit.Value)
			{
				CounterOfferUI.SetFairPriceText(__instance.price / (float)__instance.quantity);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "ChangeQuantity")]
	internal static class CounterOfferInterfaceChangeQuantityPatch
	{
		public static bool Prefix(CounterofferInterface __instance, ref int change)
		{
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				int quantity = __instance.quantity;
				int num = quantity;
				if (change > 0)
				{
					num = (quantity / 5 + 1) * 5;
				}
				else
				{
					if (change >= 0)
					{
						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 num = (float)__instance.quantity * selectedProduct.Price - __instance.price;
			__instance.ChangePrice(num);
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "SetProduct")]
	internal static class CounterOfferInterfaceSetProductPatch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			float num = (float)__instance.quantity * __instance.selectedProduct.Price - __instance.price;
			__instance.ChangePrice(num);
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				CounterOfferUI.UpdateSuccessRate(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(CounterofferInterface), "UpdateFairPrice")]
	internal static class CounterofferInterface_UpdateFairPrice_Patch
	{
		public static void Postfix(CounterofferInterface __instance)
		{
			if (CounterOfferConfig.EnablePricePerUnit.Value)
			{
				CounterOfferUI.SetFairPriceText(__instance.price);
			}
		}
	}
	[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), "GetMatchingProducts")]
	internal static class CounterOfferProductSelectorGetMatchingProductsPatch
	{
		public static void Postfix(CounterofferInterface __instance, ref List<ProductDefinition> __result, ref string searchTerm)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			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>();
			if (searchTerm.ToLower().Contains("weed"))
			{
				hashSet.Add((EDrugType)0);
			}
			if (searchTerm.ToLower().Contains("coke"))
			{
				hashSet.Add((EDrugType)2);
			}
			if (searchTerm.ToLower().Contains("meth"))
			{
				hashSet.Add((EDrugType)1);
			}
			foreach (ProductDefinition item in list)
			{
				if (hashSet.Contains(item.DrugType) || ((BaseItemDefinition)item).Name.ToLower().Contains(searchTerm))
				{
					list2.Add(item);
				}
			}
			__result = list2;
		}
	}
	public static class CounterOfferUI
	{
		public static GameObject PlayerRef = null;

		public static GameObject popupRef = null;

		public static GameObject productSelectorRef = null;

		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 Text btnText = null;

		public static Image btnBg = null;

		public static Font gameFont = null;

		public static TabController selectorTabControl;

		public static bool displayAll = false;

		public static string currTab = "Favorites";

		public static float prevTime = 0f;

		public static Gradient colorMap = new Gradient();

		public static List<ProductDefinition> currList = null;

		public static CounterOfferProductSelector selectorInterface = null;

		public static CounterofferInterface offerInterface = null;

		public static int labelCount = 0;

		public static Dictionary<string, Vector2[]> uiPositions = new Dictionary<string, Vector2[]>
		{
			{
				"Shade/Content",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(-160f, -160f),
					new Vector2(-160f, -180f),
					new Vector2(-160f, -140f),
					new Vector2(-160f, -90f)
				}
			},
			{
				"Selection",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -182f),
					new Vector2(0f, -230f),
					new Vector2(0f, -250f),
					new Vector2(0f, -250f)
				}
			},
			{
				"Subtitle",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -117f),
					new Vector2(0f, -150f),
					new Vector2(0f, -190f),
					new Vector2(0f, -220f)
				}
			},
			{
				"Remove",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(-210f, 74f),
					new Vector2(-210f, 30f),
					new Vector2(-210f, 10f),
					new Vector2(-210f, 10f)
				}
			},
			{
				"Add",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(210f, 74f),
					new Vector2(210f, 30f),
					new Vector2(210f, 10f),
					new Vector2(210f, 10f)
				}
			},
			{
				"Product",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, 74f),
					new Vector2(0f, 30f),
					new Vector2(0f, 10f),
					new Vector2(0f, 10f)
				}
			},
			{
				"Subtitle (1)",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -258.12f),
					new Vector2(0f, -260f),
					new Vector2(0f, -300f),
					new Vector2(0f, -335f)
				}
			},
			{
				"Price",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -313.12f),
					new Vector2(0f, -310f),
					new Vector2(0f, -350f),
					new Vector2(0f, -390f)
				}
			},
			{
				"Fair price",
				(Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, -362f),
					new Vector2(0f, -370f),
					new Vector2(0f, -405f),
					new Vector2(0f, -450f)
				}
			}
		};

		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)offerInterface.conversation.sender).GetComponent<Customer>();
			}
			prevTime = 0f;
			if (CounterOfferConfig.DisableAllLabels.Value)
			{
				return;
			}
			if (!CounterOfferConfig.DisableInitialOffer.Value)
			{
				if (CounterOfferConfig.EnablePricePerUnit.Value)
				{
					SetInitialPriceText(instance.price / (float)instance.quantity, ppu: true);
					SetFairPriceText(instance.price / (float)instance.quantity);
				}
				else
				{
					SetInitialPriceText(instance.price);
				}
			}
			if (!CounterOfferConfig.DisableMaxLimit.Value)
			{
				float num = CalculateSpendingLimits(component);
				SetMaxCashText(num);
			}
			if (!CounterOfferConfig.DisableSuccessRate.Value)
			{
				float num2 = CalculateSuccessProbability(component, instance.selectedProduct, instance.quantity, instance.price);
				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)
			{
				MelonLogger.Msg("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> orderDays = customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f);
			return adjustedWeeklySpend / (float)orderDays.Count * 3f;
		}

		public static float CalculateSuccessProbability(Customer customer, ProductDefinition product, int quantity, float price)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			float adjustedWeeklySpend = customer.customerData.GetAdjustedWeeklySpend(customer.NPC.RelationData.RelationDelta / 5f);
			List<EDay> orderDays = customer.customerData.GetOrderDays(customer.CurrentAddiction, customer.NPC.RelationData.RelationDelta / 5f);
			float num = adjustedWeeklySpend / (float)orderDays.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)
			{
				MelonLogger.Msg(ConsoleColor.Red, "CounterofferInterface Instance was Null!!");
				return;
			}
			if ((Object)(object)successRateText == (Object)null)
			{
				MelonLogger.Msg(ConsoleColor.Red, "successRateText Instance was Null!!");
				return;
			}
			float num = CalculateSuccessProbability(((Component)instance.conversation.sender).GetComponent<Customer>(), instance.selectedProduct, instance.quantity, instance.price);
			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;
				}
			}
			GameObject val2 = GameObject.Find("Player_Local");
			if (!((Object)(object)val2 != (Object)null))
			{
				return;
			}
			Utility.Log("Found player?");
			PlayerRef = val2;
			Transform val3 = PlayerRef.transform.Find("CameraContainer/Camera/OverlayCamera/GameplayMenu/Phone/phone/AppsCanvas/Messages/Container/CounterofferInterface/Shade/Content");
			GameObject val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				contentTransform = val3;
				CreateLabels(val3);
				GetAndShiftFairPrice(val3);
				ApplyLabelVisibility();
				UpdateSelectorUI(val3);
				((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);
			}
		}

		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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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 flag = !value && !CounterOfferConfig.DisableInitialOffer.Value;
				bool flag2 = !value && !CounterOfferConfig.DisableMaxLimit.Value;
				bool flag3 = !value && !CounterOfferConfig.DisableSuccessRate.Value;
				if ((Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).gameObject.SetActive(flag);
				}
				if ((Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).gameObject.SetActive(flag2);
				}
				if ((Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).gameObject.SetActive(flag3);
				}
				float num = 40f;
				if (flag && (Object)(object)initialOfferText != (Object)null)
				{
					((Component)initialOfferText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				if (flag2 && (Object)(object)maxCashText != (Object)null)
				{
					((Component)maxCashText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				if (flag3 && (Object)(object)successRateText != (Object)null)
				{
					((Component)successRateText).transform.localPosition = new Vector3(0f, num, 0f);
					num -= 35f;
				}
				GrowPopUpWindow(contentTransform);
				ShiftOfferElements(contentTransform);
				GetAndShiftFairPrice(contentTransform);
			}
		}

		private static void GrowPopUpWindow(Transform transform)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)transform != (Object)null)
			{
				Vector2 sizeDelta = uiPositions["Shade/Content"][labelCount];
				RectTransform component = ((Component)transform).GetComponent<RectTransform>();
				component.sizeDelta = sizeDelta;
			}
		}

		private static void AdjustUiElements(Transform parent, string searchStr)
		{
			//IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(searchStr);
			if ((Object)(object)val != (Object)null)
			{
				Vector2 anchoredPosition = uiPositions[searchStr][labelCount];
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition = anchoredPosition;
			}
			else
			{
				MelonLogger.Msg(ConsoleColor.Red, searchStr + " Couldn't be Found");
			}
		}

		private static void ShiftOfferElements(Transform parent)
		{
			AdjustUiElements(parent, "Price");
			AdjustUiElements(parent, "Subtitle (1)");
			AdjustUiElements(parent, "Product");
			AdjustUiElements(parent, "Add");
			AdjustUiElements(parent, "Remove");
			AdjustUiElements(parent, "Subtitle");
			AdjustUiElements(parent, "Selection");
		}

		private static void GetAndShiftFairPrice(Transform parent)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Fair price");
			if ((Object)(object)val != (Object)null)
			{
				Vector2 anchoredPosition = uiPositions["Fair price"][labelCount];
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition = anchoredPosition;
				fairPriceText = ((Component)val).GetComponent<Text>();
			}
		}

		private static void UpdateSelectorUI(Transform parent)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Selection");
			if ((Object)(object)val != (Object)null)
			{
				MelonLogger.Msg(ConsoleColor.Magenta, "The Selector UI now has Tabs....AWESOME");
				selectorInterface = ((Component)val).GetComponent<CounterOfferProductSelector>();
				Transform val2 = val.Find("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("Window");
				if ((Object)(object)val3 != (Object)null)
				{
					RectTransform component3 = ((Component)val3).GetComponent<RectTransform>();
					component3.anchoredPosition = new Vector2(0f, -87f);
					if (selectorTabControl == null)
					{
						selectorTabControl = new TabController(val);
						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
			{
				MelonLogger.Msg(ConsoleColor.Red, "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)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00fc: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("Title");
			if ((Object)(object)val != (Object)null)
			{
				gameFont = ((Component)val).GetComponent<Text>().font;
			}
			if (!((Object)(object)offerInfoGO != (Object)null))
			{
				offerInfoGO = new GameObject("OfferInformation");
				offerInfoGO.transform.SetParent(parent, false);
				offerInfoGO.transform.localPosition = new Vector3(181.5444f, 1.175f, -9.2547f);
				offerInfoGO.AddComponent<CanvasRenderer>();
				RectTransform val2 = offerInfoGO.AddComponent<RectTransform>();
				val2.anchoredPosition = new Vector2(-270.0037f, -150f);
				val2.anchorMin = new Vector2(1f, 1f);
				val2.anchorMax = new Vector2(1f, 1f);
				val2.pivot = new Vector2(0.5f, 0.5f);
				val2.sizeDelta = new Vector2(300f, 100f);
				initialOfferText = CreateLabel(offerInfoGO.transform, "InitialCash", "Initial Offer Price: ", new Vector3(0f, 40f, 0f));
				maxCashText = CreateLabel(offerInfoGO.transform, "MaxCash", "$1000 Max", new Vector3(0f, 5f, 0f));
				successRateText = CreateLabel(offerInfoGO.transform, "SuccessRate", "100% Success Rate", new Vector3(0f, -30f, 0f));
			}
		}

		public static Text CreateLabel(Transform parent, string title, string text, Vector3 localPosition)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			GameObject val = new GameObject(title);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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.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)val5.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)
		{
		}
	}
}