Decompiled source of Overstocked v1.2.1

Mods/Overstocked-Mel.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GorillaExtensions;
using GorillaNetworking;
using GorillaNetworking.Store;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Overstocked;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
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(Plugin), "Overstocked", "1.2.1", "NotABird", null)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Overstocked")]
[assembly: AssemblyConfiguration("MelonLoader")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8ed76b182bcf7b46e5b85c5db257c97a43c47868")]
[assembly: AssemblyProduct("Overstocked")]
[assembly: AssemblyTitle("Overstocked")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Overstocked
{
	public static class Main
	{
		[CompilerGenerated]
		private sealed class <SetStandsPageForCategoryNextFrame>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CosmeticCategory category;

			public int page;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					SetStandsPageForCategory(category, page);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static Transform? _mirrorSofa;

		private static DynamicCosmeticStand? _defaultStand;

		private static GameObject? _buttonToClone;

		private static CosmeticCategory _currentSelectedCategory = (CosmeticCategory)1;

		private static readonly List<DynamicCosmeticStand> _stands = new List<DynamicCosmeticStand>();

		private static readonly Dictionary<string, HashSet<CosmeticItem>> _allItemsWithPrice = new Dictionary<string, HashSet<CosmeticItem>>();

		private static readonly Dictionary<string, int> _categoryPage = new Dictionary<string, int>();

		private static int TotalCosmetics => _allItemsWithPrice.Sum<KeyValuePair<string, HashSet<CosmeticItem>>>((KeyValuePair<string, HashSet<CosmeticItem>> items) => items.Value.Count);

		private static int TotalShinyRocks => _allItemsWithPrice.Sum<KeyValuePair<string, HashSet<CosmeticItem>>>((KeyValuePair<string, HashSet<CosmeticItem>> items) => items.Value.Sum((CosmeticItem item) => item.cost));

		public static void Initialize()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
			GorillaTagger.OnPlayerSpawned((Action)delegate
			{
				CosmeticsController instance = CosmeticsController.instance;
				((CosmeticsController)instance).V2_OnGetCosmeticsPlayFabCatalogData_PostSuccess = (Action)Delegate.Combine(((CosmeticsController)instance).V2_OnGetCosmeticsPlayFabCatalogData_PostSuccess, new Action(OnCosmeticsLoaded));
				_defaultStand = Resources.FindObjectsOfTypeAll<DynamicCosmeticStand>().First((DynamicCosmeticStand x) => ((Object)x).name == "DynamicCosmeticStand_CustomMap");
				_buttonToClone = ((Component)((Component)_defaultStand.AddToCartButton).transform.parent).gameObject;
			});
		}

		private static void SetItemForStand(DynamicCosmeticStand stand, CosmeticItem item)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected I4, but got Unknown
			stand.AddToCartButton.isOn = false;
			stand.AddToCartButton.UpdateColor();
			if (((CosmeticsController)CosmeticsController.instance).currentCart.Contains(item))
			{
				stand.AddToCartButton.isOn = true;
				stand.AddToCartButton.UpdateColor();
			}
			stand.thisCosmeticName = item.itemName;
			stand.StandName = item.itemName;
			((StoreController)StoreController.instance).AddStandToPlayfabIDDictionary(stand);
			stand.InitializeCosmetic();
			CosmeticCategory itemCategory = item.itemCategory;
			CosmeticCategory val = itemCategory;
			switch ((int)val)
			{
			case 1:
			case 3:
			case 4:
				stand.SetStandType((BustType)1);
				break;
			case 2:
			case 5:
			case 7:
			case 8:
			case 9:
				stand.SetStandType((BustType)2);
				break;
			case 6:
				stand.SetStandType((BustType)4);
				break;
			case 10:
			case 13:
				stand.SetStandType((BustType)3);
				break;
			case 11:
			case 14:
				stand.SetStandType((BustType)7);
				break;
			default:
				stand.SetStandType((BustType)0);
				break;
			}
		}

		private static void SetStandsPageForCategory(CosmeticCategory category, int page)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			_categoryPage[((object)(CosmeticCategory)(ref category)).ToString()] = page;
			if (!_allItemsWithPrice.TryGetValue(((object)(CosmeticCategory)(ref category)).ToString(), out HashSet<CosmeticItem> value))
			{
				return;
			}
			List<CosmeticItem> list = value.Skip(page * _stands.Count).Take(_stands.Count).ToList();
			for (int i = 0; i < _stands.Count; i++)
			{
				if (list.Count <= i)
				{
					SetItemForStand(_stands[i], ((CosmeticsController)CosmeticsController.instance).nullItem);
				}
				else
				{
					SetItemForStand(_stands[i], list[i]);
				}
			}
		}

		[IteratorStateMachine(typeof(<SetStandsPageForCategoryNextFrame>d__14))]
		private static IEnumerator SetStandsPageForCategoryNextFrame(CosmeticCategory category, int page)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetStandsPageForCategoryNextFrame>d__14(0)
			{
				category = category,
				page = page
			};
		}

		private static int GetPagesForCategory(CosmeticCategory category)
		{
			if (!_allItemsWithPrice.TryGetValue(((object)(CosmeticCategory)(ref category)).ToString(), out HashSet<CosmeticItem> value) || _stands.Count == 0)
			{
				return 0;
			}
			return (value.Count + _stands.Count - 1) / _stands.Count;
		}

		private static void OnCosmeticsLoaded()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Invalid comparison between Unknown and I4
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			IEnumerable<CosmeticItem> enumerable = ((CosmeticsController)CosmeticsController.instance).allCosmetics.Where((CosmeticItem x) => x.canTryOn && (int)x.itemCategory != 0 && !((CosmeticsController)CosmeticsController.instance).unlockedCosmetics.Contains(x));
			HashSet<CosmeticItem> hashSet = new HashSet<CosmeticItem>();
			foreach (CosmeticItem item in ((CosmeticsController)CosmeticsController.instance).allCosmetics.Where((CosmeticItem x) => (int)x.itemCategory == 13))
			{
				string[] bundledItems = item.bundledItems;
				if (bundledItems != null && bundledItems.Length > 0)
				{
					string[] bundledItems2 = item.bundledItems;
					foreach (string text in bundledItems2)
					{
						hashSet.Add(((CosmeticsController)CosmeticsController.instance).GetItemFromDict(text));
					}
				}
			}
			foreach (CosmeticItem item2 in enumerable)
			{
				Dictionary<string, HashSet<CosmeticItem>> allItemsWithPrice = _allItemsWithPrice;
				CosmeticCategory itemCategory = item2.itemCategory;
				if (allItemsWithPrice.TryGetValue(((object)(CosmeticCategory)(ref itemCategory)).ToString(), out HashSet<CosmeticItem> value))
				{
					if ((int)item2.itemCategory == 13 || !hashSet.Contains(item2))
					{
						value.Add(item2);
					}
					continue;
				}
				Dictionary<string, HashSet<CosmeticItem>> allItemsWithPrice2 = _allItemsWithPrice;
				itemCategory = item2.itemCategory;
				allItemsWithPrice2.Add(((object)(CosmeticCategory)(ref itemCategory)).ToString(), new HashSet<CosmeticItem> { item2 });
				Dictionary<string, int> categoryPage = _categoryPage;
				itemCategory = item2.itemCategory;
				categoryPage.Add(((object)(CosmeticCategory)(ref itemCategory)).ToString(), 0);
			}
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref scene)).name != "City"))
			{
				Transform mirrorSofa = default(Transform);
				Transform upClearCartButton = default(Transform);
				if (!GTExt.TryFindByPath(scene, "City_Pretty/CosmeticsRoomAnchor/nicegorillastore_prefab/DressingRoom_Furniture_Prefab/mirror sofa/", ref mirrorSofa, false) || !GTExt.TryFindByPath(scene, "City_Pretty/CosmeticsRoomAnchor/nicegorillastore_prefab/DressingRoom_Mirrors_Prefab/TryOnConsole/", ref upClearCartButton, false))
				{
					Debug.LogError((object)"Could not find mirror sofa or TryOnConsole");
					return;
				}
				_mirrorSofa = mirrorSofa;
				LoadHeads(_mirrorSofa);
				SetUpCategoryButtons(_mirrorSofa);
				SetUpPageButtons(_mirrorSofa);
				SetUpText(_mirrorSofa);
				SetUpClearCartButton(upClearCartButton);
			}
		}

		private static void LoadHeads(Transform parent)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_defaultStand == (Object)null))
			{
				Vector3 localPosition = default(Vector3);
				((Vector3)(ref localPosition))..ctor(-1.2f, -0.2f, 0.45f);
				for (int i = 0; i < 3; i++)
				{
					Transform transform = ((Component)Object.Instantiate<DynamicCosmeticStand>(_defaultStand, parent, false)).transform;
					localPosition.x += 0.6f;
					transform.localPosition = localPosition;
					transform.localRotation = Quaternion.Euler(new Vector3(270f, 180f, 0f));
					_stands.Add(((Component)transform).GetComponent<DynamicCosmeticStand>());
				}
				Plugin.LoaderCoroutine(SetStandsPageForCategoryNextFrame(_currentSelectedCategory, 0));
			}
		}

		private static void SetUpCategoryButtons(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CosmeticSetButtons");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, 0.1f, 0.1f);
			val.transform.localRotation = Quaternion.Euler(new Vector3(300f, 0f, 180f));
			val.transform.localScale = Vector3.one * 0.7f;
			GridLayoutGroup val2 = val.AddComponent<GridLayoutGroup>();
			val2.cellSize = new Vector2(0.2f, 0.13f);
			((LayoutGroup)val2).childAlignment = (TextAnchor)4;
			val2.startCorner = (Corner)2;
			val2.constraint = (Constraint)2;
			foreach (KeyValuePair<string, HashSet<CosmeticItem>> set in _allItemsWithPrice.OrderByDescending<KeyValuePair<string, HashSet<CosmeticItem>>, int>((KeyValuePair<string, HashSet<CosmeticItem>> kvp) => kvp.Value.Count).Reverse())
			{
				string text = $"{set.Value.Count}\n{set.Key.ToUpper()}";
				Action onPressed = delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					_currentSelectedCategory = Enum.Parse<CosmeticCategory>(set.Key);
					Plugin.LoaderCoroutine(SetStandsPageForCategoryNextFrame(_currentSelectedCategory, _categoryPage[set.Key]));
				};
				CreateButton(val.transform, new Vector3(0f, 0f, 0.042f), Vector3.one * 0.004f, text, onPressed, 60).AddComponent<RectTransform>();
			}
		}

		private static void SetUpPageButtons(Transform parent)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00f6: 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)
			for (int i = 0; i < 2; i++)
			{
				bool first = i == 1;
				string text = (first ? "<" : ">");
				GameObject val = CreateButton(parent, new Vector3(0f, 0f, 0.042f), Vector3.one * 0.004f, text, delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					int pagesForCategory = GetPagesForCategory(_currentSelectedCategory);
					int num = ((!first) ? 1 : (-1));
					int num2 = (_categoryPage[((object)(CosmeticCategory)(ref _currentSelectedCategory)).ToString()] + num + pagesForCategory) % pagesForCategory;
					_categoryPage[((object)(CosmeticCategory)(ref _currentSelectedCategory)).ToString()] = num2;
					Plugin.LoaderCoroutine(SetStandsPageForCategoryNextFrame(_currentSelectedCategory, num2));
				});
				((Object)val).name = "Page Selector " + text;
				val.transform.localPosition = (first ? new Vector3(-0.3f, -0.02f, 0.3f) : new Vector3(0.3f, -0.02f, 0.3f));
				val.transform.localRotation = Quaternion.Euler(new Vector3(315.2f, 0f, 90f));
				val.transform.GetChild(1).localRotation = Quaternion.Euler(new Vector3(0f, 0f, 270f));
			}
		}

		private static void SetUpText(Transform parent)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_defaultStand))
			{
				Debug.LogError((object)"Failed to get defaultStand");
				return;
			}
			GameObject val = new GameObject("Text");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, 0.753f, 0f);
			val.transform.localScale = Vector3.one * 0.1f;
			val.transform.localRotation = Quaternion.Euler(new Vector3(45f, 180f, 180f));
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			((TMP_Text)val2).font = ((TMP_Text)((Component)((Component)_defaultStand.AddToCartButton).transform.parent.GetChild(1)).GetComponent<TextMeshPro>()).font;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val2).fontSize = 10f;
			((TMP_Text)val2).text = $"{TotalCosmetics:N0} COSMETICS\n{TotalShinyRocks:N0} ⑯";
		}

		private static void SetUpClearCartButton(Transform parent)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			GameObject val = Object.Instantiate<GameObject>(((Component)parent.Find("Hide1PButton")).gameObject, parent, false);
			val.transform.localPosition = new Vector3(0.1895f, 0.2657f, -0.2043f);
			PlayerPrefFlagButton component = val.GetComponent<PlayerPrefFlagButton>();
			GorillaPressableButton val2 = val.AddComponent<GorillaPressableButton>();
			GameObject val3 = Object.Instantiate<GameObject>(((Component)((GorillaPressableButton)component).myTmpText).gameObject);
			val3.transform.localPosition = new Vector3(19.398f, -0.6059f, -26.9f);
			val3.transform.localScale = ((GorillaPressableButton)component).myTmpText.transform.localScale;
			val3.transform.localRotation = ((GorillaPressableButton)component).myTmpText.transform.localRotation;
			TextMeshPro component2 = val3.GetComponent<TextMeshPro>();
			val2.myTmpText = (TMP_Text)(object)component2;
			val2.buttonRenderer = ((GorillaPressableButton)component).buttonRenderer;
			val2.unpressedMaterial = ((GorillaPressableButton)component).unpressedMaterial;
			val2.isOn = false;
			val2.offText = "CLEAR";
			val2.UpdateColor();
			val2.onPressed += delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				((CosmeticsController)CosmeticsController.instance).ClearCheckoutAndCart(false);
				Plugin.LoaderCoroutine(SetStandsPageForCategoryNextFrame(_currentSelectedCategory, _categoryPage[((object)(CosmeticCategory)(ref _currentSelectedCategory)).ToString()]));
			};
			ObjectExtensions.Destroy((Object)(object)component);
		}

		private static GameObject CreateButton(Transform parent, Vector3 localPosition, Vector3 localScale, string text, Action onPressed, int fontSize = 0)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Action onPressed2 = onPressed;
			if (!Object.op_Implicit((Object)(object)_buttonToClone))
			{
				throw new NullReferenceException("_buttonToClone is null");
			}
			GameObject val = Object.Instantiate<GameObject>(_buttonToClone, parent, false);
			ObjectExtensions.Destroy((Object)(object)val.GetComponentInChildren<DynamicCosmeticStand_Link>());
			ObjectExtensions.Destroy((Object)(object)((Component)val.transform.GetChild(2)).gameObject);
			Transform child = val.transform.GetChild(1);
			child.localPosition = localPosition;
			child.localScale = localScale;
			GorillaPressableButton componentInChildren = val.GetComponentInChildren<GorillaPressableButton>();
			if (fontSize > 0)
			{
				componentInChildren.myTmpText.fontSize = fontSize;
			}
			componentInChildren.offText = text;
			componentInChildren.UpdateColor();
			componentInChildren.onPressButton = null;
			componentInChildren.onPressed += delegate
			{
				onPressed2();
			};
			return val;
		}
	}
	public class Plugin : MelonMod
	{
		public override void OnLateInitializeMelon()
		{
			Main.Initialize();
		}

		public static void LoaderCoroutine(IEnumerator routine)
		{
			MelonCoroutines.Start(routine);
		}
	}
	public static class PluginInfo
	{
		public const string NAME = "Overstocked";

		public const string VERSION = "1.2.1";

		public const string AUTHOR = "NotABird";

		public const string GUID = "NotABird.Overstocked";
	}
}
namespace Overstocked.Patches
{
	[HarmonyPatch(typeof(BuilderSetManager))]
	public class BuilderSetManagerPatches
	{
		[HarmonyPatch("GetSeasonalSetsForSale")]
		[HarmonyPrefix]
		public static bool GetSeasonalSetsForSalePatch(BuilderSetManager __instance, ref List<BuilderPieceSet> __result)
		{
			BuilderSetManager __instance2 = __instance;
			__result = (from set in __instance2.GetAllPieceSets()
				where __instance2.GetStoreItemFromSetID(set.GetIntIdentifier()).hasPrice && !__instance2.GetPermanentSetsForSale().Contains(set)
				select set).ToList();
			return false;
		}
	}
	[HarmonyPatch(typeof(GorillaSkin))]
	public class GorillaSkinPatches
	{
		[HarmonyPatch("ApplyToRig")]
		[HarmonyPrefix]
		public static bool ApplyToRigPatch(VRRig rig)
		{
			return !GTExt.IsNull((Object)(object)rig);
		}
	}
	[HarmonyPatch(typeof(GorillaSkinToggle))]
	public class GorillaSkinTogglePatches
	{
		private static readonly FieldInfo _rig = AccessTools.Field(typeof(GorillaSkinToggle), "_rig");

