Decompiled source of DSPRecipeFinder v0.0.7

DSPRecipeFinder.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DSPRecipeFinder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSPRecipeFinder")]
[assembly: AssemblyCopyright("Appun")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("BC522B9F-75D9-4E5E-93BD-978B0B3C5E30")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace DSPRecipeFinder;

[BepInPlugin("Appun.DSP.plugin.RecipeFinder", "DSPRecipeFinder", "0.0.7")]
[BepInProcess("DSPGAME.exe")]
[HarmonyPatch]
public class Main : BaseUnityPlugin
{
	public struct recipeStruct
	{
		public int ResultsCount;

		public int[] Results;

		public int ItemsCount;

		public int[] Items;
	}

	public static GameObject incSepLine2obj;

	public static Dictionary<int, recipeStruct> recipeDictionary = new Dictionary<int, recipeStruct>();

	private static ConfigEntry<bool> ShowAllRecipe;

	public void Start()
	{
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		ShowAllRecipe = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowAllRecipe", false, "Show all recipes, even those that are not unlocked.");
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIItemTip), "SetTip")]
	[HarmonyPriority(1)]
	public static bool UIItemTip_SetTip_Prefix(UIItemTip __instance, int itemId, int corner, Vector2 offset, Transform parent, int itemCount, int incCount, ItemTipType type, bool cannothand = false, bool cannotInc = false, bool isRecipe = false, bool isSign = false)
	{
		//IL_0796: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Expected O, but got Unknown
		//IL_0821: Unknown result type (might be due to invalid IL or missing references)
		//IL_082b: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a00: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a4e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a72: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bf0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c09: 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_0d4b: Invalid comparison between Unknown and I4
		//IL_10a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b7: Invalid comparison between Unknown and I4
		//IL_0e15: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df0: Invalid comparison between Unknown and I4
		//IL_0da9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0daf: Invalid comparison between Unknown and I4
		//IL_2097: Unknown result type (might be due to invalid IL or missing references)
		//IL_20e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_10f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_1102: Unknown result type (might be due to invalid IL or missing references)
		//IL_114d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fdb: Unknown result type (might be due to invalid IL or missing references)
		//IL_1fda: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f9d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a7f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a95: Unknown result type (might be due to invalid IL or missing references)
		//IL_11c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_11db: Unknown result type (might be due to invalid IL or missing references)
		//IL_21f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_221d: Unknown result type (might be due to invalid IL or missing references)
		//IL_2222: Unknown result type (might be due to invalid IL or missing references)
		//IL_2248: Unknown result type (might be due to invalid IL or missing references)
		//IL_225b: Unknown result type (might be due to invalid IL or missing references)
		//IL_226e: Unknown result type (might be due to invalid IL or missing references)
		//IL_2281: Unknown result type (might be due to invalid IL or missing references)
		//IL_2294: Unknown result type (might be due to invalid IL or missing references)
		//IL_2299: Unknown result type (might be due to invalid IL or missing references)
		//IL_22bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_22c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_2370: Unknown result type (might be due to invalid IL or missing references)
		//IL_2375: Unknown result type (might be due to invalid IL or missing references)
		//IL_2377: Unknown result type (might be due to invalid IL or missing references)
		//IL_238e: Unknown result type (might be due to invalid IL or missing references)
		//IL_23a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_23ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_23cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b74: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c70: Unknown result type (might be due to invalid IL or missing references)
		//IL_1d70: Unknown result type (might be due to invalid IL or missing references)
		//IL_1d86: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e2c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e42: Unknown result type (might be due to invalid IL or missing references)
		//IL_133d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1353: Unknown result type (might be due to invalid IL or missing references)
		//IL_1505: Unknown result type (might be due to invalid IL or missing references)
		//IL_151b: Unknown result type (might be due to invalid IL or missing references)
		//IL_15fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_1610: Unknown result type (might be due to invalid IL or missing references)
		//IL_16e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_16f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_17f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_180c: Unknown result type (might be due to invalid IL or missing references)
		//IL_18e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_18fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_19b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_19cd: Unknown result type (might be due to invalid IL or missing references)
		__instance.showingItemId = itemId;
		__instance.cannotHandmake = cannothand;
		int num;
		int num2;
		if (itemId > 0)
		{
			num = itemId;
			num2 = 0;
		}
		else if (itemId < 0)
		{
			num = 0;
			num2 = -itemId;
		}
		else
		{
			num = 0;
			num2 = 0;
		}
		((Transform)__instance.trans).SetParent(parent, true);
		int num3 = ((itemCount == 0) ? incCount : (incCount / itemCount));
		ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num);
		RecipeProto val2 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(num2);
		if (val2 != null)
		{
			if (UIItemTip.tmp_recipeList == null)
			{
				UIItemTip.tmp_recipeList = new List<RecipeProto>();
				UIItemTip.tmp_recipeList.Add(null);
			}
			UIItemTip.tmp_recipeList[0] = val2;
		}
		string text = ((val != null) ? ((Proto)val).name : ((val2 == null) ? "Unknown item" : (Localization.Translate("括号公式") + ((Proto)val2).name)));
		string text2 = ((val != null) ? val.typeString : ((val2 == null) ? "Unknown type" : val2.madeFromString));
		string text3 = ((val != null) ? val.description : ((val2 == null) ? "" : val2.description));
		Sprite sprite = ((val != null) ? val.iconSprite : ((val2 == null) ? null : val2.iconSprite));
		List<RecipeProto> list = ((val != null) ? val.recipes : ((val2 == null) ? null : UIItemTip.tmp_recipeList));
		List<RecipeProto> list2 = new List<RecipeProto>();
		if (list != null)
		{
			foreach (RecipeProto item in list)
			{
				list2.Add(item);
			}
		}
		if (recipeDictionary.ContainsKey(itemId))
		{
			recipeStruct recipeStruct = recipeDictionary[itemId];
			List<int> list3 = new List<int>();
			for (int i = 0; i < recipeStruct.ItemsCount; i++)
			{
				RecipeProto val3 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(recipeStruct.Items[i]);
				if (ShowAllRecipe.Value)
				{
					list3.Add(recipeStruct.Items[i]);
				}
				else if (GameMain.history.recipeUnlocked.Contains(((Proto)val3).ID))
				{
					list3.Add(recipeStruct.Items[i]);
				}
			}
			for (int j = 0; j < list3.Count; j++)
			{
				RecipeProto val4 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(list3[j]);
				RecipeProto val5 = new RecipeProto();
				val5.ResultCounts = val4.ResultCounts;
				val5.Results = val4.Results;
				val5.ItemCounts = new int[val4.ItemCounts.Length];
				for (int k = 0; k < val4.ItemCounts.Length; k++)
				{
					val5.ItemCounts[k] = val4.ItemCounts[k];
				}
				val5.Items = new int[val4.Items.Length];
				for (int l = 0; l < val4.Items.Length; l++)
				{
					val5.Items[l] = val4.Items[l];
				}
				val5.Type = val4.Type;
				val5.TimeSpend = val4.TimeSpend;
				val5.Type = val4.Type;
				for (int m = 0; m < val5.Items.Length; m++)
				{
					if (val5.Items[m] == itemId)
					{
						val5.Items[0] = val4.Items[m];
						val5.Items[m] = val4.Items[0];
						val5.ItemCounts[0] = val4.ItemCounts[m];
						val5.ItemCounts[m] = val4.ItemCounts[0];
						break;
					}
				}
				list2.Add(val5);
			}
		}
		int num4 = list2.Count;
		int num5 = 0;
		bool flag = false;
		if (list2.Count > 9)
		{
			num4 = (int)Math.Ceiling((double)list2.Count / 2.0);
			flag = true;
			num5 = list2.Count - num4;
		}
		int num6 = 0;
		int num7 = 0;
		string text4 = "";
		string text5 = "";
		int num8 = 0;
		StringBuilder stringBuilder = new StringBuilder("         ", 12);
		if (val != null)
		{
			if (val.HeatValue > 0)
			{
				text2 += Localization.Translate("顿号燃料");
			}
			bool flag2 = false;
			num7 = val.DescFields.Length;
			for (int n = 0; n < num7; n++)
			{
				if (val.DescFields[n] == 40)
				{
					flag2 = true;
					continue;
				}
				text4 = text4 + val.GetPropName(n) + "\r\n";
				text5 = text5 + val.GetPropValue(n, stringBuilder, num3) + "\r\n";
			}
			if (flag2)
			{
				num7--;
			}
			if (val.maincraft != null && !string.IsNullOrEmpty(val.produceFrom))
			{
				text4 = text4 + Localization.Translate("制造于") + "\r\n";
				text5 = text5 + val.produceFrom + "\r\n";
				num7++;
			}
			if (__instance.cannotHandmake)
			{
				text4 += "\r\n";
				text5 = text5 + Localization.Translate("不能手动制造") + "\r\n";
				num7++;
			}
			else if (val.handcraft != null)
			{
				text4 = text4 + Localization.Translate("手动制造") + "\r\n";
				text5 = text5 + Localization.Translate("合成面板") + "\r\n";
				num7++;
			}
			if (!GameMain.history.ItemUnlocked(num))
			{
				if (val.preTech != null)
				{
					__instance.preTechText.text = Localization.Translate("需要科技") + "\r\n" + ((Proto)val.preTech).name;
					num8 = 2;
				}
				else if (val.missingTech)
				{
					__instance.preTechText.text = Localization.Translate("该版本尚未加入");
					num8 = 1;
				}
			}
			if (num8 == 0)
			{
				__instance.preTechText.text = "";
			}
		}
		else if (val2 != null)
		{
			num7 = 0;
			num8 = 0;
			__instance.preTechText.text = "";
			if (__instance.cannotHandmake)
			{
				text4 += "\r\n";
				text5 = text5 + Localization.Translate("不能手动制造") + "\r\n";
				num7++;
			}
		}
		__instance.nameText.text = text;
		__instance.categoryText.text = text2;
		__instance.descText.text = text3;
		__instance.propsText.text = text4;
		__instance.valuesText.text = text5;
		__instance.iconImage.sprite = sprite;
		int num9 = (int)__instance.preTechText.preferredWidth + 126;
		int num10 = (int)__instance.valuesText.preferredWidth;
		int num11 = Mathf.Max(0, num10 - 166);
		((Graphic)__instance.valuesText).rectTransform.sizeDelta = new Vector2((float)(166 + num11), ((Graphic)__instance.valuesText).rectTransform.sizeDelta.y);
		num10 += 230;
		int num12 = 290;
		if (num12 < num9)
		{
			num12 = num9;
		}
		if (num12 < num10)
		{
			num12 = num10;
		}
		int num13 = num12 - 290;
		if (num13 < 0)
		{
			num13 = 0;
		}
		((Graphic)__instance.preTechText).rectTransform.sizeDelta = new Vector2(__instance.preTechText.preferredWidth + 1f, ((Graphic)__instance.preTechText).rectTransform.sizeDelta.y);
		Vector2 val6 = default(Vector2);
		Vector2 pivot = default(Vector2);
		switch (corner)
		{
		case 1:
			((Vector2)(ref val6))..ctor(0f, 0f);
			((Vector2)(ref pivot))..ctor(1f, 1f);
			break;
		case 2:
			((Vector2)(ref val6))..ctor(0.5f, 0f);
			((Vector2)(ref pivot))..ctor(0.5f, 1f);
			break;
		case 3:
			((Vector2)(ref val6))..ctor(1f, 0f);
			((Vector2)(ref pivot))..ctor(0f, 1f);
			break;
		case 4:
			((Vector2)(ref val6))..ctor(0f, 0.5f);
			((Vector2)(ref pivot))..ctor(1f, 0.5f);
			break;
		case 5:
			((Vector2)(ref val6))..ctor(0.5f, 0.5f);
			((Vector2)(ref pivot))..ctor(0.5f, 0.5f);
			break;
		case 6:
			((Vector2)(ref val6))..ctor(1f, 0.5f);
			((Vector2)(ref pivot))..ctor(0f, 0.5f);
			break;
		case 7:
			((Vector2)(ref val6))..ctor(0f, 1f);
			((Vector2)(ref pivot))..ctor(0f, 1f);
			break;
		case 8:
			((Vector2)(ref val6))..ctor(0.5f, 1f);
			((Vector2)(ref pivot))..ctor(0.5f, 0f);
			break;
		case 9:
			((Vector2)(ref val6))..ctor(1f, 1f);
			((Vector2)(ref pivot))..ctor(0f, 0f);
			break;
		default:
			((Vector2)(ref val6))..ctor(0.5f, 0.5f);
			((Vector2)(ref pivot))..ctor(0.5f, 0.5f);
			break;
		}
		RectTransform trans = __instance.trans;
		Vector2 anchorMax = (__instance.trans.anchorMin = val6);
		trans.anchorMax = anchorMax;
		__instance.trans.pivot = pivot;
		__instance.trans.anchoredPosition = offset;
		bool flag3 = num7 + num8 <= 2;
		if (flag3)
		{
			((Graphic)__instance.descText).rectTransform.anchoredPosition = new Vector2(110f, -47f);
			((Graphic)__instance.descText).rectTransform.sizeDelta = new Vector2((float)(166 + num13), 16f);
		}
		else
		{
			((Graphic)__instance.descText).rectTransform.anchoredPosition = new Vector2(12f, -47f);
			((Graphic)__instance.descText).rectTransform.sizeDelta = new Vector2((float)(268 + num13), 16f);
		}
		int num14 = ((!string.IsNullOrEmpty(text3)) ? ((int)__instance.descText.preferredHeight) : 0);
		int num15 = 61 + num14;
		int num16 = (flag3 ? (-50) : (-num15 + 11));
		((Graphic)__instance.iconImage).rectTransform.anchoredPosition = new Vector2(15f, (float)num16);
		int num17 = num16 - 80;
		int num18 = 17 * num7 + num15;
		int num19 = ((num8 != 0) ? (num8 * 17 + 6) : 0);
		((Component)__instance.preTechText).gameObject.SetActive(num8 > 0);
		bool flag4 = false;
		int num20 = 0;
		int num21 = -(num18 + num19);
		if (num21 > num17 - 8)
		{
			num20 = num21 - (num17 - 8);
			num21 = num17 - 8;
			flag4 = true;
		}
		num20 /= 2;
		((Graphic)__instance.propsText).rectTransform.anchoredPosition = new Vector2(110f, 0f - (float)num15 + 11f - (float)num20);
		((Graphic)__instance.valuesText).rectTransform.anchoredPosition = new Vector2((float)(110 + num13 - num11), 0f - (float)num15 + 11f - (float)num20);
		((Graphic)__instance.preTechText).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.preTechText).rectTransform.anchoredPosition.x, 0f - (float)num18 + 6f - (float)num20);
		int num22 = 0;
		int num23 = 0;
		((Component)__instance.incSepLine).gameObject.SetActive(false);
		((Component)__instance.incPointText).gameObject.SetActive(false);
		((Component)__instance.incNameText1).gameObject.SetActive(false);
		((Component)__instance.incNameText2).gameObject.SetActive(false);
		((Component)__instance.incNameText3).gameObject.SetActive(false);
		for (int num24 = 0; num24 < __instance.incDescText1.Length; num24++)
		{
			((Component)__instance.incDescText1[num24]).gameObject.SetActive(false);
			((Component)__instance.incDescText2[num24]).gameObject.SetActive(false);
			((Component)__instance.incDescText3[num24]).gameObject.SetActive(false);
		}
		for (int num25 = 0; num25 < __instance.incExtraDescText.Length; num25++)
		{
			((Component)__instance.incExtraDescText[num25]).gameObject.SetActive(false);
		}
		((Behaviour)__instance.itemIncs[0]).enabled = false;
		((Behaviour)__instance.itemIncs[1]).enabled = false;
		((Behaviour)__instance.itemIncs[2]).enabled = false;
		if (GameMain.history.TechUnlocked(1151) && !isSign && (int)type != 2)
		{
			if (isRecipe)
			{
				bool flag5 = true;
				bool flag6 = false;
				bool flag7 = false;
				if (val != null)
				{
					for (int num26 = 0; num26 < val.recipes.Count; num26++)
					{
						flag5 &= val.recipes[num26].productive;
						flag6 |= (int)val.recipes[num26].Type == 8;
					}
				}
				else if (val2 != null)
				{
					flag5 = val2.productive;
					flag7 = (int)val2.Type == 8;
				}
				((Component)__instance.incSepLine).gameObject.SetActive(true);
				__instance.incSepLine.anchoredPosition = new Vector2(12f, (float)num21);
				num23 = 0;
				num22 = 40;
				((Component)__instance.incExtraDescText[0]).gameObject.SetActive(true);
				((Graphic)__instance.incExtraDescText[0]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[0]).rectTransform.anchoredPosition.x, (float)(num21 - 10 - num23 * 17));
				__instance.incExtraDescText[0].text = "+\u00a0" + (flag5 ? Localization.Translate("增产公式描述1") : Localization.Translate("增产公式描述2"));
				num23 += Mathf.FloorToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
				num22 += 17 * Mathf.FloorToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
				if (flag7)
				{
					__instance.incExtraDescText[0].text = "+\u00a0" + Localization.Translate("增产公式描述3");
				}
				if (flag6)
				{
					num23 -= Mathf.FloorToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
					num22 -= 17 * Mathf.FloorToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
					num23 += Mathf.CeilToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
					num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[0].preferredHeight / 25f);
					((Component)__instance.incExtraDescText[1]).gameObject.SetActive(true);
					((Graphic)__instance.incExtraDescText[1]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[1]).rectTransform.anchoredPosition.x, (float)(num21 - 10 - num23 * 17));
					__instance.incExtraDescText[1].text = "+\u00a0" + Localization.Translate("增产公式描述3");
					num23 += Mathf.FloorToInt(__instance.incExtraDescText[1].preferredHeight / 25f);
					num22 += 17 * Mathf.FloorToInt(__instance.incExtraDescText[1].preferredHeight / 25f);
				}
			}
			else if (val != null)
			{
				num22 = 40;
				num23 = 1;
				int num27 = 0;
				if (UIItemTip.tmp_incDic == null)
				{
					UIItemTip.tmp_incDic = new Dictionary<int, int>();
				}
				UIItemTip.tmp_incDic.Clear();
				((Component)__instance.incSepLine).gameObject.SetActive(true);
				__instance.incSepLine.anchoredPosition = new Vector2(12f, (float)num21);
				if ((int)type != 3 || incCount > 0)
				{
					((Component)__instance.incPointText).gameObject.SetActive(true);
					((Graphic)__instance.incPointText).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incPointText).rectTransform.anchoredPosition.x, (float)(num21 - 8));
					__instance.incPointText.text = Localization.Translate("增产点数共计") + incCount + Localization.Translate("空格点");
					((Graphic)__instance.incPointText).color = ((incCount > 0) ? __instance.containIncColor : __instance.noIncColor);
				}
				else
				{
					num22 = 23;
					num23 = 0;
				}
				if (incCount > 0)
				{
					num22 += 2;
					((Component)__instance.incNameText1).gameObject.SetActive(true);
					((Component)__instance.incNameText2).gameObject.SetActive(true);
					((Component)__instance.incNameText3).gameObject.SetActive(true);
					((Graphic)__instance.incNameText1).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incNameText1).rectTransform.anchoredPosition.x, (float)(num21 - 10 - num23 * 17));
					num22 += 17;
					num23++;
					int num28 = Cargo.fastIncArrowTable[(num3 > 10) ? 10 : num3];
					((Behaviour)__instance.itemIncs[0]).enabled = num28 == 1;
					((Behaviour)__instance.itemIncs[1]).enabled = num28 == 2;
					((Behaviour)__instance.itemIncs[2]).enabled = num28 == 3;
					int num29 = incCount - num3 * itemCount;
					int num30 = num3 + 1;
					int num31 = itemCount - num29;
					num3 = ((num3 > 10) ? 10 : num3);
					num30 = ((num30 > 10) ? 10 : num30);
					if (num31 > 0)
					{
						UIItemTip.tmp_incDic[num3] = num31;
					}
					if (num29 > 0)
					{
						UIItemTip.tmp_incDic[num30] = num29;
					}
					for (int num32 = 0; num32 < UIItemTip.tmp_incDic.Count; num32++)
					{
						((Component)__instance.incDescText1[num32]).gameObject.SetActive(UIItemTip.tmp_incDic.Count >= num32 + 1);
						((Component)__instance.incDescText2[num32]).gameObject.SetActive(UIItemTip.tmp_incDic.Count >= num32 + 1);
						((Component)__instance.incDescText3[num32]).gameObject.SetActive(UIItemTip.tmp_incDic.Count >= num32 + 1);
						((Graphic)__instance.incDescText1[num32]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incDescText1[num32]).rectTransform.anchoredPosition.x, (float)(num21 - 10 - num23 * 17));
						num23++;
						if (num32 >= 1)
						{
							break;
						}
					}
					int num33 = 0;
					foreach (KeyValuePair<int, int> item2 in UIItemTip.tmp_incDic)
					{
						__instance.incDescText1[num33].text = item2.Value + Localization.Translate("个物品");
						__instance.incDescText2[num33].text = (val.Productive ? "<color=#61D8FFc0>+" : "") + (val.Productive ? (((double)Cargo.incTable[item2.Key] * 0.1).ToString("0.#") + " %</color>") : "— ");
						__instance.incDescText3[num33].text = "<color=#FD965ECC>+" + ((double)Cargo.accTable[item2.Key] * 0.1).ToString("0.#") + " %</color>";
						num33++;
						if (num33 >= 2)
						{
							break;
						}
					}
					num22 += 17 * UIItemTip.tmp_incDic.Count + 2;
					((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
					((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
					__instance.incExtraDescText[num27].text = "+\u00a0" + (val.Productive ? Localization.Translate("增产剂选择描述") : Localization.Translate("增产剂加速描述"));
					num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
					num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
					num27++;
					if (val.HeatValue > 0 && ((Proto)val).ID != 2207)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + (val.Productive ? Localization.Translate("增产剂燃料描述2") : Localization.Translate("增产剂燃料描述1"));
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 1209)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂透镜描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 6001 || ((Proto)val).ID == 6002 || ((Proto)val).ID == 6003 || ((Proto)val).ID == 6004 || ((Proto)val).ID == 6005 || ((Proto)val).ID == 6006)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂矩阵描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 1141 || ((Proto)val).ID == 1142 || ((Proto)val).ID == 1143)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂套娃描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 1131)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂地基描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
				}
				else
				{
					num22 += 2;
					((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
					((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 10 - num23 * 17));
					__instance.incExtraDescText[num27].text = "+\u00a0" + (val.Productive ? Localization.Translate("无增产点描述1") : Localization.Translate("无增产点描述2"));
					num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
					num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
					num27++;
					if (val.HeatValue > 0 && ((Proto)val).ID != 2207)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + (val.Productive ? Localization.Translate("增产剂燃料描述2") : Localization.Translate("增产剂燃料描述1"));
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 1209)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂透镜描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
					if (((Proto)val).ID == 6001 || ((Proto)val).ID == 6002 || ((Proto)val).ID == 6003 || ((Proto)val).ID == 6004 || ((Proto)val).ID == 6005 || ((Proto)val).ID == 6006)
					{
						((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
						((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
						__instance.incExtraDescText[num27].text = "+\u00a0" + Localization.Translate("增产剂矩阵描述");
						num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
						num27++;
					}
				}
				((Component)__instance.incExtraDescText[num27]).gameObject.SetActive(true);
				((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition = new Vector2(((Graphic)__instance.incExtraDescText[num27]).rectTransform.anchoredPosition.x, (float)(num21 - 12 - num23 * 17));
				__instance.incExtraDescText[num27].text = Localization.Translate("增产剂通用提示");
				num23 += Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
				num22 += 17 * Mathf.CeilToInt(__instance.incExtraDescText[num27].preferredHeight / 25f);
				num27++;
			}
		}
		int num34 = 0;
		int num35 = 0;
		if (list2 != null && list2.Count > 0)
		{
			if (__instance.recipeEntryArr == null)
			{
				__instance.recipeEntryArr = (UIRecipeEntry[])(object)new UIRecipeEntry[64];
			}
			__instance.recipeEntryArr[0] = __instance.recipeEntry;
			num35 = list2[0].Results.Length + list2[0].Items.Length + 1;
			for (int num36 = 1; num36 < list2.Count; num36++)
			{
				if ((Object)(object)__instance.recipeEntryArr[num36] == (Object)null)
				{
					__instance.recipeEntryArr[num36] = Object.Instantiate<UIRecipeEntry>(__instance.recipeEntry, ((Component)__instance).transform);
				}
				__instance.recipeEntryArr[num36].SetRecipe(list2[num36]);
				if (num36 < num4)
				{
					__instance.recipeEntryArr[num36].rectTrans.anchoredPosition = new Vector2(12f, (float)(num21 - num36 * 40 - 8 - num22));
				}
				else
				{
					__instance.recipeEntryArr[num36].rectTrans.anchoredPosition = new Vector2((float)(num6 * 40 + 30) + 12f, (float)(num21 - (num36 - num4) * 40 - 8 - num22));
				}
				((Component)__instance.recipeEntryArr[num36]).gameObject.SetActive(true);
				int num37 = list2[num36].Results.Length + list2[num36].Items.Length + 1;
				if (num35 < num37)
				{
					num35 = num37;
				}
				if (flag && num36 == num4 - 1)
				{
					num6 = num35;
					num35 = 0;
				}
			}
			__instance.recipeEntry.SetRecipe(list2[0]);
			__instance.recipeEntry.rectTrans.anchoredPosition = new Vector2(12f, (float)(num21 - 8 - num22));
			((Component)__instance.recipeEntry).gameObject.SetActive(true);
			num34 = list2.Count;
			((Component)__instance.sepLine).gameObject.SetActive(true);
			__instance.sepLine.anchoredPosition = new Vector2(12f, (float)(num21 - num22));
		}
		else
		{
			((Component)__instance.sepLine).gameObject.SetActive(false);
		}
		int num38 = 290;
		if (num35 >= 7)
		{
			num38 = num35 * 40 + 30;
		}
		num38 += num6 * 40 + 20;
		if (__instance.recipeEntryArr != null)
		{
			for (int num39 = num34; num39 < __instance.recipeEntryArr.Length; num39++)
			{
				if ((Object)(object)__instance.recipeEntryArr[num39] != (Object)null)
				{
					((Component)__instance.recipeEntryArr[num39]).gameObject.SetActive(false);
				}
			}
		}
		int num40 = -num21 + ((num34 != 0) ? ((num34 - num5) * 40 + 20) : (flag4 ? 4 : 4));
		num40 /= 2;
		num40 *= 2;
		if (num38 < num12)
		{
			num38 = num12;
		}
		num38 /= 2;
		num38 *= 2;
		num22 /= 2;
		num22 *= 2;
		__instance.trans.sizeDelta = new Vector2((float)num38, (float)(num40 + num22));
		((Transform)__instance.trans).SetParent((Transform)(object)UIRoot.instance.itemTipTransform, true);
		Rect rect = UIRoot.instance.itemTipTransform.rect;
		float num41 = Mathf.RoundToInt(((Rect)(ref rect)).width);
		float num42 = Mathf.RoundToInt(((Rect)(ref rect)).height);
		float num43 = __instance.trans.anchorMin.x * num41 + __instance.trans.anchoredPosition.x;
		float num44 = __instance.trans.anchorMin.y * num42 + __instance.trans.anchoredPosition.y;
		Rect rect2 = __instance.trans.rect;
		((Rect)(ref rect2)).x = ((Rect)(ref rect2)).x + num43;
		((Rect)(ref rect2)).y = ((Rect)(ref rect2)).y + num44;
		Vector2 zero = Vector2.zero;
		if (((Rect)(ref rect2)).xMin < 0f)
		{
			zero.x -= ((Rect)(ref rect2)).xMin;
		}
		if (((Rect)(ref rect2)).yMin < 0f)
		{
			zero.y -= ((Rect)(ref rect2)).yMin;
		}
		if (((Rect)(ref rect2)).xMax > num41)
		{
			zero.x -= ((Rect)(ref rect2)).xMax - num41;
		}
		if (((Rect)(ref rect2)).yMax > num42)
		{
			zero.y -= ((Rect)(ref rect2)).yMax - num42;
		}
		__instance.trans.anchoredPosition = __instance.trans.anchoredPosition + zero;
		__instance.trans.anchoredPosition = new Vector2((float)(int)__instance.trans.anchoredPosition.x, (float)(int)__instance.trans.anchoredPosition.y);
		((Transform)__instance.trans).localScale = new Vector3(1f, 1f, 1f);
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
	public static void VFPreload_InvokeOnLoadWorkEnded_Patch()
	{
		if (recipeDictionary.Count != 0)
		{
			return;
		}
		for (int i = 0; i < ((ProtoTable)LDB.items).Length; i++)
		{
			ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray[i];
			recipeStruct value = default(recipeStruct);
			value.ResultsCount = 0;
			value.ItemsCount = 0;
			for (int j = 0; j < ((ProtoTable)LDB.recipes).Length; j++)
			{
				RecipeProto val2 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray[j];
				for (int k = 0; k < val2.Results.Length; k++)
				{
					if (val2.Results[k] == ((Proto)val).ID)
					{
						value.ResultsCount++;
						Array.Resize(ref value.Results, value.ResultsCount);
						value.Results[value.ResultsCount - 1] = ((Proto)val2).ID;
					}
				}
				for (int l = 0; l < val2.Items.Length; l++)
				{
					if (val2.Items[l] == ((Proto)val).ID)
					{
						value.ItemsCount++;
						Array.Resize(ref value.Items, value.ItemsCount);
						value.Items[value.ItemsCount - 1] = ((Proto)val2).ID;
					}
				}
			}
			recipeDictionary.Add(((Proto)val).ID, value);
		}
		LogManager.Logger.LogInfo((object)"Recipe Dictionary created");
	}
}
public class LogManager
{
	public static ManualLogSource Logger;
}