Decompiled source of FusionForge v0.9.0

FusionForge.dll

Decompiled 3 months ago
using System;
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 BepInEx;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
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("Fusion Forge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Fusion Forge")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("44c01306-d800-40ad-9fba-08e9625d6237")]
[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 kremnev8
{
	public class Registry
	{
		public static Dictionary<int, ItemProto> items = new Dictionary<int, ItemProto>();

		private static Dictionary<int, int> itemUpgradeList = new Dictionary<int, int>();

		public static Dictionary<int, RecipeProto> recipes = new Dictionary<int, RecipeProto>();

		public static Dictionary<int, StringProto> strings = new Dictionary<int, StringProto>();

		public static Dictionary<int, TechProto> techs = new Dictionary<int, TechProto>();

		public static Dictionary<int, TechProto> techUpdateList = new Dictionary<int, TechProto>();

		public static Dictionary<int, ModelProto> models = new Dictionary<int, ModelProto>();

		public static Dictionary<string, Material[]> modelMats = new Dictionary<string, Material[]>();

		public static AssetBundle bundle;

		public static string vertaFolder = "";

		public static string keyWord = "";

		public static ManualLogSource LogSource;

		public static Action onLoadingFinished;

		private static int[] textureNames;

		public static void Init(string bundleName, string keyword, bool requireBundle, bool requireVerta)
		{
			LogSource = Logger.CreateLogSource("Registry-" + keyword);
			keyWord = keyword;
			string directoryName = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Registry)).Location);
			int num = Shader.PropertyToID("_MainTex");
			int num2 = Shader.PropertyToID("_NormalTex");
			int num3 = Shader.PropertyToID("_MS_Tex");
			int num4 = Shader.PropertyToID("_EmissionTex");
			textureNames = new int[4] { num, num2, num3, num4 };
			FileInfo fileInfo = new FileInfo(directoryName + "/Verta/");
			FileInfo fileInfo2 = new FileInfo(directoryName + "/plugins/");
			if (Directory.Exists(fileInfo.Directory?.FullName))
			{
				vertaFolder = directoryName;
			}
			else if (Directory.Exists(fileInfo2.Directory?.FullName))
			{
				vertaFolder = directoryName + "/plugins";
			}
			else if (requireVerta)
			{
				vertaFolder = "";
				LogSource.LogError((object)"Cannot find folder with verta files. Mod WILL not work!");
				return;
			}
			if (requireBundle)
			{
				bundle = AssetBundle.LoadFromFile(directoryName + "/" + bundleName);
			}
			LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(onPostAdd));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(EditProto));
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}

		private static void onPostAdd()
		{
			foreach (KeyValuePair<int, ModelProto> model in models)
			{
				model.Value.Preload();
				PrefabDesc prefabDesc = model.Value.prefabDesc;
				Material[] materials = prefabDesc.materials;
				for (int i = 0; i < prefabDesc.lodCount; i++)
				{
					for (int j = 0; j < prefabDesc.lodMaterials[i].Length; j++)
					{
						prefabDesc.lodMaterials[i][j] = materials[j];
					}
				}
				LDB.models.modelArray[((Proto)model.Value).ID] = model.Value;
			}
			foreach (KeyValuePair<int, ItemProto> item in items)
			{
				item.Value.Preload(item.Value.index);
			}
			foreach (KeyValuePair<int, RecipeProto> recipe in recipes)
			{
				recipe.Value.Preload(recipe.Value.index);
			}
			foreach (KeyValuePair<int, TechProto> tech in techs)
			{
				tech.Value.Preload();
				tech.Value.Preload2();
			}
			foreach (KeyValuePair<int, TechProto> techUpdate in techUpdateList)
			{
				TechProto val = ((ProtoSet<TechProto>)(object)LDB.techs).Select(techUpdate.Key);
				val.postTechArray = CollectionExtensions.AddToArray<TechProto>(val.postTechArray, techUpdate.Value);
			}
			onLoadingFinished?.Invoke();
			LogSource.LogInfo((object)"Post loading is complete!");
		}

		private static void EditProto(Proto proto)
		{
			ItemProto val = (ItemProto)(object)((proto is ItemProto) ? proto : null);
			if (val == null)
			{
				return;
			}
			if (itemUpgradeList.ContainsKey(((Proto)val).ID))
			{
				val.Grade = itemUpgradeList[((Proto)val).ID];
				LogSource.LogDebug((object)("Changing grade of " + ((Proto)val).name));
			}
			if (val.Grade == 0 || items.ContainsKey(((Proto)val).ID))
			{
				return;
			}
			foreach (KeyValuePair<int, ItemProto> item in items)
			{
				if (item.Value.Grade != 0 && item.Value.Upgrades != null && val.Grade <= item.Value.Upgrades.Length && item.Value.Upgrades[val.Grade - 1] == ((Proto)val).ID)
				{
					val.Upgrades = item.Value.Upgrades;
					LogSource.LogDebug((object)("Updating upgrade list of " + ((Proto)val).name));
				}
			}
		}

		private static int findAvailableID<T>(int startIndex, ProtoSet<T> set, Dictionary<int, T> list) where T : Proto
		{
			int i;
			for (i = startIndex; set.dataIndices.ContainsKey(i) || list.ContainsKey(i); i++)
			{
				if (i > 12000)
				{
					LogSource.LogError((object)"Failed to find free index!");
					throw new ArgumentException("No free indices available!");
				}
			}
			return i;
		}

		public static Material CreateMaterial(string shaderName, string materialName, string color, string[] textures = null, string[] keywords = null)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = default(Color);
			ColorUtility.TryParseHtmlString(color, ref color2);
			Material val = new Material(Shader.Find(shaderName));
			val.shaderKeywords = keywords ?? new string[1] { "_ENABLE_VFINST" };
			val.color = color2;
			((Object)val).name = materialName;
			Material val2 = val;
			if (textures == null)
			{
				return val2;
			}
			for (int i = 0; i < textures.Length; i++)
			{
				if (i < textureNames.Length)
				{
					Texture2D val3 = Resources.Load<Texture2D>(textures[i]);
					val2.SetTexture(textureNames[i], (Texture)(object)val3);
				}
			}
			return val2;
		}

		public static ModelProto registerModel(int id, ItemProto proto, string prefabPath, Material[] mats, int[] descFields, int buildIndex, int grade = 0, int[] upgradesIDs = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ModelProto val = new ModelProto
			{
				Name = id.ToString(),
				PrefabPath = prefabPath,
				ID = id
			};
			proto.Type = (EItemType)6;
			proto.ModelIndex = id;
			proto.ModelCount = 1;
			proto.BuildIndex = buildIndex;
			proto.BuildMode = 1;
			proto.IsEntity = true;
			proto.CanBuild = true;
			proto.DescFields = descFields;
			if (grade != 0 && upgradesIDs != null)
			{
				proto.Grade = grade;
				for (int i = 0; i < upgradesIDs.Length; i++)
				{
					int num = upgradesIDs[i];
					if (num != 0)
					{
						itemUpgradeList.Add(num, i + 1);
					}
				}
				upgradesIDs[grade - 1] = ((Proto)proto).ID;
				proto.Upgrades = upgradesIDs;
			}
			LDBTool.PreAddProto((ProtoType)4, (Proto)(object)val);
			models.Add(((Proto)val).ID, val);
			modelMats.Add(prefabPath, mats);
			return val;
		}

		public static ItemProto registerItem(int id, string name, string description, string iconPath, int gridIndex, int stackSize = 50)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			ItemProto val = new ItemProto();
			val.Type = (EItemType)2;
			val.StackSize = stackSize;
			val.FuelType = 0;
			val.IconPath = iconPath;
			((Proto)val).Name = name;
			val.Description = description;
			val.GridIndex = gridIndex;
			val.DescFields = new int[1] { 1 };
			((Proto)val).ID = id;
			ItemProto val2 = val;
			LDBTool.PreAddProto((ProtoType)3, (Proto)(object)val2);
			items.Add(((Proto)val2).ID, val2);
			return val2;
		}

		public static RecipeProto registerRecipe(int id, ERecipeType type, int time, int[] input, int[] inCounts, int[] output, int[] outCounts, string description, int techID = 0)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			if (output.Length != 0)
			{
				ItemProto val = (items.ContainsKey(output[0]) ? items[output[0]] : ((ProtoSet<ItemProto>)(object)LDB.items).Select(output[0]));
				TechProto preTech = null;
				if (techID != 0 && ((ProtoSet<TechProto>)(object)LDB.techs).Exist(techID))
				{
					preTech = ((ProtoSet<TechProto>)(object)LDB.techs).Select(techID);
				}
				RecipeProto val2 = new RecipeProto
				{
					Type = type,
					Handcraft = true,
					TimeSpend = time,
					Items = input,
					ItemCounts = inCounts,
					Results = output,
					ResultCounts = outCounts,
					Description = description,
					GridIndex = val.GridIndex,
					IconPath = val.IconPath,
					Name = ((Proto)val).Name + "Recipe",
					preTech = preTech,
					ID = id
				};
				LDBTool.PreAddProto((ProtoType)6, (Proto)(object)val2);
				recipes.Add(id, val2);
				return val2;
			}
			throw new ArgumentException("Output array must not be empty");
		}

		public static TechProto registerTech(int id, string name, string description, string conclusion, string iconPath, int[] preTechs, int[] jellos, int[] jelloRate, long hashNeeded, int[] unlockRecipes, Vector2 position)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			bool isLabTech = jellos.Any((int itemId) => LabComponent.matrixIds.Contains(itemId));
			TechProto val = new TechProto();
			((Proto)val).ID = id;
			((Proto)val).Name = name;
			val.Desc = description;
			val.Published = true;
			val.Conclusion = conclusion;
			val.IconPath = iconPath;
			val.IsLabTech = isLabTech;
			val.PreTechs = preTechs;
			val.Items = jellos;
			val.ItemPoints = jelloRate;
			val.HashNeeded = hashNeeded;
			val.UnlockRecipes = unlockRecipes;
			val.AddItems = new int[0];
			val.AddItemCounts = new int[0];
			val.Position = position;
			val.PreTechsImplicit = new int[0];
			val.UnlockFunctions = new int[0];
			val.UnlockValues = new double[0];
			TechProto val2 = val;
			foreach (int key in preTechs)
			{
				techUpdateList.Add(key, val2);
			}
			LDBTool.PreAddProto((ProtoType)8, (Proto)(object)val2);
			techs.Add(id, val2);
			return val2;
		}

		public static void registerString(string key, string enTrans)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			int num = findAvailableID<StringProto>(100, (ProtoSet<StringProto>)(object)LDB.strings, strings);
			StringProto val = new StringProto
			{
				Name = key,
				ENUS = enTrans,
				ID = num
			};
			LDBTool.PreAddProto((ProtoType)7, (Proto)(object)val);
			strings.Add(num, val);
		}
	}
	[HarmonyPatch(typeof(UIBuildMenu), "StaticLoad")]
	internal static class UIBuildMenuPatch
	{
		[HarmonyPostfix]
		public static void Postfix(ItemProto[,] ___protos)
		{
			foreach (KeyValuePair<int, ItemProto> item in Registry.items)
			{
				int buildIndex = item.Value.BuildIndex;
				if (buildIndex > 0)
				{
					int num = buildIndex / 100;
					int num2 = buildIndex % 100;
					if (num <= 12 && num2 <= 12)
					{
						___protos[num, num2] = item.Value;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StorageComponent), "LoadStatic")]
	internal static class StorageComponentPatch
	{
		private static bool staticLoad;

		[HarmonyPostfix]
		public static void Postfix()
		{
			if (staticLoad)
			{
				return;
			}
			foreach (KeyValuePair<int, ItemProto> item in Registry.items)
			{
				StorageComponent.itemIsFuel[item.Key] = item.Value.HeatValue > 0;
				StorageComponent.itemStackCount[item.Key] = item.Value.StackSize;
			}
			staticLoad = true;
		}
	}
	[HarmonyPatch(typeof(Resources), "Load", new Type[]
	{
		typeof(string),
		typeof(Type)
	})]
	internal static class ResourcesPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(ref string path, Type systemTypeInstance, ref Object __result)
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (path.Contains(Registry.keyWord) && (Object)(object)Registry.bundle != (Object)null)
			{
				if (Registry.bundle.Contains(path + ".prefab") && systemTypeInstance == typeof(GameObject))
				{
					Material[] array = Registry.modelMats[path];
					Object val = Registry.bundle.LoadAsset(path + ".prefab");
					if (val != (Object)null)
					{
						Registry.LogSource.LogDebug((object)("Loading known asset " + path + " (" + ((val != (Object)null) ? "Success" : "Failure") + ")"));
						MeshRenderer[] componentsInChildren = ((GameObject)val).GetComponentsInChildren<MeshRenderer>();
						MeshRenderer[] array2 = componentsInChildren;
						foreach (MeshRenderer val2 in array2)
						{
							Material[] array3 = (Material[])(object)new Material[((Renderer)val2).sharedMaterials.Length];
							for (int j = 0; j < array3.Length; j++)
							{
								array3[j] = array[j];
							}
							((Renderer)val2).sharedMaterials = array3;
						}
					}
					__result = val;
					return false;
				}
				if (Registry.bundle.Contains(path + ".png"))
				{
					Object val3 = Registry.bundle.LoadAsset(path + ".png", systemTypeInstance);
					Registry.LogSource.LogDebug((object)("Loading known asset " + path + " (" + ((val3 != (Object)null) ? "Success" : "Failure") + ")"));
					__result = val3;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(VertaBuffer), "LoadFromFile")]
	internal static class VertaBufferPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(ref string filename)
		{
			if (filename.Contains(Registry.keyWord) && !Registry.vertaFolder.Equals(""))
			{
				string text = Registry.vertaFolder + "/" + filename;
				if (File.Exists(text))
				{
					filename = text;
					Registry.LogSource.LogDebug((object)("Loading known verta file " + filename));
				}
			}
			return true;
		}
	}
}
namespace FusionForge
{
	[BepInPlugin("mod.jamesfire.FusionForge", "FusionForge Plug-In", "1.1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "UtilSystem" })]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("DSPGAME.exe")]
	public class FusionForge : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"FusionForge initializing 1.1");
			ProtoRegistry.RegisterString("FusionTech", "Advanced Fusion");
			ProtoRegistry.RegisterString("FusionTechDesc", "Utilizing information and methods learned from Antimatter containment, we can create powerful and efficient fusion devices.");
			ProtoRegistry.RegisterString("FusionTechConc", "Now we can make a fully fledged Fusion Forge. It is capable of fusing raw materials very quickly, as well as more mundane Particle Collider recipes.");
			ProtoRegistry.RegisterString("FusionForge", "Fusion Forge");
			ProtoRegistry.RegisterString("FusionForgeDesc", "With advanced gravity and electromagnetic manipulation technology, this device can easily fuse pure materials. It is also capable of more mundane Particle Collider recipes.");
			ProtoRegistry.RegisterString("IronFusion", "Iron Ingot Fusion");
			ProtoRegistry.RegisterString("IronFusionDesc", "Fusing pure iron ingots from deuterium is a long process, due to being the Iron Peak of fusion.");
			ProtoRegistry.RegisterString("CopperFusion", "Copper Ingot Fusion");
			ProtoRegistry.RegisterString("CopperFusionDesc", "Fusing pure copper ingots from deuterium is a long process, due to copper being past the Iron Peak.");
			ProtoRegistry.RegisterString("CoalFusion", "Coal Fusion");
			ProtoRegistry.RegisterString("CoalFusionDesc", "Carbon is fairly easy to produce by way of fusion, if you have the right equipment.");
			ProtoRegistry.RegisterString("MagnetFusion", "Magnet Fusion");
			ProtoRegistry.RegisterString("MagnetFusionDesc", "Fusing pure iron ingots from deuterium is a long process, due to being the Iron Peak of fusion.");
			ProtoRegistry.RegisterString("SiliconFusion", "Silicon Ingot Fusion");
			ProtoRegistry.RegisterString("SiliconFusionDesc", "Silicon is a medium difficulty fusion product, but is still doable with some time.");
			ProtoRegistry.RegisterString("TitaniumFusion", "Titanium Ingot Fusion");
			ProtoRegistry.RegisterString("TitaniumFusionDesc", "Titanium fusion production is difficult, but less so than iron or copper.");
			ProtoRegistry.RegisterString("StoneFusion", "Stone Fusion");
			ProtoRegistry.RegisterString("StoneFusionDesc", "An amourphous solid, made up of several elements, stone is still a fusable material.");
			ProtoRegistry.RegisterString("OrganicFusion", "Organic Crystal Fusion");
			ProtoRegistry.RegisterString("OrganicFusionDesc", "Fusing Organic Crystal is complicated, due to the crystal structure present.");
			ProtoRegistry.RegisterString("OpticalFusion", "Optical Grating Crystal Fusion");
			ProtoRegistry.RegisterString("OpticalFusionDesc", "Fusing Optical Grating Crystal is possible, but requires care to get the correct surface features.");
			ProtoRegistry.RegisterString("FireFusion", "Fire Ice Fusion");
			ProtoRegistry.RegisterString("FireFusionDesc", "Fire Ice is fairly easy to produce by way of fusion, if you have the right equipment.");
			ProtoRegistry.RegisterString("SpinoFusion", "Spinoform Stalagmite Crystal Fusion");
			ProtoRegistry.RegisterString("SpinoFusionDesc", "Spinoform Stalagmite Crystal is fairly easy to produce by way of fusion, if you have the right equipment.");
			ProtoRegistry.RegisterString("FractalFusion", "Fractal Silicon Fusion");
			ProtoRegistry.RegisterString("FractalFusionDesc", "Fractal Silicon is a medium difficulty fusion product, but is still doable with some time.");
			ProtoRegistry.RegisterString("KimberFusion", "Kimberlite Ore Fusion");
			ProtoRegistry.RegisterString("KimberFusionDesc", "Kimberlite Ore fusion production is difficult, but less so than iron or copper.");
			ProtoRegistry.RegisterString("UnipolarFusion", "Unipolar Magnet Fusion");
			ProtoRegistry.RegisterString("UnipolarFusionDesc", "Unipolar Magnets have special magnetic properties that make them difficult to fuse, but they are still a fusable material.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Making Forge tech");
			TechProto val = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1144);
			TechProto val2 = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1704);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Making Forging Recipes");
			double num = 60.0;
			double num2 = 10.0;
			double x = 2.0;
			double num3 = 1.1;
			int digits = 0;
			double num4 = 2.27;
			double num5 = 12.0;
			int num6 = 1144;
			double num7 = 1.41;
			double num8 = 7.87;
			double num9 = 55.0;
			int num10 = (int)Math.Ceiling(num9 / num5 * (num8 / num4));
			int num11 = (int)Math.Ceiling(num9 / num5 * (num8 % num4 * num7));
			int num12 = (int)Math.Round(num * Math.Pow(x, (num9 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num13 = 8.96;
			double num14 = 63.0;
			int num15 = (int)Math.Ceiling(num14 / num5 * (num13 / num4));
			int num16 = (int)Math.Ceiling(num14 / num5 * (num13 % num4 * num7));
			int num17 = (int)Math.Round(num * Math.Pow(x, (num14 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num18 = 1.0;
			double num19 = 15.0;
			int num20 = (int)Math.Ceiling(num19 / 2.0 * (num18 / num7 * num7));
			int num21 = (int)Math.Round(num * Math.Pow(x, (num19 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num22 = 2.33;
			double num23 = 28.0;
			int num24 = (int)Math.Ceiling(num23 / num5 * (num22 / num4));
			int num25 = (int)Math.Ceiling(num23 / num5 * (num22 % num4 * num7));
			int num26 = (int)Math.Round(num * Math.Pow(x, (num23 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num27 = 4.5;
			double num28 = 47.0;
			int num29 = (int)Math.Ceiling(num28 / num5 * (num27 / num4));
			int num30 = (int)Math.Ceiling(num28 / num5 * (num27 % num4 * num7));
			int num31 = (int)Math.Round(num * Math.Pow(x, (num28 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num32 = 2.2;
			double num33 = 22.0;
			int num34 = (int)Math.Ceiling(num33 / num5 * (num32 / num4));
			int num35 = (int)Math.Ceiling(num33 / num5 * (num32 % num4 * num7));
			int num36 = (int)Math.Round(num * Math.Pow(x, (num33 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num37 = (int)Math.Ceiling((num18 * 5.0 + 3.0 + 1.0) * num3);
			double num38 = (int)Math.Ceiling(16.0 * num3);
			int num39 = (int)Math.Ceiling(num38 / num5 * (num37 / num4));
			int num40 = (int)Math.Ceiling(num38 / num5 * (num37 % num4) * num7);
			int num41 = (int)Math.Round(num * Math.Pow(x, (num38 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num42 = (int)Math.Ceiling((num37 + 3.0 * num27) / 8.0);
			double num43 = (int)Math.Ceiling(Math.Max(num38, num28) * num3);
			int num44 = (int)Math.Ceiling(num43 / num5 * (num42 / num4));
			int num45 = (int)Math.Ceiling(num43 / num5 * (num42 % num4) * num7);
			int num46 = (int)Math.Round(num * Math.Pow(x, (num43 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num47 = (int)(Math.Ceiling((num4 * 2.0 + 1.0) / 2.0) * num3);
			double num48 = (int)Math.Ceiling((num5 * 2.0 + 1.0) * num3 / 2.0);
			int num49 = (int)Math.Ceiling(num48 * (num47 / num7));
			int num50 = (int)Math.Round(num * Math.Pow(x, (num48 - 1.0) / num2), digits, MidpointRounding.AwayFromZero);
			double num51 = (int)Math.Ceiling((num27 / 2.0 + num4 * 1.5) / 2.0 / 3.0 * num3);
			double num52 = (int)Math.Ceiling(num28 * num3);
			int num53 = (int)Math.Ceiling(num52 * (num51 / num4) * num7);
			int num54 = (int)Math.Round(num * Math.Pow(x, (num52 - 1.0) / num2), digits, MidpointRounding.AwayFromZero);
			double num55 = (int)Math.Ceiling(num22 / 2.0 * num3);
			double num56 = (int)Math.Ceiling(num23 * num3);
			int num57 = (int)Math.Ceiling(num56 / num5 * (num55 / num4));
			int num58 = (int)Math.Ceiling(num56 / num5 * (num55 % num4) * num7);
			int num59 = (int)Math.Round(num * Math.Pow(x, (num56 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			double num60 = (int)(Math.Ceiling(2.0 * num18) * num3);
			double num61 = (int)Math.Ceiling(num19 * num3);
			int num62 = (int)Math.Ceiling(num61 * (num60 / num7));
			int num63 = (int)Math.Round(num * Math.Pow(x, (num61 - 1.0) / num2), digits, MidpointRounding.AwayFromZero);
			double num64 = (int)Math.Ceiling((num4 * 2.0 + (12.0 * num8 + 3.0 * num13)) / 10.0 / 17.0 * num3);
			double num65 = (int)Math.Ceiling(num14 * num3);
			int num66 = (int)Math.Ceiling(num65 / num5 * (num64 / num4));
			int num67 = (int)Math.Ceiling(num65 * (num64 % num7));
			int num68 = (int)Math.Round(num * Math.Pow(x, (num65 - num5) / num2), digits, MidpointRounding.AwayFromZero);
			ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1101);
			ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1104);
			ItemProto val5 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1006);
			ItemProto val6 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1102);
			ItemProto val7 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1105);
			ItemProto val8 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1106);
			ItemProto val9 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1005);
			ItemProto val10 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1117);
			ItemProto val11 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1014);
			ItemProto val12 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1011);
			ItemProto val13 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1015);
			ItemProto val14 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1013);
			ItemProto val15 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1012);
			ItemProto val16 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1016);
			ProtoRegistry.RegisterRecipe(5003, (ERecipeType)5, num12, new int[2] { 1121, 1123 }, new int[2] { num11, num10 }, new int[1] { 1101 }, new int[1] { 1 }, "IronFusionDesc", num6, 2801, "IronFusion", val3.IconPath);
			ProtoRegistry.RegisterRecipe(5004, (ERecipeType)5, num17, new int[2] { 1121, 1123 }, new int[2] { num16, num15 }, new int[1] { 1104 }, new int[1] { 1 }, "CopperFusionDesc", num6, 2802, "CopperFusion", val4.IconPath);
			ProtoRegistry.RegisterRecipe(5005, (ERecipeType)5, num21, new int[1] { 1121 }, new int[1] { num20 }, new int[1] { 1006 }, new int[1] { 1 }, "CoalFusionDesc", num6, 2803, "CoalFusion", val5.IconPath);
			ProtoRegistry.RegisterRecipe(5006, (ERecipeType)5, num12, new int[2] { 1121, 1123 }, new int[2] { num11, num10 }, new int[1] { 1102 }, new int[1] { 1 }, "MagnetFusionDesc", num6, 2804, "MagnetFusion", val6.IconPath);
			ProtoRegistry.RegisterRecipe(5007, (ERecipeType)5, num26, new int[2] { 1121, 1123 }, new int[2] { num25, num24 }, new int[1] { 1105 }, new int[1] { 1 }, "SiliconFusionDesc", num6, 2805, "SiliconFusion", val7.IconPath);
			ProtoRegistry.RegisterRecipe(5008, (ERecipeType)5, num31, new int[2] { 1121, 1123 }, new int[2] { num30, num29 }, new int[1] { 1106 }, new int[1] { 1 }, "TitaniumFusionDesc", num6, 2806, "TitaniumFusion", val8.IconPath);
			ProtoRegistry.RegisterRecipe(5009, (ERecipeType)5, num36, new int[2] { 1121, 1123 }, new int[2] { num35, num34 }, new int[1] { 1005 }, new int[1] { 1 }, "StoneFusionDesc", num6, 2807, "StoneFusion", val9.IconPath);
			ProtoRegistry.RegisterRecipe(5010, (ERecipeType)5, num41, new int[2] { 1121, 1123 }, new int[2] { num40, num39 }, new int[1] { 1117 }, new int[1] { 1 }, "OrganicFusionDesc", num6, 2808, "OrganicFusion", val10.IconPath);
			ProtoRegistry.RegisterRecipe(5011, (ERecipeType)5, num46, new int[2] { 1121, 1123 }, new int[2] { num45, num44 }, new int[1] { 1014 }, new int[1] { 1 }, "OpticalFusionDesc", num6, 2809, "OpticalFusion", val11.IconPath);
			ProtoRegistry.RegisterRecipe(5012, (ERecipeType)5, num50, new int[1] { 1121 }, new int[1] { num49 }, new int[1] { 1011 }, new int[1] { 1 }, "FireFusionDesc", num6, 2810, "FireFusion", val12.IconPath);
			ProtoRegistry.RegisterRecipe(5013, (ERecipeType)5, num54, new int[1] { 1121 }, new int[1] { num53 }, new int[1] { 1015 }, new int[1] { 1 }, "SpinoFusionDesc", num6, 2811, "SpinoFusion", val13.IconPath);
			ProtoRegistry.RegisterRecipe(5014, (ERecipeType)5, num59, new int[2] { 1121, 1123 }, new int[2] { num58, num57 }, new int[1] { 1013 }, new int[1] { 1 }, "FractalFusionDesc", num6, 2812, "FractalFusion", val14.IconPath);
			ProtoRegistry.RegisterRecipe(5015, (ERecipeType)5, num63, new int[1] { 1121 }, new int[1] { num62 }, new int[1] { 1012 }, new int[1] { 1 }, "KimberFusionDesc", num6, 2813, "KimberFusion", val15.IconPath);
			ProtoRegistry.RegisterRecipe(5016, (ERecipeType)5, num68, new int[2] { 1121, 1123 }, new int[2] { num67, num66 }, new int[1] { 1016 }, new int[1] { 1 }, "UnipolarFusionDesc", num6, 2814, "UnipolarFusion", val16.IconPath);
			LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(OnPostAdd));
		}

		private void OnPostAdd()
		{
			ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1101);
			ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1104);
			ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1006);
			ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1102);
			ItemProto val5 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1105);
			ItemProto val6 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1106);
			ItemProto val7 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1005);
			ItemProto val8 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1117);
			ItemProto val9 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1014);
			ItemProto val10 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1011);
			ItemProto val11 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1015);
			ItemProto val12 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1013);
			ItemProto val13 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1012);
			ItemProto val14 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(1016);
			RecipeProto item = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5003);
			RecipeProto item2 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5004);
			RecipeProto item3 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5005);
			RecipeProto item4 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5006);
			RecipeProto item5 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5007);
			RecipeProto item6 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5008);
			RecipeProto item7 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5009);
			RecipeProto item8 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5010);
			RecipeProto item9 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5011);
			RecipeProto item10 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5012);
			RecipeProto item11 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5013);
			RecipeProto item12 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5014);
			RecipeProto item13 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5015);
			RecipeProto item14 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(5016);
			val.recipes.Add(item);
			val2.recipes.Add(item2);
			val3.recipes.Add(item4);
			val4.recipes.Add(item3);
			val5.recipes.Add(item5);
			val6.recipes.Add(item6);
			val7.recipes.Add(item7);
			val8.recipes.Add(item8);
			val9.recipes.Add(item9);
			val10.recipes.Add(item10);
			val11.recipes.Add(item11);
			val12.recipes.Add(item12);
			val13.recipes.Add(item13);
			val14.recipes.Add(item14);
		}
	}
}