Decompiled source of SmelterMiner v1.6.8

SmelterMiner.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
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("Water electrolysis")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Water electrolysis")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7c9af07a-64ff-409f-b5bc-b78e172b5e36")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SmelterMiner;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "TabSystem", "LocalizationModule" })]
[BepInPlugin("Gnimaerd.DSP.plugin.SmelterMiner", "SmelterMiner", "1.6")]
public class SmelterMiner : BaseUnityPlugin
{
	public static string GUID = "Gnimaerd.DSP.plugin.SmelterMiner";

	private Sprite iconA;

	private Sprite iconB;

	private Sprite iconC;

	private Sprite iconBigA;

	private Sprite iconBigB;

	private Sprite iconBigC;

	private Sprite iconO;

	public static ConfigEntry<bool> EasyMode;

	public static ConfigEntry<bool> ActiveCustomizeRate;

	public static ConfigEntry<float> CustomRate;

	public static Dictionary<int, int> ProductMapA;

	public static Dictionary<int, int> ProductMapB;

	public static Dictionary<int, int> ProductMapC;

	public static Dictionary<int, int> ProductMapO;

	public static Dictionary<int, int> SmelterRatio;

	public static ResourceData resources;

	private void Awake()
	{
		AssetBundle val = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("SmelterMiner.scmicons"));
		iconA = val.LoadAsset<Sprite>("SmelterMinerA");
		iconB = val.LoadAsset<Sprite>("SmelterMinerB");
		iconC = val.LoadAsset<Sprite>("SmelterMinerC");
		iconO = val.LoadAsset<Sprite>("SmelterMinerO");
		iconBigA = val.LoadAsset<Sprite>("SmelterMinerBigA");
		iconBigB = val.LoadAsset<Sprite>("SmelterMinerBigB");
		iconBigC = val.LoadAsset<Sprite>("SmelterMinerBigC");
		EasyMode = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "EasyMode", false, "Trun this to true to greatly reduce technological requirements and construction costs of the new mining machines (Not recommended). 设置为true使得科技需求和建造成本大幅降低,让你在前期即可使用这些新的矿机(不推荐)。");
		ActiveCustomizeRate = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "ActiveCustomizeMiningRate", false, "Turn this to true if you want to customize mining rate(possibility to consume the minerals).如果你想自定义矿物消耗速率请把此项设置为true。");
		CustomRate = ((BaseUnityPlugin)this).Config.Bind<float>("config", "MiningRate", 1f, "Cutomize your mining rate. 自定义采矿消耗速度。");
		ProductMapA = new Dictionary<int, int>();
		ProductMapB = new Dictionary<int, int>();
		ProductMapC = new Dictionary<int, int>();
		ProductMapO = new Dictionary<int, int>();
		SmelterRatio = new Dictionary<int, int>();
		ProductMapA.Add(1001, 1101);
		ProductMapB.Add(1001, 1102);
		SmelterRatio.Add(1101, 1);
		SmelterRatio.Add(1102, 1);
		ProductMapA.Add(1002, 1104);
		ProductMapB.Add(1002, 1104);
		SmelterRatio.Add(1104, 1);
		ProductMapA.Add(1003, 1105);
		ProductMapB.Add(1003, 1105);
		SmelterRatio.Add(1105, 2);
		ProductMapA.Add(1004, 1106);
		ProductMapB.Add(1004, 1106);
		SmelterRatio.Add(1106, 2);
		ProductMapA.Add(1005, 1108);
		ProductMapB.Add(1005, 1110);
		SmelterRatio.Add(1108, 1);
		SmelterRatio.Add(1110, 2);
		ProductMapA.Add(1006, 1109);
		ProductMapB.Add(1006, 1109);
		SmelterRatio.Add(1109, 2);
		ProductMapA.Add(1012, 1112);
		ProductMapB.Add(1012, 1112);
		SmelterRatio.Add(1112, 1);
		ProductMapA.Add(1013, 1113);
		ProductMapB.Add(1013, 1113);
		SmelterRatio.Add(1113, 1);
		ProductMapA.Add(6201, 7705);
		ProductMapB.Add(6201, 7705);
		SmelterRatio.Add(7705, 1);
		ProductMapA.Add(6202, 6203);
		ProductMapB.Add(6202, 6203);
		SmelterRatio.Add(6203, 1);
		ProductMapA.Add(6207, 6277);
		ProductMapB.Add(6207, 6277);
		SmelterRatio.Add(6277, 1);
		ProductMapC.Add(1011, 1123);
		SmelterRatio.Add(1123, 1);
		ProductMapC.Add(1015, 1124);
		SmelterRatio.Add(1124, 2);
		ProductMapC.Add(1117, 7709);
		SmelterRatio.Add(7709, 8);
		ProductMapO.Add(1007, 1114);
		SmelterRatio.Add(1007, 1);
		AddTranslate();
		AddTranslate2();
		AddTranslate3();
		AddTranslate4();
		LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(AddSmelterMiners));
		Harmony.CreateAndPatchAll(typeof(SmelterMiner), (string)null);
	}

	public static int SmeltIt(int minerID, int OreID)
	{
		if (minerID == 9446 || minerID == 9466 || minerID == 9447 || minerID == 9467 || minerID == 9448 || minerID == 9468 || minerID == 9469)
		{
		}
		return OreID;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(MinerComponent), "InternalUpdate")]
	public static bool InternalUpdatePatch(ref MinerComponent __instance, ref uint __result, ref PlanetFactory factory, ref VeinData[] veinPool, float power, ref float miningRate, ref float miningSpeed, ref int[] productRegister)
	{
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Invalid comparison between Unknown and I4
		//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d9: Invalid comparison between Unknown and I4
		//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ce: Invalid comparison between Unknown and I4
		//IL_0b12: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b18: Invalid comparison between Unknown and I4
		//IL_0b31: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b37: Invalid comparison between Unknown and I4
		//IL_0bd7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bdd: Invalid comparison between Unknown and I4
		//IL_0637: Unknown result type (might be due to invalid IL or missing references)
		//IL_064d: Unknown result type (might be due to invalid IL or missing references)
		//IL_056d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Expected I4, but got Unknown
		//IL_057d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_059c: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (ActiveCustomizeRate.Value)
			{
				miningRate = CustomRate.Value;
			}
			if (power < 0.1f)
			{
				return true;
			}
			int protoId = factory.entityPool[__instance.entityId].protoId;
			if (protoId != 9446 && protoId != 9447 && protoId != 9448 && protoId != 9466 && protoId != 9467 && protoId != 9468 && protoId != 9469)
			{
				return true;
			}
			Dictionary<int, int> dictionary = ((protoId != 9446 && protoId != 9466) ? ((protoId != 9447 && protoId != 9467) ? ((protoId != 9448 && protoId != 9468) ? ProductMapO : ProductMapC) : ProductMapB) : ProductMapA);
			int num = __instance.veins[__instance.currentVeinIndex];
			Assert.Positive(num);
			int productId = veinPool[num].productId;
			int num2 = productId;
			int num3 = 1;
			if (dictionary.ContainsKey(productId) && SmelterRatio.ContainsKey(dictionary[productId]))
			{
				num2 = dictionary[productId];
				num3 = SmelterRatio[dictionary[productId]];
			}
			int productId2 = veinPool[num].productId;
			int num4 = productId2;
			__result = 0u;
			uint num5 = 0u;
			if ((int)__instance.type == 2)
			{
				if (__instance.veinCount > 0)
				{
					if (__instance.time <= __instance.period)
					{
						__instance.time += (int)(power * (float)__instance.speed * miningSpeed * (float)__instance.veinCount / (float)num3);
						num5 = 1u;
					}
					if (__instance.time >= __instance.period)
					{
						int num6 = __instance.veins[__instance.currentVeinIndex];
						Assert.Positive(num6);
						VeinData[] array = veinPool;
						if (dictionary.ContainsKey(productId2) && SmelterRatio.ContainsKey(dictionary[productId2]))
						{
							num4 = dictionary[productId2];
						}
						lock (array)
						{
							if (veinPool[num6].id == 0)
							{
								((MinerComponent)(ref __instance)).RemoveVeinFromArray(__instance.currentVeinIndex);
								((MinerComponent)(ref __instance)).GetMinimumVeinAmount(factory, veinPool);
								if (__instance.veinCount > 1)
								{
									__instance.currentVeinIndex %= __instance.veinCount;
								}
								else
								{
									__instance.currentVeinIndex = 0;
								}
								__instance.time += (int)(power * (float)__instance.speed * miningSpeed * (float)__instance.veinCount / (float)num3);
								__result = 0u;
								return false;
							}
							if (__instance.productCount < 50 && (__instance.productId == 0 || __instance.productId == num4 || __instance.productId == productId2))
							{
								__instance.productId = num4;
								int num7 = __instance.time / __instance.period;
								int num8 = 0;
								if (veinPool[num6].amount > 0)
								{
									if (miningRate > 0f)
									{
										int num9 = 0;
										if (miningRate < 0.99999f)
										{
											for (int i = 0; i < num7; i++)
											{
												__instance.seed = (uint)((int)((ulong)((long)(__instance.seed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
												num9 += (((double)__instance.seed / 2147483646.0 < (double)miningRate) ? 1 : 0);
												num8++;
												if (num9 == veinPool[num6].amount)
												{
													break;
												}
											}
										}
										else
										{
											num8 = ((num7 > veinPool[num6].amount) ? veinPool[num6].amount : num7);
											num9 = num8;
										}
										if (num9 > 0)
										{
											num9 *= num3;
											int groupIndex = veinPool[num6].groupIndex;
											int num10 = num6;
											veinPool[num10].amount = veinPool[num10].amount - num9;
											if (veinPool[num6].amount < __instance.minimumVeinAmount)
											{
												__instance.minimumVeinAmount = veinPool[num6].amount;
											}
											VeinGroup[] veinGroups = factory.veinGroups;
											int num11 = groupIndex;
											veinGroups[num11].amount = veinGroups[num11].amount - num9;
											factory.veinAnimPool[num6].time = ((veinPool[num6].amount >= 20000) ? 0f : (1f - (float)veinPool[num6].amount * 5E-05f));
											if (veinPool[num6].amount <= 0)
											{
												int num12 = (int)veinPool[num6].type;
												Vector3 pos = veinPool[num6].pos;
												factory.RemoveVeinWithComponents(num6);
												factory.RecalculateVeinGroup(groupIndex);
												factory.NotifyVeinExhausted(num12, pos);
												((MinerComponent)(ref __instance)).RemoveVeinFromArray(__instance.currentVeinIndex);
												((MinerComponent)(ref __instance)).GetMinimumVeinAmount(factory, veinPool);
											}
											else
											{
												__instance.currentVeinIndex++;
											}
										}
									}
									else
									{
										num8 = num7;
									}
									int num13 = num8;
									if (__instance.productId == 1112)
									{
										num13 *= 2;
									}
									__instance.productCount += num13;
									int[] array2 = productRegister;
									lock (array2)
									{
										productRegister[__instance.productId] += num13;
										factory.AddMiningFlagUnsafe(veinPool[num6].type);
										factory.AddVeinMiningFlagUnsafe(veinPool[num6].type);
									}
								}
								else
								{
									((MinerComponent)(ref __instance)).RemoveVeinFromArray(__instance.currentVeinIndex);
									((MinerComponent)(ref __instance)).GetMinimumVeinAmount(factory, veinPool);
								}
								__instance.time -= __instance.period * num8;
								if (__instance.veinCount > 1)
								{
									__instance.currentVeinIndex %= __instance.veinCount;
								}
								else
								{
									__instance.currentVeinIndex = 0;
								}
							}
						}
					}
				}
			}
			else if ((int)__instance.type == 3)
			{
				if (__instance.veinCount > 0)
				{
					int num14 = __instance.veins[0];
					VeinData[] array3 = veinPool;
					int productId3 = veinPool[num14].productId;
					int productId4 = productId3;
					if (dictionary.ContainsKey(productId3))
					{
						productId4 = dictionary[productId3];
					}
					lock (array3)
					{
						float num15 = (float)veinPool[num14].amount * VeinData.oilSpeedMultiplier;
						if (__instance.time < __instance.period)
						{
							__instance.time += (int)(power * (float)__instance.speed * miningSpeed * num15 + 0.5f);
							num5 = 1u;
						}
						if (__instance.time >= __instance.period && __instance.productCount < 50)
						{
							__instance.productId = productId4;
							int num16 = __instance.time / __instance.period;
							int num17 = 0;
							if (miningRate > 0f && veinPool[num14].amount > 2500)
							{
								int num18 = 0;
								int num19 = veinPool[num14].amount - 2500;
								for (int j = 0; j < num16; j++)
								{
									__instance.seed = (uint)((int)((ulong)((long)(__instance.seed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
									num18 += (((double)__instance.seed / 2147483646.0 < (double)miningRate) ? 1 : 0);
									num17++;
								}
								if (num18 > 0)
								{
									if (num18 > num19)
									{
										num18 = num19;
									}
									int num20 = num14;
									veinPool[num20].amount = veinPool[num20].amount - num18;
									VeinGroup[] veinGroups2 = factory.veinGroups;
									short groupIndex2 = veinPool[num14].groupIndex;
									veinGroups2[groupIndex2].amount = veinGroups2[groupIndex2].amount - num18;
									factory.veinAnimPool[num14].time = ((veinPool[num14].amount >= 25000) ? 0f : (1f - (float)veinPool[num14].amount * VeinData.oilSpeedMultiplier));
								}
							}
							else
							{
								num17 = num16;
							}
							__instance.productCount += num17;
							int[] array4 = productRegister;
							lock (array4)
							{
								productRegister[__instance.productId] += num17;
							}
							__instance.time -= __instance.period * num17;
						}
					}
				}
			}
			else if ((int)__instance.type == 1)
			{
				if (__instance.time < __instance.period)
				{
					__instance.time += (int)(power * (float)__instance.speed * miningSpeed);
					num5 = 1u;
				}
				if (__instance.time >= __instance.period)
				{
					int num21 = __instance.time / __instance.period;
					if (__instance.productCount < 50)
					{
						__instance.productId = factory.planet.waterItemId;
						if (__instance.productId > 0)
						{
							__instance.productCount += num21;
							int[] array5 = productRegister;
							lock (array5)
							{
								productRegister[__instance.productId] += num21;
							}
						}
						else
						{
							__instance.productId = 0;
						}
						__instance.time -= __instance.period * num21;
					}
				}
			}
			if (__instance.productCount > 0 && __instance.insertTarget > 0 && __instance.productId > 0)
			{
				double num22 = 36000000.0 / (double)__instance.period * (double)miningSpeed;
				if ((int)__instance.type == 2)
				{
					num22 *= (double)__instance.veinCount;
				}
				else if ((int)__instance.type == 3)
				{
					num22 *= (double)((float)veinPool[__instance.veins[0]].amount * VeinData.oilSpeedMultiplier);
				}
				int num23 = (int)(num22 - 0.009999999776482582) / 1800 + 1;
				num23 = ((num23 >= 4) ? 4 : ((num23 < 1) ? 1 : num23));
				int num24 = ((__instance.productCount < num23) ? __instance.productCount : num23);
				byte b = 0;
				int num25 = factory.InsertInto(__instance.insertTarget, 0, __instance.productId, (byte)num24, (byte)0, ref b);
				__instance.productCount -= num25;
				if (__instance.productCount == 0 && (int)__instance.type == 2)
				{
					__instance.productId = 0;
				}
			}
			__result = num5;
			return false;
		}
		catch (Exception)
		{
			Debug.LogWarning((object)"SmelterMinerInternalUpdatePatchError Exception. Return false now.");
			return false;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(StationComponent), "UpdateVeinCollection")]
	public static bool UpdateVeinCollectionPatch(ref StationComponent __instance, ref PlanetFactory factory, ref int[] productRegister)
	{
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		int protoId = factory.entityPool[__instance.entityId].protoId;
		if (protoId != 9466 && protoId != 9467 && protoId != 9468)
		{
			return true;
		}
		Dictionary<int, int> dictionary = protoId switch
		{
			9466 => ProductMapA, 
			9467 => ProductMapB, 
			_ => ProductMapC, 
		};
		StationStore[] storage = __instance.storage;
		lock (storage)
		{
			if (__instance.storage[0].count < __instance.storage[0].max)
			{
				MinerComponent[] minerPool = factory.factorySystem.minerPool;
				if (minerPool[__instance.minerId].productId != 0 && minerPool[__instance.minerId].productCount > 0)
				{
					if (dictionary.ContainsKey(__instance.storage[0].itemId))
					{
						__instance.storage[0].itemId = dictionary[__instance.storage[0].itemId];
					}
					int productCount = minerPool[__instance.minerId].productCount;
					int num = __instance.storage[0].max - __instance.storage[0].count;
					num = ((num > productCount) ? productCount : num);
					if (num != 0)
					{
						StationStore[] storage2 = __instance.storage;
						int num2 = 0;
						storage2[num2].count = storage2[num2].count + num;
						MinerComponent[] array = minerPool;
						int minerId = __instance.minerId;
						array[minerId].productCount = array[minerId].productCount - num;
						if (minerPool[__instance.minerId].productCount == 0)
						{
							minerPool[__instance.minerId].productId = 0;
						}
						factory.AddMiningFlagUnsafe(LDB.veins.GetVeinTypeByItemId(__instance.storage[0].itemId));
					}
				}
			}
		}
		return false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlanetFactory), "CreateEntityLogicComponents")]
	public static void MinerProductIconPatch(ref PlanetFactory __instance, int entityId, PrefabDesc desc, int prebuildId)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Invalid comparison between Unknown and I4
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Invalid comparison between Unknown and I4
		int protoId = __instance.entityPool[entityId].protoId;
		if ((protoId != 9446 && protoId != 9447 && protoId != 9448 && protoId != 9466 && protoId != 9467 && protoId != 9468 && protoId != 9469) || (int)desc.minerType == 0 || desc.minerPeriod <= 0)
		{
			return;
		}
		int minerId = __instance.entityPool[entityId].minerId;
		MinerComponent[] minerPool = __instance.factorySystem.minerPool;
		if ((int)minerPool[minerId].type == 2 || (int)minerPool[minerId].type == 3)
		{
			Dictionary<int, int> dictionary = ProductMapA;
			if (protoId == 9446 || protoId == 9466)
			{
				dictionary = ProductMapA;
			}
			else if (protoId == 9447 || protoId == 9467)
			{
				dictionary = ProductMapB;
			}
			else if (protoId == 9448 || protoId == 9468)
			{
				dictionary = ProductMapC;
			}
			else if (protoId == 9469)
			{
				dictionary = ProductMapO;
			}
			int num = ((minerPool[minerId].veinCount != 0) ? minerPool[minerId].veins[0] : 0);
			if (dictionary.ContainsKey(__instance.veinPool[num].productId))
			{
				__instance.entitySignPool[entityId].iconId0 = (uint)dictionary[__instance.veinPool[num].productId];
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PlanetFactory), "AddEntityDataWithComponents")]
	public static bool AddEntityDataPrePatch(EntityData entity, out PrefabDesc __state)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		int protoId = entity.protoId;
		if (protoId != 9446 && protoId != 9447 && protoId != 9448 && protoId != 9466 && protoId != 9467 && protoId != 9468 && protoId != 9469)
		{
			__state = null;
			return true;
		}
		ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)entity.protoId);
		if (val == null || !val.IsEntity)
		{
			__state = null;
			return true;
		}
		ModelProto val2 = ((ProtoSet<ModelProto>)(object)LDB.models).Select((int)entity.modelIndex);
		__state = val2.prefabDesc;
		val2.prefabDesc = MethedEx.Copy<PrefabDesc>(__state);
		val2.prefabDesc.workEnergyPerTick = val.prefabDesc.workEnergyPerTick;
		val2.prefabDesc.idleEnergyPerTick = val.prefabDesc.idleEnergyPerTick;
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlanetFactory), "AddEntityDataWithComponents")]
	public static void AddEntityDataPostPatch(EntityData entity, PrefabDesc __state)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		if (__state != null)
		{
			int protoId = entity.protoId;
			if (protoId == 9446 || protoId == 9447 || protoId == 9448 || protoId == 9466 || protoId == 9467 || protoId == 9468 || protoId == 9469)
			{
				ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select((int)entity.modelIndex);
				val.prefabDesc = __state;
			}
		}
	}

	private void AddSmelterMiners()
	{
		RecipeProto val = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(48);
		ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2301);
		ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1107);
		ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1119);
		ItemProto val5 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1305);
		ItemProto val6 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1401);
		ItemProto val7 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2308);
		ItemProto val8 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2302);
		ItemProto val9 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2309);
		RecipeProto val10 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(119);
		ItemProto val11 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2316);
		RecipeProto val12 = MethedEx.Copy<RecipeProto>(val);
		ItemProto val13 = MethedEx.Copy<ItemProto>(val2);
		((Proto)val12).ID = 452;
		((Proto)val12).Name = "熔炉采矿机A型";
		((Proto)val12).name = Localization.Translate("熔炉采矿机A型");
		val12.Items = new int[3] { 2301, 1107, 1119 };
		val12.ItemCounts = new int[3] { 1, 10, 10 };
		val12.Results = new int[1] { 9446 };
		val12.ResultCounts = new int[1] { 1 };
		val12.GridIndex = 2610;
		Traverse.Create((object)val12).Field("_iconSprite").SetValue((object)iconA);
		val12.TimeSpend = 60;
		val12.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1126);
		if (EasyMode.Value)
		{
			val12.Items = new int[2] { 2301, 2302 };
			val12.ItemCounts = new int[2] { 1, 5 };
			val12.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1401);
		}
		((Proto)val13).ID = 9446;
		((Proto)val13).Name = "熔炉采矿机A型";
		((Proto)val13).name = Localization.Translate("熔炉采矿机A型");
		val13.Description = "熔炉采矿机A型描述";
		val13.description = Localization.Translate("熔炉采矿机A型描述");
		val13.BuildIndex = 205;
		val13.GridIndex = 2610;
		val13.handcraft = val12;
		val13.handcrafts = new List<RecipeProto> { val12 };
		val13.maincraft = val12;
		val13.recipes = new List<RecipeProto> { val12 };
		val13.makes = new List<RecipeProto>();
		val13.prefabDesc = MethedEx.Copy<PrefabDesc>(val2.prefabDesc);
		val13.prefabDesc.workEnergyPerTick = 40000L;
		val13.prefabDesc.idleEnergyPerTick = 1000L;
		Traverse.Create((object)val13).Field("_iconSprite").SetValue((object)iconA);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val12);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val13);
		RecipeProto val14 = MethedEx.Copy<RecipeProto>(val10);
		ItemProto val15 = MethedEx.Copy<ItemProto>(val11);
		((Proto)val14).ID = 472;
		((Proto)val14).Name = "大型熔炉采矿机A型";
		((Proto)val14).name = Localization.Translate("大型熔炉采矿机A型");
		val14.Items = new int[3] { 2316, 1107, 1119 };
		val14.ItemCounts = new int[3] { 1, 20, 20 };
		val14.Results = new int[1] { 9466 };
		val14.ResultCounts = new int[1] { 1 };
		val14.GridIndex = 2710;
		Traverse.Create((object)val14).Field("_iconSprite").SetValue((object)iconBigA);
		val14.TimeSpend = 60;
		val14.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		if (EasyMode.Value)
		{
			val14.Items = new int[2] { 2316, 2302 };
			val14.ItemCounts = new int[2] { 1, 10 };
			val14.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		}
		((Proto)val15).ID = 9466;
		((Proto)val15).Name = "大型熔炉采矿机A型";
		((Proto)val15).name = Localization.Translate("大型熔炉采矿机A型");
		val15.Description = "大型熔炉采矿机A型描述";
		val15.description = Localization.Translate("大型熔炉采矿机A型描述");
		val15.BuildIndex = 208;
		val15.GridIndex = 2710;
		val15.handcraft = val14;
		val15.handcrafts = new List<RecipeProto> { val14 };
		val15.maincraft = val14;
		val15.recipes = new List<RecipeProto> { val14 };
		val15.makes = new List<RecipeProto>();
		val15.prefabDesc = MethedEx.Copy<PrefabDesc>(val11.prefabDesc);
		val15.prefabDesc.workEnergyPerTick = 120000L;
		val15.prefabDesc.idleEnergyPerTick = 3000L;
		Traverse.Create((object)val15).Field("_iconSprite").SetValue((object)iconBigA);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val14);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val15);
		RecipeProto val16 = MethedEx.Copy<RecipeProto>(val);
		ItemProto val17 = MethedEx.Copy<ItemProto>(val2);
		((Proto)val16).ID = 453;
		((Proto)val16).Name = "熔炉采矿机B型";
		((Proto)val16).name = Localization.Translate("熔炉采矿机B型");
		val16.Items = new int[3] { 2301, 1107, 1119 };
		val16.ItemCounts = new int[3] { 1, 10, 10 };
		val16.Results = new int[1] { 9447 };
		val16.ResultCounts = new int[1] { 1 };
		val16.GridIndex = 2611;
		Traverse.Create((object)val16).Field("_iconSprite").SetValue((object)iconB);
		val16.TimeSpend = 60;
		val16.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1126);
		if (EasyMode.Value)
		{
			val16.Items = new int[2] { 2301, 2302 };
			val16.ItemCounts = new int[2] { 1, 5 };
			val16.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1401);
		}
		((Proto)val17).ID = 9447;
		((Proto)val17).Name = "熔炉采矿机B型";
		((Proto)val17).name = Localization.Translate("熔炉采矿机B型");
		val17.Description = "熔炉采矿机B型描述";
		val17.description = Localization.Translate("熔炉采矿机B型描述");
		val17.BuildIndex = 206;
		val17.GridIndex = 2611;
		val17.handcraft = val16;
		val17.handcrafts = new List<RecipeProto> { val16 };
		val17.maincraft = val16;
		val17.recipes = new List<RecipeProto> { val16 };
		val17.makes = new List<RecipeProto>();
		val17.prefabDesc = MethedEx.Copy<PrefabDesc>(val2.prefabDesc);
		val17.prefabDesc.workEnergyPerTick = 40000L;
		val17.prefabDesc.idleEnergyPerTick = 1000L;
		Traverse.Create((object)val17).Field("_iconSprite").SetValue((object)iconB);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val16);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val17);
		RecipeProto val18 = MethedEx.Copy<RecipeProto>(val10);
		ItemProto val19 = MethedEx.Copy<ItemProto>(val11);
		((Proto)val18).ID = 473;
		((Proto)val18).Name = "大型熔炉采矿机B型";
		((Proto)val18).name = Localization.Translate("大型熔炉采矿机B型");
		val18.Items = new int[3] { 2316, 1107, 1119 };
		val18.ItemCounts = new int[3] { 1, 20, 20 };
		val18.Results = new int[1] { 9467 };
		val18.ResultCounts = new int[1] { 1 };
		val18.GridIndex = 2711;
		Traverse.Create((object)val18).Field("_iconSprite").SetValue((object)iconBigB);
		val18.TimeSpend = 60;
		val18.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		if (EasyMode.Value)
		{
			val18.Items = new int[2] { 2316, 2302 };
			val18.ItemCounts = new int[2] { 1, 10 };
			val18.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		}
		((Proto)val19).ID = 9467;
		((Proto)val19).Name = "大型熔炉采矿机B型";
		((Proto)val19).name = Localization.Translate("大型熔炉采矿机B型");
		val19.Description = "大型熔炉采矿机B型描述";
		val19.description = Localization.Translate("大型熔炉采矿机B型描述");
		val19.BuildIndex = 209;
		val19.GridIndex = 2711;
		val19.handcraft = val18;
		val19.handcrafts = new List<RecipeProto> { val18 };
		val19.maincraft = val18;
		val19.recipes = new List<RecipeProto> { val18 };
		val19.makes = new List<RecipeProto>();
		val19.prefabDesc = MethedEx.Copy<PrefabDesc>(val11.prefabDesc);
		val19.prefabDesc.workEnergyPerTick = 120000L;
		val19.prefabDesc.idleEnergyPerTick = 3000L;
		Traverse.Create((object)val19).Field("_iconSprite").SetValue((object)iconBigB);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val18);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val19);
		RecipeProto val20 = MethedEx.Copy<RecipeProto>(val);
		ItemProto val21 = MethedEx.Copy<ItemProto>(val2);
		((Proto)val20).ID = 454;
		((Proto)val20).Name = "化工采矿机C型";
		((Proto)val20).name = Localization.Translate("化工采矿机C型");
		val20.Items = new int[3] { 2301, 1107, 1305 };
		val20.ItemCounts = new int[3] { 1, 20, 5 };
		val20.Results = new int[1] { 9448 };
		val20.ResultCounts = new int[1] { 1 };
		val20.GridIndex = 2612;
		Traverse.Create((object)val20).Field("_iconSprite").SetValue((object)iconC);
		val20.TimeSpend = 60;
		val20.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1303);
		if (EasyMode.Value)
		{
			val20.Items = new int[2] { 2301, 2309 };
			val20.ItemCounts = new int[2] { 1, 5 };
			val20.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1121);
		}
		((Proto)val21).ID = 9448;
		((Proto)val21).Name = "化工采矿机C型";
		((Proto)val21).name = Localization.Translate("化工采矿机C型");
		val21.Description = "化工采矿机C型描述";
		val21.description = Localization.Translate("化工采矿机C型描述");
		val21.BuildIndex = 207;
		val21.GridIndex = 2612;
		val21.handcraft = val20;
		val21.handcrafts = new List<RecipeProto> { val20 };
		val21.maincraft = val20;
		val21.recipes = new List<RecipeProto> { val20 };
		val21.makes = new List<RecipeProto>();
		val21.prefabDesc = MethedEx.Copy<PrefabDesc>(val2.prefabDesc);
		val21.prefabDesc.workEnergyPerTick = 80000L;
		val21.prefabDesc.idleEnergyPerTick = 2000L;
		Traverse.Create((object)val21).Field("_iconSprite").SetValue((object)iconC);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val20);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val21);
		RecipeProto val22 = MethedEx.Copy<RecipeProto>(val10);
		ItemProto val23 = MethedEx.Copy<ItemProto>(val11);
		((Proto)val22).ID = 474;
		((Proto)val22).Name = "大型化工采矿机C型";
		((Proto)val22).name = Localization.Translate("大型化工采矿机C型");
		val22.Items = new int[3] { 2316, 1107, 1305 };
		val22.ItemCounts = new int[3] { 1, 30, 10 };
		val22.Results = new int[1] { 9468 };
		val22.ResultCounts = new int[1] { 1 };
		val22.GridIndex = 2712;
		Traverse.Create((object)val22).Field("_iconSprite").SetValue((object)iconBigC);
		val22.TimeSpend = 60;
		val22.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		if (EasyMode.Value)
		{
			val22.Items = new int[2] { 2316, 2309 };
			val22.ItemCounts = new int[2] { 1, 10 };
			val22.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1304);
		}
		((Proto)val23).ID = 9468;
		((Proto)val23).Name = "大型化工采矿机C型";
		((Proto)val23).name = Localization.Translate("大型化工采矿机C型");
		val23.Description = "大型化工采矿机C型描述";
		val23.description = Localization.Translate("大型化工采矿机C型描述");
		val23.BuildIndex = 210;
		val23.GridIndex = 2712;
		val23.handcraft = val22;
		val23.handcrafts = new List<RecipeProto> { val22 };
		val23.maincraft = val22;
		val23.recipes = new List<RecipeProto> { val22 };
		val23.makes = new List<RecipeProto>();
		val23.prefabDesc = MethedEx.Copy<PrefabDesc>(val11.prefabDesc);
		val23.prefabDesc.workEnergyPerTick = 150000L;
		val23.prefabDesc.idleEnergyPerTick = 3000L;
		Traverse.Create((object)val23).Field("_iconSprite").SetValue((object)iconBigC);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val22);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val23);
		RecipeProto val24 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(15);
		ItemProto val25 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2307);
		RecipeProto val26 = MethedEx.Copy<RecipeProto>(val24);
		ItemProto val27 = MethedEx.Copy<ItemProto>(val25);
		((Proto)val26).ID = 475;
		((Proto)val26).Name = "等离子精炼油井";
		((Proto)val26).name = Localization.Translate("等离子精炼油井");
		val26.Items = new int[3] { 2301, 1401, 1119 };
		val26.ItemCounts = new int[3] { 1, 30, 15 };
		val26.Results = new int[1] { 9469 };
		val26.ResultCounts = new int[1] { 1 };
		val26.GridIndex = 2609;
		Traverse.Create((object)val26).Field("_iconSprite").SetValue((object)iconO);
		val26.TimeSpend = 60;
		val26.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1126);
		if (EasyMode.Value)
		{
			val26.Items = new int[2] { 2307, 2308 };
			val26.ItemCounts = new int[2] { 1, 5 };
			val26.preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1102);
		}
		((Proto)val27).ID = 9469;
		((Proto)val27).Name = "等离子精炼油井";
		((Proto)val27).name = Localization.Translate("等离子精炼油井");
		val27.Description = "等离子精炼油井描述";
		val27.description = Localization.Translate("等离子精炼油井描述");
		val27.BuildIndex = 705;
		val27.GridIndex = 2609;
		val27.handcraft = val26;
		val27.handcrafts = new List<RecipeProto> { val26 };
		val27.maincraft = val26;
		val27.recipes = new List<RecipeProto> { val26 };
		val27.makes = new List<RecipeProto>();
		val27.prefabDesc = MethedEx.Copy<PrefabDesc>(val25.prefabDesc);
		val27.prefabDesc.workEnergyPerTick = 100000L;
		val27.prefabDesc.idleEnergyPerTick = 2500L;
		Traverse.Create((object)val27).Field("_iconSprite").SetValue((object)iconO);
		LDBTool.PostAddProto((ProtoType)6, (Proto)(object)val26);
		LDBTool.PostAddProto((ProtoType)3, (Proto)(object)val27);
		try
		{
			LDBTool.SetBuildBar(2, 5, 9446);
			LDBTool.SetBuildBar(2, 6, 9447);
			LDBTool.SetBuildBar(2, 7, 9448);
			LDBTool.SetBuildBar(2, 8, 9466);
			LDBTool.SetBuildBar(2, 9, 9467);
			LDBTool.SetBuildBar(2, 10, 9468);
		}
		catch (Exception)
		{
		}
		val2.makes = new List<RecipeProto> { val12, val16, val20 };
		val11.makes = new List<RecipeProto> { val14, val18, val22 };
		val25.makes = new List<RecipeProto> { val26 };
		if (!EasyMode.Value)
		{
			val3.makes.Add(val12);
			val3.makes.Add(val16);
			val3.makes.Add(val20);
			val4.makes.Add(val12);
			val4.makes.Add(val16);
			val4.makes.Add(val14);
			val4.makes.Add(val18);
			val4.makes.Add(val26);
			val5.makes.Add(val20);
			val5.makes.Add(val22);
			val6.makes.Add(val26);
		}
		else
		{
			val8.makes.Add(val12);
			val8.makes.Add(val16);
			val9.makes.Add(val20);
			val8.makes.Add(val14);
			val8.makes.Add(val18);
			val9.makes.Add(val22);
			val7.makes.Add(val26);
		}
	}

	private void AddTranslate()
	{
		LocalizationModule.RegisterTranslation("熔炉采矿机A型", "Smelter Mining Machine A", "熔炉采矿机 A型", "Smelter Mining Machine A");
		LocalizationModule.RegisterTranslation("熔炉采矿机A型描述", "Mine minerals then automatically smelt the minerals into primary products (iron ingot, stone brick, copper ingot, etc.) and output them.", "在完成对矿产的采集后,自动将矿物熔炼为一级产物(铁块、石材、铜块等)输出。", "Mine minerals then automatically smelt the minerals into primary products (iron ingot, stone brick, copper ingot, etc.) and output them.");
		LocalizationModule.RegisterTranslation("大型熔炉采矿机A型", "Advanced Smelter Mining Machine A", "大型熔炉采矿机 A型", "Advanced Smelter Mining Machine A");
		LocalizationModule.RegisterTranslation("大型熔炉采矿机A型描述", "Mine minerals then automatically smelt the minerals into primary products (iron ingot, stone brick, copper ingot, etc.) and output them.", "在完成对矿产的采集后,自动将矿物熔炼为一级产物(铁块、石材、铜块等)输出。", "Mine minerals then automatically smelt the minerals into primary products (iron ingot, stone brick, copper ingot, etc.) and output them.");
	}

	private void AddTranslate2()
	{
		LocalizationModule.RegisterTranslation("熔炉采矿机B型", "Smelter Mining Machine B", "熔炉采矿机 B型", "Smelter Mining Machine B");
		LocalizationModule.RegisterTranslation("熔炉采矿机B型描述", "Mine minerals then automatically smelt the minerals into primary products (magnet, glass, copper ingot, etc.) and output them.", "在完成对矿产的采集后,自动将矿物熔炼为一级产物(磁铁、玻璃、铜块等)输出。", "Mine minerals then automatically smelt the minerals into primary products (magnet, glass, copper ingot, etc.) and output them.");
		LocalizationModule.RegisterTranslation("大型熔炉采矿机B型", "Advanced Smelter Mining Machine B", "大型熔炉采矿机 B型", "Advanced Smelter Mining Machine B");
		LocalizationModule.RegisterTranslation("大型熔炉采矿机B型描述", "Mine minerals then automatically smelt the minerals into primary products (magnet, glass, copper ingot, etc.) and output them.", "在完成对矿产的采集后,自动将矿物熔炼为一级产物(磁铁、玻璃、铜块等)输出。", "Mine minerals then automatically smelt the minerals into primary products (magnet, glass, copper ingot, etc.) and output them.");
	}

	private void AddTranslate3()
	{
		LocalizationModule.RegisterTranslation("化工采矿机C型", "Smelter Mining Machine B", "化工采矿机 C型", "Smelter Mining Machine B");
		LocalizationModule.RegisterTranslation("化工采矿机C型描述", "Mine fire ice, output graphene. Mine spiniform stalagmite crystal, output carbon nanotube.", "采集可燃冰输出石墨烯(氢气会被浪费),采集刺笋晶体输出碳纳米管。", "Mine fire ice, output graphene. Mine spiniform stalagmite crystal, output carbon nanotube.");
		LocalizationModule.RegisterTranslation("大型化工采矿机C型", "Advanced Smelter Mining Machine B", "大型化工采矿机 C型", "Advanced Smelter Mining Machine B");
		LocalizationModule.RegisterTranslation("大型化工采矿机C型描述", "Mine fire ice, output graphene. Mine spiniform stalagmite crystal, output carbon nanotube.", "采集可燃冰输出石墨烯(氢气会被浪费),采集刺笋晶体输出碳纳米管。", "Mine fire ice, output graphene. Mine spiniform stalagmite crystal, output carbon nanotube.");
	}

	private void AddTranslate4()
	{
		LocalizationModule.RegisterTranslation("等离子精炼油井", "Refinery Oil Extractor", "等离子精炼油井", "Refinery Oil Extractor");
		LocalizationModule.RegisterTranslation("等离子精炼油井描述", "Extract crude oil and output the refined oil directly (Hydrogen will be wasted).", "采集原油并直接产出精炼油(氢气会被浪费)。", "Extract crude oil and output the refined oil directly (Hydrogen will be wasted).");
	}
}