Decompiled source of RecipeBook v2.2.1

plugins/RecipeBook/RecipeBook.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CasperEquinoxGUI;
using CasperEquinoxGUI.BaseClasses;
using CasperEquinoxGUI.Controls;
using CasperEquinoxGUI.Layouts;
using CasperEquinoxGUI.Utilities;
using EquinoxsModUtils;
using HarmonyLib;
using RecipeBook.Controls;
using RecipeBook.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RecipeBook")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RecipeBook")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("98abb3c9-7deb-4c5f-ab01-516a5100cbed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RecipeBook
{
	public static class FavouritesWindow
	{
		public static Window favouritesWindow;

		public static WrapPanel itemsPanel;

		public static List<int> favourites = new List<int>();

		private const string key = "recipeBookFavourites";

		public static void CreateWindow()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0036: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			itemsPanel = new WrapPanel
			{
				RowIndex = 1u
			};
			DrawItemButtons();
			favouritesWindow = new Window
			{
				HorizontalAlignment = (HorizontalAlignment)0,
				VerticalAlignment = (VerticalAlignment)3,
				Margin = new Thickness(20),
				Visible = false,
				Title = "Favourites",
				ShowShader = false,
				ShowCloseButton = false,
				RootLayout = (Layout)(object)itemsPanel,
				Width = RecipeBookPlugin.itemsPanelWidth.Value
			};
			CaspuinoxGUI.RegisterWindow(ref favouritesWindow);
		}

		public static void ToggleFavourite(int resId)
		{
			if (favourites.Contains(resId))
			{
				favourites.Remove(resId);
			}
			else
			{
				favourites.Add(resId);
			}
			DrawItemButtons();
			Save();
		}

		public static void Save()
		{
			string text = string.Join(",", favourites);
			CustomData.Update<string>(0u, "recipeBookFavourites", text);
		}

		public static void Load()
		{
			if (!CustomData.FieldExists<string>(0u, "recipeBookFavourites"))
			{
				return;
			}
			string[] array = CustomData.Get<string>(0u, "recipeBookFavourites").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				if (int.TryParse(array[i], out var result))
				{
					favourites.Add(result);
				}
			}
		}

		private static void DrawItemButtons()
		{
			//IL_0023: 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_0038: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0054: 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_0060: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			((Layout)itemsPanel).ClearChildren();
			using List<int>.Enumerator enumerator = favourites.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ResourceButton val = new ResourceButton(SaveState.GetResInfoFromId(enumerator.Current))
				{
					ImageWidth = RecipeBookPlugin.itemImageSize.Value,
					ImageHeight = RecipeBookPlugin.itemImageSize.Value,
					Margin = new Thickness(5),
					Padding = new Thickness(5)
				};
				((ClickableControl)val).LeftClicked += ItemsPanelGUI.OnResourceButtonLeftClicked;
				((ClickableControl)val).RightClicked += ItemsPanelGUI.OnResourceButtonRightClicked;
				((Layout)itemsPanel).AddControl((Control)(object)val);
			}
		}
	}
	internal static class Images
	{
		internal static bool initialised = false;

		internal static ModImage oneToOne = new ModImage("OneToOne.png", 366f, 122f);

		internal static ModImage oneToThree = new ModImage("OneToThree.png", 366f, 274f);

		internal static ModImage oneToTwo = new ModImage("OneToTwo.png", 366f, 198f);

		internal static ModImage star = new ModImage("Star.png", 20f, 20f);

		internal static ModImage threeToOne = new ModImage("ThreeToOne.png", 366f, 274f);

		internal static ModImage threeToThree = new ModImage("ThreeToThree.png", 366f, 274f);

		internal static ModImage threeToTwo = new ModImage("ThreeToTwo.png", 366f, 274f);

		internal static ModImage twoToOne = new ModImage("TwoToOne.png", 366f, 198f);

		internal static ModImage twoToThree = new ModImage("TwoToThree.png", 366f, 274f);

		internal static ModImage twoToTwo = new ModImage("TwoToTwo.png", 366f, 198f);

		private static List<ModImage> modImages = new List<ModImage> { oneToOne, oneToThree, oneToTwo, star, threeToOne, threeToThree, threeToTwo, twoToOne, twoToThree, twoToTwo };

		internal static void InitialiseStyles()
		{
			initialised = true;
			foreach (ModImage modImage in modImages)
			{
				modImage.InitialiseStyle();
			}
		}
	}
	internal class ModImage
	{
		internal float width;

		internal float height;

		internal Texture2D texture2d;

		internal Sprite sprite;

		internal Rect rect;

		internal GUIStyle style;

		internal void InitialiseStyle()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			GUIStyle val = new GUIStyle();
			val.normal.background = texture2d;
			style = val;
		}

		internal void Draw(float xPos, float yPos)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			((Rect)(ref rect)).x = xPos;
			((Rect)(ref rect)).y = yPos;
			GUI.Box(rect, "", style);
		}

		internal void Draw(float xPos, float yPos, float _width, float _height)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			rect = new Rect(xPos, yPos, _width, _height);
			GUI.Box(rect, "", style);
		}

		internal bool DrawAsButton(float xPos, float yPos)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			((Rect)(ref rect)).x = xPos;
			((Rect)(ref rect)).y = yPos;
			return GUI.Button(rect, "", style);
		}

		internal bool DrawAsButton(float xPos, float yPos, float _width, float _height)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			rect = new Rect(xPos, yPos, _width, _height);
			return GUI.Button(rect, "", style);
		}

		internal ModImage(string path, float _width, float _height)
		{
			//IL_002b: 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)
			width = _width;
			height = _height;
			rect = new Rect(0f, 0f, width, height);
			string text = path ?? "";
			texture2d = Images.LoadTexture2DFromFile(text, false, (Assembly)null);
			sprite = Images.LoadSpriteFromFile(text, false);
		}
	}
	public static class ItemsPanelGUI
	{
		public static Window itemsWindow;

		private static Textbox searchBar;

		private static WrapPanel itemsPanel;

		public static List<string> itemsToShow;

		public static bool isOpen;

		public static float sSinceOpen;

		public static float sSinceClose;

		public static void CreateItemsPanel()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: 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_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_004c: Expected O, but got Unknown
			//IL_004c: 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_005f: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			Grid val = new Grid(1u, 2u, new string[1] { "equal" }, new string[2] { "60", "equal" });
			searchBar = new Textbox
			{
				Hint = "Search...",
				Margin = new Thickness(0, 0, 0, 10),
				HorizontalContentAlignment = (HorizontalAlignment)0,
				VerticalContentAlignment = (VerticalAlignment)1
			};
			searchBar.TextChanged += OnSearchBarTextChanged;
			((Layout)val).AddControl((Control)(object)searchBar);
			itemsPanel = new WrapPanel
			{
				RowIndex = 1u
			};
			Events.TechTreeStateLoaded += OnTechTreeStateLoaded;
			((Layout)val).AddControl((Control)(object)itemsPanel);
			itemsWindow = new Window
			{
				HorizontalAlignment = (HorizontalAlignment)2,
				VerticalAlignment = (VerticalAlignment)3,
				Margin = new Thickness(20),
				Visible = false,
				Title = "Recipe Book",
				ShowShader = false,
				ShowCloseButton = false,
				RootLayout = (Layout)(object)val,
				Width = RecipeBookPlugin.itemsPanelWidth.Value
			};
			CaspuinoxGUI.RegisterWindow(ref itemsWindow);
		}

		public static void Show()
		{
			InputHandler.instance.uiInputBlocked = true;
			sSinceOpen = 0f;
			isOpen = true;
			Window obj = itemsWindow;
			if (obj != null)
			{
				obj.Show();
			}
		}

		public static void Hide()
		{
			if ((Object)(object)InputHandler.instance != (Object)null)
			{
				InputHandler.instance.uiInputBlocked = false;
			}
			isOpen = false;
			Window obj = itemsWindow;
			if (obj != null)
			{
				obj.Hide();
			}
			sSinceClose = 0f;
			RecipesGUI.Hide();
		}

		private static void OnTechTreeStateLoaded()
		{
			DrawItemButtons();
		}

		private static void OnSearchBarTextChanged(object sender, EventArgs e)
		{
			itemsToShow = Resources.SafeResources.Where((string name) => name.ToLower().Contains(searchBar.Input.ToLower()) && TechTreeState.instance.IsResourceKnown(Resources.GetResourceInfoByName(name, false))).ToList();
			((Layout)itemsPanel).ClearChildren();
			DrawItemButtons();
		}

		public static void OnResourceButtonLeftClicked(object sender, EventArgs e)
		{
			RecipesGUI.ShowRecipesForResource(((ResourceButton)((sender is ResourceButton) ? sender : null)).Resource);
		}

		public static void OnResourceButtonRightClicked(object sender, EventArgs e)
		{
			RecipesGUI.ShowUsesForResource(((ResourceButton)((sender is ResourceButton) ? sender : null)).Resource);
		}

		private static void DrawItemButtons()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0087: 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_0093: Expected O, but got Unknown
			//IL_0094: Expected O, but got Unknown
			if (!LoadingStates.hasTechTreeStateLoaded)
			{
				return;
			}
			if (itemsToShow == null)
			{
				itemsToShow = Resources.SafeResources.Where((string name) => name.ToLower().Contains(searchBar.Input.ToLower()) && TechTreeState.instance.IsResourceKnown(Resources.GetResourceInfoByName(name, false))).ToList();
			}
			using List<string>.Enumerator enumerator = itemsToShow.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ResourceButton val = new ResourceButton(enumerator.Current)
				{
					ImageWidth = RecipeBookPlugin.itemImageSize.Value,
					ImageHeight = RecipeBookPlugin.itemImageSize.Value,
					Margin = new Thickness(5),
					Padding = new Thickness(5)
				};
				((ClickableControl)val).LeftClicked += OnResourceButtonLeftClicked;
				((ClickableControl)val).RightClicked += OnResourceButtonRightClicked;
				((Layout)itemsPanel).AddControl((Control)(object)val);
			}
		}
	}
	[BepInPlugin("com.equinox.RecipeBook", "RecipeBook", "2.2.1")]
	public class RecipeBookPlugin : BaseUnityPlugin
	{
		internal const string MyGUID = "com.equinox.RecipeBook";

		private const string PluginName = "RecipeBook";

		private const string VersionString = "2.2.1";

		private static readonly Harmony Harmony = new Harmony("com.equinox.RecipeBook");

		public static ManualLogSource Log = new ManualLogSource("RecipeBook");

		public static string selectedItem = "";

		public static ConfigEntry<bool> filterUnknown;

		public static ConfigEntry<KeyCode> openRecipeBookHotkey;

		public static ConfigEntry<bool> openWithInventory;

		public static ConfigEntry<int> itemsPanelWidth;

		public static ConfigEntry<int> itemImageSize;

		public static ConfigEntry<int> defaultMachineMk;

		public static ConfigEntry<int> recipesPanelWidth;

		public static ConfigEntry<int> recipesPanelHeight;

		public static ConfigEntry<int> recipesPanelTopMargin;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: RecipeBook, VersionString: 2.2.1 is loading...");
			Harmony.PatchAll();
			BindEvents();
			CreateConfigEntries();
			ApplyPatches();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: RecipeBook, VersionString: 2.2.1 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private void Update()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (UnityInput.Current.GetKey(openRecipeBookHotkey.Value) && ItemsPanelGUI.sSinceClose > 0.5f && (Object)(object)UIManager.instance != (Object)null && !UIManager.instance.anyMenuOpen)
			{
				ItemsPanelGUI.itemsWindow.ShowShader = true;
				ItemsPanelGUI.itemsWindow.FreeCursor = true;
				ItemsPanelGUI.Show();
			}
		}

		private void OnGUI()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!Images.initialised)
			{
				Images.InitialiseStyles();
			}
			ItemsPanelGUI.sSinceOpen += Time.deltaTime;
			ItemsPanelGUI.sSinceClose += Time.deltaTime;
			if (ItemsPanelGUI.isOpen && ItemsPanelGUI.sSinceOpen > 0.5f && (UnityInput.Current.GetKey((KeyCode)27) || UnityInput.Current.GetKey((KeyCode)9) || UnityInput.Current.GetKey(openRecipeBookHotkey.Value)))
			{
				ItemsPanelGUI.Hide();
				((CarouselMenu)UIManager.instance.inventoryCraftingMenu).Close(false);
			}
			if (FavouritesWindow.favouritesWindow != null && ItemsPanelGUI.itemsWindow != null)
			{
				FavouritesWindow.favouritesWindow.Visible = FavouritesWindow.favourites.Count != 0 && ItemsPanelGUI.itemsWindow.Visible;
			}
		}

		private void OnReadyForGUI()
		{
			ItemsPanelGUI.CreateItemsPanel();
			RecipesGUI.CreateRecipesWindow();
			FavouritesWindow.CreateWindow();
		}

		private void BindEvents()
		{
			CaspuinoxGUI.ReadyForGUI += OnReadyForGUI;
		}

		private void CreateConfigEntries()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			filterUnknown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Filter Unknown", true, new ConfigDescription("Whether to hide items and recipes you have not discovered yet.", (AcceptableValueBase)null, Array.Empty<object>()));
			openRecipeBookHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Open Recipe Book Hotkey", (KeyCode)292, new ConfigDescription("Pressing this key opens the Recipe Book without the inventory screen.", (AcceptableValueBase)null, Array.Empty<object>()));
			openWithInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Open With Inventory", true, new ConfigDescription("When true, Recipe Book opens at the same time as the inventory and crafting menu.", (AcceptableValueBase)null, Array.Empty<object>()));
			itemsPanelWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Items Panel", "Items Panel Width", 460, new ConfigDescription("The width of the Items Panel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 10000), Array.Empty<object>()));
			itemImageSize = ((BaseUnityPlugin)this).Config.Bind<int>("Items Panel", "Item Image Size", 50, new ConfigDescription("The width and height of each item's image in the Items Panel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>()));
			defaultMachineMk = ((BaseUnityPlugin)this).Config.Bind<int>("Recipes Panel", "Default Machine Mk", 1, new ConfigDescription("The default 'Machine Mk' to use", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			recipesPanelWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Recipes Panel", "Recipes Panel Width", 500, new ConfigDescription("The width of the Recipes Panel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 1000), Array.Empty<object>()));
			recipesPanelHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Recipes Panel", "Recipes Panel Height", 825, new ConfigDescription("The height of the Recipes Panel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 2000), Array.Empty<object>()));
			recipesPanelTopMargin = ((BaseUnityPlugin)this).Config.Bind<int>("Recipes Panel", "Recipes Panel Top Margin", 245, new ConfigDescription("Distance between the top of the screen and the top of the Recipes Panel", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
		}

		private void ApplyPatches()
		{
			Harmony.CreateAndPatchAll(typeof(InventoryAndCraftingUIPatch), (string)null);
		}
	}
	public static class RecipesGUI
	{
		public static Window recipesWindow;

		public static StackPanel recipesPanel;

		private static RadioButton mk1RadioButton;

		private static RadioButton mk2RadioButton;

		private static RadioButton mk3RadioButton;

		private static ResourceInfo currentResource;

		private static bool showingRecipes;

		public static bool UseMk1Machines => mk1RadioButton.IsChecked;

		public static bool UseMk2Machines => mk2RadioButton.IsChecked;

		public static bool UseMk3Machines => mk3RadioButton.IsChecked;

		public static void CreateRecipesWindow()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			Grid val = new Grid(1u, 2u, "equal", new string[2] { "60", "equal" });
			((Layout)val).AddControl((Control)(object)CreateMachineMkGUI());
			recipesPanel = new StackPanel
			{
				Orientation = (Orientation)1,
				Margin = new Thickness(40, 0, 20, 0),
				RowIndex = 1u
			};
			((Layout)val).AddControl((Control)(object)recipesPanel);
			Button val2 = new Button(Images.star.texture2d)
			{
				HorizontalAlignment = (HorizontalAlignment)0,
				VerticalAlignment = (VerticalAlignment)2,
				Margin = new Thickness(5),
				RowIndex = 1u
			};
			((ClickableControl)val2).LeftClicked += OnFavouriteClicked;
			((Layout)val).AddControl((Control)(object)val2);
			recipesWindow = new Window
			{
				RootLayout = (Layout)(object)val,
				Visible = false,
				Width = RecipeBookPlugin.recipesPanelWidth.Value,
				Height = RecipeBookPlugin.recipesPanelHeight.Value,
				Margin = new Thickness(0, RecipeBookPlugin.recipesPanelTopMargin.Value, 0, 0),
				VerticalAlignment = (VerticalAlignment)0
			};
			CaspuinoxGUI.RegisterWindow(ref recipesWindow);
		}

		public static void ShowRecipesForResource(ResourceInfo resource)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			currentResource = resource;
			showingRecipes = true;
			((Layout)recipesPanel).ClearChildren();
			recipesWindow.Title = "Recipes For " + resource.displayName;
			recipesWindow.Visible = true;
			List<SchematicsRecipeData> list = GameDefines.instance.schematicsRecipeEntries.Where((SchematicsRecipeData recipe) => recipe.outputTypes.Contains(resource)).ToList();
			if (RecipeBookPlugin.filterUnknown.Value)
			{
				list = list.Where((SchematicsRecipeData recipe) => TechTreeState.instance.IsRecipeKnown(recipe)).ToList();
			}
			foreach (SchematicsRecipeData item in list)
			{
				StackPanel obj = recipesPanel;
				RecipePanel recipePanel = new RecipePanel(item);
				((Control)recipePanel).Margin = new Thickness(10, 5);
				((Layout)obj).AddControl((Control)(object)recipePanel);
			}
		}

		public static void ShowUsesForResource(ResourceInfo resource)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			currentResource = resource;
			showingRecipes = false;
			((Layout)recipesPanel).ClearChildren();
			recipesWindow.Title = "Uses For " + resource.displayName;
			recipesWindow.Visible = true;
			List<SchematicsRecipeData> list = GameDefines.instance.schematicsRecipeEntries.Where((SchematicsRecipeData recipe) => recipe.ingTypes.Contains(resource)).ToList();
			if (RecipeBookPlugin.filterUnknown.Value)
			{
				list = list.Where((SchematicsRecipeData recipe) => TechTreeState.instance.IsRecipeKnown(recipe)).ToList();
			}
			foreach (SchematicsRecipeData item in list)
			{
				StackPanel obj = recipesPanel;
				RecipePanel recipePanel = new RecipePanel(item);
				((Control)recipePanel).Margin = new Thickness(10, 5);
				((Layout)obj).AddControl((Control)(object)recipePanel);
			}
		}

		public static void Hide()
		{
			if (recipesWindow != null)
			{
				recipesWindow.Visible = false;
			}
		}

		public static string GetRateStringForItem(SchematicsRecipeData recipe, int index, bool isIng)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			CraftingMethod craftingMethod = recipe.craftingMethod;
			return (int)craftingMethod switch
			{
				0 => GetRateStringForAssembler(recipe, index, isIng), 
				2 => GetRateStringForSmelter(recipe, index, isIng), 
				4 => GetRateStringForBlastSmelter(recipe, index, isIng), 
				3 => GetRateStringForThresher(recipe, index, isIng), 
				5 => GetRateStringForPlanter(recipe, index, isIng), 
				6 => GetRateStringForCrusher(recipe, index, isIng), 
				_ => "?/m", 
			};
		}

		public static string GetMadeInString(SchematicsRecipeData recipe)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if ((int)recipe.craftingMethod == 4)
			{
				return "Made in: Blast Smelter";
			}
			return $"Made in: {recipe.craftingMethod}";
		}

		public static void OnMachineMkChanged(object sender, EventArgs e)
		{
			if (showingRecipes)
			{
				ShowRecipesForResource(currentResource);
			}
			else
			{
				ShowUsesForResource(currentResource);
			}
		}

		private static void OnFavouriteClicked(object sender, EventArgs e)
		{
			FavouritesWindow.ToggleFavourite(((UniqueIdScriptableObject)currentResource).uniqueId);
		}

		private static Grid CreateMachineMkGUI()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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)
			//IL_00be: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			Grid val = new Grid(4u, 1u, "equal", "equal");
			((Layout)val).AddControl((Control)new TextBlock
			{
				Text = "Machine Mk:",
				Margin = new Thickness(10, 0, 0, 0),
				VerticalAlignment = (VerticalAlignment)1
			});
			mk1RadioButton = new RadioButton("com.equinox.RecipeBook", "MachineMk")
			{
				Label = "Mk 1",
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 1u,
				IsChecked = (RecipeBookPlugin.defaultMachineMk.Value == 1)
			};
			mk2RadioButton = new RadioButton("com.equinox.RecipeBook", "MachineMk")
			{
				Label = "Mk 2",
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 2u,
				IsChecked = (RecipeBookPlugin.defaultMachineMk.Value == 2)
			};
			mk3RadioButton = new RadioButton("com.equinox.RecipeBook", "MachineMk")
			{
				Label = "Mk 3",
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 3u,
				IsChecked = (RecipeBookPlugin.defaultMachineMk.Value == 3)
			};
			mk1RadioButton.IsCheckedChanged += OnMachineMkChanged;
			mk2RadioButton.IsCheckedChanged += OnMachineMkChanged;
			mk3RadioButton.IsCheckedChanged += OnMachineMkChanged;
			((Layout)val).AddControl((Control)(object)mk1RadioButton);
			((Layout)val).AddControl((Control)(object)mk2RadioButton);
			((Layout)val).AddControl((Control)(object)mk3RadioButton);
			return val;
		}

		private static string GetRateStringForAssembler(SchematicsRecipeData recipe, int index, bool isIng)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			float craftingEfficiency = ((AssemblerDefinition)Resources.GetResourceInfoByName("Assembler", false)).runtimeSettings.craftingEfficiency;
			if (UseMk2Machines || UseMk3Machines)
			{
				craftingEfficiency = ((AssemblerDefinition)Resources.GetResourceInfoByName("Assembler MKII", false)).runtimeSettings.craftingEfficiency;
			}
			float num = (isIng ? recipe.runtimeIngQuantities[index] : recipe.outputQuantities[index]);
			if (!isIng)
			{
				num *= 2f;
			}
			if (!isIng && (UseMk2Machines || UseMk3Machines))
			{
				num *= 2f;
			}
			float num2 = num * AssemblerInstance.assemblerSpeedMultiplier * craftingEfficiency / recipe.duration * 60f;
			return $"{num2:0.##}/m";
		}

		private static string GetRateStringForSmelter(SchematicsRecipeData recipe, int index, bool isIng)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			float num = ((SmelterDefinition)Resources.GetResourceInfoByName("Smelter", false)).runtimeSettings.craftingEfficiency;
			if (UseMk2Machines)
			{
				num = ((SmelterDefinition)Resources.GetResourceInfoByName("Smelter MKII", false)).runtimeSettings.craftingEfficiency;
			}
			if (UseMk3Machines)
			{
				num = (num = ((SmelterDefinition)Resources.GetResourceInfoByName("Smelter MKIII", false)).runtimeSettings.craftingEfficiency);
			}
			float num2 = (float)(isIng ? recipe.runtimeIngQuantities[index] : recipe.outputQuantities[index]) * SmelterInstance.smelterSpeedMultiplier * num / recipe.duration * 60f;
			return $"{num2:0.##}/m";
		}

		private static string GetRateStringForBlastSmelter(SchematicsRecipeData recipe, int index, bool isIng)
		{
			float num = 1f;
			if (TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)Unlocks.GetUnlockByName("BSM-MultiBlast II", false)).uniqueId))
			{
				num = 4f;
			}
			if (TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)Unlocks.GetUnlockByName("BSM-MultiBlast III", false)).uniqueId))
			{
				num = 6f;
			}
			if (TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)Unlocks.GetUnlockByName("BSM-MultiBlast IV", false)).uniqueId))
			{
				num = 8f;
			}
			if (TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)Unlocks.GetUnlockByName("BSM-MultiBlast V", false)).uniqueId))
			{
				num = 10f;
			}
			float num2 = (isIng ? recipe.runtimeIngQuantities[index] : recipe.outputQuantities[index]);
			float num3 = num * num2 * 5f;
			return $"<={num3}/m";
		}

		private static string GetRateStringForThresher(SchematicsRecipeData recipe, int index, bool isIng)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			float craftingEfficiency = ((ThresherDefinition)Resources.GetResourceInfoByName("Thresher", false)).runtimeSettings.craftingEfficiency;
			if (UseMk2Machines || UseMk3Machines)
			{
				craftingEfficiency = ((ThresherDefinition)Resources.GetResourceInfoByName("Thresher MKII", false)).runtimeSettings.craftingEfficiency;
			}
			float num = (float)(isIng ? recipe.runtimeIngQuantities[index] : recipe.outputQuantities[index]) * ThresherInstance.thresherSpeedMultiplier * craftingEfficiency / recipe.duration * 60f;
			return $"{num:0.##/m}";
		}

		private static string GetRateStringForPlanter(SchematicsRecipeData recipe, int index, bool isIng)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			float craftingEfficiency = ((PlanterDefinition)Resources.GetResourceInfoByName("Planter", false)).runtimeSettings.craftingEfficiency;
			if (UseMk2Machines || UseMk3Machines)
			{
				craftingEfficiency = ((PlanterDefinition)Resources.GetResourceInfoByName("Planter MKII", false)).runtimeSettings.craftingEfficiency;
			}
			float num = 240f * craftingEfficiency / recipe.duration;
			return $"{num:0.##}/m";
		}

		private static string GetRateStringForCrusher(SchematicsRecipeData recipe, int index, bool isIng)
		{
			float num = (float)(isIng ? recipe.runtimeIngQuantities[index] : recipe.outputQuantities[index]) / recipe.duration * 60f;
			return $"{num:0.##/m}";
		}
	}
}
namespace RecipeBook.Patches
{
	internal class InventoryAndCraftingUIPatch
	{
		[HarmonyPatch(typeof(InventoryAndCraftingUI), "Open")]
		[HarmonyPrefix]
		private static bool BlockOpening()
		{
			if (ItemsPanelGUI.sSinceClose < 0.5f)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(InventoryAndCraftingUI), "OnOpen")]
		[HarmonyPrefix]
		private static void ShowItemsPanel()
		{
			if (RecipeBookPlugin.openWithInventory.Value)
			{
				ItemsPanelGUI.itemsWindow.ShowShader = false;
				ItemsPanelGUI.itemsWindow.FreeCursor = false;
				ItemsPanelGUI.Show();
			}
		}

