Decompiled source of EXTRA SHOP SHELVES v1.0.0

ExtraShopShelves.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Rehaan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EXTRA_SHOP_SHELVES")]
[assembly: AssemblyTitle("ExtraShopShelves")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI.")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExtraShelves
{
	[BepInPlugin("Rehaan.ExtraShopShelves", "EXTRA SHOP SHELVES", "1.0.0")]
	public sealed class ExtraShelvesPlugin : BaseUnityPlugin
	{
		public const string Guid = "Rehaan.ExtraShopShelves";

		public const string Name = "EXTRA SHOP SHELVES";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static Settings Options;

		internal static ExtraShelvesPlugin Self;

		private GameObject _panelObject;

		private SettingsPanel _panel;

		private bool _errorLogged;

		private void Awake()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			Self = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Options = new Settings(((BaseUnityPlugin)this).Config);
			ShelfEnv.Log = delegate(string s)
			{
				Log.LogInfo((object)s);
			};
			ShelfEnv.Warn = delegate(string s)
			{
				Log.LogWarning((object)s);
			};
			ShelfEnv.Removed = Placer.Forget;
			ShopHooks.Install();
			Options.LookChanged += Shelves.LookChanged;
			Log.LogInfo((object)("EXTRA SHOP SHELVES 1.0.0 loaded. Panel key: " + ((object)Options.PanelKey.Value/*cast due to .constrained prefix*/).ToString() + "."));
		}

		private void Start()
		{
			try
			{
				ShopHooks.CheckOthers();
				if (ShopHooks.FoundOther != null)
				{
					Notice.Show(ShopHooks.Advice);
				}
			}
			catch
			{
			}
		}

		private void Update()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!SettingsPanel.Rebinding && InputCompat.Pressed(Options.PanelKey.Value))
				{
					TogglePanel();
				}
				ShelfSync.Tick();
				Shelves.Tick();
			}
			catch (Exception ex)
			{
				if (!_errorLogged)
				{
					_errorLogged = true;
					Log.LogWarning((object)("EXTRA SHOP SHELVES: update skipped after an error: " + ex.GetType().Name + ": " + ex.Message));
				}
			}
		}

		internal void TogglePanel()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)_panelObject == (Object)null)
			{
				_panelObject = new GameObject("ExtraShopShelves Panel");
				((Object)_panelObject).hideFlags = (HideFlags)61;
				_panelObject.transform.SetParent(((Component)this).transform, false);
				_panelObject.SetActive(false);
				_panel = _panelObject.AddComponent<SettingsPanel>();
			}
			if (!_panelObject.activeSelf)
			{
				_panelObject.SetActive(true);
				_panel.Opened();
			}
			else
			{
				_panel.Closing();
				_panelObject.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Self == (Object)(object)this)
			{
				Self = null;
			}
			ShopHooks.Uninstall();
		}
	}
	internal static class InputCompat
	{
		private static readonly Dictionary<KeyCode, Key> Map = new Dictionary<KeyCode, Key>();

		private static bool _legacyBroken;

		internal static bool Pressed(KeyCode code)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((int)code == 0)
			{
				return false;
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				Key val = KeyOf(code);
				if ((int)val != 0)
				{
					return ((ButtonControl)current[val]).wasPressedThisFrame;
				}
				return false;
			}
			if (_legacyBroken)
			{
				return false;
			}
			try
			{
				return Input.GetKeyDown(code);
			}
			catch (InvalidOperationException)
			{
				_legacyBroken = true;
				return false;
			}
		}

		private unsafe static Key KeyOf(KeyCode code)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (Map.TryGetValue(code, out var value))
			{
				return value;
			}
			string text = ((object)(*(KeyCode*)(&code))/*cast due to .constrained prefix*/).ToString();
			if ((int)code <= 96)
			{
				if ((int)code != 13)
				{
					if ((int)code != 96)
					{
						goto IL_0072;
					}
					text = "Backquote";
				}
				else
				{
					text = "Enter";
				}
			}
			else if ((int)code != 271)
			{
				if ((int)code != 305)
				{
					if ((int)code != 306)
					{
						goto IL_0072;
					}
					text = "LeftCtrl";
				}
				else
				{
					text = "RightCtrl";
				}
			}
			else
			{
				text = "NumpadEnter";
			}
			goto IL_00b4;
			IL_00b4:
			if (!Enum.TryParse<Key>(text, out value))
			{
				value = (Key)0;
			}
			Map[code] = value;
			return value;
			IL_0072:
			if (text.StartsWith("Alpha", StringComparison.Ordinal))
			{
				text = "Digit" + text.Substring(5);
			}
			else if (text.StartsWith("Keypad", StringComparison.Ordinal))
			{
				text = "Numpad" + text.Substring(6);
			}
			goto IL_00b4;
		}
	}
	internal sealed class Notice : MonoBehaviour
	{
		private string _text;

		private float _until;

		private GUIStyle _style;

		private Texture2D _bg;

		internal static void Show(string text, float seconds = 20f)
		{
			//IL_0005: 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)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			GameObject val = new GameObject("ESS Notice")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			Notice notice = val.AddComponent<Notice>();
			notice._text = text;
			notice._until = Time.unscaledTime + seconds;
		}

		private void OnGUI()
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00aa: Expected O, but got Unknown
			//IL_00af: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime > _until)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (_style == null)
			{
				_bg = new Texture2D(1, 1)
				{
					hideFlags = (HideFlags)61
				};
				_bg.SetPixel(0, 0, new Color(0.08f, 0.04f, 0.02f, 0.92f));
				_bg.Apply();
				_style = new GUIStyle(GUI.skin.box)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1,
					wordWrap = true,
					alignment = (TextAnchor)4,
					padding = new RectOffset(18, 18, 12, 12)
				};
				_style.normal.background = _bg;
				_style.normal.textColor = new Color(1f, 0.78f, 0.35f);
			}
			float num = Mathf.Min(760f, (float)Screen.width - 40f);
			GUIContent val = new GUIContent("EXTRA SHOP SHELVES\n" + _text + "\n(click to close)");
			float num2 = _style.CalcHeight(val, num);
			if (GUI.Button(new Rect(((float)Screen.width - num) * 0.5f, 24f, num, num2), val, _style))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bg != (Object)null)
			{
				Object.Destroy((Object)(object)_bg);
			}
		}
	}
	internal sealed class ItemKind
	{
		public itemType Type;

		public string Label;

		public ConfigEntry<int> InShop;

		public ConfigEntry<int> Limit;

		public int Extra;
	}
	internal sealed class Settings
	{
		private const string HideFromModsMenu = "HideFromREPOConfig";

		private const string Shop = "1. Shop";

		private const string InShop = "2. Items In Shop";

		private const string Limits = "3. Purchase Limits";

		private const string Decor = "4. Decorations";

		public ConfigEntry<bool> Enabled;

		public ConfigEntry<ShelfTheme> Theme;

		public ConfigEntry<int> ExtraShelves;

		public ConfigEntry<bool> AutoShelves;

		public ConfigEntry<bool> ShowUnaffordable;

		public ConfigEntry<bool> FillEverySpot;

		public ConfigEntry<bool> OtherModsItems;

		public ConfigEntry<bool> SingleUseUpgrades;

		public ConfigEntry<bool> ShelfLights;

		public ConfigEntry<bool> StepInFront;

		public ConfigEntry<bool> Log;

		public ConfigEntry<bool> MakeRoom;

		public readonly List<ItemKind> Kinds = new List<ItemKind>();

		public ConfigEntry<int> DecorAmount;

		public ConfigEntry<int> GlowStrength;

		public ConfigEntry<bool> Animate;

		private readonly Dictionary<string, ConfigEntry<bool>> _pieces = new Dictionary<string, ConfigEntry<bool>>();

		public ConfigEntry<KeyCode> PanelKey;

		public ConfigEntry<float> PanelScale;

		public ConfigEntry<float> PanelOpacity;

		public ConfigEntry<float> PanelX;

		public ConfigEntry<float> PanelY;

		public ConfigEntry<string> PanelTab;

		public ConfigEntry<string> CardOrder;

		public ConfigEntry<string> CardsFolded;

		public ConfigEntry<bool> WindowLocked;

		public ConfigEntry<bool> CardsLocked;

		public ConfigEntry<float> PanelW;

		public ConfigEntry<float> PanelH;

		private readonly ConfigFile _file;

		internal event Action LookChanged;

		public Settings(ConfigFile file)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			_file = file;
			Enabled = file.Bind<bool>("1. Shop", "Enabled", true, "Master switch. Off = the shop is left exactly as the game makes it (no extra shelves, no changed numbers).");
			Theme = file.Bind<ShelfTheme>("1. Shop", "Shelf Theme", ShelfTheme.Auto, "Look of the extra shelves. Auto = by today's date: Halloween (1 Oct - 2 Nov), Christmas (1 - 26 Dec), New Year (27 Dec - 6 Jan), Easter (the week before Easter Sunday up to Easter Monday), Spring (from the start of spring to 20 Jun), otherwise Classic. New Year, Spring and Easter are locked outside their season and open at 00:00 on their date: New Year on 1 Dec (until 10 Jan), Spring on 1 Feb (until 20 Jun), Easter on 1 Mar (until Easter Monday). The host's choice is used by everyone.");
			ExtraShelves = file.Bind<int>("1. Shop", "Extra Shelves", 1, new ConfigDescription("How many extra shelves are placed in the shop at least (host, at most 2). Not every shop has room for both: then fewer are placed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
			AutoShelves = file.Bind<bool>("1. Shop", "Auto Extra Shelves", true, "Host: when the shop has more items than spots, more shelves are added by themselves (up to 2), so every item gets a place. Also when other mods add items.");
			ShowUnaffordable = file.Bind<bool>("1. Shop", "Show Items You Cannot Afford", true, "Host: items that cost more than the team has are put on the shelves too (the game leaves most of them out).");
			FillEverySpot = file.Bind<bool>("1. Shop", "Fill Every Spot", true, "Host: every free spot gets an item, instead of the game's fixed number of items per visit.");
			OtherModsItems = file.Bind<bool>("1. Shop", "Change Items Of Other Mods", false, "Host: the numbers below also change items and upgrades that other mods add. Off = those keep the numbers their own mod gave them.");
			SingleUseUpgrades = file.Bind<bool>("1. Shop", "Change Single-Use Upgrades", false, "Host: upgrades that the game sells only once also get the number below.");
			StepInFront = file.Bind<bool>("1. Shop", "Step In Front", true, "A step (30 cm high, with a slope, a little in front of the shelf) for every extra shelf: stand on it to reach the top board.");
			ShelfLights = file.Bind<bool>("1. Shop", "Shelf Lights", true, "The lamps of the extra shelves (and their theme glow). Off = no extra lights (a little faster on slow PCs).");
			Log = file.Bind<bool>("1. Shop", "Item Log", false, "Writes every item number and every shelf that is placed to the BepInEx log.");
			MakeRoom = file.Bind<bool>("1. Shop", "Make Room For Other Shop Mods", true, "When another mod also changes how the shop is filled, this mod leaves the shop alone (no double shelves, no fighting over the numbers).");
			DecorAmount = file.Bind<int>("4. Decorations", "Decoration Amount", 2, new ConfigDescription("How much is put on and around the shelves. 0 = none (plain shelf), 1 = a few pieces, 2 = normal, 3 = lots.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 3), Array.Empty<object>()));
			GlowStrength = file.Bind<int>("4. Decorations", "Glow Strength", 100, new ConfigDescription("Brightness of everything that glows (bulbs, sign, candles, fireworks), in percent. 0 = nothing glows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			Animate = file.Bind<bool>("4. Decorations", "Animate", true, "Bulbs twinkle, candles flicker and fireworks pulse. Off = everything glows steadily.");
			foreach (Piece item in Themes.Catalog)
			{
				_pieces[item.Key] = file.Bind<bool>("4. Decorations", item.ConfigName, true, item.Description);
			}
			Kind((itemType)3, "Upgrades", 10, 50, 70);
			Kind((itemType)8, "Health packs", 15, 40, 20);
			Kind((itemType)5, "Energy crystals", 10, 20, 20, 1);
			Kind((itemType)7, "Melee weapons", 3, 25, 20);
			Kind((itemType)9, "Guns", 3, 20, 20);
			Kind((itemType)6, "Grenades", 2, 20, 20);
			Kind((itemType)11, "Mines", 1, 20, 20);
			Kind((itemType)15, "Launchers", 0, 20, 20);
			Kind((itemType)0, "Drones", 5, 20, 20);
			Kind((itemType)1, "Orbs", 3, 20, 20);
			Kind((itemType)10, "Trackers", 1, 20, 20);
			Kind((itemType)13, "Tools", 1, 20, 20);
			Kind((itemType)2, "Carts", 2, 4, 20);
			Kind((itemType)12, "Pocket carts", 1, 4, 20);
			Kind((itemType)14, "Vehicles", 1, 5, 20);
			PanelKey = Hidden<KeyCode>("Panel Key", (KeyCode)284, "Key that opens / closes the EXTRA SHOP SHELVES panel (main menu, lobby, shop and levels).", null);
			PanelScale = Hidden("Panel Scale", 1f, "Size of the panel (text and controls).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.75f, 2f));
			PanelOpacity = Hidden("Panel Opacity", 0.96f, "Background opacity of the panel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 1f));
			PanelX = Hidden("Panel X", 70f, "Last position of the panel (left).", null);
			PanelY = Hidden("Panel Y", 70f, "Last position of the panel (top).", null);
			PanelTab = Hidden("Panel Page", "Shop", "Last page shown in the panel.", null);
			CardOrder = Hidden("Card Order", "", "The order of the cards on each page (drag a card by its title).", null);
			CardsFolded = Hidden("Folded Cards", "", "Cards that are folded (click a card's title).", null);
			WindowLocked = Hidden("Lock Window Size", defaultValue: false, "On: the panel keeps its size (it can still be moved). Off: a corner at the bottom right lets you drag the panel to the size you want.", null);
			CardsLocked = Hidden("Lock Card Order", defaultValue: false, "On: the cards cannot be dragged to another place (a click on a title still folds the card). Off: hold a card's title and drag it up or down.", null);
			PanelW = Hidden("Panel Width", 980f, "Last width of the panel.", null);
			PanelH = Hidden("Panel Height", 680f, "Last height of the panel.", null);
			EventHandler eventHandler = delegate
			{
				this.LookChanged?.Invoke();
			};
			Theme.SettingChanged += eventHandler;
			ShelfLights.SettingChanged += eventHandler;
			DecorAmount.SettingChanged += eventHandler;
			GlowStrength.SettingChanged += eventHandler;
			Animate.SettingChanged += eventHandler;
			foreach (ConfigEntry<bool> value in _pieces.Values)
			{
				value.SettingChanged += eventHandler;
			}
		}

		private void Kind(itemType type, string label, int shopDefault, int shopMax, int limitMax, int extra = 0)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			Kinds.Add(new ItemKind
			{
				Type = type,
				Label = label,
				Extra = extra,
				InShop = _file.Bind<int>("2. Items In Shop", label, shopDefault, new ConfigDescription("How many of EACH " + Lower(label) + " item can be in the shop. -1 = the game's own number.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, shopMax), Array.Empty<object>())),
				Limit = _file.Bind<int>("3. Purchase Limits", label, 0, new ConfigDescription("How many " + Lower(label) + " can be bought in total (per item, whole run). 0 = no limit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, limitMax), Array.Empty<object>()))
			});
		}

		private static string Lower(string s)
		{
			return s.ToLowerInvariant();
		}

		internal ShelfLook Look(ShelfTheme theme)
		{
			return new ShelfLook
			{
				Theme = theme,
				Amount = ShelfLook.Amounts[Mathf.Clamp(DecorAmount.Value, 0, 3)],
				Glow = (float)Mathf.Clamp(GlowStrength.Value, 0, 200) / 100f * 1.6f,
				Lamps = ShelfLights.Value,
				Animate = Animate.Value,
				Log = Log.Value,
				Step = StepInFront.Value,
				PieceOn = PieceOn
			};
		}

		internal ConfigEntry<bool> PieceEntry(Piece p)
		{
			if (!_pieces.TryGetValue(p.Key, out var value))
			{
				return null;
			}
			return value;
		}

		internal bool PieceOn(Piece p)
		{
			return PieceEntry(p)?.Value ?? true;
		}

		internal ItemKind KindOf(itemType type)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			foreach (ItemKind kind in Kinds)
			{
				if (kind.Type == type)
				{
					return kind;
				}
			}
			return null;
		}

		private ConfigEntry<T> Hidden<T>(string key, T defaultValue, string description, AcceptableValueBase range)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			return _file.Bind<T>("Z.Settings Panel", key, defaultValue, new ConfigDescription(description, range, new object[1] { "HideFromREPOConfig" }));
		}
	}
	internal static class ShelfSync
	{
		private const string Key = "ESS.shelves";

		private const int CheckEveryFrames = 20;

		private static bool _published;

		private static string _seen;

		private static int _frames;

		internal static void Publish(string token, ShelfTheme theme, List<string> spots)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_003b: Expected O, but got Unknown
			try
			{
				if (SemiFunc.IsMultiplayer() && SemiFunc.IsMasterClient())
				{
					Room currentRoom = PhotonNetwork.CurrentRoom;
					if (currentRoom != null)
					{
						Hashtable val = new Hashtable();
						((Dictionary<object, object>)val).Add((object)"ESS.shelves", (object)Placer.Pack(token, theme, spots));
						currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
						_published = true;
					}
				}
			}
			catch (Exception ex)
			{
				ExtraShelvesPlugin.Log.LogWarning((object)("Could not send the shelves to the other players: " + ex.Message));
			}
		}

		private static void Clear()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Expected O, but got Unknown
			_published = false;
			try
			{
				Room currentRoom = PhotonNetwork.CurrentRoom;
				if (currentRoom != null && PhotonNetwork.IsMasterClient)
				{
					Hashtable val = new Hashtable();
					((Dictionary<object, object>)val).Add((object)"ESS.shelves", (object)null);
					currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				}
			}
			catch
			{
			}
		}

		internal static void Tick()
		{
			if (++_frames < 20)
			{
				return;
			}
			_frames = 0;
			if ((Object)(object)GameManager.instance == (Object)null || (Object)(object)RunManager.instance == (Object)null)
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				_published = false;
				_seen = null;
				return;
			}
			bool flag = SemiFunc.RunIsShop();
			if (SemiFunc.IsMasterClient())
			{
				if (_published && !flag)
				{
					Clear();
				}
			}
			else if (!flag)
			{
				if (_seen != null)
				{
					_seen = null;
					Shelves.ForgetClient();
				}
			}
			else
			{
				if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
				{
					return;
				}
				Room currentRoom = PhotonNetwork.CurrentRoom;
				if (currentRoom != null && ((RoomInfo)currentRoom).CustomProperties != null && ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"ESS.shelves", out object value) && value is string text && !(text == _seen))
				{
					_seen = text;
					if (Placer.Parse(text, out var token, out var theme, out var ids))
					{
						Shelves.FromHost(token, theme, ids);
					}
				}
			}
		}
	}
	internal sealed class SettingsPanel : MonoBehaviour
	{
		private sealed class CardRec
		{
			public string Title;

			public string Shown;

			public string Note;

			public Action Body;
		}

		private sealed class Page
		{
			public string Id;

			public string Title;

			public Action Draw;
		}

		private delegate Rect Mapper(float z0, float z1, float y0, float y1);

		private List<CardRec> _collect;

		private List<Action> _tail;

		private string _cardTab;

		private readonly Dictionary<string, Rect> _cardRects = new Dictionary<string, Rect>();

		private readonly Dictionary<string, float> _cardOff = new Dictionary<string, float>();

		private readonly Dictionary<string, List<string>> _orders = new Dictionary<string, List<string>>();

		private readonly HashSet<string> _folded = new HashSet<string>();

		private string _ordersSrc;

		private string _foldedSrc;

		private string _pressKey;

		private Vector2 _pressPos;

		private bool _dragging;

		private float _dragY;

		private float _grabDY;

		private float _swapAt = -9f;

		private int _swapFrame = -9;

		internal static bool IsOpen;

		internal static bool Rebinding;

		private const int WindowId = 1163088689;

		private const float NavWidth = 200f;

		private const float HeaderHeight = 58f;

		private const float MinWidth = 860f;

		private const float MinHeight = 500f;

		private Rect _rect = new Rect(70f, 70f, 980f, 680f);

		private Vector2 _scroll;

		private Vector2 _navScroll;

		private string _tab;

		private bool _resizing;

		private float _confirmResetUntil;

		private CursorLockMode _prevLock;

		private bool _prevVisible;

		private bool _dirty;

		private float _saveAt = -1f;

		private float _scale = 1f;

		private string _toast;

		private float _toastUntil;

		private Vector2 _gripOff;

		private static bool _legacyMouseOff;

		private static Rect _screenRect;

		private static Vector2 _mouseScreen = new Vector2(-1f, -1f);

		private static bool _hoverPatched;

		private List<Page> _pages;

		private static readonly ShelfTheme[] ThemeOrder = new ShelfTheme[7]
		{
			ShelfTheme.Auto,
			ShelfTheme.Classic,
			ShelfTheme.Christmas,
			ShelfTheme.Halloween,
			ShelfTheme.Spring,
			ShelfTheme.Easter,
			ShelfTheme.NewYear
		};

		private const float PreviewH = 170f;

		private static readonly Color BgBase = new Color(0.035f, 0.05f, 0.065f);

		private Color _accent = new Color(0.45f, 0.92f, 0.86f);

		private readonly Color _alt = new Color(0.79f, 0.91f, 0.9f);

		private Color _card;

		private Color _row;

		private Color _line;

		private readonly Color _text = new Color(0.95f, 0.97f, 0.96f);

		private readonly Color _dim = new Color(0.66f, 0.72f, 0.73f);

		private readonly Color _warnCol = new Color(1f, 0.68f, 0.32f);

		private GUIStyle _win;

		private GUIStyle _cardSt;

		private GUIStyle _title;

		private GUIStyle _small;

		private GUIStyle _smallRight;

		private GUIStyle _lbl;

		private GUIStyle _desc;

		private GUIStyle _hint;

		private GUIStyle _warn;

		private GUIStyle _cardTitle;

		private GUIStyle _btnText;

		private GUIStyle _navText;

		private GUIStyle _value;

		private GUIStyle _closeBtn;

		private GUIStyle _toastSt;

		private Texture2D _tWin;

		private Texture2D _tCard;

		private float _styleKey = -1f;

		private float _rowWidth = 500f;

		private static readonly Dictionary<int, GUIStyle> RoundStyles = new Dictionary<int, GUIStyle>();

		private string _tip;

		private GUIStyle _tipSt;

		private string _editKey;

		private string _editBuf;

		private bool _editFocus;

		private bool _editHadFocus;

		private GUIStyle _field;

		private const string NumControl = "ess-number";

		private readonly Dictionary<string, float> _heightCache = new Dictionary<string, float>();

		private Settings P => ExtraShelvesPlugin.Options;

		private void Card(string title, Action body, string note = null, string shown = null)
		{
			CardRec cardRec = new CardRec
			{
				Title = title,
				Shown = shown,
				Note = note,
				Body = body
			};
			if (_collect != null)
			{
				_collect.Add(cardRec);
			}
			else
			{
				DrawCard(cardRec, _cardTab ?? "");
			}
		}

		private void Below(Action a)
		{
			if (_tail != null)
			{
				_tail.Add(a);
			}
			else
			{
				a();
			}
		}

		private void LoadCardState()
		{
			string text = P.CardOrder.Value ?? "";
			if (text != _ordersSrc)
			{
				_ordersSrc = text;
				_orders.Clear();
				string[] array = text.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string text2 in array)
				{
					int num = text2.IndexOf(':');
					if (num > 0)
					{
						_orders[text2.Substring(0, num)] = new List<string>(text2.Substring(num + 1).Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries));
					}
				}
			}
			string text3 = P.CardsFolded.Value ?? "";
			if (text3 != _foldedSrc)
			{
				_foldedSrc = text3;
				_folded.Clear();
				string[] array = text3.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string item in array)
				{
					_folded.Add(item);
				}
			}
		}

		private void SaveOrders()
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, List<string>> order in _orders)
			{
				if (order.Value.Count > 0)
				{
					list.Add(order.Key + ":" + string.Join("|", order.Value.ToArray()));
				}
			}
			_ordersSrc = string.Join(";", list.ToArray());
			Set((ConfigEntryBase)(object)P.CardOrder, _ordersSrc);
		}

		private void SaveFolded()
		{
			_foldedSrc = string.Join("|", new List<string>(_folded).ToArray());
			Set((ConfigEntryBase)(object)P.CardsFolded, _foldedSrc);
		}

		internal void ResetCards()
		{
			_orders.Clear();
			_folded.Clear();
			SaveOrders();
			SaveFolded();
		}

		private void FlushCards(List<CardRec> list, string tab)
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Invalid comparison between Unknown and I4
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			_cardTab = tab;
			if (list == null || list.Count == 0)
			{
				return;
			}
			LoadCardState();
			_orders.TryGetValue(tab, out var value);
			if (value != null && value.Count > 0)
			{
				List<KeyValuePair<int, CardRec>> list2 = new List<KeyValuePair<int, CardRec>>();
				for (int i = 0; i < list.Count; i++)
				{
					int num = value.IndexOf(list[i].Title);
					list2.Add(new KeyValuePair<int, CardRec>((num < 0) ? (100000 + i) : num, list[i]));
				}
				list2.Sort((KeyValuePair<int, CardRec> a, KeyValuePair<int, CardRec> b) => a.Key.CompareTo(b.Key));
				list = new List<CardRec>();
				foreach (KeyValuePair<int, CardRec> item2 in list2)
				{
					list.Add(item2.Value);
				}
			}
			if (_dragging && _pressKey != null && (int)Event.current.type == 8 && Time.unscaledTime - _swapAt > 0.1f && Time.frameCount > _swapFrame + 2)
			{
				int num2 = list.FindIndex((CardRec c) => Key(tab, c.Title) == _pressKey);
				if (num2 >= 0 && _cardRects.TryGetValue(_pressKey, out var value2))
				{
					float num3 = _dragY - _grabDY + ((Rect)(ref value2)).height * 0.5f;
					int num4 = -1;
					Rect value4;
					if (num2 + 1 < list.Count && _cardRects.TryGetValue(Key(tab, list[num2 + 1].Title), out var value3) && num3 > ((Rect)(ref value3)).y + ((Rect)(ref value3)).height * 0.5f)
					{
						num4 = num2 + 1;
					}
					else if (num2 > 0 && _cardRects.TryGetValue(Key(tab, list[num2 - 1].Title), out value4) && num3 < ((Rect)(ref value4)).y + ((Rect)(ref value4)).height * 0.5f)
					{
						num4 = num2 - 1;
					}
					if (num4 >= 0)
					{
						string key = Key(tab, list[num4].Title);
						Rect val = _cardRects[key];
						float num5 = ((num4 > num2) ? (((Rect)(ref val)).y - ((Rect)(ref value2)).yMax) : (((Rect)(ref value2)).y - ((Rect)(ref val)).yMax));
						float num6 = ((num4 > num2) ? ((Rect)(ref value2)).y : (((Rect)(ref val)).y + ((Rect)(ref value2)).height + num5));
						_cardOff.TryGetValue(key, out var value5);
						_cardOff[key] = ((Rect)(ref val)).y + value5 - num6;
						CardRec item = list[num2];
						list.RemoveAt(num2);
						list.Insert(num4, item);
						List<string> list3 = new List<string>();
						foreach (CardRec item3 in list)
						{
							list3.Add(item3.Title);
						}
						_orders[tab] = list3;
						SaveOrders();
						_swapAt = Time.unscaledTime;
						_swapFrame = Time.frameCount;
					}
				}
			}
			foreach (CardRec item4 in list)
			{
				DrawCard(item4, tab);
			}
		}

		private static string Key(string tab, string title)
		{
			return tab + "/" + title;
		}

		private void DrawCard(CardRec c, string tab)
		{
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			//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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_0100: 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_0193: Invalid comparison between Unknown and I4
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			string text = Key(tab, c.Title);
			LoadCardState();
			float num = CardOffset(text);
			Matrix4x4 matrix = GUI.matrix;
			bool flag = Mathf.Abs(num) > 0.5f;
			if (flag)
			{
				GUI.matrix = matrix * Matrix4x4.Translate(new Vector3(0f, num, 0f));
			}
			GUILayout.BeginVertical(_cardSt, Array.Empty<GUILayoutOption>());
			bool folded = _folded.Contains(text);
			GUIContent val = new GUIContent((folded ? "+   " : "-   ") + (c.Shown ?? c.Title).ToUpperInvariant());
			Rect rect = GUILayoutUtility.GetRect(val, _cardTitle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) });
			if ((int)Event.current.type == 7)
			{
				_cardTitle.Draw(rect, val, false, false, false, false);
				Rect val2 = rect;
				((Rect)(ref val2)).x = ((Rect)(ref val2)).x + 0.7f;
				_cardTitle.Draw(val2, val, false, false, false, false);
			}
			TitleInput(text, rect, ref folded);
			Tip(rect, P.CardsLocked.Value ? "Click: fold or open this card. The card order is locked (This panel > Lock card order)." : "Click: fold or open this card. Hold and drag: move the card. Lock the order: This panel > Lock card order.");
			if (!folded)
			{
				if (!string.IsNullOrEmpty(c.Note))
				{
					GUILayout.Label(c.Note, _hint, Array.Empty<GUILayoutOption>());
				}
				GUILayout.Space(4f);
				c.Body();
			}
			GUILayout.EndVertical();
			if (flag)
			{
				GUI.matrix = matrix;
			}
			if ((int)Event.current.type == 7)
			{
				Rect lastRect = GUILayoutUtility.GetLastRect();
				_cardRects[text] = lastRect;
				if (_dragging && _pressKey == text)
				{
					RFill(lastRect, new Color(1f, 1f, 1f, 0.08f), 14);
				}
			}
		}

		private void TitleInput(string key, Rect tr, ref bool folded)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref tr)).Contains(current.mousePosition))
			{
				_pressKey = key;
				_pressPos = current.mousePosition;
				_dragging = false;
				_grabDY = (_cardRects.TryGetValue(key, out var value) ? (current.mousePosition.y - ((Rect)(ref value)).y) : 12f);
				current.Use();
			}
			else
			{
				if (!(_pressKey == key))
				{
					return;
				}
				if ((int)current.type == 1 && current.button == 0)
				{
					if (!_dragging)
					{
						if (folded)
						{
							_folded.Remove(key);
						}
						else
						{
							_folded.Add(key);
						}
						folded = !folded;
						SaveFolded();
					}
					_pressKey = null;
					_dragging = false;
					current.Use();
				}
				else if ((int)current.type == 3 && !P.CardsLocked.Value)
				{
					if (!_dragging)
					{
						Vector2 val = current.mousePosition - _pressPos;
						if (((Vector2)(ref val)).magnitude > 8f)
						{
							_dragging = true;
						}
					}
					if (_dragging)
					{
						_dragY = current.mousePosition.y;
						current.Use();
					}
				}
				else if ((int)current.rawType == 1)
				{
					_pressKey = null;
					_dragging = false;
				}
			}
		}

		private float CardOffset(string key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			if ((int)Event.current.type != 7)
			{
				return 0f;
			}
			_cardOff.TryGetValue(key, out var value);
			if (_dragging && _pressKey == key)
			{
				if (_cardRects.TryGetValue(key, out var value2))
				{
					value = _dragY - _grabDY - ((Rect)(ref value2)).y;
				}
			}
			else if (value != 0f)
			{
				value = Mathf.Lerp(value, 0f, 1f - Mathf.Exp(-16f * Mathf.Min(0.05f, Time.unscaledDeltaTime)));
				if (Mathf.Abs(value) < 0.4f)
				{
					value = 0f;
				}
			}
			_cardOff[key] = value;
			return value;
		}

		private void DragAutoScroll(ref Vector2 scroll, float viewH)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if (_dragging && _pressKey != null && !(viewH < 60f) && (int)Event.current.type == 7)
			{
				float num = _dragY - scroll.y;
				float num2 = Mathf.Min(Time.unscaledDeltaTime, 0.05f);
				if (num < 50f)
				{
					scroll.y = Mathf.Max(0f, scroll.y - (50f - Mathf.Max(num, -50f)) * 12f * num2);
				}
				else if (num > viewH - 50f)
				{
					scroll.y += (num - (viewH - 50f)) * 12f * num2;
				}
			}
		}

		internal void Opened()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			IsOpen = true;
			Rebinding = false;
			_resizing = false;
			_prevLock = Cursor.lockState;
			_prevVisible = Cursor.visible;
			((Rect)(ref _rect)).x = P.PanelX.Value;
			((Rect)(ref _rect)).y = P.PanelY.Value;
			((Rect)(ref _rect)).width = Mathf.Max(860f, P.PanelW.Value);
			((Rect)(ref _rect)).height = Mathf.Max(500f, P.PanelH.Value);
			_tab = P.PanelTab.Value;
			_styleKey = -1f;
			InstallHoverGuard();
		}

		internal void Closing()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			IsOpen = false;
			Rebinding = false;
			_editKey = null;
			_pressKey = null;
			_dragging = false;
			_resizing = false;
			P.PanelX.Value = ((Rect)(ref _rect)).x;
			P.PanelY.Value = ((Rect)(ref _rect)).y;
			P.PanelW.Value = ((Rect)(ref _rect)).width;
			P.PanelH.Value = ((Rect)(ref _rect)).height;
			P.PanelTab.Value = _tab ?? "Shop";
			_dirty = true;
			SaveNow();
			Cursor.lockState = _prevLock;
			Cursor.visible = _prevVisible;
		}

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			try
			{
				if ((int)Cursor.lockState != 0)
				{
					Cursor.lockState = (CursorLockMode)0;
				}
				if (!Cursor.visible)
				{
					Cursor.visible = true;
				}
				if (!((Object)(object)GameDirector.instance != (Object)null) || (int)GameDirector.instance.currentState != 0)
				{
					if ((Object)(object)PlayerController.instance != (Object)null && PlayerController.instance.InputDisableTimer < 0.1f)
					{
						PlayerController.instance.InputDisableTimer = 0.1f;
					}
					if ((Object)(object)InputManager.instance != (Object)null)
					{
						InputManager.instance.DisableAiming(0.2f);
					}
				}
				if (_dirty && _saveAt > 0f && Time.unscaledTime >= _saveAt)
				{
					SaveNow();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ExtraShelvesPlugin.Log;
				if (log != null)
				{
					log.LogDebug((object)("Panel update: " + ex.Message));
				}
			}
		}

		private void OnDisable()
		{
			IsOpen = false;
		}

		private void OnApplicationQuit()
		{
			SaveNow();
		}

		private void Set(ConfigEntryBase entry, object value)
		{
			if (entry != null && !object.Equals(entry.BoxedValue, value))
			{
				ConfigFile configFile = entry.ConfigFile;
				bool saveOnConfigSet = configFile.SaveOnConfigSet;
				configFile.SaveOnConfigSet = false;
				try
				{
					entry.BoxedValue = value;
				}
				finally
				{
					configFile.SaveOnConfigSet = saveOnConfigSet;
				}
				_dirty = true;
				_saveAt = Time.unscaledTime + 0.8f;
			}
		}

		private void SaveNow()
		{
			if (!_dirty)
			{
				return;
			}
			_dirty = false;
			_saveAt = -1f;
			try
			{
				ExtraShelvesPlugin self = ExtraShelvesPlugin.Self;
				if (self != null)
				{
					((BaseUnityPlugin)self).Config.Save();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ExtraShelvesPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("Could not save settings: " + ex.Message));
				}
			}
		}

		private void Toast(string text)
		{
			_toast = text;
			_toastUntil = Time.unscaledTime + 2.5f;
		}

		private void OnGUI()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			if (P == null)
			{
				return;
			}
			TrackMouse();
			Event current = Event.current;
			if (Rebinding && current != null && (int)current.type == 4 && (int)current.keyCode != 0)
			{
				if ((int)current.keyCode != 27)
				{
					Set((ConfigEntryBase)(object)P.PanelKey, current.keyCode);
					Toast("Panel key: " + ((object)P.PanelKey.Value/*cast due to .constrained prefix*/).ToString());
				}
				Rebinding = false;
				current.Use();
			}
			EnsureStyles();
			if (GUIUtility.hotControl == 0)
			{
				_scale = Mathf.Clamp(P.PanelScale.Value, 0.75f, 2f);
			}
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(_scale, _scale, 1f));
			float num = (float)Screen.width / _scale;
			float num2 = (float)Screen.height / _scale;
			ResizeFollow(num, num2);
			((Rect)(ref _rect)).width = Mathf.Clamp(((Rect)(ref _rect)).width, 860f, Mathf.Max(860f, num - 8f));
			((Rect)(ref _rect)).height = Mathf.Clamp(((Rect)(ref _rect)).height, 500f, Mathf.Max(500f, num2 - 8f));
			_rect = GUI.Window(1163088689, _rect, new WindowFunction(DrawWindow), GUIContent.none, _win);
			((Rect)(ref _rect)).x = Mathf.Clamp(((Rect)(ref _rect)).x, 0f, Mathf.Max(0f, num - 120f));
			((Rect)(ref _rect)).y = Mathf.Clamp(((Rect)(ref _rect)).y, 0f, Mathf.Max(0f, num2 - 60f));
			GUI.matrix = matrix;
		}

		private void DrawWindow(int id)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Invalid comparison between Unknown and I4
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 7)
			{
				_tip = null;
			}
			GUI.Label(new Rect(22f, 10f, 360f, 34f), "EXTRA SHOP SHELVES", _title);
			GUI.Label(new Rect(300f, 22f, 120f, 20f), "v1.0.0", _small);
			string text = (((int)P.PanelKey.Value == 0) ? "" : (((object)P.PanelKey.Value/*cast due to .constrained prefix*/).ToString() + " = close"));
			GUI.Label(new Rect(((Rect)(ref _rect)).width - 128f, 21f, 80f, 20f), text, _smallRight);
			if (GUI.Button(new Rect(((Rect)(ref _rect)).width - 40f, 14f, 28f, 28f), "X", _closeBtn))
			{
				ExtraShelvesPlugin.Self?.TogglePanel();
				return;
			}
			Fill(new Rect(18f, 56f, ((Rect)(ref _rect)).width - 36f, 1f), _line);
			List<Page> list = Pages();
			if (_tab == null || list.FindIndex((Page p) => p.Id == _tab) < 0)
			{
				_tab = list[0].Id;
			}
			GUILayout.BeginArea(new Rect(18f, 66f, 200f, ((Rect)(ref _rect)).height - 58f - 20f));
			_navScroll = GUILayout.BeginScrollView(_navScroll, GUIStyle.none, GUIStyle.none, Array.Empty<GUILayoutOption>());
			string text2 = null;
			foreach (Page item in list)
			{
				if (NavItem(item.Title, item.Id == _tab))
				{
					text2 = item.Id;
				}
			}
			GUILayout.Space(10f);
			GUILayout.Label("Changes apply at once and are saved automatically. Every setting is also in the game's Mods menu.", _hint, Array.Empty<GUILayoutOption>());
			if (!P.Enabled.Value)
			{
				GUILayout.Space(6f);
				GUILayout.Label("The mod is switched OFF (Shop page).", _warn, Array.Empty<GUILayoutOption>());
			}
			else if (ShopHooks.FoundOther != null)
			{
				GUILayout.Space(6f);
				GUILayout.Label("Another shop mod is on. Advice: turn it off (see the Shop page).", _warn, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.EndArea();
			float num = 230f;
			float num2 = ((Rect)(ref _rect)).width - num - 18f;
			float num3 = ((Rect)(ref _rect)).height - 58f - 20f;
			GUILayout.BeginArea(new Rect(num, 66f, num2, num3));
			DragAutoScroll(ref _scroll, num3);
			_scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>());
			_rowWidth = num2 - 34f;
			Page page = list.Find((Page p) => p.Id == _tab);
			_collect = new List<CardRec>();
			_tail = new List<Action>();
			try
			{
				page.Draw();
			}
			catch (Exception ex)
			{
				GUILayout.Label("Page error: " + ex.Message, _warn, Array.Empty<GUILayoutOption>());
			}
			List<CardRec> collect = _collect;
			List<Action> tail = _tail;
			_collect = null;
			_tail = null;
			try
			{
				FlushCards(collect, page.Id);
				foreach (Action item2 in tail)
				{
					item2();
				}
			}
			catch (Exception ex2)
			{
				GUILayout.Label("Page error: " + ex2.Message, _warn, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(12f);
			GUILayout.EndScrollView();
			GUILayout.EndArea();
			if (text2 != null && text2 != _tab)
			{
				_tab = text2;
				_scroll = Vector2.zero;
				_confirmResetUntil = 0f;
			}
			if (!string.IsNullOrEmpty(_toast) && Time.unscaledTime < _toastUntil)
			{
				GUIContent val = new GUIContent(_toast);
				Vector2 val2 = _toastSt.CalcSize(val);
				Rect val3 = new Rect((((Rect)(ref _rect)).width - val2.x) / 2f - 14f, ((Rect)(ref _rect)).height - 50f, val2.x + 28f, 32f);
				RFill(val3, new Color(0f, 0f, 0f, 0.82f), 14);
				GUI.Label(val3, val, _toastSt);
			}
			Event current2 = Event.current;
			if (!P.WindowLocked.Value)
			{
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref _rect)).width - 26f, ((Rect)(ref _rect)).height - 26f, 24f, 24f);
				for (int num4 = 0; num4 < 10; num4++)
				{
					Fill(new Rect(((Rect)(ref r)).xMax - (float)(num4 + 1) * 2f, ((Rect)(ref r)).y + 4f + (float)num4 * 2f, (float)(num4 + 1) * 2f, 2f), new Color(_accent.r, _accent.g, _accent.b, 0.6f));
				}
				Tip(r, "Drag to resize the panel. Lock the size: This panel > Lock window size.");
				if ((int)current2.type == 0 && current2.button == 0 && ((Rect)(ref r)).Contains(current2.mousePosition))
				{
					_resizing = true;
					_gripOff = new Vector2(((Rect)(ref _rect)).width - current2.mousePosition.x, ((Rect)(ref _rect)).height - current2.mousePosition.y);
					current2.Use();
				}
			}
			else
			{
				_resizing = false;
			}
			if (_resizing && (int)current2.type == 3)
			{
				current2.Use();
			}
			DrawTip();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 54f));
		}

		private void ResizeFollow(float sw, float sh)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_0035: 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_004f: 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)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (!_resizing || current == null)
			{
				return;
			}
			if ((int)current.rawType == 1 && current.button == 0)
			{
				_resizing = false;
			}
			else if ((int)current.type == 8)
			{
				Vector2 val = MouseOnScreen() / Mathf.Max(0.01f, _scale);
				((Rect)(ref _rect)).width = Mathf.Clamp(val.x - ((Rect)(ref _rect)).x + _gripOff.x, 860f, Mathf.Max(860f, sw - ((Rect)(ref _rect)).x - 4f));
				((Rect)(ref _rect)).height = Mathf.Clamp(val.y - ((Rect)(ref _rect)).y + _gripOff.y, 500f, Mathf.Max(500f, sh - ((Rect)(ref _rect)).y - 4f));
				if (!MouseHeld())
				{
					_resizing = false;
				}
			}
		}

		private static Vector2 MouseOnScreen()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			Mouse current = Mouse.current;
			if (current != null)
			{
				Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
				return new Vector2(val.x, (float)Screen.height - val.y);
			}
			if (!_legacyMouseOff)
			{
				try
				{
					Vector3 mousePosition = Input.mousePosition;
					return new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y);
				}
				catch (InvalidOperationException)
				{
					_legacyMouseOff = true;
				}
			}
			return _mouseScreen;
		}

		private static bool MouseHeld()
		{
			Mouse current = Mouse.current;
			if (current != null)
			{
				return current.leftButton.isPressed;
			}
			if (!_legacyMouseOff)
			{
				try
				{
					return Input.GetMouseButton(0);
				}
				catch (InvalidOperationException)
				{
					_legacyMouseOff = true;
				}
			}
			return true;
		}

		private static void InstallHoverGuard()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (_hoverPatched)
			{
				return;
			}
			_hoverPatched = true;
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "UIMouseHover", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					new Harmony("Rehaan.ExtraShopShelves.panel").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SettingsPanel), "UIMouseHoverPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ExtraShelvesPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("Panel: hover guard not installed: " + ex.Message));
				}
			}
		}

		private static bool UIMouseHoverPrefix(ref bool __result)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (IsOpen && ((Rect)(ref _screenRect)).Contains(_mouseScreen))
			{
				__result = false;
				return false;
			}
			return true;
		}

		private void TrackMouse()
		{
			//IL_005c: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current != null)
			{
				_mouseScreen = current.mousePosition;
			}
			_screenRect = new Rect(((Rect)(ref _rect)).x * _scale, ((Rect)(ref _rect)).y * _scale, ((Rect)(ref _rect)).width * _scale, ((Rect)(ref _rect)).height * _scale);
		}

		private List<Page> Pages()
		{
			if (_pages != null)
			{
				return _pages;
			}
			_pages = new List<Page>
			{
				new Page
				{
					Id = "Shop",
					Title = "Shop & shelves",
					Draw = PageShop
				},
				new Page
				{
					Id = "Decor",
					Title = "Decorations",
					Draw = PageDecor
				},
				new Page
				{
					Id = "Items",
					Title = "Items in shop",
					Draw = PageItems
				},
				new Page
				{
					Id = "Limits",
					Title = "Purchase limits",
					Draw = PageLimits
				},
				new Page
				{
					Id = "Rules",
					Title = "Shop rules",
					Draw = PageRules
				},
				new Page
				{
					Id = "Panel",
					Title = "This panel",
					Draw = PagePanel
				}
			};
			return _pages;
		}

		private static bool InShop()
		{
			try
			{
				return (Object)(object)RunManager.instance != (Object)null && SemiFunc.RunIsShop();
			}
			catch
			{
				return false;
			}
		}

		private static bool IsHost()
		{
			try
			{
				return (Object)(object)GameManager.instance == (Object)null || !SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient();
			}
			catch
			{
				return true;
			}
		}

		private void PageShop()
		{
			ShelfTheme shown = ((InShop() && Shelves.Count > 0) ? Shelves.ShownTheme : Themes.Resolve(P.Theme.Value));
			if (ShopHooks.FoundOther != null)
			{
				Card("Warning", delegate
				{
					GUILayout.Label(ShopHooks.Advice, _warn, Array.Empty<GUILayoutOption>());
				});
			}
			Card("Now", delegate
			{
				DrawPreview(shown);
				string text = ((P.Theme.Value == ShelfTheme.Auto) ? " (Auto: by today's date)" : ((P.Theme.Value != shown) ? (" (" + Themes.Title(P.Theme.Value) + " is still locked)") : ""));
				Hint("Theme: " + Themes.Title(shown) + text);
				if (InShop())
				{
					Hint((Shelves.Count > 0) ? ("In this shop: " + Shelves.Count + " extra shelf/shelves (" + string.Join(", ", Shelves.LastSpots.ToArray()) + ").") : "In this shop: no extra shelves (none asked for, no free spot, or the host does not have this mod).");
					if (Shelves.AutoNote != null)
					{
						Hint("Auto: " + Shelves.AutoNote + ".");
					}
				}
				else
				{
					Hint("Not in a shop right now. Shelves are placed when the next shop loads; a new look shows at once while you stand in the shop.");
				}
				if (!IsHost())
				{
					Hint("You are not the host: the host decides the theme and the number of shelves. Decoration, glow and lamps follow your own settings.");
				}
			});
			Card("Shelves", delegate
			{
				Switch(P.Enabled, "Mod enabled", "Master switch. Off = the shop is exactly as the game makes it.");
				ThemeChoice();
				SliderInt(P.ExtraShelves, "Extra shelves", "At least this many extra shelves (host, at most 2). Some shops have room for fewer. Each shelf holds 72 items.");
				Switch(P.AutoShelves, "Auto extra shelves", "When the shop has more items than spots (also when other mods add items), more shelves come by themselves, up to 2.");
				Switch(P.ShelfLights, "Shelf lamps", "Two soft lamps per shelf. Off = no extra lights at all (fastest).");
			});
			ReshuffleCard();
			Below(delegate
			{
				ResetPageButton((ConfigEntryBase)P.Enabled, (ConfigEntryBase)P.Theme, (ConfigEntryBase)P.ExtraShelves, (ConfigEntryBase)P.AutoShelves, (ConfigEntryBase)P.ShelfLights);
			});
		}

		private void ReshuffleCard()
		{
			Card("Shuffle the shop", delegate
			{
				//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_007a: 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)
				Hint("Puts a fresh set of items on the shelves: other upgrades, weapons, drones and variants. Items someone holds, items in the cart and items on the extraction stay where they are.");
				string text = Reshuffle.Blocked();
				GUILayout.Space(2f);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				Rect rect = GUILayoutUtility.GetRect(230f, 34f, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(230f),
					GUILayout.Height(34f)
				});
				bool enabled = GUI.enabled;
				GUI.enabled = text == null;
				bool num = ButtonAt(rect, Reshuffle.Busy ? "Shuffling..." : "Shuffle the shop", _accent);
				GUI.enabled = enabled;
				Tip(rect, text);
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
				if (num && text == null)
				{
					Reshuffle.Run();
					Toast("Shuffling the shop...");
				}
				GUILayout.Space(2f);
				if (text != null && !Reshuffle.Busy)
				{
					Hint(text);
				}
				else if (Reshuffle.Last != null)
				{
					Hint(Reshuffle.Last);
				}
			});
		}

		private void ThemeChoice()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00fc: Invalid comparison between Unknown and I4
			//IL_00d8: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			float[] array = new float[ThemeOrder.Length];
			float num = 0f;
			for (int i = 0; i < ThemeOrder.Length; i++)
			{
				bool flag = !Themes.IsOpen(ThemeOrder[i]);
				array[i] = Mathf.Max(58f, _btnText.CalcSize(new GUIContent(Themes.Title(ThemeOrder[i]))).x + 20f + (flag ? 16f : 0f));
				num += array[i] + 6f;
			}
			bool flag2 = num > _rowWidth * 0.62f;
			float textWidth;
			Rect r = RowRect("Auto picks the season by date. A locked theme opens on its date (hover it to see when).", flag2 ? 0f : num, out textWidth);
			if (flag2)
			{
				((Rect)(ref r)).height = ((Rect)(ref r)).height + 40f;
				GUILayoutUtility.GetRect(10f, 40f);
			}
			bool hover = ((Rect)(ref r)).Contains(Event.current.mousePosition);
			if ((int)Event.current.type == 7)
			{
				RowText(r, "Theme", "Auto picks the season by date. A locked theme opens on its date (hover it to see when).", flag2 ? (_rowWidth - 30f) : textWidth, hover, dim: false);
			}
			float num2 = (flag2 ? (((Rect)(ref r)).x + 12f) : (((Rect)(ref r)).xMax - num - 8f));
			float num3 = (flag2 ? (((Rect)(ref r)).yMax - 40f) : (((Rect)(ref r)).center.y - 14f));
			Rect r2 = default(Rect);
			for (int j = 0; j < ThemeOrder.Length; j++)
			{
				ShelfTheme shelfTheme = ThemeOrder[j];
				string text = Themes.LockText(shelfTheme);
				((Rect)(ref r2))..ctor(num2, num3, array[j], 28f);
				bool flag3 = P.Theme.Value == shelfTheme;
				bool flag4 = Chip(r2, Themes.Title(shelfTheme), flag3, text != null);
				if (text != null)
				{
					Padlock(new Rect(((Rect)(ref r2)).xMax - 19f, ((Rect)(ref r2)).center.y - 7f, 11f, 13f));
					Tip(r2, text);
					if (flag4)
					{
						Toast(text);
					}
				}
				else
				{
					Tip(r2, (shelfTheme == ShelfTheme.Auto) ? ("Today: " + Themes.Title(Themes.ByDate(DateTime.Now)) + ".") : null);
					if (flag4)
					{
						Set((ConfigEntryBase)(object)P.Theme, shelfTheme);
					}
				}
				num2 += array[j] + 6f;
			}
			GUILayout.Space(3f);
		}

		private void Padlock(Rect r)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 7)
			{
				Color val = Color.Lerp(_dim, _warnCol, 0.5f);
				ROutline(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 4f, ((Rect)(ref r)).height * 0.6f), Color.Lerp(_row, Color.black, 0.2f), val, 4);
				RFill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height * 0.42f, ((Rect)(ref r)).width, ((Rect)(ref r)).height * 0.58f), val, 2);
			}
		}

		private void PageDecor()
		{
			Card("All themes", delegate
			{
				AmountRow();
				SliderInt(P.GlowStrength, "Glow", "Brightness of bulbs, signs, candles, snow and fireworks.", " %");
				Switch(P.Animate, "Animate", "Bulbs twinkle, candles flicker, fireworks pulse (ten small updates a second).");
			});
			ShelfTheme shelfTheme = Themes.Resolve(P.Theme.Value);
			ShelfTheme[] themeOrder = ThemeOrder;
			foreach (ShelfTheme shelfTheme2 in themeOrder)
			{
				if (shelfTheme2 != ShelfTheme.Auto)
				{
					DecorCard(shelfTheme2, shelfTheme2 == shelfTheme);
				}
			}
			List<ConfigEntryBase> all = new List<ConfigEntryBase>
			{
				(ConfigEntryBase)(object)P.DecorAmount,
				(ConfigEntryBase)(object)P.GlowStrength,
				(ConfigEntryBase)(object)P.Animate
			};
			foreach (Piece item in Themes.Catalog)
			{
				all.Add((ConfigEntryBase)(object)P.PieceEntry(item));
			}
			Below(delegate
			{
				ResetPageButton(all.ToArray());
			});
		}

		private void AmountRow()
		{
			string[] array = new string[4] { "none", "a few", "normal", "lots" };
			int value = P.DecorAmount.Value;
			int num = Mathf.Clamp(Mathf.RoundToInt(SliderRow((ConfigEntryBase)(object)P.DecorAmount, "Amount", "How much decoration stands on and around the shelves (0 - 3).", value, 0f, 3f, array[Mathf.Clamp(value, 0, 3)], dim: false)), 0, 3);
			if (num != value)
			{
				Set((ConfigEntryBase)(object)P.DecorAmount, num);
			}
		}

		private void DecorCard(ShelfTheme t, bool current)
		{
			string lockText = Themes.LockText(t);
			string shown = Themes.Title(t) + (current ? "  (shown now)" : ((lockText != null) ? "  (locked)" : ""));
			bool off = P.DecorAmount.Value == 0;
			Card("Theme " + t, delegate
			{
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: 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)
				if (lockText != null)
				{
					GUILayout.Label(lockText, _warn, Array.Empty<GUILayoutOption>());
					GUILayout.Space(2f);
				}
				foreach (Piece item in Themes.Catalog)
				{
					if (item.Theme == t)
					{
						Switch(P.PieceEntry(item), item.Label, item.Description.Replace(" (" + Themes.Title(t) + " theme.)", ""), off);
					}
				}
				if (!current && IsHost())
				{
					GUILayout.Space(2f);
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.FlexibleSpace();
					bool enabled = GUI.enabled;
					Rect rect = GUILayoutUtility.GetRect(170f, 32f, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(170f),
						GUILayout.Height(32f)
					});
					GUI.enabled = lockText == null;
					bool num = ButtonAt(rect, "Use this theme", _accent);
					GUI.enabled = enabled;
					Tip(rect, lockText);
					if (num && lockText == null)
					{
						Set((ConfigEntryBase)(object)P.Theme, t);
						Toast("Theme: " + Themes.Title(t));
					}
					GUILayout.EndHorizontal();
				}
			}, null, shown);
		}

		private void PageItems()
		{
			ReshuffleCard();
			Card("How many of each item", delegate
			{
				foreach (ItemKind kind in P.Kinds)
				{
					KindSlider(kind.InShop, kind.Label, "-1 = the game's own number.", minusIsGame: true);
				}
			}, "Host. Per item: with 3 guns, every kind of gun can be in the shop up to 3 times. Applies when the next shop loads.");
			List<ConfigEntryBase> list = new List<ConfigEntryBase>();
			foreach (ItemKind kind2 in P.Kinds)
			{
				list.Add((ConfigEntryBase)(object)kind2.InShop);
			}
			Below(delegate
			{
				ResetPageButton(list.ToArray());
			});
		}

		private void PageLimits()
		{
			Card("Most you can buy", delegate
			{
				foreach (ItemKind kind in P.Kinds)
				{
					KindSlider(kind.Limit, kind.Label, "Per item, for the whole run. 0 = no limit.", minusIsGame: false);
				}
			}, "Host. When the limit is reached the item is no longer put on the shelves, and one visit never shows more than can still be bought.");
			List<ConfigEntryBase> list = new List<ConfigEntryBase>();
			foreach (ItemKind kind2 in P.Kinds)
			{
				list.Add((ConfigEntryBase)(object)kind2.Limit);
			}
			Below(delegate
			{
				ResetPageButton(list.ToArray());
			});
		}

		private void KindSlider(ConfigEntry<int> e, string title, string desc, bool minusIsGame)
		{
			int num = 0;
			int num2 = 20;
			if (((ConfigEntryBase)e).Description.AcceptableValues is AcceptableValueRange<int> val)
			{
				num = val.MinValue;
				num2 = val.MaxValue;
			}
			string shown = ((minusIsGame && e.Value < 0) ? "game" : ((!minusIsGame && e.Value == 0) ? "none" : e.Value.ToString()));
			int num3 = Mathf.Clamp(Mathf.RoundToInt(SliderRow((ConfigEntryBase)(object)e, title, desc, e.Value, num, num2, shown, dim: false)), num, num2);
			if (num3 != e.Value)
			{
				Set((ConfigEntryBase)(object)e, num3);
			}
		}

		private void PageRules()
		{
			Card("Filling the shop (host)", delegate
			{
				Switch(P.ShowUnaffordable, "Show items you cannot afford", "The game leaves out most items that cost more than the team has. On = they are all in the running.");
				Switch(P.FillEverySpot, "Fill every spot", "Every free spot gets an item, instead of the game's fixed number per visit.");
				Switch(P.OtherModsItems, "Change items of other mods", "The item numbers also apply to items and upgrades that other mods add.");
				Switch(P.SingleUseUpgrades, "Change single-use upgrades", "Upgrades the game sells only once also get the number from 'Items in shop'.");
			});
			Card("Working with other mods", delegate
			{
				Switch(P.MakeRoom, "Make room for other shop mods", "When another mod also fills the shop, this mod stays out of it: no double shelves, no fighting over numbers.");
				Switch(P.Log, "Item log", "Writes the item numbers and the placed shelves to the BepInEx log (for bug reports).");
			});
			Below(delegate
			{
				ResetPageButton((ConfigEntryBase)P.ShowUnaffordable, (ConfigEntryBase)P.FillEverySpot, (ConfigEntryBase)P.OtherModsItems, (ConfigEntryBase)P.SingleUseUpgrades, (ConfigEntryBase)P.MakeRoom, (ConfigEntryBase)P.Log);
			});
		}

		private void PagePanel()
		{
			Card("Panel", delegate
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: 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_0030: Invalid comparison between Unknown and I4
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				float textWidth;
				Rect r = RowRect("Click, then press the new key. Esc cancels.", 190f, out textWidth);
				bool hover = ((Rect)(ref r)).Contains(Event.current.mousePosition);
				if ((int)Event.current.type == 7)
				{
					RowText(r, "Open / close key", "Click, then press the new key. Esc cancels.", textWidth, hover, dim: false);
				}
				string label = (Rebinding ? "press a key..." : ((object)P.PanelKey.Value/*cast due to .constrained prefix*/).ToString());
				if (Chip(new Rect(((Rect)(ref r)).xMax - 188f, ((Rect)(ref r)).center.y - 15f, 180f, 30f), label, Rebinding))
				{
					Rebinding = !Rebinding;
				}
				GUILayout.Space(3f);
				SliderFloat(P.PanelScale, "Size", "Size of this panel.", "0.00", "x");
				SliderFloat(P.PanelOpacity, "Background", "Opacity of this panel's background.", "0.00");
			});
			Card("Window", delegate
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				Switch(P.WindowLocked, "Lock window size", "On: the panel keeps its size (it can still be moved by its top bar). Off: a corner at the bottom right lets you drag the panel to the size you want.");
				GUILayout.Space(2f);
				if (Button("Default window", _accent, 200f))
				{
					_rect = new Rect(70f, 70f, 980f, 680f);
					P.PanelW.Value = ((Rect)(ref _rect)).width;
					P.PanelH.Value = ((Rect)(ref _rect)).height;
					Toast("The panel is back at its standard size and place.");
				}
			});
			Card("Cards", delegate
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				Switch(P.CardsLocked, "Lock card order", "On: the cards stay where they are (a click on a title still folds the card). Off: hold a card's title and drag it up or down to put it where you want it (per page).");
				Hint("Click a card's title to fold or open it. 'Reset card order' puts every page back as it was.");
				if (Button("Reset card order", _accent, 200f))
				{
					ResetCards();
					Toast("Cards are back in the standard order.");
				}
			});
			Card("Everything back to default", delegate
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				Hint("All settings of this mod go back to their defaults (the panel key and window position stay).");
				bool flag = Time.unscaledTime < _confirmResetUntil;
				if (Button(flag ? "Click again to confirm" : "Reset all settings", flag ? _warnCol : _accent, 260f))
				{
					if (flag)
					{
						int num = ResetAll();
						_confirmResetUntil = 0f;
						Toast(num + " setting(s) reset.");
					}
					else
					{
						_confirmResetUntil = Time.unscaledTime + 4f;
					}
				}
			});
			Card("About", delegate
			{
				Hint("EXTRA SHOP SHELVES  v1.0.0");
				Hint("Saved in BepInEx/config/Rehaan.ExtraShopShelves.cfg");
				Hint("The same settings are in the game's Mods menu (REPOConfig).");
			});
		}

		private void ResetPageButton(params ConfigEntryBase[] entries)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			bool flag = false;
			ConfigEntryBase[] array = entries;
			foreach (ConfigEntryBase val in array)
			{
				if (val != null && !object.Equals(val.BoxedValue, val.DefaultValue))
				{
					flag = true;
					break;
				}
			}
			bool enabled = GUI.enabled;
			GUI.enabled = flag;
			if (Button("Reset this page", _alt, 170f) && flag)
			{
				int num = 0;
				array = entries;
				foreach (ConfigEntryBase val2 in array)
				{
					if (val2 != null && !object.Equals(val2.BoxedValue, val2.DefaultValue))
					{
						Set(val2, val2.DefaultValue);
						num++;
					}
				}
				Toast(num + " setting(s) reset.");
			}
			GUI.enabled = enabled;
			GUILayout.EndHorizontal();
		}

		private int ResetAll()
		{
			int num = 0;
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in ((BaseUnityPlugin)ExtraShelvesPlugin.Self).Config)
			{
				ConfigEntryBase value = item.Value;
				if (value != null && (object)value != P.PanelKey && (object)value != P.PanelX && (object)value != P.PanelY && (object)value != P.PanelW && (object)value != P.PanelH && (object)value != P.PanelTab && (object)value != P.CardOrder && (object)value != P.CardsFolded && !object.Equals(value.BoxedValue, value.DefaultValue))
				{
					Set(value, value.DefaultValue);
					num++;
				}
			}
			return num;
		}

		private void DrawPreview(ShelfTheme theme)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			float scale = 43.367348f;
			float num = 6.879f * scale;
			Rect rect = GUILayoutUtility.GetRect(10f, 186f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if ((int)Event.current.type != 7)
			{
				return;
			}
			Palette palette = Themes.PaletteOf(theme);
			float x0 = ((Rect)(ref rect)).x + (((Rect)(ref rect)).width - num) * 0.5f;
			float floor = ((Rect)(ref rect)).y + 170f + 8f;
			RFill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 186f), Color.Lerp(_row, Color.black, 0.35f), 12);
			float num2 = 3.4395f;
			Fill(R(0f - num2, num2, 0f, 3.903f), palette.Back);
			Fill(R(0f - num2, num2, 0f, 0.4286f), palette.Frame);
			Fill(R(0f - num2, num2, 3.05f, 3.903f), palette.Header);
			Fill(R(0f - num2, num2, 3.84f, 3.903f), palette.Frame);
			Fill(R(num2 - 0.06f, num2, 0f, 3.903f), palette.Frame);
			Fill(R(0f - num2, 0f - num2 + 0.06f, 0f, 3.903f), palette.Frame);
			float[] dividers = ShelfModel.Dividers;
			foreach (float num3 in dividers)
			{
				Fill(R(num3 - 0.025f, num3 + 0.025f, 0.4286f, 3.05f), palette.Frame);
			}
			float[] array = new float[5] { 2.644f, 1.322f, 0f, -1.322f, -2.644f };
			float[][] array2 = new float[5][]
			{
				new float[4] { 0.9375f, 1.4646f, 1.9736f, 2.4836f },
				new float[3] { 1.4646f, 1.9736f, 2.4836f },
				new float[4] { 0.9375f, 1.4646f, 1.9736f, 2.4836f },
				new float[4] { 0.9375f, 1.4646f, 1.9736f, 2.4836f },
				new float[1] { 2.4836f }
			};
			Color c = default(Color);
			((Color)(ref c))..ctor(0.55f, 0.6f, 0.62f, 0.55f);
			for (int j = 0; j < 5; j++)
			{
				float num4 = array[j];
				float num5 = 0.62f;
				float y = 0.4286f;
				dividers = array2[j];
				foreach (float num6 in dividers)
				{
					Fill(R(num4 - num5, num4 + num5, num6 - 0.04f, num6), palette.Board);
					Fill(R(num4 - num5, num4 + num5, num6 - 0.07f, num6 - 0.04f), palette.Trim);
					Items(R, num4, y, num6 - 0.07f, c);
					y = num6;
				}
				Items(R, num4, y, 2.95f, c);
			}
			Fill(R(0f - num2, num2, 0.3786f, 0.4286f), palette.Trim);
			Fill(R(0f - num2, num2, 3.05f, 3.09f), palette.Trim);
			Fill(R((0f - num2) * 0.95f, num2 * 0.95f, 3.02f, 3.05f), palette.Strip);
			Figures(theme, R, scale);
			Rect R(float z0, float z1, float num10, float num9)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				float num7 = x0 + (3.4395f - Mathf.Max(z0, z1)) * scale;
				float num8 = x0 + (3.4395f - Mathf.Min(z0, z1)) * scale;
				return new Rect(num7, floor - num9 * scale, num8 - num7, (num9 - num10) * scale);
			}
		}

		private void Items(Mapper R, float zc, float y0, float y1, Color c)
		{
			//IL_0036: 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)
			float num = (y1 - y0) * 0.55f;
			if (!(num < 0.08f))
			{
				for (int i = -1; i <= 1; i++)
				{
					float num2 = zc + (float)i * 0.36f;
					Fill(R(num2 - 0.13f, num2 + 0.13f, y0, y0 + num), c);
				}
			}
		}

		private void Dot(Mapper R, float z, float y, float d, Color c)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = R(z - d * 0.5f, z + d * 0.5f, y - d * 0.5f, y + d * 0.5f);
			RFill(rect, c, Mathf.Max(2, Mathf.RoundToInt(((Rect)(ref rect)).width * 0.5f)));
		}

		private void Figures(ShelfTheme t, Mapper R, float scale)
		{
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac5: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c03: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c08: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0caf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d48: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			float num = 3.09f;
			if (P.DecorAmount.Value <= 0)
			{
				return;
			}
			switch (t)
			{
			case ShelfTheme.Christmas:
			{
				for (int k = 0; k < 3; k++)
				{
					float num4 = 0.46f - (float)k * 0.11f;
					Fill(R((0f - num4) * 0.5f, num4 * 0.5f, num + 0.1f + (float)k * 0.17f, num + 0.32f + (float)k * 0.17f), new Color(0.08f, 0.4f, 0.16f));
				}
				Dot(R, 0f, num + 0.74f, 0.13f, new Color(1f, 0.8f, 0.25f));
				float[] array = new float[2] { 1.7f, -1.7f };
				foreach (float num5 in array)
				{
					Dot(R, num5, num + 0.13f, 0.28f, Color.white);
					Dot(R, num5, num + 0.34f, 0.2f, Color.white);
					Dot(R, num5, num + 0.5f, 0.15f, Color.white);
					Fill(R(num5 - 0.05f, num5 + 0.05f, num + 0.58f, num + 0.68f), Color.black);
				}
				Fill(R(0.6f, 0.84f, num, num + 0.2f), new Color(0.8f, 0.1f, 0.1f));
				Fill(R(-0.84f, -0.6f, num, num + 0.2f), new Color(0.2f, 0.35f, 0.8f));
				array = new float[2] { 1.22f, -1.22f };
				foreach (float num6 in array)
				{
					Fill(R(num6 - 0.08f, num6 + 0.08f, num, num + 0.06f), new Color(0.4f, 0.25f, 0.13f));
					Dot(R, num6, num + 0.16f, 0.2f, new Color(0.75f, 0.88f, 1f, 0.75f));
				}
				for (float num7 = -3.2f; num7 <= 3.2f; num7 += 0.21f)
				{
					Dot(R, num7, num - 0.08f, 0.06f, (num7 * 7f % 2f > 1f) ? new Color(1f, 0.25f, 0.2f) : new Color(1f, 0.8f, 0.3f));
				}
				break;
			}
			case ShelfTheme.Halloween:
			{
				float[] array = new float[4] { 1.7f, -1.7f, 2.85f, -2.85f };
				foreach (float num13 in array)
				{
					Dot(R, num13, num + 0.14f, (Mathf.Abs(num13) < 2f) ? 0.34f : 0.26f, new Color(0.95f, 0.45f, 0.05f));
				}
				Dot(R, 0f, num + 0.5f, 0.26f, new Color(0.93f, 0.95f, 1f));
				Fill(R(-0.17f, 0.17f, num + 0.06f, num + 0.45f), new Color(0.93f, 0.95f, 1f));
				for (float num14 = -3f; num14 <= 3f; num14 += 1.2f)
				{
					Dot(R, num14, num - 0.2f, 0.09f, Color.black);
				}
				break;
			}
			case ShelfTheme.Spring:
			{
				Fill(R(0.4f, 3.25f, num, num + 0.12f), new Color(0.55f, 0.36f, 0.22f));
				Fill(R(-3.25f, -0.4f, num, num + 0.12f), new Color(0.55f, 0.36f, 0.22f));
				Color[] array4 = (Color[])(object)new Color[4]
				{
					new Color(0.98f, 0.55f, 0.7f),
					new Color(1f, 0.85f, 0.25f),
					Color.white,
					new Color(0.72f, 0.58f, 0.95f)
				};
				int num9 = 0;
				float num10 = -3.1f;
				while (num10 <= 3.1f)
				{
					if (Mathf.Abs(num10) > 0.45f)
					{
						Dot(R, num10, num + 0.32f + (float)(num9 % 3) * 0.05f, 0.09f, array4[num9 % array4.Length]);
					}
					num10 += 0.27f;
					num9++;
				}
				Fill(R(-0.1f, 0.1f, num + 0.24f, num + 0.48f), new Color(0.55f, 0.75f, 0.95f));
				Fill(R(-0.13f, 0.13f, num + 0.48f, num + 0.56f), new Color(0.92f, 0.42f, 0.38f));
				break;
			}
			case ShelfTheme.Easter:
			{
				Dot(R, 0f, num + 0.16f, 0.28f, new Color(0.93f, 0.92f, 0.9f));
				Dot(R, 0f, num + 0.38f, 0.18f, new Color(0.93f, 0.92f, 0.9f));
				Fill(R(0.02f, 0.07f, num + 0.45f, num + 0.66f), new Color(0.93f, 0.92f, 0.9f));
				Fill(R(-0.07f, -0.02f, num + 0.45f, num + 0.66f), new Color(0.93f, 0.92f, 0.9f));
				Color[] array5 = (Color[])(object)new Color[4]
				{
					new Color(0.98f, 0.7f, 0.78f),
					new Color(0.7f, 0.85f, 1f),
					new Color(1f, 0.92f, 0.5f),
					new Color(0.72f, 0.92f, 0.72f)
				};
				float[] array = new float[2] { 1.7f, -1.7f };
				foreach (float num11 in array)
				{
					Fill(R(num11 - 0.17f, num11 + 0.17f, num, num + 0.07f), new Color(0.62f, 0.45f, 0.22f));
					for (int l = 0; l < 4; l++)
					{
						Dot(R, num11 - 0.12f + (float)l * 0.08f, num + 0.11f, 0.1f, array5[l]);
					}
				}
				array = new float[2] { 0.62f, -0.62f };
				foreach (float num12 in array)
				{
					Fill(R(num12 - 0.1f, num12 + 0.1f, num + 0.02f, num + 0.26f), array5[(num12 > 0f) ? 1 : 2]);
					Fill(R(num12 - 0.1f, num12 + 0.1f, num + 0.12f, num + 0.15f), Color.white);
				}
				array = new float[2] { 1.15f, -1.15f };
				foreach (float z3 in array)
				{
					Dot(R, z3, num + 0.08f, 0.1f, new Color(1f, 0.88f, 0.25f));
				}
				break;
			}
			case ShelfTheme.NewYear:
			{
				Fill(R(-0.55f, 0.55f, 3.27f, 3.63f), new Color(1f, 0.78f, 0.25f, 0.85f));
				float[] array = new float[2] { 1.75f, -1.75f };
				foreach (float z in array)
				{
					Dot(R, z, num + 0.27f, 0.3f, new Color(0.85f, 0.87f, 0.92f));
				}
				array = new float[4] { 1.05f, -1.05f, 2.45f, -2.45f };
				foreach (float z2 in array)
				{
					Dot(R, z2, 3.45