Decompiled source of FractionateEverything v1.3.0

FractionateEverything.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using DSP_Battle;
using FractionateEverything.Compatibility;
using FractionateEverything.Main;
using FractionateEverything.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
using xiaoye97;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FractionateEverything")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FractionateEverything")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3204cf73-a6e8-4c3b-a91d-e4baf6fca974")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FractionateEverything
{
	[BepInPlugin("com.menglei.dsp.FractionateEverything", "FractionateEverything", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "TabSystem", "LocalizationModule" })]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class FractionateEverything : BaseUnityPlugin
	{
		public const string GUID = "com.menglei.dsp.FractionateEverything";

		public const string NAME = "FractionateEverything";

		public const string VERSION = "1.3.0";

		private static ManualLogSource logger;

		public static bool showRecipes;

		public static int iconVersion;

		public static bool enableDestroy;

		public static int tab分馏1;

		public static int tab分馏2;

		public static ResourceData fracicons;

		public static readonly Dictionary<int, Dictionary<int, double>> fracRecipeNumRatioDic = new Dictionary<int, Dictionary<int, double>>();

		public static readonly List<int> fracSelfRecipeList = new List<int>();

		public const string SPRITE_CSV_PATH = "D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv";

		public static void LogDebug(object data)
		{
			logger.LogDebug(data);
		}

		public static void LogInfo(object data)
		{
			logger.LogInfo(data);
		}

		public static void LogWarning(object data)
		{
			logger.LogWarning(data);
		}

		public static void LogError(object data)
		{
			logger.LogError(data);
		}

		public static void LogFatal(object data)
		{
			logger.LogFatal(data);
		}

		public void Awake()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			using (ProtoRegistry.StartModLoad("com.menglei.dsp.FractionateEverything"))
			{
				logger = ((BaseUnityPlugin)this).Logger;
				Translation.RegisterTranslations();
				LoadConfig();
				if (showRecipes)
				{
					string iconPath = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1134).IconPath;
					tab分馏1 = TabSystem.RegisterTab("com.menglei.dsp.FractionateEverything:com.menglei.dsp.FractionateEverythingTab1", new TabData(Localization.Translate("分馏页面1"), iconPath));
					tab分馏2 = TabSystem.RegisterTab("com.menglei.dsp.FractionateEverything:com.menglei.dsp.FractionateEverythingTab2", new TabData(Localization.Translate("分馏页面2"), iconPath));
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				fracicons = new ResourceData("com.menglei.dsp.FractionateEverything", "fracicons", Path.GetDirectoryName(executingAssembly.Location));
				fracicons.LoadAssetBundle("fracicons");
				ProtoRegistry.AddResource(fracicons);
				LDBTool.PreAddDataAction = (Action)Delegate.Combine(LDBTool.PreAddDataAction, new Action(PreAddData));
				LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(PostAddData));
				Harmony val = new Harmony("com.menglei.dsp.FractionateEverything");
				Type[] types = executingAssembly.GetTypes();
				foreach (Type type in types)
				{
					if (type.Namespace != null && !type.Namespace.StartsWith("FractionateEverything.Compatibility"))
					{
						val.PatchAll(type);
					}
				}
				MethodInfo methodInfo = AccessTools.Method(typeof(VFPreload), "InvokeOnLoadWorkEnded", (Type[])null, (Type[])null);
				HarmonyMethod val2 = new HarmonyMethod(typeof(AddFractionateRecipes), "AddFracRecipesAfterLDBToolPostAddData", (Type[])null);
				val2.after = new string[1] { "me.xiaoye97.plugin.Dyson.LDBTool" };
				val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		public void LoadConfig()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "ShowFractionateRecipes", true, new ConfigDescription("Whether show all fractionate recipes or not.\n是否显示所有的分馏配方。", (AcceptableValueBase)(object)new AcceptableBoolValue(defVal: true), (object[])null));
			showRecipes = val.Value;
			ConfigEntry<int> val2 = ((BaseUnityPlugin)this).Config.Bind<int>("config", "IconVersion", 3, new ConfigDescription("Which version of the fractionation icon to use.\n1 for the original deuterium fractionation style, 2 for the straight line segmentation style, 3 for the circular segmentation style (recommended).\n使用哪个版本的分馏图标。\n1表示原版重氢分馏样式,2表示直线分割样式,3表示圆弧分割样式(推荐)。", (AcceptableValueBase)(object)new AcceptableIntValue(3, 1, 3), (object[])null));
			iconVersion = val2.Value;
			ConfigEntry<bool> val3 = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "EnableDestroy", true, new ConfigDescription("Whether or not to enable the probability of damage in a fractionated recipe.\nFractionation recipes with a probability of destruction (usually matrix) fractionate with a probability of destruction of the feedstock when enabled (recommended).\n是否启用分馏配方中的损毁概率。\n启用情况下,有损毁概率的分馏配方(通常为矩阵)分馏时原料有概率损毁(推荐)。", (AcceptableValueBase)(object)new AcceptableBoolValue(defVal: true), (object[])null));
			enableDestroy = val3.Value;
			(Traverse.Create((object)((BaseUnityPlugin)this).Config).Property("OrphanedEntries", (object[])null).GetValue() as IDictionary)?.Clear();
			((BaseUnityPlugin)this).Config.Save();
		}

		public void PreAddData()
		{
			Tech.AddTechs();
			FractionatorBuilding.OriginFractionatorAdaptation();
			FractionatorBuilding.CreateAndPreAddNewFractionators();
		}

		public void PostAddData()
		{
			if (File.Exists("D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv"))
			{
				File.Delete("D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv");
			}
		}

		public static void PreloadAndInitAll()
		{
			((ProtoSet<ItemProto>)(object)LDB.items).OnAfterDeserialize();
			((ProtoSet<RecipeProto>)(object)LDB.recipes).OnAfterDeserialize();
			((ProtoSet<TechProto>)(object)LDB.techs).OnAfterDeserialize();
			((ProtoSet<ModelProto>)(object)LDB.models).OnAfterDeserialize();
			((ProtoSet<MilestoneProto>)(object)LDB.milestones).OnAfterDeserialize();
			((ProtoSet<JournalPatternProto>)(object)LDB.journalPatterns).OnAfterDeserialize();
			((ProtoSet<ThemeProto>)(object)LDB.themes).OnAfterDeserialize();
			((ProtoSet<VeinProto>)(object)LDB.veins).OnAfterDeserialize();
			TechProto[] dataArray = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray;
			foreach (TechProto val in dataArray)
			{
				val.Preload();
			}
			for (int j = 0; j < ((ProtoSet<ItemProto>)(object)LDB.items).dataArray.Length; j++)
			{
				((ProtoSet<ItemProto>)(object)LDB.items).dataArray[j].recipes = null;
				((ProtoSet<ItemProto>)(object)LDB.items).dataArray[j].rawMats = null;
				((ProtoSet<ItemProto>)(object)LDB.items).dataArray[j].Preload(j);
			}
			for (int k = 0; k < ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray.Length; k++)
			{
				((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray[k].Preload(k);
			}
			TechProto[] dataArray2 = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray;
			foreach (TechProto val2 in dataArray2)
			{
				val2.PreTechsImplicit = val2.PreTechsImplicit.Except(val2.PreTechs).ToArray();
				val2.UnlockRecipes = val2.UnlockRecipes.Distinct().ToArray();
				val2.Preload2();
			}
			ItemProto.InitFuelNeeds();
			ItemProto.InitTurretNeeds();
			ItemProto.InitFluids();
			ItemProto.InitTurrets();
			ItemProto.InitEnemyDropTables();
			ItemProto.InitConstructableItems();
			ItemProto.InitItemIds();
			ItemProto.InitItemIndices();
			ItemProto.InitMechaMaterials();
			ItemProto.InitFighterIndices();
			ModelProto.InitMaxModelIndex();
			ModelProto.InitModelIndices();
			ModelProto.InitModelOrders();
			RecipeProto.InitFractionatorNeeds();
			RaycastLogic.LoadStatic();
		}
	}
}
namespace FractionateEverything.Main
{
	public static class FractionatorBuilding
	{
		public static void OriginFractionatorAdaptation()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			FractionatorUtils.ModelFractionator = ((ProtoSet<ModelProto>)(object)LDB.models).Select(119);
			FractionatorUtils.ItemFractionator = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2314);
			ItemProto itemFractionator = FractionatorUtils.ItemFractionator;
			if (!GenesisBook.Enable)
			{
				FractionatorUtils.RecipeFractionator = FractionatorUtils.ItemFractionator.maincraft;
				int[] array = new int[3] { 2309, 2317, 2310 };
				int[] array2 = array;
				foreach (int num in array2)
				{
					ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num);
					val.GridIndex--;
					RecipeProto maincraft = val.maincraft;
					maincraft.GridIndex--;
				}
			}
			else
			{
				CollectionExtensions.AddToArray<int>(((ProtoSet<TechProto>)(object)LDB.techs).Select(1122).UnlockRecipes, 1003);
				RecipeProto val2 = new RecipeProto();
				((Proto)val2).ID = 1003;
				val2.Type = (ERecipeType)9;
				val2.Handcraft = true;
				((Proto)val2).Name = "通用分馏塔";
				val2.TimeSpend = 240;
				val2.Items = new int[3] { 6502, 1107, 1119 };
				val2.ItemCounts = new int[3] { 4, 8, 4 };
				val2.Results = new int[1] { 2314 };
				val2.ResultCounts = new int[1] { 1 };
				val2.GridIndex = 2603;
				val2.IconPath = "Icons/ItemRecipe/fractionator";
				val2.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1122);
				FractionatorUtils.RecipeFractionator = val2;
				LDBTool.PreAddProto((Proto)(object)FractionatorUtils.RecipeFractionator);
				FractionatorUtils.RecipeFractionator.Preload(1003);
				((Proto)FractionatorUtils.RecipeFractionator).ID = 1003;
				itemFractionator.maincraft = FractionatorUtils.RecipeFractionator;
			}
			((Proto)itemFractionator).Name = "通用分馏塔";
			itemFractionator.Description = "I通用分馏塔";
			itemFractionator.GridIndex = 2603;
			itemFractionator.maincraft.GridIndex = 2603;
			itemFractionator.BuildIndex = 408;
			itemFractionator.Preload(itemFractionator.index);
			LDBTool.SetBuildBar(itemFractionator.BuildIndex / 100, itemFractionator.BuildIndex % 100, ((Proto)itemFractionator).ID);
		}

		public static void CreateAndPreAddNewFractionators()
		{
			//IL_0097: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: 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_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			(RecipeProto, ModelProto, ItemProto) tuple = FractionatorUtils.CreateAndPreAddNewFractionator("精准分馏塔", 1001, 2320, 530, (!GenesisBook.Enable) ? new int[4] { 1101, 1108, 1110, 1301 } : new int[3] { 6501, 1101, 1110 }, (!GenesisBook.Enable) ? new int[4] { 4, 2, 2, 1 } : new int[3] { 2, 4, 2 }, 2601, GenesisBook.Enable ? 1941 : 1001, 406, new Color(1f, 0.7019f, 0.4f), 0.4);
			(RecipeProto, ModelProto, ItemProto) tuple2 = FractionatorUtils.CreateAndPreAddNewFractionator("建筑极速分馏塔", 1002, 2321, 531, (!GenesisBook.Enable) ? new int[4] { 1101, 1108, 1110, 1301 } : new int[3] { 6501, 1103, 1110 }, (!GenesisBook.Enable) ? new int[4] { 4, 2, 2, 1 } : new int[3] { 2, 4, 2 }, 2602, 1602, 407, new Color(0.4f, 1f, 0.949f));
			(RecipeProto, ModelProto, ItemProto) tuple3 = (FractionatorUtils.RecipeFractionator, ((ProtoSet<ModelProto>)(object)LDB.models).Select(119), FractionatorUtils.ItemFractionator);
			(RecipeProto, ModelProto, ItemProto) tuple4 = FractionatorUtils.CreateAndPreAddNewFractionator("点数聚集分馏塔", 1004, 2322, 532, (!GenesisBook.Enable) ? new int[4] { 1103, 1123, 1119, 1303 } : new int[4] { 6503, 7707, 7706, 7805 }, (!GenesisBook.Enable) ? new int[4] { 8, 4, 4, 1 } : new int[4] { 4, 8, 4, 1 }, 2604, Tech.tech增产点数聚集, 409, new Color(0.2509f, 0.8392f, 1f), 2.0);
			(RecipeProto, ModelProto, ItemProto) tuple5 = FractionatorUtils.CreateAndPreAddNewFractionator("增产分馏塔", 1005, 2323, 533, (!GenesisBook.Enable) ? new int[5] { 1107, 1402, 1304, 1305, 5203 } : new int[5] { 6503, 6271, 7706, 7806, 5203 }, (!GenesisBook.Enable) ? new int[5] { 16, 8, 4, 1, 30 } : new int[5] { 10, 20, 8, 1, 30 }, 2605, Tech.tech增产分馏, 410, new Color(0.6235f, 0.6941f, 0.8f), 4.0);
			tuple.Item3.Grade = 1;
			tuple3.Item3.Grade = 2;
			tuple.Item3.Upgrades = new int[2]
			{
				((Proto)tuple.Item3).ID,
				((Proto)tuple3.Item3).ID
			};
			tuple3.Item3.Upgrades = new int[2]
			{
				((Proto)tuple.Item3).ID,
				((Proto)tuple3.Item3).ID
			};
			if (GenesisBook.Enable)
			{
				tuple.Item1.Type = (ERecipeType)4;
				tuple2.Item1.Type = (ERecipeType)4;
				tuple3.Item1.Type = (ERecipeType)9;
				tuple4.Item1.Type = (ERecipeType)10;
				tuple5.Item1.Type = (ERecipeType)10;
			}
		}
	}
	public static class FractionatorLogic
	{
		private static uint seed2 = (uint)new Random().Next(int.MinValue, int.MaxValue);

		private static uint seed3 = (uint)new Random().Next(int.MinValue, int.MaxValue);

		private static int totalUIUpdateTimes = 0;

		private static bool isFirstUpdateUI = true;

		private static Vector3 productProbTextPos;

		private static Vector3 oriProductProbTextPos;

		private static string lastProductProbText = "";

		private static string lastOriProductProbText = "";

		private static int MaxStackSize = 1;

		public static int MaxInputTimes = 1;

		public static int MaxOutputTimes = 2;

		public static int[] beltSpeed = new int[3] { 6, 12, 30 };

		public static double k1;

		public static double b1;

		public static double k2;

		public static double b2;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameData), "GameTick")]
		public static void GameTickPostPatch(long time)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Invalid comparison between Unknown and I4
			if (time % 30 == 0L || GameMain.history == null)
			{
				return;
			}
			int num = 1;
			for (int i = 0; i < 3; i++)
			{
				if (GameMain.history.TechUnlocked(3804 + i))
				{
					num++;
				}
			}
			MaxStackSize = num;
			int num2 = RecipeProto.fractionatorRecipes.Length;
			RecipeProto[] dataArray = ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray;
			List<RecipeProto> list = new List<RecipeProto>();
			List<int> list2 = new List<int>();
			RecipeProto[] array = dataArray;
			foreach (RecipeProto val in array)
			{
				if ((int)val.Type != 8)
				{
					continue;
				}
				int num3 = val.Items[0];
				int num4 = val.Results[0];
				if (num3 >= 5201 && num3 <= 5206 && num4 >= 5201 && num4 <= 5206)
				{
					if (!GameMain.history.ItemCanDropByEnemy(num3) || !GameMain.history.ItemCanDropByEnemy(num4))
					{
						GameMain.history.recipeUnlocked.Remove(((Proto)val).ID);
						continue;
					}
					GameMain.history.recipeUnlocked.Add(((Proto)val).ID);
				}
				if (GameMain.history.RecipeUnlocked(((Proto)val).ID))
				{
					list.Add(val);
					list2.Add(val.Items[0]);
				}
			}
			RecipeProto.fractionatorRecipes = list.ToArray();
			RecipeProto.fractionatorNeeds = list2.ToArray();
			int num5 = RecipeProto.fractionatorRecipes.Length;
			if (num2 != num5)
			{
				FractionateEverything.LogInfo($"RecipeProto.fractionatorRecipes.Length: {num2} -> {num5}");
			}
		}

		private static double ProcessNum2Ratio(int processNum)
		{
			if (processNum <= beltSpeed[0])
			{
				return 3.0;
			}
			if (processNum <= beltSpeed[1])
			{
				return k1 * (double)processNum + b1;
			}
			return Math.Max(0.0, k2 * (double)processNum + b2);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(FractionatorComponent), "InternalUpdate")]
		public static bool FractionatorUpdatePatch(ref FractionatorComponent __instance, PlanetFactory factory, float power, SignData[] signPool, int[] productRegister, int[] consumeRegister, ref uint __result)
		{
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a77: Unknown result type (might be due to invalid IL or missing references)
			if (power < 0.1f)
			{
				__result = 0u;
				return false;
			}
			int protoId = factory.entityPool[__instance.entityId].protoId;
			bool flag = (uint)(protoId - 2322) <= 1u;
			bool flag2 = flag;
			int num = (flag2 ? __instance.fluidId : __instance.productId);
			double num2 = 1.0;
			if (__instance.fluidInputCount == 0)
			{
				__instance.fluidInputCargoCount = 0f;
			}
			else
			{
				num2 = (((double)__instance.fluidInputCargoCount > 0.0001) ? ((float)__instance.fluidInputCount / __instance.fluidInputCargoCount) : 4f);
			}
			FractionatorComponent val;
			if (__instance.fluidInputCount > 0 && __instance.productOutputCount < __instance.productOutputMax && __instance.fluidOutputCount < __instance.fluidOutputMax)
			{
				int num3 = (int)((double)power * 166.66666666666666 * (double)((__instance.fluidInputCargoCount < 30f) ? __instance.fluidInputCargoCount : 30f) * num2 + 0.75);
				__instance.progress += num3;
				if (__instance.progress > 100000)
				{
					__instance.progress = 100000;
				}
				while (__instance.progress >= 10000)
				{
					val = __instance;
					int num4 = ((val.fluidInputInc > 0 && val.fluidInputCount > 0) ? (__instance.fluidInputInc / __instance.fluidInputCount) : 0);
					__instance.seed = (uint)((int)((ulong)((long)(__instance.seed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
					double randomVal = (double)__instance.seed / 2147483646.0;
					double num5 = 1.0;
					if (!flag2)
					{
						num5 *= 1.0 + Cargo.accTableMilli[(num4 < 10) ? num4 : 10];
					}
					switch (protoId)
					{
					case 2320:
					{
						double num6 = ProcessNum2Ratio(__instance.fluidInputCount);
						num5 = ((num6 >= 0.0) ? (num5 * num6) : 1.0);
						break;
					}
					case 2321:
					{
						ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(__instance.fluidId);
						num5 = ((val2.BuildMode == 0) ? (num5 / 10.0) : (num5 * 12.5));
						break;
					}
					}
					if (!FractionateEverything.fracRecipeNumRatioDic.TryGetValue(__instance.fluidId, out var value))
					{
						value = null;
					}
					int num7 = GetOutputNum(randomVal, num5, value);
					switch (protoId)
					{
					case 2323:
						seed2 = (uint)((int)((ulong)((long)(seed2 % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
						if ((double)seed2 / 2147483646.0 < Cargo.incTableMilli[(num4 < 10) ? num4 : 10])
						{
							num7 *= 2;
						}
						break;
					case 2322:
						if (num7 > 0)
						{
							num7 = Math.Min(__instance.fluidInputInc / 10, 4);
						}
						break;
					}
					__instance.fractionSuccess = num7 > 0;
					if (protoId == 2322 && __instance.fractionSuccess)
					{
						__instance.fluidInputCount -= num7;
						__instance.fluidInputInc -= 10 * num7;
					}
					else
					{
						__instance.fluidInputCount--;
						__instance.fluidInputInc -= num4;
					}
					__instance.fluidInputCargoCount -= (float)(1.0 / num2);
					if (__instance.fluidInputCargoCount < 0f)
					{
						__instance.fluidInputCargoCount = 0f;
					}
					if (num7 > 0)
					{
						__instance.productOutputCount += num7;
						__instance.productOutputTotal += num7;
						lock (productRegister)
						{
							productRegister[num] += num7;
						}
						lock (consumeRegister)
						{
							consumeRegister[__instance.fluidId] += num7;
						}
					}
					else if (num7 == 0)
					{
						__instance.fluidOutputCount++;
						__instance.fluidOutputTotal++;
						__instance.fluidOutputInc += num4;
					}
					__instance.progress -= 10000;
				}
			}
			else
			{
				__instance.fractionSuccess = false;
			}
			CargoTraffic cargoTraffic = factory.cargoTraffic;
			byte b = default(byte);
			byte b2 = default(byte);
			if (__instance.belt1 > 0)
			{
				if (__instance.isOutput1)
				{
					if (__instance.fluidOutputCount > 0)
					{
						CargoPath cargoPath = cargoTraffic.GetCargoPath(cargoTraffic.beltPool[__instance.belt1].segPathId);
						if (cargoPath != null)
						{
							for (int i = 0; i < MaxOutputTimes; i++)
							{
								if (__instance.fluidOutputCount <= 0)
								{
									break;
								}
								int num8 = __instance.fluidOutputInc / __instance.fluidOutputCount;
								if (cargoPath.TryUpdateItemAtHeadAndFillBlank(__instance.fluidId, Mathf.CeilToInt((float)(num2 - 0.1)), (byte)1, (byte)num8))
								{
									__instance.fluidOutputCount--;
									__instance.fluidOutputInc -= num8;
									continue;
								}
								break;
							}
						}
					}
				}
				else if (!__instance.isOutput1 && __instance.fluidInputCargoCount < (float)__instance.fluidInputMax)
				{
					for (int j = 0; j < MaxInputTimes; j++)
					{
						if (__instance.fluidInputCargoCount >= (float)__instance.fluidInputMax)
						{
							break;
						}
						if (__instance.fluidId > 0)
						{
							if (cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, (int[])null, ref b, ref b2) > 0)
							{
								__instance.fluidInputCount += b;
								__instance.fluidInputInc += b2;
								__instance.fluidInputCargoCount += 1f;
								continue;
							}
							break;
						}
						int num9 = cargoTraffic.TryPickItemAtRear(__instance.belt1, 0, flag2 ? null : RecipeProto.fractionatorNeeds, ref b, ref b2);
						if (num9 > 0)
						{
							__instance.fluidInputCount += b;
							__instance.fluidInputInc += b2;
							__instance.fluidInputCargoCount += 1f;
							if (flag2)
							{
								__instance.fluidId = num9;
								__instance.productId = num9;
								__instance.produceProb = 0.01f;
								signPool[__instance.entityId].iconId0 = (uint)__instance.productId;
								signPool[__instance.entityId].iconType = ((__instance.productId != 0) ? 1u : 0u);
							}
							else
							{
								((FractionatorComponent)(ref __instance)).SetRecipe(num9, signPool);
							}
							continue;
						}
						break;
					}
				}
			}
			if (__instance.belt2 > 0)
			{
				if (__instance.isOutput2)
				{
					if (__instance.fluidOutputCount > 0)
					{
						CargoPath cargoPath2 = cargoTraffic.GetCargoPath(cargoTraffic.beltPool[__instance.belt2].segPathId);
						if (cargoPath2 != null)
						{
							for (int k = 0; k < MaxOutputTimes; k++)
							{
								if (__instance.fluidOutputCount <= 0)
								{
									break;
								}
								int num10 = __instance.fluidOutputInc / __instance.fluidOutputCount;
								if (cargoPath2.TryUpdateItemAtHeadAndFillBlank(__instance.fluidId, Mathf.CeilToInt((float)(num2 - 0.1)), (byte)1, (byte)num10))
								{
									__instance.fluidOutputCount--;
									__instance.fluidOutputInc -= num10;
									continue;
								}
								break;
							}
						}
					}
				}
				else if (!__instance.isOutput2 && __instance.fluidInputCargoCount < (float)__instance.fluidInputMax)
				{
					for (int l = 0; l < MaxInputTimes; l++)
					{
						if (__instance.fluidInputCargoCount >= (float)__instance.fluidInputMax)
						{
							break;
						}
						if (__instance.fluidId > 0)
						{
							if (cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, (int[])null, ref b, ref b2) > 0)
							{
								__instance.fluidInputCount += b;
								__instance.fluidInputInc += b2;
								__instance.fluidInputCargoCount += 1f;
								continue;
							}
							break;
						}
						int num11 = cargoTraffic.TryPickItemAtRear(__instance.belt2, 0, flag2 ? null : RecipeProto.fractionatorNeeds, ref b, ref b2);
						if (num11 > 0)
						{
							__instance.fluidInputCount += b;
							__instance.fluidInputInc += b2;
							__instance.fluidInputCargoCount += 1f;
							if (flag2)
							{
								__instance.fluidId = num11;
								__instance.productId = num11;
								__instance.produceProb = 0.01f;
								signPool[__instance.entityId].iconId0 = (uint)__instance.productId;
								signPool[__instance.entityId].iconType = ((__instance.productId != 0) ? 1u : 0u);
							}
							else
							{
								((FractionatorComponent)(ref __instance)).SetRecipe(num11, signPool);
							}
							continue;
						}
						break;
					}
				}
			}
			val = __instance;
			if (val.belt0 > 0 && val.isOutput0)
			{
				for (int m = 0; m < MaxOutputTimes; m++)
				{
					if (__instance.productOutputCount >= MaxStackSize)
					{
						if (cargoTraffic.TryInsertItemAtHead(__instance.belt0, __instance.productId, (byte)MaxStackSize, (byte)((protoId == 2322) ? ((uint)(10 * MaxStackSize)) : 0u)))
						{
							__instance.productOutputCount -= MaxStackSize;
							continue;
						}
						break;
					}
					val = __instance;
					if (val.productOutputCount > 0 && val.fluidInputCount == 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt0, __instance.productId, (byte)__instance.productOutputCount, (byte)((protoId == 2322) ? ((uint)(10 * __instance.productOutputCount)) : 0u)))
					{
						__instance.productOutputCount = 0;
						continue;
					}
					break;
				}
			}
			val = __instance;
			if (val.fluidInputCount == 0 && val.fluidOutputCount == 0 && val.productOutputCount == 0)
			{
				__instance.fluidId = 0;
				__instance.productId = 0;
				signPool[__instance.entityId].iconId0 = (uint)__instance.productId;
				signPool[__instance.entityId].iconType = ((__instance.productId != 0) ? 1u : 0u);
			}
			__instance.isWorking = __instance.fluidInputCount > 0 && __instance.productOutputCount < __instance.productOutputMax && __instance.fluidOutputCount < __instance.fluidOutputMax;
			if (!__instance.isWorking)
			{
				__result = 0u;
				return false;
			}
			__result = 1u;
			return false;
		}

		public static int GetOutputNum(double randomVal, double successRatePlus, Dictionary<int, double> fracNumRatioDic = null)
		{
			if (fracNumRatioDic == null)
			{
				fracNumRatioDic = new Dictionary<int, double> { { 1, 0.01 } };
			}
			if (fracNumRatioDic.TryGetValue(-1, out var value))
			{
				seed3 = (uint)((int)((ulong)((long)(seed3 % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
				if ((double)seed3 / 2147483646.0 < value)
				{
					return -1;
				}
			}
			double num = 0.0;
			randomVal /= successRatePlus;
			foreach (KeyValuePair<int, double> item in fracNumRatioDic.Where((KeyValuePair<int, double> p) => p.Key > 0))
			{
				if (randomVal < num + item.Value)
				{
					return item.Key;
				}
				num += item.Value;
			}
			return 0;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIFractionatorWindow), "_OnUpdate")]
		public static void FractionatorUIUpdatePatch(ref UIFractionatorWindow __instance)
		{
			//IL_003d: 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_0043: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: 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_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.fractionatorId == 0 || __instance.factory == null)
			{
				totalUIUpdateTimes = 20;
				return;
			}
			FractionatorComponent val = __instance.factorySystem.fractionatorPool[__instance.fractionatorId];
			if (val.id != __instance.fractionatorId)
			{
				totalUIUpdateTimes = 20;
				return;
			}
			if (val.fluidId == 0)
			{
				totalUIUpdateTimes = 20;
				return;
			}
			totalUIUpdateTimes++;
			if (totalUIUpdateTimes < 20)
			{
				__instance.productProbText.text = lastProductProbText;
				__instance.oriProductProbText.text = lastOriProductProbText;
				return;
			}
			totalUIUpdateTimes = 0;
			int protoId = __instance.factory.entityPool[val.entityId].protoId;
			double num = 1.0;
			double num2 = 0.0;
			switch (protoId)
			{
			case 2320:
			{
				num *= 1.0 + (double)((FractionatorComponent)(ref val)).extraIncProduceProb;
				int fluidInputCount = val.fluidInputCount;
				num = Math.Max(num * ProcessNum2Ratio(fluidInputCount), 0.0);
				break;
			}
			case 2321:
			{
				num *= 1.0 + (double)((FractionatorComponent)(ref val)).extraIncProduceProb;
				ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val.fluidId);
				num = ((val3.BuildMode == 0) ? (num / 10.0) : (num * 12.5));
				break;
			}
			case 2314:
				num *= 1.0 + (double)((FractionatorComponent)(ref val)).extraIncProduceProb;
				break;
			case 2322:
			{
				double val2 = (double)val.fluidInputInc / (double)val.fluidInputCount;
				num *= Math.Min(val2, 4.0);
				break;
			}
			case 2323:
				if (val.fluidInputCount > 0 && val.fluidInputInc > 0)
				{
					int num3 = val.fluidInputInc / val.fluidInputCount;
					int num4 = ((num3 < 10) ? num3 : 10);
					num2 = Cargo.incTableMilli[num4];
				}
				break;
			}
			StringBuilder stringBuilder = new StringBuilder();
			Dictionary<int, double> value;
			if (protoId == 2323)
			{
				value = (FractionateEverything.fracSelfRecipeList.Contains(val.fluidId) ? FractionateEverything.fracRecipeNumRatioDic[val.fluidId] : new Dictionary<int, double> { { 1, 0.01 } });
			}
			else if (!FractionateEverything.fracRecipeNumRatioDic.TryGetValue(val.fluidId, out value))
			{
				value = new Dictionary<int, double> { { 1, 0.01 } };
			}
			value.TryGetValue(-1, out var value2);
			double num5 = 1.0;
			Dictionary<int, double> dictionary = new Dictionary<int, double>();
			int num6 = 0;
			foreach (KeyValuePair<int, double> item in value)
			{
				if (item.Key < 0)
				{
					continue;
				}
				double num7 = item.Value * num;
				if (protoId == 2323)
				{
					double num8 = num7 * (1.0 - num2);
					if (dictionary.ContainsKey(item.Key))
					{
						dictionary[item.Key] += num8;
					}
					else
					{
						dictionary.Add(item.Key, num8);
					}
					if (num2 > 0.0)
					{
						double num9 = num7 * num2;
						if (dictionary.ContainsKey(item.Key * 2))
						{
							dictionary[item.Key * 2] += num9;
						}
						else
						{
							dictionary.Add(item.Key * 2, num9);
						}
					}
				}
				else
				{
					stringBuilder.Append($"{item.Key}({num7:0.###%})\n");
					num6++;
				}
				num5 -= num7;
			}
			if (protoId == 2323)
			{
				foreach (KeyValuePair<int, double> item2 in dictionary)
				{
					stringBuilder.Append($"{item2.Key}({item2.Value:0.###%})\n");
					num6++;
				}
			}
			if (isFirstUpdateUI)
			{
				__instance.productProbText.verticalOverflow = (VerticalWrapMode)1;
				__instance.oriProductProbText.verticalOverflow = (VerticalWrapMode)1;
				productProbTextPos = ((Component)__instance.productProbText).transform.position;
				oriProductProbTextPos = ((Component)__instance.oriProductProbText).transform.position;
				isFirstUpdateUI = false;
			}
			string text = stringBuilder.ToString().Substring(0, stringBuilder.Length - 1);
			Vector3 position = productProbTextPos;
			position.y += 0.085f * (float)(num6 - 1);
			((Component)__instance.productProbText).transform.position = position;
			string text2 = string.Format("{0}({1:0.###%})", Localization.Translate("流动"), num5);
			position = oriProductProbTextPos;
			if (value2 > 0.0)
			{
				position.y -= 0.085f;
				text2 += string.Format("\n{0}({1:0.###%})", Localization.Translate("损毁"), value2);
			}
			((Component)__instance.oriProductProbText).transform.position = position;
			__instance.productProbText.text = text;
			__instance.oriProductProbText.text = text2;
			lastProductProbText = text;
			lastOriProductProbText = text2;
		}
	}
	public static class Tech
	{
		public static TechProto tech增产点数聚集;

		public static TechProto tech增产分馏;

		public static void AddTechs()
		{
			AddTech增产点数聚集();
			AddTech增产分馏();
			MoveOriTechs();
			AddTech分馏塔产物集装物流();
		}

		private static void AddTech增产点数聚集()
		{
			//IL_009f: 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)
			tech增产点数聚集 = ProtoRegistry.RegisterTech(1159, "T增产点数聚集", "增产点数聚集描述", "增产点数聚集结果", "Assets/fracicons/tech增产点数聚集", (!GenesisBook.Enable) ? new int[2] { 1153, 1312 } : new int[1] { 1151 }, new int[4] { 6001, 6002, 6003, 6004 }, new int[4] { 8, 6, 4, 4 }, 360000L, new int[1] { 1004 }, GenesisBook.Enable ? new Vector2(29f, 29f) : new Vector2(45f, -11f));
			((Proto)tech增产点数聚集).ID = 1159;
			tech增产点数聚集.PreTechsImplicit = new int[1] { 1312 };
			tech增产点数聚集.Preload();
			tech增产点数聚集.Preload2();
		}

		private static void AddTech增产分馏()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			tech增产分馏 = ProtoRegistry.RegisterTech(1908, "T增产分馏", "增产分馏描述", "增产分馏结果", "Assets/fracicons/tech增产分馏", GenesisBook.Enable ? Array.Empty<int>() : new int[1] { 1159 }, new int[1] { 5201 }, new int[1] { 200 }, 36000L, new int[1] { 1005 }, GenesisBook.Enable ? new Vector2(45f, -23f) : new Vector2(49f, -11f));
			((Proto)tech增产分馏).ID = 1908;
			tech增产分馏.IsHiddenTech = true;
			tech增产分馏.PreItem = new int[2] { 5201, 1305 };
			tech增产分馏.PreTechsImplicit = new int[2] { 1159, 1303 };
			tech增产分馏.Preload();
			tech增产分馏.Preload2();
		}

		private static void MoveOriTechs()
		{
		}

		private static void AddTech分馏塔产物集装物流()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			TechProto val = ProtoRegistry.RegisterTech(3804, "T分馏塔产物集装物流1", "分馏塔产物集装物流描述1", "分馏塔产物集装物流结果1", ((ProtoSet<TechProto>)(object)LDB.techs).Select(3801).IconPath, Array.Empty<int>(), new int[3] { 6001, 6002, 6003 }, new int[3] { 8, 8, 8 }, 180000L, Array.Empty<int>(), new Vector2(37f, -31f));
			((Proto)val).ID = 3804;
			((Proto)val).Name = "T分馏塔产物集装物流";
			val.Level = 1;
			val.PreTechsImplicit = new int[1] { GenesisBook.Enable ? 1963 : 1607 };
			TechProto val2 = ProtoRegistry.RegisterTech(3805, "T分馏塔产物集装物流2", "分馏塔产物集装物流描述2", "分馏塔产物集装物流结果2", ((ProtoSet<TechProto>)(object)LDB.techs).Select(3802).IconPath, new int[1] { 3804 }, new int[4] { 6001, 6002, 6003, 6004 }, new int[4] { 8, 8, 8, 8 }, 360000L, Array.Empty<int>(), new Vector2(41f, -31f));
			((Proto)val2).ID = 3805;
			((Proto)val2).Name = "T分馏塔产物集装物流";
			val2.Level = 2;
			TechProto val3 = ProtoRegistry.RegisterTech(3806, "T分馏塔产物集装物流3", "分馏塔产物集装物流描述2", "分馏塔产物集装物流结果2", ((ProtoSet<TechProto>)(object)LDB.techs).Select(3803).IconPath, new int[1] { 3805 }, new int[5] { 6001, 6002, 6003, 6004, 6005 }, new int[5] { 8, 8, 8, 8, 8 }, 720000L, Array.Empty<int>(), new Vector2(45f, -31f));
			((Proto)val3).ID = 3806;
			((Proto)val3).Name = "T分馏塔产物集装物流";
			val3.Level = 3;
			val3.PreTechsMax = true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(TechProto), "UnlockFunctionText")]
		public static bool UnlockFunctionTextPrePatch(ref TechProto __instance, ref string __result)
		{
			int iD = ((Proto)__instance).ID;
			if ((iD < 3804 || iD > 3806) ? true : false)
			{
				return true;
			}
			__result = "+1" + Localization.Translate("分馏塔产物集装等级");
			return false;
		}
	}
	public class Translation
	{
		public static void RegisterTranslations()
		{
			RegisterTranslationUtils.RegisterTranslation("分馏页面1", "Fractionate I", "分馏 I");
			RegisterTranslationUtils.RegisterTranslation("分馏页面2", "Fractionate II", "分馏 II");
			RegisterTranslationUtils.RegisterTranslation("分馏", " Fractionation");
			RegisterTranslationUtils.RegisterTranslation("从", "Fractionate ");
			RegisterTranslationUtils.RegisterTranslation("中分馏出", " to ");
			RegisterTranslationUtils.RegisterTranslation("。", ".");
			RegisterTranslationUtils.RegisterTranslation("分馏出", " fractionated ");
			RegisterTranslationUtils.RegisterTranslation("个产物", " product");
			RegisterTranslationUtils.RegisterTranslation("损毁分馏警告1", "<color=\"#FD965ECC\">WARNING: </color>This item is difficult to fractionate and has a ", "<color=\"#FD965ECC\">警告:</color>该物品难以分馏,有");
			RegisterTranslationUtils.RegisterTranslation("损毁分馏警告2", " chance of being destroyed!", "概率损毁!");
			RegisterTranslationUtils.RegisterTranslation("流动", "Flow");
			RegisterTranslationUtils.RegisterTranslation("损毁", "Destroy");
			RegisterTranslationUtils.RegisterTranslation("精准分馏塔", "Precision Fractionator");
			RegisterTranslationUtils.RegisterTranslation("I精准分馏塔", "It can accurately fractionate the target product with low power consumption. Due to the special characteristics of the structure, it cannot fractionate a large number of items at the same time. The more items need to be fractionated at the same time, the lower the fractionation success rate.", "可以精准分馏出目标产物,耗电较低。由于结构的特殊性,它无法同时分馏大量物品。需要同时分馏的物品数越多,则分馏成功率越低。");
			RegisterTranslationUtils.RegisterTranslation("建筑极速分馏塔", "Building-HighSpeed Fractionator");
			RegisterTranslationUtils.RegisterTranslation("I建筑极速分馏塔", "Quickly converts low-level buildings to high-level buildings, but non-building items are extremely inefficient to fractionate. You should carefully verify that the item being fractionated is not a building before fractionating.", "快速将低级建筑转换为高级建筑,但非建筑物品分馏效率极低。分馏前应仔细确认被分馏的物品是不是建筑。");
			RegisterTranslationUtils.RegisterTranslation("通用分馏塔", "Universal Fractionator");
			RegisterTranslationUtils.RegisterTranslation("I通用分馏塔", "It is heavily used for deuterium fractionation by Icarus in all parts of the universe. In fact, the Universal Fractionator has unlimited potential, as it can fractionate everything in the universe!", "被宇宙各处的伊卡洛斯大量用于重氢分馏。实际上,通用分馏塔潜力无限,因为它可以分馏宇宙万物!");
			RegisterTranslationUtils.RegisterTranslation("点数聚集分馏塔", "Points Aggregate Fractionator");
			RegisterTranslationUtils.RegisterTranslation("I点数聚集分馏塔", "Crafts an item with 10 Incremental Yield Points by concentrating the item's Incremental Yield Points on a portion of the item, breaking the upper limit of Incremental Yield Points. Accepts any item as a raw material.", "将物品的增产点数集中到一部分物品上,突破增产点数的上限,从而制作出10增产点数的物品。可接受任何物品作为原料。");
			RegisterTranslationUtils.RegisterTranslation("增产分馏塔", "Increase Production Fractionator");
			RegisterTranslationUtils.RegisterTranslation("I增产分馏塔", "Instead of boosting the success rate of fractionation, the production increase points boost the number of products, truly achieving the effect of creating something from nothing. Accepts any item as a raw material.", "增产点数不再提升分馏成功率,而是提升产物数目,真正达到无中生有的效果。可接受任何物品作为原料。");
			RegisterTranslationUtils.RegisterTranslation("T分馏塔产物集装物流", "Fractionator product consolidation logistics", "分馏塔产物集装物流");
			RegisterTranslationUtils.RegisterTranslation("分馏塔产物集装物流描述1", "The product of the fractionator will be exported as much as possible in a containerized form.", "分馏塔的产物将会尽可能以集装形式输出。");
			RegisterTranslationUtils.RegisterTranslation("分馏塔产物集装物流结果1", "All products from the fractionator will now be consolidated as much as possible before being exported.", "现在,所有分馏塔的产物都将尽可能集装后再输出。");
			RegisterTranslationUtils.RegisterTranslation("分馏塔产物集装物流描述2", "Further increase the number of sets of output products from the fractionator.", "进一步提高分馏塔输出产物的集装数量。");
			RegisterTranslationUtils.RegisterTranslation("分馏塔产物集装物流结果2", "The number of product assemblies in all fractionators was further improved.", "所有分馏塔的产物集装数量进一步提升了。");
			RegisterTranslationUtils.RegisterTranslation("分馏塔产物集装等级", "Quantity of output product set from fractionator", "分馏塔输出产物集装数量");
			RegisterTranslationUtils.RegisterTranslation("T增产点数聚集", "Aggregation of yield points", "增产点数聚集");
			RegisterTranslationUtils.RegisterTranslation("增产点数聚集描述", "Due to the limitations of material technology, the spawn line is unable to create more advanced yield enhancers, but fractionation technology can break through the limitations by concentrating the raw material's yield enhancement points into a certain number of items. It was found that the yield increase points of items could be stacked indefinitely, but the portion over 10 points did not work. The Yield Increase Point Aggregation technique can fractionate just the items with 10 Yield Increase Points.", "由于材料技术的限制,产线无法制造更高级的增产剂,但分馏技术可以将原料的增产点数集中到某几个物品上,从而突破限制。研究发现,物品的增产点数可以无限叠加,但超过10点的部分不起作用。增产点数聚集技术可以刚好分馏出10点增产点数的物品。");
			RegisterTranslationUtils.RegisterTranslation("增产点数聚集结果", "You have mastered the yield increase point aggregation technique. The item's yield increase points can now be pushed to the limit, and production capacity has been greatly increased!", "你已经掌握了增产点数聚集技术。现在物品的增产点数可以突破到极限,产能得到了极大的提升!");
			RegisterTranslationUtils.RegisterTranslation("T增产分馏", "Increase production fractionate", "增产分馏");
			RegisterTranslationUtils.RegisterTranslation("增产分馏描述", "Typically, yield increase points only boost the fractionation success rate. If the yield increase points are used to boost the number of fractionation products and keep the products consistent with the inputs, we can achieve the effect of creating something out of nothing.\nIt is clear that the direction of transforming yield-enhancing points in fractionation is highly uncontrollable. This research exists only in anecdotal evidence and whether it can be done is still unknown.\n<color=\"#FD965ECC\">Warning:</color>The technology associated with this technology has been banned by the COSMO Technology Ethics Committee, <color=\"#FD965ECC\">Please research manually.</color>", "通常情况下,增产点数只能提升分馏成功率。如果将增产点数用于提升分馏产物的数目,并保持产物与输入一致,我们就能达到无中生有的效果。\n显然,转变增产点数在分馏中的应用方向高度不可控。这项研究仅存在于在传闻中,能否做到是仍是未知。\n<color=\"#FD965ECC\">警告:</color>该科技的相关技术已被COSMO技术伦理委员会禁用,<color=\"#FD965ECC\">请手动研究。</color>");
			RegisterTranslationUtils.RegisterTranslation("增产分馏结果", "You have unlocked the Increased Production Fractionation technology. Now you truly have the ability to create something from nothing!", "你已经掌握了增产分馏技术。现在,你真正拥有了无中生有的能力!");
		}
	}
}
namespace FractionateEverything.Utils
{
	public static class AddFractionateRecipes
	{
		private static RecipeHelper helper;

		private static readonly List<Proto> recipeList = new List<Proto>();

		private static bool _finished;

		public static void AddFracRecipesAfterLDBToolPostAddData()
		{
			if (!_finished)
			{
				FractionateEverything.PreloadAndInitAll();
				FractionatorLogic.beltSpeed = new int[3]
				{
					((ProtoSet<ItemProto>)(object)LDB.items).Select(2001).prefabDesc.beltSpeed * 6,
					((ProtoSet<ItemProto>)(object)LDB.items).Select(2002).prefabDesc.beltSpeed * 6,
					((ProtoSet<ItemProto>)(object)LDB.items).Select(2003).prefabDesc.beltSpeed * 6
				};
				FractionatorLogic.k1 = -1.0 / (double)(FractionatorLogic.beltSpeed[1] - FractionatorLogic.beltSpeed[0]);
				FractionatorLogic.b1 = 3.0 - FractionatorLogic.k1 * (double)FractionatorLogic.beltSpeed[0];
				FractionatorLogic.k2 = -1.0 / (double)(FractionatorLogic.beltSpeed[2] - FractionatorLogic.beltSpeed[1]);
				FractionatorLogic.b2 = 2.0 - FractionatorLogic.k2 * (double)FractionatorLogic.beltSpeed[1];
				int num = (from item in ((ProtoSet<ItemProto>)(object)LDB.items).dataArray
					where (int)item.Type == 5 && item.prefabDesc.isBelt
					select item.prefabDesc.beltSpeed * 6).Prepend(0).Max();
				FractionatorLogic.MaxInputTimes = (int)Math.Ceiling((double)num / 60.0);
				FractionatorLogic.MaxOutputTimes = (int)Math.Ceiling((double)num / 15.0);
				FractionateEverything.LogInfo("Begin to add fractionate recipes...");
				helper = new RecipeHelper(FractionateEverything.tab分馏1);
				AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 2320, 2321, 2314, 2322, 2323 }));
				if (!MoreMegaStructure.Enable)
				{
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2107, 2103, 2104, 2105 }));
				}
				else
				{
					List<RecipeProto> list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 2107, 2103, 2104, 9512, 2105 }));
					list[2].ModifyGridIndex(MoreMegaStructure.tab巨构, 410);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[7] { 9488, 9489, 9490, 9491, 9492, 9510, 9488 }), cycle: false).ModifyGridIndex(MoreMegaStructure.tab巨构, 601);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[9] { 9493, 9494, 9495, 9496, 9497, 9501, 9498, 9502, 9493 }), cycle: false).ModifyGridIndex(MoreMegaStructure.tab巨构, 701);
				}
				if (!GenesisBook.Enable)
				{
					AddFracRecipe(1001, 1001, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 101);
					AddFracRecipe(1002, 1002, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 102);
					AddFracRecipe(1003, 1003, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 103).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1402);
					AddFracRecipe(1004, 1004, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 104).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1413);
					AddFracRecipe(1005, 1005, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 105);
					AddFracRecipe(1006, 1006, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 106);
					AddFracRecipe(1011, 1011, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 208).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1131);
					AddFracRecipe(1012, 1012, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 306).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1403);
					AddFracRecipe(1013, 1013, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 303).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1133);
					AddFracRecipe(1014, 1014, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 605).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1125);
					AddFracRecipe(1015, 1015, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 508).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1132);
					AddFracRecipe(1016, 1016, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 606).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1703);
					AddFracRecipe(1117, 1117, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 309).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1122);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1101, 1103, 1107 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1125, 1502, 1503 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1105, 1113 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1108, 1131 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1110, 1119, 1304 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1111, 1401, 1404, 1501 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1109, 1112 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1123, 1124, 1402 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1206, 1127, 1209, 1210 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1114, 1115, 1117 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1118, 1126 }), cycle: false);
					List<RecipeProto> list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1000, 1116 }));
					list[1].ModifyGridIndex(FractionateEverything.tab分馏1, 407).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1121);
					list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1102, 1202, 1203 }), cycle: false);
					list[0].ModifyGridIndex(FractionateEverything.tab分馏1, 201);
					list[1].ModifyGridIndex(FractionateEverything.tab分馏1, 202);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1203, 1204, 1205 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1301, 1303, 1305 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 5101, 5102, 5103 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 5111, 5112 }));
					list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1208, 1122 }));
					list[1].ModifyGridIndex(FractionateEverything.tab分馏1, 608);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[6] { 5206, 5201, 5203, 5202, 5204, 5205 })).ModifyGridIndex(FractionateEverything.tab分馏1, 806);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 6001, 6002, 6003, 6004, 6005 }), cycle: true, new Dictionary<int, double>
					{
						{ 1, 0.01 },
						{ -1, 0.03 }
					});
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1141, 1142, 1143 }), cycle: true, new Dictionary<int, double> { { 2, 0.01 } });
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1128, 1129, 1130 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1407, 1405, 1406 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 5003, 5001, 5002 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1801, 1802, 1803, 1804 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1601, 1602, 1603 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1604, 1605, 1606 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1609, 1610, 1611 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1607, 1608 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1612, 1613 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2201, 2202, 2212 }));
					list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 2203, 2205, 2206, 2207, 2209 }));
					list[2].ModifyGridIndex(FractionateEverything.tab分馏2, 113);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2204, 2213, 2211, 2210 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2001, 2002, 2003 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2030, 2020, 2313, 2040 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2101, 2106, 2102 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2011, 2012, 2013, 2014 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2301, 2316 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2306, 2307, 2308 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2309, 2317 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2302, 2315, 2319 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2303, 2304, 2305, 2318 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2901, 2902 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2311, 2208, 2312 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 3001, 3005, 3003 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 3002, 3004, 3010 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 3009, 3007, 3006, 3008 }));
				}
				else
				{
					AddFracRecipe(1001, 1001, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 101);
					AddFracRecipe(1002, 1002, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 102);
					AddFracRecipe(6202, 6202, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 103);
					AddFracRecipe(1003, 1003, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 104).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1402);
					AddFracRecipe(1004, 1004, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 105).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1413);
					AddFracRecipe(6201, 6201, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 106).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1413);
					AddFracRecipe(1006, 1006, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 107).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1402);
					AddFracRecipe(1005, 1005, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 108);
					AddFracRecipe(6207, 6207, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 109).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1929);
					AddFracRecipe(6222, 6222, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(GenesisBook.tab精炼, 302).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1916);
					AddFracRecipe(6225, 6225, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(GenesisBook.tab精炼, 305).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1916);
					AddFracRecipe(6226, 6226, useInputTech: false, new Dictionary<int, double> { { 2, 0.04 } }).ModifyGridIndex(GenesisBook.tab精炼, 306).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1916);
					AddFracRecipe(1012, 1012, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 504).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1403);
					AddFracRecipe(1013, 1013, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 505).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1133);
					AddFracRecipe(1011, 1011, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 506).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1131);
					AddFracRecipe(1015, 1015, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 507).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1132);
					AddFracRecipe(1117, 1117, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 508).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1123);
					AddFracRecipe(1014, 1014, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 510).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1502);
					AddFracRecipe(1016, 1016, useInputTech: false, new Dictionary<int, double> { { 2, 0.02 } }).ModifyGridIndex(FractionateEverything.tab分馏1, 511).preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1703);
					List<RecipeProto> list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1120, 1121 }));
					list[1].ModifyGridIndex(FractionateEverything.tab分馏1, 113);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 6234, 6235 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1103, 1107, 7707, 6271 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1125, 1502, 1503 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1105, 1113 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1108, 6208 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1110, 1119, 7706 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1111, 1401, 1404, 1501 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1109, 1112 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1123, 1124, 1402 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1402, 7804 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1206, 1127, 1209, 1210 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1118, 1126 }), cycle: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 6501, 6502, 6503 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 7501, 7504 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 7805, 7806 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1000, 1116 })).ModifyGridIndex(FractionateEverything.tab分馏1, 313);
					AddFracRecipe(1202, 1203).ModifyGridIndex(FractionateEverything.tab分馏1, 302);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1203, 1204, 1205 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1301, 1303, 1305, 7803 }));
					list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1208, 1122 }));
					list[1].ModifyGridIndex(FractionateEverything.tab分馏1, 514);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1407, 1405, 1406 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 5003, 5001, 5002 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[6] { 5206, 5201, 5203, 5202, 5204, 5205 })).ModifyGridIndex(FractionateEverything.tab分馏1, 115, addColumn: false);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 6001, 6002, 6003, 6004, 6005 }), cycle: true, new Dictionary<int, double>
					{
						{ 1, 0.01 },
						{ -1, 0.03 }
					});
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2201, 2202, 2212 }));
					list = AddFracChain(new <>z__ReadOnlyArray<int>(new int[6] { 2203, 2205, 6221, 2206, 2207, 2209 }));
					list[3].ModifyGridIndex(FractionateEverything.tab分馏2, 114);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 2204, 2213, 2211, 2210, 6261 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2001, 2002, 2003 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[5] { 2020, 2030, 6267, 2313, 2040 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2101, 2102, 6231 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2106, 6229 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2011, 2012, 2013, 2014 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2301, 2316 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2306, 6266 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2307, 2308 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2309, 2317 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2302, 6230, 2315, 2319 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 2303, 2304, 2305, 2318 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 2901, 2902 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 2311, 2208, 2312 }));
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1801, 6217, 6216 })).ModifyGridIndex(GenesisBook.tab精炼, 601);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 6242, 6241, 6243 })).ModifyGridIndex(GenesisBook.tab精炼, 604);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1802, 6244, 6245 })).ModifyGridIndex(GenesisBook.tab精炼, 607);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1803, 1804 })).ModifyGridIndex(GenesisBook.tab精炼, 610);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 1115, 7708, 7709 })).ModifyGridIndex(GenesisBook.tab化工, 105);
					AddFracRecipe(1143, 1143, useInputTech: false, new Dictionary<int, double> { { 2, 0.01 } }).ModifyGridIndex(GenesisBook.tab化工, 506);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[3] { 5101, 5102, 5103 })).ModifyGridIndex(GenesisBook.tab防御, 109);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 5111, 5112 })).ModifyGridIndex(GenesisBook.tab防御, 112);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 3002, 7618, 3004, 3010 })).ModifyGridIndex(GenesisBook.tab防御, 209);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 3009, 3007, 3006, 3008 })).ModifyGridIndex(GenesisBook.tab防御, 213);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[6] { 1601, 7607, 1603, 7608, 7609, 7616 })).ModifyGridIndex(GenesisBook.tab防御, 311);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1128, 1129, 7610, 7611 })).ModifyGridIndex(GenesisBook.tab防御, 411);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 3003, 7617 })).ModifyGridIndex(GenesisBook.tab防御, 509);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1604, 1605, 7612, 7613 })).ModifyGridIndex(GenesisBook.tab防御, 511);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[4] { 1609, 1610, 1611, 7615 })).ModifyGridIndex(GenesisBook.tab防御, 611);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1607, 1608 })).ModifyGridIndex(GenesisBook.tab防御, 711);
					AddFracChain(new <>z__ReadOnlyArray<int>(new int[2] { 1612, 1613 })).ModifyGridIndex(GenesisBook.tab防御, 713);
				}
				typeof(LDBTool).GetMethod("AddProtosToSet", AccessTools.all)?.MakeGenericMethod(typeof(RecipeProto)).Invoke(null, new object[2]
				{
					LDB.recipes,
					recipeList
				});
				FractionateEverything.LogInfo("Finish to add fractionate recipes.");
				_finished = true;
			}
		}

		public static List<RecipeProto> AddFracChain(IReadOnlyList<int> itemChain, bool cycle = true, Dictionary<int, double> fracNumRatioDic = null)
		{
			if (fracNumRatioDic == null)
			{
				fracNumRatioDic = new Dictionary<int, double> { { 1, 0.01 } };
			}
			List<RecipeProto> list = new List<RecipeProto>();
			for (int i = 0; i < itemChain.Count - 1; i++)
			{
				list.Add(AddFracRecipe(itemChain[i], itemChain[i + 1], useInputTech: false, fracNumRatioDic));
			}
			if (cycle)
			{
				Dictionary<int, double> dictionary = new Dictionary<int, double>();
				foreach (KeyValuePair<int, double> item in fracNumRatioDic)
				{
					dictionary.Add((item.Key > 0) ? (item.Key * itemChain.Count) : item.Key, item.Value);
				}
				list.Add(AddFracRecipe(itemChain[itemChain.Count - 1], itemChain[0], useInputTech: true, dictionary));
			}
			return list;
		}

		public static RecipeProto AddFracRecipe(int inputItemID, int outputItemID, bool useInputTech = false, Dictionary<int, double> fracNumRatioDic = null)
		{
			return AddFracRecipe(inputItemID, outputItemID, useInputTech ? ((ProtoSet<ItemProto>)(object)LDB.items).Select(inputItemID).preTech : ((ProtoSet<ItemProto>)(object)LDB.items).Select(outputItemID).preTech, fracNumRatioDic);
		}

		public static RecipeProto AddFracRecipe(int inputItemID, int outputItemID, TechProto preTech, Dictionary<int, double> fracNumRatioDic = null)
		{
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Expected O, but got Unknown
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			if (fracNumRatioDic == null)
			{
				fracNumRatioDic = new Dictionary<int, double> { { 1, 0.01 } };
			}
			if (!FractionateEverything.enableDestroy && fracNumRatioDic.ContainsKey(-1))
			{
				fracNumRatioDic.Remove(-1);
			}
			try
			{
				int unusedRecipeID = helper.GetUnusedRecipeID();
				ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(inputItemID);
				ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(outputItemID);
				string text = ((Proto)val2).name + Localization.Translate("分馏");
				if (preTech == null)
				{
					preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1);
				}
				int gridIndex = ((val2.recipes.Count != 0) ? (val2.recipes[0].GridIndex + (FractionateEverything.tab分馏1 - 1) * 1000) : 0);
				string text2 = "";
				Sprite val3 = null;
				string text3 = val.IconPath?.Substring(val.IconPath.LastIndexOf("/") + 1);
				string text4 = val2.IconPath?.Substring(val2.IconPath.LastIndexOf("/") + 1);
				if (string.IsNullOrEmpty(text3))
				{
					if (string.IsNullOrEmpty(text4))
					{
						FractionateEverything.LogWarning("缺失" + text + "原料图标" + val.IconPath + "、产物图标" + val2.IconPath + ",配方图标无法显示!");
					}
					else
					{
						FractionateEverything.LogWarning("缺失" + text + "原料图标" + val.IconPath + ",配方图标改为使用产物" + ((Proto)val2).Name + "图标!");
						text2 = val2.IconPath;
						val3 = val2.iconSprite;
					}
				}
				else if (string.IsNullOrEmpty(text4))
				{
					FractionateEverything.LogWarning("缺失" + text + "产物图标" + val2.IconPath + ",配方图标无法显示!");
				}
				else
				{
					string text5 = $"{text3}-{text4}-formula-v{FractionateEverything.iconVersion}";
					text2 = "Assets/fracicons/" + text5;
					val3 = FractionateEverything.fracicons.bundle.LoadAsset<Sprite>(text5);
					if ((Object)(object)val3 == (Object)null)
					{
						FractionateEverything.LogWarning("缺失" + text + "配方图标" + text2 + ",配方图标改为使用产物" + ((Proto)val2).Name + "图标!");
						text2 = val2.IconPath;
						val3 = val2.iconSprite;
					}
				}
				string text6 = Localization.Translate("从") + ((Proto)val).name + Localization.Translate("中分馏出") + ((Proto)val2).name + Localization.Translate("。");
				foreach (KeyValuePair<int, double> item in fracNumRatioDic.Where((KeyValuePair<int, double> p) => p.Key > 0))
				{
					text6 += string.Format("\n{0}%{1}{2}{3}", Math.Round(item.Value * 100.0, 3), Localization.Translate("分馏出"), item.Key, Localization.Translate("个产物"));
				}
				if (fracNumRatioDic.TryGetValue(-1, out var value))
				{
					text6 += string.Format("\n{0}{1}%{2}", Localization.Translate("损毁分馏警告1"), Math.Round(value * 100.0, 3), Localization.Translate("损毁分馏警告2"));
				}
				RecipeProto val4 = new RecipeProto();
				val4.Type = (ERecipeType)8;
				val4.Handcraft = false;
				val4.Explicit = true;
				val4.TimeSpend = 60;
				val4.Items = new int[1] { inputItemID };
				val4.ItemCounts = new int[1] { 100 };
				val4.Results = new int[1] { outputItemID };
				val4.ResultCounts = new int[1] { 1 };
				val4.Description = "R" + ((Proto)val).Name + "分馏";
				val4.description = text6;
				val4.GridIndex = gridIndex;
				((Proto)val4).Name = ((Proto)val).Name + "分馏";
				((Proto)val4).name = text;
				val4.preTech = preTech;
				val4.IconPath = text2;
				((Proto)val4).ID = unusedRecipeID;
				RecipeProto val5 = val4;
				if ((Object)(object)val3 != (Object)null)
				{
					Traverse.Create((object)val5).Field("_iconSprite").SetValue((object)val3);
				}
				val5.ModifyGridIndex(gridIndex);
				recipeList.Add((Proto)(object)val5);
				((Proto)val5).ID = unusedRecipeID;
				val2.recipes.Add(val5);
				FractionateEverything.fracRecipeNumRatioDic.Add(inputItemID, fracNumRatioDic);
				if (inputItemID == outputItemID)
				{
					FractionateEverything.fracSelfRecipeList.Add(inputItemID);
				}
				if (Directory.Exists("D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv".Substring(0, "D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv".LastIndexOf('\\'))))
				{
					using StreamWriter streamWriter = new StreamWriter("D:\\project\\csharp\\DSP MOD\\MLJ_DSPmods\\GetDspData\\gamedata\\fracIconPath.csv", append: true, Encoding.UTF8);
					streamWriter.WriteLine(text3 + "," + text4);
				}
				return val5;
			}
			catch (Exception ex)
			{
				FractionateEverything.LogError(ex.ToString());
				return null;
			}
		}

		private static void ModifyGridIndex(this List<RecipeProto> recipes, int tab, int rowColumn, bool addColumn = true)
		{
			if (FractionateEverything.showRecipes)
			{
				for (int i = 0; i < recipes.Count - 1; i++)
				{
					helper.ModifyGridIndex(recipes[i], tab, rowColumn + (addColumn ? (i + 1) : ((i + 1) * 100)));
				}
				helper.ModifyGridIndex(recipes[recipes.Count - 1], tab, rowColumn);
				return;
			}
			foreach (RecipeProto recipe in recipes)
			{
				recipe.GridIndex = 0;
			}
		}

		private static RecipeProto ModifyGridIndex(this RecipeProto r, int tab, int rowColumn)
		{
			if (FractionateEverything.showRecipes)
			{
				helper.ModifyGridIndex(r, tab, rowColumn);
			}
			else
			{
				r.GridIndex = 0;
			}
			return r;
		}

		private static RecipeProto ModifyGridIndex(this RecipeProto r, int gridIndex)
		{
			if (FractionateEverything.showRecipes)
			{
				helper.ModifyGridIndex(r, gridIndex);
			}
			else
			{
				r.GridIndex = 0;
			}
			return r;
		}
	}
	public class AcceptableIntValue : AcceptableValueBase
	{
		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private int <min>P;

		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private int <max>P;

		private readonly int defVal;

		public AcceptableIntValue(int defVal, int min, int max)
		{
			<min>P = min;
			<max>P = max;
			this.defVal = ((defVal >= <min>P && defVal <= <max>P) ? defVal : <min>P);
			((AcceptableValueBase)this)..ctor(typeof(int));
		}

		public override object Clamp(object value)
		{
			return ((AcceptableValueBase)this).IsValid(value) ? ((int)value) : defVal;
		}

		public override bool IsValid(object value)
		{
			return value.GetType() == ((AcceptableValueBase)this).ValueType && (int)value >= <min>P && (int)value <= <max>P;
		}

		public override string ToDescriptionString()
		{
			return null;
		}
	}
	public class AcceptableBoolValue : AcceptableValueBase
	{
		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private bool <defVal>P;

		public AcceptableBoolValue(bool defVal)
		{
			<defVal>P = defVal;
			((AcceptableValueBase)this)..ctor(typeof(bool));
		}

		public override object Clamp(object value)
		{
			return ((AcceptableValueBase)this).IsValid(value) ? ((bool)value) : <defVal>P;
		}

		public override bool IsValid(object value)
		{
			return value.GetType() == ((AcceptableValueBase)this).ValueType;
		}

		public override string ToDescriptionString()
		{
			return null;
		}
	}
	public static class FractionatorUtils
	{
		public static RecipeProto RecipeFractionator;

		public static ModelProto ModelFractionator;

		public static ItemProto ItemFractionator;

		public static (RecipeProto, ModelProto, ItemProto) CreateAndPreAddNewFractionator(string name, int recipeID, int itemID, int modelID, int[] items, int[] itemCounts, int gridIndex, int preTech, int buildIndex, Color color, double energyRatio = 1.0)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return CreateAndPreAddNewFractionator(name, recipeID, itemID, modelID, items, itemCounts, gridIndex, ((ProtoSet<TechProto>)(object)LDB.techs).Select(preTech), buildIndex, color, energyRatio);
		}

		public static (RecipeProto, ModelProto, ItemProto) CreateAndPreAddNewFractionator(string name, int recipeID, int itemID, int modelID, int[] items, int[] itemCounts, int gridIndex, TechProto preTech, int buildIndex, Color color, double energyRatio = 1.0)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			ItemProto itemFractionator = ItemFractionator;
			ModelProto modelFractionator = ModelFractionator;
			RecipeProto recipeFractionator = RecipeFractionator;
			PrefabDesc prefabDesc = modelFractionator.prefabDesc;
			string text = $"Assets/fracicons/fractionator-{gridIndex % 10}";
			Sprite value = Resources.Load<Sprite>(text);
			RecipeProto val = new RecipeProto();
			CopyPropertiesExtenstion.CopyPropsTo<RecipeProto, RecipeProto>(recipeFractionator, ref val);
			((Proto)val).ID = recipeID;
			((Proto)val).Name = name;
			((Proto)val).name = Localization.Translate(name);
			val.Items = items;
			val.ItemCounts = itemCounts;
			val.Results = new int[1] { itemID };
			val.ResultCounts = new int[1] { 1 };
			val.GridIndex = gridIndex;
			val.IconPath = text;
			Traverse.Create((object)val).Field("_iconSprite").SetValue((object)value);
			val.preTech = preTech;
			LDBTool.PreAddProto((Proto)(object)val);
			((Proto)val).ID = recipeID;
			ModelProto val2 = new ModelProto();
			CopyPropertiesExtenstion.CopyPropsTo<ModelProto, ModelProto>(modelFractionator, ref val2);
			GameObject val3 = Resources.Load<GameObject>(val2.PrefabPath);
			GameObject val4 = Resources.Load<GameObject>(val2.ColliderPath);
			val2.prefabDesc = (PrefabDesc)((Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val4)) ? ((object)new PrefabDesc(modelID, val3, val4)) : ((!Object.op_Implicit((Object)(object)val3)) ? ((object)PrefabDesc.none) : ((object)new PrefabDesc(modelID, val3))));
			((Proto)val2).ID = modelID;
			((Proto)val2).Name = modelID.ToString();
			((Proto)val2).name = modelID.ToString();
			((Proto)val2).SID = name;
			((Proto)val2).sid = name;
			val2.Order = 38000 + modelID;
			Traverse.Create((object)val2).Field("_iconSprite").SetValue((object)value);
			val2.prefabDesc.modelIndex = modelID;
			val2.prefabDesc.workEnergyPerTick = (long)((double)val2.prefabDesc.workEnergyPerTick * energyRatio);
			val2.prefabDesc.idleEnergyPerTick = (long)((double)val2.prefabDesc.idleEnergyPerTick * energyRatio);
			Material val5 = new Material(prefabDesc.lodMaterials[0][0])
			{
				color = color
			};
			Material val6 = prefabDesc.lodMaterials[0][1];
			Material val7 = prefabDesc.lodMaterials[0][2];
			Material val8 = prefabDesc.lodMaterials[0][3];
			Material val9 = new Material(prefabDesc.lodMaterials[1][0])
			{
				color = color
			};
			Material val10 = new Material(prefabDesc.lodMaterials[2][0])
			{
				color = color
			};
			val2.prefabDesc.lodMaterials = new Material[4][]
			{
				(Material[])(object)new Material[4] { val5, val6, val7, val8 },
				(Material[])(object)new Material[4] { val9, val6, val7, val8 },
				(Material[])(object)new Material[4] { val10, val6, val7, val8 },
				null
			};
			LDBTool.PreAddProto((Proto)(object)val2);
			ItemProto val11 = new ItemProto();
			CopyPropertiesExtenstion.CopyPropsTo<ItemProto, ItemProto>(itemFractionator, ref val11);
			val11.prefabDesc = val2.prefabDesc;
			val11.ModelIndex = modelID;
			((Proto)val11).ID = itemID;
			((Proto)val11).Name = name;
			((Proto)val11).name = Localization.Translate(name);
			val11.Description = "I" + name;
			val11.description = Localization.Translate("I" + name);
			val11.GridIndex = gridIndex;
			val11.IconPath = text;
			Traverse.Create((object)val11).Field("_iconSprite").SetValue((object)value);
			val11.preTech = preTech;
			val11.recipes = new List<RecipeProto>(1) { val };
			val11.maincraft = val;
			val11.handcraft = val;
			val11.handcrafts = new List<RecipeProto>(1) { val };
			val11.BuildIndex = buildIndex;
			LDBTool.PreAddProto((Proto)(object)val11);
			LDBTool.SetBuildBar(buildIndex / 100, buildIndex % 100, ((Proto)val11).ID);
			return (val, val2, val11);
		}
	}
	public class RecipeHelper
	{
		private int currID = 1010;

		private readonly List<int> recipeIDList = new List<int>();

		private readonly int maxRowCount;

		private readonly int maxColumnCount;

		private int tab;

		private int row;

		private int column;

		private readonly int firstEmptyGridIndex;

		private Dictionary<RecipeProto, int> gridIndexDic = new Dictionary<RecipeProto, int>();

		public RecipeHelper(int firstPage)
		{
			RecipeProto[] dataArray = ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray;
			foreach (RecipeProto val in dataArray)
			{
				if (val != null && val.GridIndex > 0)
				{
					recipeIDList.Add(((Proto)val).ID);
				}
			}
			tab = firstPage + 1;
			row = 6;
			column = 5;
			firstEmptyGridIndex = tab * 1000 + row * 100 + column + 1;
			if (GenesisBook.Enable)
			{
				maxRowCount = 7;
				maxColumnCount = 17;
			}
			else
			{
				maxRowCount = 8;
				maxColumnCount = 14;
			}
			RecipeProto[] dataArray2 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray;
			foreach (RecipeProto val2 in dataArray2)
			{
				if (val2 != null && val2.GridIndex > 0)
				{
					gridIndexDic.Add(val2, val2.GridIndex);
				}
			}
		}

		public int GetUnusedRecipeID()
		{
			while (((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(currID) != null || recipeIDList.Contains(currID))
			{
				currID++;
			}
			recipeIDList.Add(currID);
			return currID;
		}

		public void ModifyGridIndex(RecipeProto r, int tab, int rowColumn)
		{
			ModifyGridIndex(r, tab * 1000 + rowColumn);
		}

		public void ModifyGridIndex(RecipeProto r, int gridIndex)
		{
			if (gridIndex <= 0)
			{
				column++;
				if (column > maxColumnCount)
				{
					column = 1;
					row++;
				}
				int num = tab * 1000 + row * 100 + column;
				if (row > maxRowCount)
				{
					FractionateEverything.LogWarning($"配方{((Proto)r).name}图标超出显示范围,当前GridIndex={num}");
				}
				gridIndexDic[r] = num;
				r.GridIndex = num;
				return;
			}
			if (gridIndexDic.ContainsValue(gridIndex))
			{
				ModifyGridIndex(r, -1);
				return;
			}
			if (gridIndexDic.ContainsKey(r))
			{
				int num2 = gridIndexDic[r];
				gridIndexDic.Remove(r);
				if (num2 / 1000 == tab && num2 >= firstEmptyGridIndex)
				{
					Dictionary<RecipeProto, int> dictionary = new Dictionary<RecipeProto, int>();
					foreach (KeyValuePair<RecipeProto, int> item in gridIndexDic)
					{
						if (item.Value / 1000 == tab && item.Value > num2)
						{
							int num3 = item.Value % 1000 / 100;
							int num4 = item.Value % 1000 % 100;
							if (num4 >= 2)
							{
								item.Key.GridIndex = item.Value - 1;
							}
							else
							{
								item.Key.GridIndex = tab * 1000 + (num3 - 1) * 100 + maxColumnCount;
							}
							dictionary.Add(item.Key, item.Key.GridIndex);
						}
						else
						{
							dictionary.Add(item.Key, item.Value);
						}
					}
					gridIndexDic = dictionary;
					column--;
					if (column <= 0)
					{
						row--;
						column = maxColumnCount;
					}
				}
			}
			gridIndexDic.Add(r, gridIndex);
			r.GridIndex = gridIndex;
		}
	}
	public static class ProtoID
	{
		internal const int I铁矿 = 1001;

		internal const int I铜矿 = 1002;

		internal const int I硅石 = 1003;

		internal const int I钛石 = 1004;

		internal const int I石矿 = 1005;

		internal const int I煤矿 = 1006;

		internal const int I木材 = 1030;

		internal const int I植物燃料 = 1031;

		internal const int I可燃冰 = 1011;

		internal const int I金伯利矿石 = 1012;

		internal const int I分形硅石 = 1013;

		internal const int I光栅石 = 1014;

		internal const int I刺笋结晶 = 1015;

		internal const int I单极磁石 = 1016;

		internal const int I铁块 = 1101;

		internal const int I铜块 = 1104;

		internal const int I高纯硅块 = 1105;

		internal const int I钛块 = 1106;

		internal const int I石材 = 1108;

		internal const int I高能石墨 = 1109;

		internal const int I钢材 = 1103;

		internal const int I钛合金 = 1107;

		internal const int I玻璃 = 1110;

		internal const int I钛化玻璃 = 1119;

		internal const int I棱镜 = 1111;

		internal const int I金刚石 = 1112;

		internal const int I晶格硅 = 1113;

		internal const int I齿轮 = 1201;

		internal const int I磁铁 = 1102;

		internal const int I磁线圈_GB铜线圈 = 1202;

		internal const int I电动机 = 1203;

		internal const int I电磁涡轮 = 1204;

		internal const int I超级磁场环 = 1205;

		internal const int I粒子容器 = 1206;

		internal const int I奇异物质 = 1127;

		internal const int I电路板 = 1301;

		internal const int I处理器 = 1303;

		internal const int I量子芯片 = 1305;

		internal const int I微晶元件 = 1302;

		internal const int I位面过滤器 = 1304;

		internal const int I粒子宽带 = 1402;

		internal const int I电浆激发器 = 1401;

		internal const int I光子合并器 = 1404;

		internal const int I太阳帆 = 1501;

		internal const int I = 1000;

		internal const int I原油 = 1007;

		internal const int I精炼油_GB焦油 = 1114;

		internal const int I硫酸 = 1116;

		internal const int I = 1120;

		internal const int I重氢 = 1121;

		internal const int I反物质 = 1122;

		internal const int I临界光子 = 1208;

		internal const int I液氢燃料棒 = 1801;

		internal const int I氘核燃料棒 = 1802;

		internal const int I反物质燃料棒 = 1803;

		internal const int I奇异湮灭燃料棒 = 1804;

		internal const int I塑料_GB聚丙烯 = 1115;

		internal const int I石墨烯 = 1123;

		internal const int I碳纳米管 = 1124;

		internal const int I有机晶体 = 1117;

		internal const int I钛晶石 = 1118;

		internal const int I卡西米尔晶体 = 1126;

		internal const int I燃烧单元 = 1128;

		internal const int I爆破单元 = 1129;

		internal const int I晶石爆破单元 = 1130;

		internal const int I引力透镜 = 1209;

		internal const int I空间翘曲器 = 1210;

		internal const int I湮灭约束球 = 1403;

		internal const int I动力引擎 = 1407;

		internal const int I推进器 = 1405;

		internal const int I加力推进器 = 1406;

		internal const int I配送运输机 = 5003;

		internal const int I物流运输机 = 5001;

		internal const int I星际物流运输船 = 5002;

		internal const int I框架材料 = 1125;

		internal const int I戴森球组件 = 1502;

		internal const int I小型运载火箭 = 1503;

		internal const int I地基 = 1131;

		internal const int I增产剂MkI = 1141;

		internal const int I增产剂MkII = 1142;

		internal const int I增产剂MkIII_GB增产剂 = 1143;

		internal const int I机枪弹箱 = 1601;

		internal const int I钛化弹箱 = 1602;

		internal const int I超合金弹箱 = 1603;

		internal const int I炮弹组 = 1604;

		internal const int I高爆炮弹组 = 1605;

		internal const int I晶石炮弹组 = 1606;

		internal const int I等离子胶囊 = 1607;

		internal const int I反物质胶囊 = 1608;

		internal const int I导弹组 = 1609;

		internal const int I超音速导弹组 = 1610;

		internal const int I引力导弹组 = 1611;

		internal const int I干扰胶囊 = 1612;

		internal const int I压制胶囊 = 1613;

		internal const int I原型机 = 5101;

		internal const int I精准无人机 = 5102;

		internal const int I攻击无人机 = 5103;

		internal const int I护卫舰 = 5111;

		internal const int I驱逐舰 = 5112;

		internal const int I黑雾矩阵 = 5201;

		internal const int I硅基神经元 = 5202;

		internal const int I物质重组器 = 5203;

		internal const int I负熵奇点 = 5204;

		internal const int I核心素 = 5205;

		internal const int I能量碎片 = 5206;

		internal const int I传送带 = 2001;

		internal const int I高速传送带 = 2002;

		internal const int I极速传送带 = 2003;

		internal const int I分拣器 = 2011;

		internal const int I高速分拣器 = 2012;

		internal const int I极速分拣器 = 2013;

		internal const int I集装分拣器 = 2014;

		internal const int I四向分流器 = 2020;

		internal const int I自动集装机 = 2040;

		internal const int I流速监测器 = 2030;

		internal const int I喷涂机 = 2313;

		internal const int I物流配送器 = 2107;

		internal const int I小型储物仓 = 2101;

		internal const int I大型储物仓 = 2102;

		internal const int I储液罐 = 2106;

		internal const int I制造台MkI_GB基础制造台 = 2303;

		internal const int I制造台MkII_GB标准制造单元 = 2304;

		internal const int I制造台MkIII_GB高精度装配线 = 2305;

		internal const int I重组式制造台_GB物质重组工厂 = 2318;

		internal const int I电力感应塔 = 2201;

		internal const int I无线输电塔 = 2202;

		internal const int I卫星配电站 = 2212;

		internal const int I风力涡轮机 = 2203;

		internal const int I火力发电厂 = 2204;

		internal const int I微型聚变发电站_GB裂变能源发电站 = 2211;

		internal const int I地热发电站 = 2213;

		internal const int I采矿机 = 2301;

		internal const int I大型采矿机 = 2316;

		internal const int I抽水站 = 2306;

		internal const int I电弧熔炉 = 2302;

		internal const int I位面熔炉 = 2315;

		internal const int I负熵熔炉 = 2319;

		internal const int I原油萃取站 = 2307;

		internal const int I原油精炼厂 = 2308;

		internal const int I化工厂 = 2309;

		internal const int I量子化工厂_GB先进化学反应釜 = 2317;

		internal const int I分馏塔_FE通用分馏塔 = 2314;

		internal const int I太阳能板 = 2205;

		internal const int I蓄电器 = 2206;

		internal const int I蓄电器满 = 2207;

		internal const int I电磁轨道弹射器 = 2311;

		internal const int I射线接收站 = 2208;

		internal const int I垂直发射井 = 2312;

		internal const int I能量枢纽 = 2209;

		internal const int I微型粒子对撞机 = 2310;

		internal const int I人造恒星_GB人造恒星MKI = 2210;

		internal const int I行星内物流运输站 = 2103;

		internal const int I星际物流运输站 = 2104;

		internal const int I轨道采集器 = 2105;

		internal const int I矩阵研究站 = 2901;

		internal const int I自演化研究站 = 2902;

		internal const int I高斯机枪塔 = 3001;

		internal const int I高频激光塔_GB高频激光塔MKI = 3002;

		internal const int I聚爆加农炮_GB聚爆加农炮MKI = 3003;

		internal const int I磁化电浆炮 = 3004;

		internal const int I导弹防御塔 = 3005;

		internal const int I干扰塔 = 3006;

		internal const int I信号塔 = 3007;

		internal const int I行星护盾发生器 = 3008;

		internal const int I战场分析基站 = 3009;

		internal const int I近程电浆塔 = 3010;

		internal const int I电磁矩阵 = 6001;

		internal const int I能量矩阵 = 6002;

		internal const int I结构矩阵 = 6003;

		internal const int I信息矩阵 = 6004;

		internal const int I引力矩阵 = 6005;

		internal const int I宇宙矩阵 = 6006;

		internal const int I沙土 = 1099;

		internal const int IMS引力发生装置 = 9480;

		internal const int IMS位面约束环 = 9481;

		internal const int IMS引力钻头 = 9482;

		internal const int IMS隧穿激发装置 = 9483;

		internal const int IMS谐振盘 = 9484;

		internal const int IMS光子探针 = 9485;

		internal const int IMS量子计算机 = 9486;

		internal const int IMS星际组装厂组件 = 9487;

		internal const int IMS物质解压器运载火箭 = 9488;

		internal const int IMS科学枢纽运载火箭 = 9489;

		internal const int IMS谐振发射器运载火箭 = 9490;

		internal const int IMS星际组装厂运载火箭 = 9491;

		internal const int IMS晶体重构器运载火箭 = 9492;

		internal const int IMS多功能集成组件 = 9500;

		internal const int IMS力场发生器 = 9503;

		internal const int IMS复合态晶体 = 9504;

		internal const int IMS电磁力抑制器 = 9505;

		internal const int IMS胶子发生器 = 9506;

		internal const int IMS强力过载装置 = 9507;

		internal const int IMS导流框架 = 9508;

		internal const int IMS恒星炮组件 = 9509;

		internal const int IMS恒星炮运载火箭 = 9510;

		internal const int IMS水滴 = 9511;

		internal const int IMS铁金属重构装置 = 9493;

		internal const int IMS铜金属重构装置 = 9494;

		internal const int IMS高纯硅重构装置 = 9495;

		internal const int IMS钛金属重构装置 = 9496;

		internal const int IMS单极磁石重构装置 = 9497;

		internal const int IMS晶体接收器 = 9498;

		internal const int IMS组件集成装置 = 9499;

		internal const int IMS石墨提炼装置 = 9501;

		internal const int IMS光栅晶体接收器 = 9502;

		internal const int IMS物资交换物流站 = 9512;

		internal const int IVD水滴额外伤害 = 8035;

		internal const int IVD星河卫士勋章 = 9513;

		internal const int IGB钨矿 = 6201;

		internal const int IGB铝矿 = 6202;

		internal const int IGB铝块 = 6203;

		internal const int IGB铝合金 = 6204;

		internal const int IGB二氧化碳 = 6206;

		internal const int IGB硫矿 = 6207;

		internal const int IGB混凝土 = 6208;

		internal const int IGB四氢双环戊二烯JP10 = 6212;

		internal const int IGB四氢双环戊二烯燃料棒 = 6216;

		internal const int IGB煤油燃料棒 = 6217;

		internal const int IGB = 6220;

		internal const int IGB同位素温差发电机 = 6221;

		internal const int IGB放射性矿物 = 6222;

		internal const int IGB铀矿 = 6225;

		internal const int IGB钚矿 = 6226;

		internal const int IGB含铀核燃料 = 6227;

		internal const int IGB含钚核燃料 = 6228;

		internal const int IGB量子储液罐 = 6229;

		internal const int IGB矿物处理厂 = 6230;

		internal const int IGB量子储物仓 = 6231;

		internal const int IGB = 6234;

		internal const int IGB氦三 = 6235;

		internal const int IGB钚燃料棒 = 6241;

		internal const int IGB铀燃料棒 = 6242;

		internal const int IGBMOX燃料棒 = 6243;

		internal const int IGB氦三燃料棒 = 6244;

		internal const int IGB氘氦混合燃料棒 = 6245;

		internal const int IGB石粉 = 6251;

		internal const int IGB铁矿粉 = 6252;

		internal const int IGB铜矿粉 = 6253;

		internal const int IGB硅矿粉 = 6254;

		internal const int IGB钛矿粉 = 6255;

		internal const int IGB煤矿粉 = 6256;

		internal const int IGB天穹装配厂 = 6257;

		internal const int IGB物质裂解塔 = 6258;

		internal const int IGB埃克森美孚化工厂 = 6259;

		internal const int IGB工业先锋精密加工中心 = 6260;

		internal const int IGB人造恒星MKII = 6261;

		internal const int IGB氦闪约束器 = 6263;

		internal const int IGB物质分解设施 = 6264;

		internal const int IGB苍穹粒子加速器 = 6265;

		internal const int IGB聚束液体汲取设施 = 6266;

		internal const int IGB大气采集站 = 6267;

		internal const int IGB三元精金 = 6271;

		internal const int IGB铝矿粉 = 6273;

		internal const int IGB硫粉 = 6277;

		internal const int IGB通量矩阵 = 6278;

		internal const int IGB空间矩阵 = 6279;

		internal const int IGB宇宙矩阵粗坯 = 6280;

		internal const int IGB钨矿粉 = 6281;

		internal const int IGB基础机械组件 = 6501;

		internal const int IGB先进机械组件 = 6502;

		internal const int IGB尖端机械组件 = 6503;

		internal const int IGB超级机械组件 = 6504;

		internal const int IGB创世之书 = 6506;

		internal const int IGB虚空之书 = 6507;

		internal const int IGB起源之书 = 6508;

		internal const int IGB空燃料棒 = 6509;

		internal const int IGB开发者日志01 = 6511;

		internal const int IGB开发者日志02 = 6512;

		internal const int IGB开发者日志03 = 6513;

		internal const int IGB开发者日志04 = 6514;

		internal const int IGB开发者日志05 = 6515;

		internal const int IGB开发者日志06 = 6516;

		internal const int IGB开发者日志07 = 6517;

		internal const int IGB开发者日志08 = 6518;

		internal const int IGB开发者日志09 = 6519;

		internal const int IGB开发者日志10 = 6520;

		internal const int IGB开发者日志11 = 6521;

		internal const int IGB电力节约 = 6522;

		internal const int IGB上传扩容 = 6523;

		internal const int IGB燃料回收 = 6524;

		internal const int IGB风力扩容 = 6525;

		internal const int IGB光伏扩容 = 6526;

		internal const int IGB热聚增效 = 6527;

		internal const int IGB资源采掘 = 6528;

		internal const int IGB裂变增效 = 6529;

		internal const int IGB先进推进 = 6530;

		internal const int IGB特征向量模拟 = 6531;

		internal const int IGB中继信号干扰 = 6532;

		internal const int IGB神经元重编程 = 6533;

		internal const int IGB异常代码分析 = 6534;

		internal const int IGB = 7002;

		internal const int IGB = 7006;

		internal const int IGB丙烯 = 7009;

		internal const int IGB盐酸 = 7014;

		internal const int IGB三氯化铁 = 7015;

		internal const int IGB硝酸 = 7017;

		internal const int IGB海水 = 7018;

		internal const int IGB = 70