		[HarmonyPatch(typeof(InventoryAndCraftingUI), "OnClose")]
		[HarmonyPrefix]
		internal static void HideItemsPanel()
		{
			if (RecipeBookPlugin.openWithInventory.Value)
			{
				ItemsPanelGUI.Hide();
				RecipesGUI.Hide();
			}
		}
	}
}
namespace RecipeBook.Controls
{
	public class RecipePanel : Panel
	{
		private SchematicsRecipeData recipe;

		private ModImage background;

		private Grid grid;

		public RecipePanel(SchematicsRecipeData recipe)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0091: Expected O, but got Unknown
			//IL_0096: Expected O, but got Unknown
			((Panel)this).ShowBackground = false;
			((Control)this).HorizontalAlignment = (HorizontalAlignment)1;
			this.recipe = recipe;
			GetBackgroundAndGrid();
			for (int i = 0; i < recipe.ingTypes.Length; i++)
			{
				DrawIngredient(i);
			}
			for (int j = 0; j < recipe.outputTypes.Length; j++)
			{
				DrawOutput(j);
			}
			((Layout)grid).AddControl((Control)new TextBlock
			{
				Text = RecipesGUI.GetMadeInString(recipe),
				HorizontalAlignment = (HorizontalAlignment)1,
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 2u,
				Margin = new Thickness(0, 10, 0, 0)
			});
			((Panel)this).Layout = (Layout)(object)grid;
		}