		[HarmonyPatch("OnEnable")]
		[HarmonyPrefix]
		public static bool OnEnablePatch(GorillaSkinToggle __instance)
		{
			return _rig.GetValue(__instance) != null;
		}
	}
	[HarmonyPatch(typeof(StoreController))]
	public class StoreControllerPatches
	{
		[HarmonyPatch("AddStandToPlayfabIDDictionary")]
		[HarmonyPrefix]
		public static bool AddStandToPlayfabIDDictionaryPatch(StoreController __instance, DynamicCosmeticStand dynamicCosmeticStand)
		{
			if (StringUtils.IsNullOrEmpty(dynamicCosmeticStand.StandName) || StringUtils.IsNullOrEmpty(dynamicCosmeticStand.thisCosmeticName))
			{
				return false;
			}
			if (__instance.StandsByPlayfabID.ContainsKey(dynamicCosmeticStand.thisCosmeticName))
			{
				if (!__instance.StandsByPlayfabID[dynamicCosmeticStand.thisCosmeticName].Contains(dynamicCosmeticStand))
				{
					__instance.StandsByPlayfabID[dynamicCosmeticStand.thisCosmeticName].Add(dynamicCosmeticStand);
				}
			}
			else
			{
				__instance.StandsByPlayfabID.Add(dynamicCosmeticStand.thisCosmeticName, new List<DynamicCosmeticStand>(1) { dynamicCosmeticStand });
			}
			return false;
		}
	}
}