		private void GetBackgroundAndGrid()
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			string[] array = new string[5] { "10", "50", "equal", "50", "10" };
			string[] array2 = new string[5] { "10", "26", "26", "50", "10" };
			string[] array3 = new string[7] { "10", "26", "26", "50", "26", "50", "10" };
			string[] array4 = new string[9] { "10", "26", "26", "50", "26", "50", "26", "50", "10" };
			switch (recipe.ingTypes.Length)
			{
			case 1:
				switch (recipe.outputTypes.Length)
				{
				case 1:
					background = Images.oneToOne;
					grid = new Grid(5u, 5u, array, array2);
					break;
				case 2:
					background = Images.oneToTwo;
					grid = new Grid(5u, 7u, array, array3);
					break;
				case 3:
					background = Images.oneToThree;
					grid = new Grid(5u, 9u, array, array4);
					break;
				}
				break;
			case 2:
				switch (recipe.outputTypes.Length)
				{
				case 1:
					background = Images.twoToOne;
					grid = new Grid(5u, 7u, array, array3);
					break;
				case 2:
					background = Images.twoToTwo;
					grid = new Grid(5u, 7u, array, array3);
					break;
				case 3:
					background = Images.twoToThree;
					grid = new Grid(5u, 9u, array, array4);
					break;
				}
				break;
			case 3:
				switch (recipe.outputTypes.Length)
				{
				case 1:
					background = Images.threeToOne;
					grid = new Grid(5u, 9u, array, array4);
					break;
				case 2:
					background = Images.threeToTwo;
					grid = new Grid(5u, 9u, array, array4);
					break;
				case 3:
					background = Images.threeToThree;
					grid = new Grid(5u, 9u, array, array4);
					break;
				}
				break;
			}
		}

		private void DrawIngredient(int index)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0023: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			ResourceButton val = new ResourceButton(recipe.ingTypes[index].displayName)
			{
				Padding = new Thickness(5),
				ImageWidth = 40,
				ImageHeight = 40,
				ColumnIndex = 1u,
				RowIndex = (uint)(2 * index + 3)
			};
			((ClickableControl)val).LeftClicked += ItemsPanelGUI.OnResourceButtonLeftClicked;
			((ClickableControl)val).RightClicked += ItemsPanelGUI.OnResourceButtonRightClicked;
			((Layout)grid).AddControl((Control)(object)val);
			TextBlock val2 = new TextBlock
			{
				Text = RecipesGUI.GetRateStringForItem(recipe, index, isIng: true),
				HorizontalAlignment = (HorizontalAlignment)1,
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 1u,
				RowIndex = (uint)(2 * index + 2)
			};
			((Layout)grid).AddControl((Control)(object)val2);
		}

		private void DrawOutput(int index)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0023: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			ResourceButton val = new ResourceButton(recipe.outputTypes[index].displayName)
			{
				Padding = new Thickness(5),
				ImageWidth = 40,
				ImageHeight = 40,
				ColumnIndex = 3u,
				RowIndex = (uint)(2 * index + 3)
			};
			((ClickableControl)val).LeftClicked += ItemsPanelGUI.OnResourceButtonLeftClicked;
			((ClickableControl)val).RightClicked += ItemsPanelGUI.OnResourceButtonRightClicked;
			((Layout)grid).AddControl((Control)(object)val);
			TextBlock val2 = new TextBlock
			{
				Text = RecipesGUI.GetRateStringForItem(recipe, index, isIng: false),
				HorizontalAlignment = (HorizontalAlignment)1,
				VerticalAlignment = (VerticalAlignment)1,
				ColumnIndex = 3u,
				RowIndex = (uint)(2 * index + 2)
			};
			((Layout)grid).AddControl((Control)(object)val2);
		}

		public override void Draw()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			ModImage modImage = background;
			Rect contentRectFloat = ((Control)this).ContentRectFloat;
			float x = ((Rect)(ref contentRectFloat)).x;
			contentRectFloat = ((Control)this).ContentRectFloat;
			modImage.Draw(x, ((Rect)(ref contentRectFloat)).y);
			((Panel)this).Draw();
		}

		protected override int CalculateContentWidth()
		{
			if (background == null)
			{
				return 366;
			}
			return (int)background.width;
		}

		protected override int CalculateContentHeight()
		{
			if (background == null)
			{
				return 10;
			}
			return (int)background.height;
		}
	}
}