Decompiled source of CustomCreateBirthStar v1.3.4

CustomCreateBirthStar.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomCreateBirthStar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomCreateBirthStar")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb70a84a-aebb-48e9-849f-0254338582c0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomCreateBirthStar;

internal class ItemConfig
{
	public class PowerCoreCfg
	{
		public const long PowerCoreMaxEnergy = 1200000000000L;

		public const long ExchangeEnergyPerTick = 400000000L;
	}
}
internal class ItemManage
{
	private static TechProto NewTechProto0;

	private static TechProto NewTechProto1;

	public static void AddString()
	{
		LocalizationModule.RegisterTranslation("星际能量枢纽MK2", "Planetary Energy Hub MK2", "行星能量枢纽 MK2", "Planetary Energy Hub MK2");
		LocalizationModule.RegisterTranslation("星际能量枢纽MK2_描述", "One of the technologies of ancient civilizations uses the planetary ionosphere and drone relay stations around the world to expand the range of wireless power transmission. Warning: There are still flaws in the reverse engineering technology. If the system is destroyed, it may trigger a planetary electromagnetic pulse.", "古文明技术之一,利用行星电离层与遍布全球的无人机中继站扩大无线输电范围。警告:逆向技术尚存在缺陷,系统被摧毁时可能引发行星级电磁脉冲。", "One of the technologies of ancient civilizations uses the planetary ionosphere and drone relay stations around the world to expand the range of wireless power transmission. Warning: There are still flaws in the reverse engineering technology. If the system is destroyed, it may trigger a planetary electromagnetic pulse.");
		LocalizationModule.RegisterTranslation("能量核心", "PowerCore", "能量核心", "PowerCore");
		LocalizationModule.RegisterTranslation("能量核心_描述", "One of the technologies of ancient civilizations, using the mass effect field produced by strange matter, can store a large amount of energy! Warning: There are still flaws in the reverse technology, please do not charge the mass field beyond the Chandrasekhar limit.", "古文明技术之一,利用奇异物质产生的质量效应场,可以存储大量能量!警告:逆向技术尚存在缺陷,对质量场的充能请勿超过钱德拉塞卡极限。", "One of the technologies of ancient civilizations, using the mass effect field produced by strange matter, can store a large amount of energy! Warning: There are still flaws in the reverse technology, please do not charge the mass field beyond the Chandrasekhar limit.");
		LocalizationModule.RegisterTranslation("能量核心满", "PowerCore", "能量核心(满)", "PowerCore");
		LocalizationModule.RegisterTranslation("能量核心满_描述", "One of the technologies of ancient civilizations, using the mass effect field produced by strange matter, can store a large amount of energy! Warning: There are still flaws in the reverse technology, please do not charge the mass field beyond the Chandrasekhar limit.", "古文明技术之一,利用奇异物质产生的质量效应场,可以存储大量能量!警告:逆向技术尚存在缺陷,对质量场的充能请勿超过钱德拉塞卡极限。", "One of the technologies of ancient civilizations, using the mass effect field produced by strange matter, can store a large amount of energy! Warning: There are still flaws in the reverse technology, please do not charge the mass field beyond the Chandrasekhar limit.");
		LocalizationModule.RegisterTranslation("星际能量枢纽", "Planetary energy hub", "行星能量枢纽", "Planetary energy hub");
		LocalizationModule.RegisterTranslation("星际能量枢纽_描述", "One of the technologies of ancient civilization, it greatly improves the output power of the energy hub, but the cost is high. It has perfectly reversed the technology of ancient civilizations.", "古文明技术之一,极大得提高了能量枢纽的输出功率,但造价高昂。已经完美逆向了古代文明的技术。", "One of the technologies of ancient civilization, it greatly improves the output power of the energy hub, but the cost is high. It has perfectly reversed the technology of ancient civilizations.");
		LocalizationModule.RegisterTranslation("星际电力传输", "Ancient Civilization Technology - Planetary Power Transmission", "遗落科技 - 行星级电力传输", "Ancient Civilization Technology - Planetary Power Transmission");
		LocalizationModule.RegisterTranslation("星际电力传输_描述", "By reverse engineering the legacy technology of ancient civilizations, we have obtained ancient but still advanced technology (it is said that caches of its prototype technology are scattered at the edge of the star sector closest to the black hole)", "通过对古代文明遗留技术的逆向解析,我们获得了古老但仍然先进的技术(据说在星区边缘离黑洞最近的地方散落着它的原型技术缓存)", "By reverse engineering the legacy technology of ancient civilizations, we have obtained ancient but still advanced technology (it is said that caches of its prototype technology are scattered at the edge of the star sector closest to the black hole)");
		LocalizationModule.RegisterTranslation("行星级无线输电", "Ancient Civilization Technology - Planetary Wireless Power Transmission", "遗落科技 - 行星级无线输电", "Ancient Civilization Technology - Planetary Wireless Power Transmission");
		LocalizationModule.RegisterTranslation("行星级无线输电_描述", "By reverse engineering the legacy technology of ancient civilizations, we have obtained ancient but still advanced technology (it is said that caches of its prototype technology are scattered at the edge of the star sector closest to the black hole)", "通过对古代文明遗留技术的逆向解析,我们获得了古老但仍然先进的技术(据说在星区边缘离黑洞最近的地方散落着它的原型技术缓存)", "By reverse engineering the legacy technology of ancient civilizations, we have obtained ancient but still advanced technology (it is said that caches of its prototype technology are scattered at the edge of the star sector closest to the black hole)");
	}

	public static void AddTech0()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
		int num = 8000;
		string text = "星际电力传输";
		string text2 = "星际电力传输_描述";
		string text3 = "星际电力传输";
		string iconPath = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1512).IconPath;
		int[] preTechs = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).PreTechs;
		int[] array = new int[2] { 9448, 9446 };
		long num2 = 54000L;
		int[] array2 = new int[2]
		{
			(int)(54000 / num2),
			(int)(432000 / num2)
		};
		int[] array3 = new int[3] { 454, 452, 453 };
		Vector2 position = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).Position;
		position.y -= 0f;
		NewTechProto0 = ProtoRegistry.RegisterTech(num, text, text2, text3, iconPath, preTechs, array, array2, num2, array3, position);
		ProtoRegistry.onLoadingFinished += Finished0;
	}

	public static void Finished0()
	{
		IDCNT[] array = (IDCNT[])(object)new IDCNT[1];
		array[0].id = 6006;
		array[0].count = 500000000;
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8000).PropertyItemCounts = new int[1] { 500000000 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8000).PropertyOverrideItems = new int[1] { 6006 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8000).PropertyOverrideItemArray = array;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技添加完成");
	}

	public static void AddTech1()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		int num = 8001;
		string text = "行星级无线输电";
		string text2 = "行星级无线输电_描述";
		string text3 = "行星级无线输电";
		string iconPath = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1512).IconPath;
		int[] preTechs = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).PreTechs;
		int[] array = new int[1] { 9448 };
		long num2 = 720000L;
		int[] array2 = new int[1] { (int)(720000 / num2) };
		int[] array3 = new int[1] { 455 };
		Vector2 position = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).Position;
		position.y -= 4f;
		NewTechProto1 = ProtoRegistry.RegisterTech(num, text, text2, text3, iconPath, preTechs, array, array2, num2, array3, position);
		ProtoRegistry.onLoadingFinished += Finished1;
	}

	public static void Finished1()
	{
		IDCNT[] array = (IDCNT[])(object)new IDCNT[1];
		array[0].id = 6006;
		array[0].count = 500000000;
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8001).PropertyItemCounts = new int[1] { 500000000 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8001).PropertyOverrideItems = new int[1] { 6006 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8001).PropertyOverrideItemArray = array;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技添加完成");
	}
}
internal class ItemPowerCore
{
	private static ItemProto oldItem;

	private static RecipeProto oldRecipe;

	private static ModelProto oldModel;

	private static ItemProto NewItem;

	private static RecipeProto NewRecipe;

	private static ModelProto NewModel;

	public static void AddItem()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		oldItem = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2206);
		oldRecipe = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(76);
		oldModel = ((ProtoSet<ModelProto>)(object)LDB.models).Select(oldItem.ModelIndex);
		string iconPath = oldItem.IconPath;
		int num = 2711;
		NewItem = ProtoRegistry.RegisterItem(9446, "能量核心", "能量核心_描述", iconPath, num, 50, (EItemType)5);
		int num2 = 452;
		ERecipeType type = oldRecipe.Type;
		int num3 = 18000;
		int[] array = new int[3] { 2206, 1107, 1127 };
		int[] array2 = new int[3] { 100, 200, 10 };
		int[] array3 = new int[1] { ((Proto)NewItem).ID };
		int[] array4 = new int[1] { 1 };
		int num4 = 8000;
		NewRecipe = ProtoRegistry.RegisterRecipe(num2, type, num3, array, array2, array3, array4, "能量核心_描述", num4, num, "能量核心", iconPath);
		string prefabPath = oldModel.PrefabPath;
		int[] descFields = oldItem.DescFields;
		int num5 = 0;
		NewModel = ProtoRegistry.RegisterModel(520, NewItem, prefabPath, (Material[])null, descFields, num5);
		ProtoRegistry.onLoadingFinished += Finished;
	}

	private static void Finished()
	{
		NewModel.prefabDesc.maxAcuEnergy = 1200000000000L;
		NewModel.prefabDesc.outputEnergyPerTick = 0L;
		NewModel.prefabDesc.inputEnergyPerTick = 0L;
		NewItem.CanBuild = false;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "原型添加完成");
	}
}
internal class ItemPowerCoreFull
{
	private static ItemProto oldItem;

	private static ModelProto oldModel;

	private static ItemProto NewItem;

	private static ModelProto NewModel;

	private static RecipeProto NewRecipe;

	public static void AddItem()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		oldItem = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2207);
		oldModel = ((ProtoSet<ModelProto>)(object)LDB.models).Select(oldItem.ModelIndex);
		string iconPath = oldItem.IconPath;
		int num = 2712;
		NewItem = ProtoRegistry.RegisterItem(9447, "能量核心满", "能量核心满_描述", iconPath, num, 50, (EItemType)4);
		int num2 = 453;
		ERecipeType val = (ERecipeType)4;
		int num3 = 18000;
		int[] array = new int[2] { 9446, 1802 };
		int[] array2 = new int[2] { 1, 250 };
		int[] array3 = new int[1] { 9447 };
		int[] array4 = new int[1] { 1 };
		int num4 = 8000;
		NewRecipe = ProtoRegistry.RegisterRecipe(num2, val, num3, array, array2, array3, array4, "能量核心满_描述", num4, num, "能量核心满", iconPath);
		string prefabPath = oldModel.PrefabPath;
		int[] descFields = oldItem.DescFields;
		int num5 = 0;
		NewModel = ProtoRegistry.RegisterModel(521, NewItem, prefabPath, (Material[])null, descFields, num5);
		ProtoRegistry.onLoadingFinished += Finished;
	}

	private static void Finished()
	{
		NewModel.prefabDesc.maxAcuEnergy = 1200000000000L;
		NewItem.HeatValue = 1200000000000L;
		NewModel.prefabDesc.outputEnergyPerTick = 0L;
		NewModel.prefabDesc.inputEnergyPerTick = 0L;
		NewItem.CanBuild = false;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "原型添加完成");
	}
}
internal class ItemPowerExchange
{
	private static ItemProto oldItem;

	private static RecipeProto oldRecipe;

	private static ModelProto oldModel;

	private static ItemProto NewItem;

	private static RecipeProto NewRecipe;

	private static ModelProto NewModel;

	public static void AddItem()
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		oldItem = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2209);
		oldRecipe = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(77);
		oldModel = ((ProtoSet<ModelProto>)(object)LDB.models).Select(oldItem.ModelIndex);
		string iconPath = oldItem.IconPath;
		int num = 2709;
		NewItem = ProtoRegistry.RegisterItem(9448, "星际能量枢纽", "星际能量枢纽_描述", iconPath, num, 250, (EItemType)5);
		int num2 = 454;
		ERecipeType type = oldRecipe.Type;
		int num3 = 54000;
		int[] array = new int[5] { 2209, 1403, 1016, 1305, 1111 };
		int[] array2 = new int[5] { 1, 100, 1500, 100, 200 };
		int[] array3 = new int[1] { 9448 };
		int[] array4 = new int[1] { 1 };
		int num4 = 8000;
		NewRecipe = ProtoRegistry.RegisterRecipe(num2, type, num3, array, array2, array3, array4, "星际能量枢纽_描述", num4, num, "星际能量枢纽", iconPath);
		string prefabPath = oldModel.PrefabPath;
		int[] descFields = oldItem.DescFields;
		int num5 = 0;
		NewModel = ProtoRegistry.RegisterModel(522, NewItem, prefabPath, (Material[])null, descFields, num5);
		ProtoRegistry.onLoadingFinished += Finished;
	}

	private static void Finished()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		NewModel.prefabDesc.maxAcuEnergy = 1200000000000L;
		NewModel.prefabDesc.maxExcEnergy = 1200000000000L;
		NewModel.prefabDesc.exchangeEnergyPerTick = 400000000L;
		NewModel.prefabDesc.fullId = 9447;
		NewModel.prefabDesc.emptyId = 9446;
		Material val = Object.Instantiate<Material>(NewModel.prefabDesc.lodMaterials[0][0]);
		val.color = Color.red;
		NewModel.prefabDesc.lodMaterials[0][0] = val;
		NewModel.HpMax = 1500000;
		NewModel.HpRecover = 10000;
		NewItem.HpMax = 1500000;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "原型添加完成");
	}
}
internal class ItemPowerExchangeMK2
{
	private static ItemProto oldItem;

	private static RecipeProto oldRecipe;

	private static ModelProto oldModel;

	private static ItemProto NewItem;

	private static RecipeProto NewRecipe;

	private static ModelProto NewModel;

	public static void AddItem()
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		oldItem = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2209);
		oldRecipe = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(77);
		oldModel = ((ProtoSet<ModelProto>)(object)LDB.models).Select(oldItem.ModelIndex);
		string iconPath = oldItem.IconPath;
		int num = 2710;
		NewItem = ProtoRegistry.RegisterItem(9449, "星际能量枢纽MK2", "星际能量枢纽MK2_描述", iconPath, num, 250, (EItemType)5);
		int num2 = 455;
		ERecipeType type = oldRecipe.Type;
		int num3 = 54000;
		int[] array = new int[5] { 9448, 2212, 1209, 1125, 5001 };
		int[] array2 = new int[5] { 1, 300, 80, 500, 300 };
		int[] array3 = new int[1] { 9449 };
		int[] array4 = new int[1] { 1 };
		int num4 = 8000;
		NewRecipe = ProtoRegistry.RegisterRecipe(num2, type, num3, array, array2, array3, array4, "星际能量枢纽MK2_描述", num4, num, "星际能量枢纽MK2", iconPath);
		string prefabPath = oldModel.PrefabPath;
		int[] descFields = oldItem.DescFields;
		int num5 = 0;
		NewModel = ProtoRegistry.RegisterModel(523, NewItem, prefabPath, (Material[])null, descFields, num5);
		ProtoRegistry.onLoadingFinished += Finished;
	}

	private static void Finished()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		NewModel.prefabDesc.maxAcuEnergy = 1200000000000L;
		NewModel.prefabDesc.maxExcEnergy = 1200000000000L;
		NewModel.prefabDesc.exchangeEnergyPerTick = 400000000L;
		NewModel.prefabDesc.fullId = 9447;
		NewModel.prefabDesc.emptyId = 9446;
		NewModel.prefabDesc.powerCoverRadius = 460f;
		NewModel.prefabDesc.powerConnectDistance = 80f;
		NewModel.prefabDesc.isPowerNode = true;
		Material val = Object.Instantiate<Material>(NewModel.prefabDesc.lodMaterials[0][0]);
		val.color = new Color(1f, 0f, 0f, 0.8f);
		NewModel.prefabDesc.lodMaterials[0][0] = val;
		NewModel.HpMax = 4500000;
		NewModel.HpRecover = 10000;
		NewItem.HpMax = 4500000;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "原型添加完成");
	}
}
internal class myConst
{
	public const int Second = 60;
}
public class ProtoID
{
	public class 配方
	{
		public const int 卫星配电站 = 73;

		public const int 蓄电器 = 76;

		public const int 能量枢纽 = 77;

		public const int 星际物流运输站 = 95;

		public const int 能量核心 = 452;

		public const int 能量核心满 = 453;

		public const int 星际能量枢纽 = 454;

		public const int 星际能量枢纽MK2 = 455;

		public const int 轨道开采站 = 456;
	}

	public class 物品
	{
		public const int  = 1006;

		public const int 原油 = 1007;

		public const int 单极磁石 = 1016;

		public const int 钛合金 = 1107;

		public const int 棱镜 = 1111;

		public const int 框架材料 = 1125;

		public const int 奇异物质 = 1127;

		public const int 引力透镜 = 1209;

		public const int 空间翘曲器 = 1210;

		public const int 量子芯片 = 1305;

		public const int 湮灭约束球 = 1403;

		public const int 氘核燃料罐 = 1802;

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

		public const int 轨道采集器 = 2105;

		public const int 蓄电器 = 2206;

		public const int 蓄电器满 = 2207;

		public const int 能量枢纽 = 2209;

		public const int 卫星配电站 = 2212;

		public const int 抽水站 = 2306;

		public const int 原油萃取站 = 2307;

		public const int 大型采矿机 = 2316;

		public const int 物流运输机 = 5001;

		public const int 黑雾矩阵 = 5201;

		public const int 能量核心 = 9446;

		public const int 能量核心满 = 9447;

		public const int 星际能量枢纽 = 9448;

		public const int 星际能量枢纽MK2 = 9449;

		public const int 轨道开采站 = 9450;
	}

	public class GRID
	{
		public const int 能量核心 = 2711;

		public const int 能量核心满 = 2712;

		public const int 星际能量枢纽 = 2709;

		public const int 星际能量枢纽MK2 = 2710;

		public const int 轨道开采站 = 2704;
	}

	public class BuildID
	{
		public const int 能量核心 = 0;

		public const int 能量核心满 = 0;

		public const int 星际能量枢纽 = 0;

		public const int 星际能量枢纽MK2 = 0;

		public const int 轨道开采站 = 0;
	}

	public class ModelID
	{
		public const int 能量核心 = 520;

		public const int 能量核心满 = 521;

		public const int 星际能量枢纽 = 522;

		public const int 星际能量枢纽MK2 = 523;

		public const int 轨道开采站 = 530;
	}

	public class Tech
	{
		public const int 光子聚束采矿科技 = 1304;

		public const int 行星电离层应用 = 1505;

		public const int 星际电力运输 = 1512;

		public const int 星际物流系统 = 1605;

		public const int 古代技术_星际电力传输 = 8000;

		public const int 古代技术_行星级无线输电 = 8001;

		public const int 黑雾科技_黑雾物流算法 = 8002;
	}

	public class String
	{
		public const string 科技_古文明_星际电力传输 = "星际电力传输";

		public const string 科技_古文明_星际电力传输_描述 = "星际电力传输_描述";

		public const string 科技_古文明_行星级无线输电 = "行星级无线输电";

		public const string 科技_古文明_行星级无线输电_描述 = "行星级无线输电_描述";

		public const string 科技_黑雾物流算法 = "黑雾物流算法";

		public const string 科技_黑雾物流算法_描述 = "黑雾物流算法_描述";

		public const string 物品_星际能量枢纽MK2 = "星际能量枢纽MK2";

		public const string 物品_星际能量枢纽MK2_描述 = "星际能量枢纽MK2_描述";

		public const string 物品_能量核心 = "能量核心";

		public const string 物品_能量核心_描述 = "能量核心_描述";

		public const string 物品_能量核心满 = "能量核心满";

		public const string 物品_能量核心满_描述 = "能量核心满_描述";

		public const string 物品_星际能量枢纽 = "星际能量枢纽";

		public const string 物品_星际能量枢纽_描述 = "星际能量枢纽_描述";
	}
}
internal class ItemStationSolt
{
	public static bool isUnlockTech;

	private static TechProto NewTechProto;

	public static bool IsTechUnlocked()
	{
		return isUnlockTech;
	}

	public static void Create()
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		LocalizationModule.RegisterTranslation("黑雾物流算法", "Darkfog Technology - Darkfog Logistics Algorithm (Experimental)", "黑雾科技 - 黑雾物流算法(实验性)", "Darkfog Technology - Darkfog Logistics Algorithm (Experimental)");
		LocalizationModule.RegisterTranslation("黑雾物流算法_描述", "By studying Darkfog behavior, we optimized the logistics drone group control algorithm. Logistics towers now allow multiple shipments of the same material to be sent and received at the same time. Warning: Since we have not yet fully understood the underlying logic of Darkfog’s large-scale group control, there may be bugs in logistics drones.", "通过研究黑雾行为学,我们优化了物流无人机群控算法。现在,物流塔允许同时收发多个相同物料。警告:由于我们尚未彻底搞懂黑雾大规模群控的底层逻辑,物流无人机可能存在Bug。", "By studying Darkfog behavior, we optimized the logistics drone group control algorithm. Logistics towers now allow multiple shipments of the same material to be sent and received at the same time. Warning: Since we have not yet fully understood the underlying logic of Darkfog’s large-scale group control, there may be bugs in logistics drones.");
		int num = 8002;
		string text = "黑雾物流算法";
		string text2 = "黑雾物流算法_描述";
		string text3 = "黑雾物流算法";
		string iconPath = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1605).IconPath;
		int[] preTechs = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).PreTechs;
		int[] array = new int[1] { 5201 };
		long num2 = 60000L;
		int[] array2 = new int[1] { (int)(108000000 / num2) };
		int[] array3 = new int[0];
		Vector2 position = ((ProtoSet<TechProto>)(object)LDB.techs).Select(1).Position;
		position.y -= 8f;
		NewTechProto = ProtoRegistry.RegisterTech(num, text, text2, text3, iconPath, preTechs, array, array2, num2, array3, position);
		ProtoRegistry.onLoadingFinished += Finished;
	}

	private static void Finished()
	{
		IDCNT[] array = (IDCNT[])(object)new IDCNT[1];
		array[0].id = 6006;
		array[0].count = 500000000;
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8002).PropertyItemCounts = new int[1] { 500000000 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8002).PropertyOverrideItems = new int[1] { 6006 };
		((ProtoSet<TechProto>)(object)LDB.techs).Select(8002).PropertyOverrideItemArray = array;
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技添加完成");
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameHistoryData), "Import")]
	public static void OnGameHistoryData_Import(GameHistoryData __instance, BinaryReader r)
	{
		isUnlockTech = GameMain.history.TechUnlocked(8002);
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技:黑雾物流算法 " + (isUnlockTech ? "已解锁" : "未解锁"));
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameHistoryData), "SetForNewGame")]
	public static void OnGameHistoryData_SetForNewGame(GameHistoryData __instance)
	{
		isUnlockTech = GameMain.history.TechUnlocked(8002);
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技:黑雾物流算法 " + (isUnlockTech ? "已解锁" : "未解锁"));
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameHistoryData), "NotifyTechUnlock")]
	public static void OnGameHistoryData_onTechUnlocked(GameHistoryData __instance, int _techId, int _level, bool _unlockedDirect)
	{
		if (_techId == 8002)
		{
			isUnlockTech = __instance.TechUnlocked(8002);
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "科技:黑雾物流算法 " + (isUnlockTech ? "已解锁" : "未解锁"));
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIStationStorage), "OnItemPickerReturn")]
	public static bool OnItemPickerReturn(UIStationStorage __instance, ItemProto itemProto)
	{
		if (!CustomCreateBirthStarPlugin.NanoTech)
		{
			return true;
		}
		if (!IsTechUnlocked())
		{
			return true;
		}
		if (itemProto == null || __instance.station == null || __instance.index >= __instance.station.storage.Length)
		{
			return false;
		}
		ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)__instance.stationWindow.factory.entityPool[__instance.station.entityId].protoId);
		if (val == null)
		{
			return false;
		}
		int additionStorage = __instance.GetAdditionStorage();
		__instance.stationWindow.transport.SetStationStorage(__instance.station.id, __instance.index, ((Proto)itemProto).ID, val.prefabDesc.stationMaxItemCount + additionStorage, (ELogisticStorage)1, (ELogisticStorage)(__instance.station.isStellar ? 1 : 0), GameMain.mainPlayer);
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(StationComponent), "AddItem")]
	[HarmonyPriority(800)]
	public static bool StationComponentAddItem(StationComponent __instance, ref int itemId, ref int count, ref int inc, ref int __result)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Invalid comparison between Unknown and I4
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Invalid comparison between Unknown and I4
		if (!CustomCreateBirthStarPlugin.NanoTech)
		{
			return true;
		}
		if (!IsTechUnlocked())
		{
			return true;
		}
		__result = 0;
		if (itemId <= 0)
		{
			return false;
		}
		lock (__instance.storage)
		{
			int num = -1;
			int num2 = count;
			count = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = -1;
			for (int i = 0; i < __instance.storage.Length; i++)
			{
				if (((int)__instance.storage[i].localLogic == 2 || (int)__instance.storage[i].remoteLogic == 2) && __instance.storage[i].itemId == itemId)
				{
					num = i;
					num3 = __instance.storage[i].max - __instance.storage[i].count;
					if (num4 < num3)
					{
						num4 = num3;
						num5 = i;
					}
				}
			}
			if (num4 > 0 && num5 > -1)
			{
				__instance.storage[num5].count += num2;
				__instance.storage[num5].inc += inc;
				__result = num2;
			}
			else if (num > -1)
			{
				__instance.storage[num].count += num2;
				__instance.storage[num].inc += inc;
				__result = num2;
			}
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPriority(800)]
	public static bool StationComponentTakeItem2(StationComponent __instance, ref int itemId, ref int count, out int inc)
	{
		inc = 0;
		if (!CustomCreateBirthStarPlugin.NanoTech)
		{
			return true;
		}
		if (!IsTechUnlocked())
		{
			return true;
		}
		int num = -1;
		int num2 = -1;
		int num3 = 0;
		if (itemId > 0 && count > 0)
		{
			lock (__instance.storage)
			{
				for (int i = 0; i < __instance.storage.Length; i++)
				{
					if (__instance.storage[i].itemId == itemId && __instance.storage[i].count > 0)
					{
						if (count <= __instance.storage[i].count)
						{
							num = i;
							num2 = -1;
							break;
						}
						if (num3 < __instance.storage[i].count)
						{
							num3 = __instance.storage[i].count;
							num2 = i;
						}
					}
				}
				if (num > -1)
				{
					itemId = __instance.storage[num].itemId;
					inc = split_inc(ref __instance.storage[num].count, ref __instance.storage[num].inc, count);
					return false;
				}
				if (num2 > -1)
				{
					count = ((count < __instance.storage[num2].count) ? count : __instance.storage[num2].count);
					itemId = __instance.storage[num2].itemId;
					inc = split_inc(ref __instance.storage[num2].count, ref __instance.storage[num2].inc, count);
					return false;
				}
			}
		}
		itemId = 0;
		count = 0;
		inc = 0;
		return false;
	}

	private static int split_inc(ref int n, ref int m, int p)
	{
		if (n == 0)
		{
			return 0;
		}
		int num = m / n;
		int num2 = m - num * n;
		n -= p;
		int num3 = num2 - n;
		int num4 = ((num3 > 0) ? (num * p + num3) : (num * p));
		m -= num4;
		return num4;
	}
}
public static class Stellar4Stars
{
	private const int STAR_ID_GIANT = 2;

	private const int STAR_BLACKHOLE = 3;

	private const int STAR_NEUTRONSTAR = 4;

	private const int STAR_MAINSEQSTAR_O = 5;

	public static void Prepare(ref GalaxyData galaxy, ref VectorLF3 pos, ref int id, ref int seed, ref EStarType needtype, ref ESpectrType needSpectr)
	{
		if (CustomCreateBirthStarPlugin.StarTypePatch)
		{
			switch (id)
			{
			case 2:
				needtype = (EStarType)1;
				needSpectr = (ESpectrType)6;
				break;
			case 3:
				needtype = (EStarType)4;
				needSpectr = (ESpectrType)7;
				break;
			case 4:
				needtype = (EStarType)3;
				needSpectr = (ESpectrType)7;
				break;
			case 5:
				needtype = (EStarType)0;
				needSpectr = (ESpectrType)6;
				break;
			}
		}
	}

	public static void Create(ref StarData __result, int id, int seed)
	{
		if (CustomCreateBirthStarPlugin.StarTypePatch)
		{
			switch (__result.id)
			{
			case 2:
				__result.name = "先知的隐居地";
				__result.habitableRadius /= 2.5f;
				break;
			case 3:
				__result.name = "光之终结";
				break;
			case 4:
				__result.name = "围墙花园";
				break;
			case 5:
				__result.name = "至纯瑰宝";
				break;
			}
		}
	}

	public static bool CreatePlanet(ref double[] ___pGas, ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc)
	{
		if (!CustomCreateBirthStarPlugin.StarTypePatch)
		{
			return true;
		}
		switch (star.id)
		{
		case 2:
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		case 5:
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		default:
			return true;
		}
	}

	public static void CreateStarPlanets(ref double[] ___pGas, ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Invalid comparison between Unknown and I4
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Invalid comparison between Unknown and I4
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Invalid comparison between Unknown and I4
		//IL_0d8e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d94: Invalid comparison between Unknown and I4
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Invalid comparison between Unknown and I4
		//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0876: Unknown result type (might be due to invalid IL or missing references)
		//IL_087c: Invalid comparison between Unknown and I4
		//IL_0929: Unknown result type (might be due to invalid IL or missing references)
		//IL_092f: Invalid comparison between Unknown and I4
		//IL_09be: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c4: Invalid comparison between Unknown and I4
		//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a59: Invalid comparison between Unknown and I4
		//IL_0ae8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aee: Invalid comparison between Unknown and I4
		//IL_0b87: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b8d: Invalid comparison between Unknown and I4
		//IL_10eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_10f1: Expected O, but got Unknown
		//IL_1172: Unknown result type (might be due to invalid IL or missing references)
		//IL_1177: Unknown result type (might be due to invalid IL or missing references)
		//IL_1186: Unknown result type (might be due to invalid IL or missing references)
		//IL_118b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1190: Unknown result type (might be due to invalid IL or missing references)
		//IL_1195: Unknown result type (might be due to invalid IL or missing references)
		//IL_11a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_11b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_11bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_11c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_11c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_11cb: Unknown result type (might be due to invalid IL or missing references)
		DotNet35Random val = new DotNet35Random(star.seed);
		val.Next();
		val.Next();
		val.Next();
		DotNet35Random val2 = new DotNet35Random(val.Next());
		double num = val2.NextDouble();
		double num2 = val2.NextDouble();
		double num3 = val2.NextDouble();
		double num4 = val2.NextDouble();
		double num5 = val2.NextDouble();
		double num6 = val2.NextDouble() * 0.2 + 0.9;
		double num7 = val2.NextDouble() * 0.2 + 0.9;
		DotNet35Random val3 = new DotNet35Random(val.Next());
		AccessTools.Method(typeof(StarGen), "SetHiveOrbitsConditionsTrue", (Type[])null, (Type[])null).Invoke(null, new object[0]);
		if ((int)star.type != 4 && (int)star.type != 3 && (int)star.type != 2)
		{
			if ((int)star.type == 1)
			{
				if (star.id == 2)
				{
					star.planetCount = 8;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					val2.Next();
					val2.Next();
					int num8 = val2.Next();
					int num9 = val2.Next();
					int num10 = val2.Next();
					int num11 = val2.Next();
					num8 = val2.Next();
					num9 = val2.Next();
					star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, 1, 1, true, num8, num9);
					if (num8 > num9)
					{
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 1, 1, 0, false, num8, num9);
						num8 = val2.Next();
						num9 = val2.Next();
						star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 2, 1, 2, 0, false, num8, num9);
						num8 = val2.Next();
						num9 = val2.Next();
						star.planets[3] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 3, 1, 5, 0, false, num8, num9);
					}
					else
					{
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 1, 1, 0, false, num8, num9);
						num8 = val2.Next();
						num9 = val2.Next();
						star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 2, 0, 2, 0, false, num8, num9);
						num8 = val2.Next();
						num9 = val2.Next();
						star.planets[3] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 3, 0, 3, 0, false, num8, num9);
					}
					num8 = val2.Next();
					num9 = val2.Next();
					star.planets[4] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 4, 0, 4, 0, false, num8, num9);
					num10 = val2.Next();
					num11 = val2.Next();
					star.planets[5] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 5, 0, 5, 0, false, num10, num11);
					num10 = val2.Next();
					num11 = val2.Next();
					star.planets[6] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 6, 0, 6, 7, true, num10, num11);
					num10 = val2.Next();
					num11 = val2.Next();
					star.planets[7] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 7, 7, 1, 0, false, num10, num11);
					if (CustomCreateBirthStarPlugin.BirthStarAtOStar.Value)
					{
						CustomCreateBirthStarPlugin.BirthStarId = star.id;
						CustomCreateBirthStarPlugin.BirthPlanetId = star.planets[7].id;
					}
				}
				else if (num < 0.30000001192092896)
				{
					star.planetCount = 1;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					int num12 = val2.Next();
					int num13 = val2.Next();
					int num14 = ((num3 > 0.5) ? 3 : 2);
					star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, num14, 1, false, num12, num13);
				}
				else if (num < 0.800000011920929)
				{
					star.planetCount = 2;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					if (num2 < 0.25)
					{
						int num15 = val2.Next();
						int num16 = val2.Next();
						int num17 = ((num3 > 0.5) ? 3 : 2);
						star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, num17, 1, false, num15, num16);
						int num18 = val2.Next();
						int num19 = val2.Next();
						int num20 = ((num3 > 0.5) ? 4 : 3);
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 0, num20, 2, false, num18, num19);
					}
					else
					{
						int num21 = val2.Next();
						int num22 = val2.Next();
						star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, 3, 1, true, num21, num22);
						int num23 = val2.Next();
						int num24 = val2.Next();
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 1, 1, 1, false, num23, num24);
					}
				}
				else
				{
					star.planetCount = 3;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					if (num2 < 0.15000000596046448)
					{
						int num25 = val2.Next();
						int num26 = val2.Next();
						int num27 = ((num3 > 0.5) ? 3 : 2);
						star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, num27, 1, false, num25, num26);
						int num28 = val2.Next();
						int num29 = val2.Next();
						int num30 = ((num3 > 0.5) ? 4 : 3);
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 0, num30, 2, false, num28, num29);
						int num31 = val2.Next();
						int num32 = val2.Next();
						int num33 = ((num3 > 0.5) ? 5 : 4);
						star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 2, 0, num33, 3, false, num31, num32);
					}
					else if (num2 < 0.75)
					{
						int num34 = val2.Next();
						int num35 = val2.Next();
						int num36 = ((num3 > 0.5) ? 3 : 2);
						star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, num36, 1, false, num34, num35);
						int num37 = val2.Next();
						int num38 = val2.Next();
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 0, 4, 2, true, num37, num38);
						int num39 = val2.Next();
						int num40 = val2.Next();
						star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 2, 2, 1, 1, false, num39, num40);
					}
					else
					{
						int num41 = val2.Next();
						int num42 = val2.Next();
						int num43 = ((num3 > 0.5) ? 4 : 3);
						star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 0, 0, num43, 1, true, num41, num42);
						int num44 = val2.Next();
						int num45 = val2.Next();
						star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 1, 1, 1, 1, false, num44, num45);
						int num46 = val2.Next();
						int num47 = val2.Next();
						star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, 2, 1, 2, 2, false, num46, num47);
					}
				}
			}
			else
			{
				Array.Clear(___pGas, 0, ___pGas.Length);
				if (star.index == 0)
				{
					star.planetCount = 4;
					___pGas[0] = 0.0;
					___pGas[1] = 0.0;
					___pGas[2] = 0.0;
				}
				else if ((int)star.spectr == 0)
				{
					star.planetCount = ((!(num >= 0.1)) ? 1 : ((!(num >= 0.3)) ? 2 : ((num >= 0.8) ? 4 : 3)));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.2;
						___pGas[2] = 0.3;
					}
				}
				else if ((int)star.spectr == 1)
				{
					star.planetCount = ((!(num >= 0.1)) ? 1 : ((!(num >= 0.2)) ? 2 : ((!(num >= 0.7)) ? 3 : ((num >= 0.95) ? 5 : 4))));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.18;
						___pGas[1] = 0.18;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.18;
						___pGas[2] = 0.28;
						___pGas[3] = 0.28;
					}
				}
				else if ((int)star.spectr == 2)
				{
					star.planetCount = ((!(num >= 0.4)) ? 3 : ((num >= 0.9) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.18;
						___pGas[1] = 0.18;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.2;
						___pGas[2] = 0.3;
						___pGas[3] = 0.3;
					}
				}
				else if ((int)star.spectr == 3)
				{
					star.planetCount = ((!(num >= 0.35)) ? 3 : ((num >= 0.8) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.22;
						___pGas[2] = 0.31;
						___pGas[3] = 0.31;
					}
				}
				else if ((int)star.spectr == 4)
				{
					star.planetCount = ((!(num >= 0.3)) ? 3 : ((num >= 0.75) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.1;
						___pGas[1] = 0.28;
						___pGas[2] = 0.3;
						___pGas[3] = 0.35;
					}
				}
				else if ((int)star.spectr == 5)
				{
					star.planetCount = ((!(num >= 0.3)) ? 4 : ((num >= 0.75) ? 6 : 5));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.1;
						___pGas[1] = 0.22;
						___pGas[2] = 0.28;
						___pGas[3] = 0.35;
						___pGas[4] = 0.35;
					}
				}
				else if ((int)star.spectr == 6)
				{
					star.planetCount = ((num >= 0.5) ? 6 : 5);
					___pGas[0] = 0.1;
					___pGas[1] = 0.2;
					___pGas[2] = 0.25;
					___pGas[3] = 0.3;
					___pGas[4] = 0.32;
					___pGas[5] = 0.35;
				}
				else
				{
					star.planetCount = 1;
				}
				star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
				int num48 = 0;
				int num49 = 0;
				int num50 = 0;
				int num51 = 1;
				for (int i = 0; i < star.planetCount; i++)
				{
					int num52 = val2.Next();
					int num53 = val2.Next();
					double num54 = val2.NextDouble();
					double num55 = val2.NextDouble();
					bool flag = false;
					if (num50 == 0)
					{
						num48++;
						if (i < star.planetCount - 1 && num54 < ___pGas[i])
						{
							flag = true;
							if (num51 < 3)
							{
								num51 = 3;
							}
						}
						while (true)
						{
							if (star.index != 0 || num51 != 3)
							{
								int num56 = star.planetCount - i;
								int num57 = 9 - num51;
								if (num57 <= num56)
								{
									break;
								}
								float num58 = (float)num56 / (float)num57;
								float num59 = ((num51 <= 3) ? (Mathf.Lerp(num58, 1f, 0.15f) + 0.01f) : (Mathf.Lerp(num58, 1f, 0.45f) + 0.01f));
								if (val2.NextDouble() < (double)num59)
								{
									break;
								}
								num51++;
								continue;
							}
							flag = true;
							break;
						}
					}
					else
					{
						num49++;
						flag = false;
					}
					star.planets[i] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, i, num50, (num50 == 0) ? num51 : num49, (num50 == 0) ? num48 : num49, flag, num52, num53);
					num51++;
					if (flag)
					{
						num50 = num48;
						num49 = 0;
					}
					if (num49 >= 1 && num55 < 0.8)
					{
						num50 = 0;
						num49 = 0;
					}
				}
			}
		}
		int num60 = 0;
		int num61 = 0;
		int num62 = 0;
		for (int j = 0; j < star.planetCount; j++)
		{
			if ((int)star.planets[j].type == 5)
			{
				num60 = star.planets[j].orbitIndex;
				break;
			}
		}
		for (int k = 0; k < star.planetCount; k++)
		{
			if (star.planets[k].orbitAround == 0)
			{
				num61 = star.planets[k].orbitIndex;
			}
		}
		if (num60 > 0)
		{
			int num63 = num60 - 1;
			bool flag2 = true;
			for (int l = 0; l < star.planetCount; l++)
			{
				if (star.planets[l].orbitAround == 0 && star.planets[l].orbitIndex == num60 - 1)
				{
					flag2 = false;
					break;
				}
			}
			if (flag2 && num4 < 0.2 + (double)num63 * 0.2)
			{
				num62 = num63;
			}
		}
		int num64 = ((!(num5 >= 0.2)) ? (num61 + 3) : ((!(num5 >= 0.4)) ? (num61 + 2) : ((!(num5 >= 0.8)) ? (num61 + 1) : 0)));
		if (num64 != 0 && num64 < 5)
		{
			num64 = 5;
		}
		star.asterBelt1OrbitIndex = num62;
		star.asterBelt2OrbitIndex = num64;
		if (num62 > 0)
		{
			star.asterBelt1Radius = StarGen.orbitRadius[num62] * (float)num6 * star.orbitScaler;
		}
		if (num64 > 0)
		{
			star.asterBelt2Radius = StarGen.orbitRadius[num64] * (float)num7 * star.orbitScaler;
		}
		for (int m = 0; m < star.planetCount; m++)
		{
			PlanetData val4 = star.planets[m];
			AccessTools.Method(typeof(StarGen), "SetHiveOrbitConditionFalse", (Type[])null, (Type[])null).Invoke(null, new object[4]
			{
				val4.orbitIndex,
				(val4.orbitAroundPlanet != null) ? val4.orbitAroundPlanet.orbitIndex : 0,
				val4.sunDistance / star.orbitScaler,
				star.index
			});
		}
		star.hiveAstroOrbits = (AstroOrbitData[])(object)new AstroOrbitData[8];
		AstroOrbitData[] hiveAstroOrbits = star.hiveAstroOrbits;
		int num65 = 0;
		for (int n = 0; n < StarGen.hiveOrbitCondition.Length; n++)
		{
			if (StarGen.hiveOrbitCondition[n])
			{
				num65++;
			}
		}
		for (int num66 = 0; num66 < 8; num66++)
		{
			double value = val3.NextDouble() * 2.0 - 1.0;
			double num67 = val3.NextDouble();
			double num68 = val3.NextDouble();
			double num69 = (double)Math.Sign(value) * Math.Pow(Math.Abs(value), 0.7) * 90.0;
			double num70 = num67 * 360.0;
			double num71 = num68 * 360.0;
			float num72 = 0.3f;
			Assert.Positive(num65);
			if (num65 > 0)
			{
				int num73 = ((star.index != 0) ? 5 : 2);
				int num74 = ((num65 > num73) ? num73 : num65) * 100;
				int num75 = num74 * 100;
				int num76 = val3.Next(num74);
				int num77 = num76 * num76 / num75;
				for (int num78 = 0; num78 < StarGen.hiveOrbitCondition.Length; num78++)
				{
					if (StarGen.hiveOrbitCondition[num78])
					{
						if (num77 == 0)
						{
							num72 = StarGen.hiveOrbitRadius[num78];
							StarGen.hiveOrbitCondition[num78] = false;
							num65--;
							break;
						}
						num77--;
					}
				}
			}
			hiveAstroOrbits[num66] = new AstroOrbitData();
			hiveAstroOrbits[num66].orbitRadius = num72 * star.orbitScaler;
			hiveAstroOrbits[num66].orbitInclination = (float)num69;
			hiveAstroOrbits[num66].orbitLongitude = (float)num70;
			hiveAstroOrbits[num66].orbitPhase = (float)num71;
			hiveAstroOrbits[num66].orbitalPeriod = Math.Sqrt(39.47841760435743 * (double)num72 * (double)num72 * (double)num72 / (1.3538551990520382E-06 * (double)star.mass));
			hiveAstroOrbits[num66].orbitRotation = Quaternion.AngleAxis(hiveAstroOrbits[num66].orbitLongitude, Vector3.up) * Quaternion.AngleAxis(hiveAstroOrbits[num66].orbitInclination, Vector3.forward);
			AstroOrbitData obj = hiveAstroOrbits[num66];
			VectorLF3 val5 = Maths.QRotateLF(hiveAstroOrbits[num66].orbitRotation, new VectorLF3(0f, 1f, 0f));
			obj.orbitNormal = ((VectorLF3)(ref val5)).normalized;
		}
	}

	public static void AddPlantTraits(GalaxyData galaxy, StarData star, int[] themeIds, int index, int orbitAround, int orbitIndex, int number, bool gasGiant, int info_seed, int gen_seed, ref PlanetData __result)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		if (!CustomCreateBirthStarPlugin.StarTypePatch)
		{
			return;
		}
		switch (star.id)
		{
		case 2:
			if (!gasGiant && orbitAround < 1 && index < 7 && index > 3)
			{
				PlanetData obj2 = __result;
				obj2.obliquity *= 0.01f;
				__result.rotationPeriod = __result.orbitalPeriod;
				__result.singularity = (EPlanetSingularity)1;
			}
			break;
		case 5:
			if (!gasGiant && orbitAround < 1 && index < 7 && index > 3)
			{
				PlanetData obj = __result;
				obj.obliquity *= 0.01f;
				__result.rotationPeriod = __result.orbitalPeriod;
				__result.singularity = (EPlanetSingularity)1;
			}
			break;
		case 3:
		case 4:
			break;
		}
	}
}
public static class SuperMassBlackHole
{
	private const int STAR_ID_BigHole = 28;

	private const int STAR_ID_Custom1 = 29;

	private const int STAR_ID_Custom2 = 30;

	private const int STAR_ID_Custom3 = 31;

	private const int STAR_ID_Custom4 = 32;

	private static VectorLF3 BigHoleVector;

	public static void Prepare(ref GalaxyData galaxy, ref VectorLF3 pos, ref int id, ref int seed, ref EStarType needtype, ref ESpectrType needSpectr)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		if (CustomCreateBirthStarPlugin.NewSuperMassBlackHole)
		{
			if (id == 28)
			{
				double num = 1.0;
				needtype = (EStarType)4;
				needSpectr = (ESpectrType)7;
				pos.x = num * 20.0;
				pos.y = num * 20.0;
				pos.z = 135.0;
				BigHoleVector = pos;
			}
			else if (id == 29)
			{
				needtype = (EStarType)1;
				needSpectr = (ESpectrType)4;
				pos.x = BigHoleVector.x - 2.5;
				pos.y = BigHoleVector.y;
				pos.z = BigHoleVector.z - 2.5;
			}
			else if (id == 30)
			{
				needtype = (EStarType)1;
				needSpectr = (ESpectrType)2;
				pos.x = BigHoleVector.x + 2.5;
				pos.y = BigHoleVector.y;
				pos.z = BigHoleVector.z + 2.5;
			}
			else if (id == 31)
			{
				needtype = (EStarType)1;
				needSpectr = (ESpectrType)6;
				pos.x = BigHoleVector.x - 2.5;
				pos.y = BigHoleVector.y;
				pos.z = BigHoleVector.z + 2.5;
			}
			else if (id == 32)
			{
				needtype = (EStarType)1;
				needSpectr = (ESpectrType)0;
				pos.x = BigHoleVector.x + 2.5;
				pos.y = BigHoleVector.y;
				pos.z = BigHoleVector.z - 2.5;
			}
		}
	}

	public static void Create(ref StarData __result, int id, int seed)
	{
		//IL_0068: 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_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		if (CustomCreateBirthStarPlugin.NewSuperMassBlackHole)
		{
			double num = 1.0;
			switch (id)
			{
			case 29:
				__result.mass = 4.280622f + (float)(num * 0.5);
				__result.lifetime = 194.1946f + (float)(num * 20.0);
				__result.age = 0.9697264f + (float)(num * 0.08);
				__result.type = (EStarType)1;
				__result.temperature = 9900.992f + (float)(num * 100.0);
				__result.spectr = (ESpectrType)4;
				__result.classFactor = 0.4409298f;
				__result.color = 0.788186f;
				__result.luminosity = 4.147003f;
				__result.radius = 4.960629f + (float)(num * 0.5);
				__result.habitableRadius = 135.11641f;
				__result.lightBalanceRadius = 105.3492f;
				__result.dysonRadius = 1.92224f;
				__result.orbitScaler = 6.865142f;
				__result.level = 0.9919679f;
				__result.resourceCoef = 60f;
				__result.name = "残破庇护所 B";
				__result.safetyFactor = 0.09f;
				Util.OutputStarData(__result);
				break;
			case 30:
				__result.mass = 0.9786646f + (float)(num * 0.5);
				__result.lifetime = 3705.706f + (float)(num * 20.0);
				__result.age = 0.9654025f + (float)(num * 0.08);
				__result.type = (EStarType)1;
				__result.temperature = 4466.139f + (float)(num * 100.0);
				__result.spectr = (ESpectrType)2;
				__result.classFactor = -2.383485f;
				__result.color = 0.2233031f;
				__result.luminosity = 1.476674f;
				__result.radius = 14.48091f + (float)(num * 0.5);
				__result.habitableRadius = 9.592921f;
				__result.lightBalanceRadius = 28.77876f;
				__result.dysonRadius = 0.8838208f;
				__result.orbitScaler = 3.156503f;
				__result.level = 0.9919679f;
				__result.resourceCoef = 60f;
				__result.name = "残破庇护所 A";
				__result.safetyFactor = 0.89f;
				Util.OutputStarData(__result);
				break;
			case 31:
				__result.spectr = (ESpectrType)6;
				__result.luminosity = 28.656673f + (float)(num * 0.3);
				__result.resourceCoef = 60f;
				__result.name = "残破工业区";
				__result.safetyFactor = 0.5f;
				__result.initialHiveCount = 1 + (int)((double)CustomCreateBirthStarPlugin.DarkFogLv.Value * 0.5);
				__result.hivePatternLevel = 1 + (int)((double)CustomCreateBirthStarPlugin.DarkFogLv.Value * 0.5);
				__result.maxHiveCount = 8;
				Util.OutputStarData(__result);
				break;
			case 32:
				__result.spectr = (ESpectrType)0;
				__result.name = "古战场";
				__result.safetyFactor = 0.001f;
				__result.resourceCoef = 60f;
				__result.safetyFactor = 0.001f;
				__result.initialHiveCount = 1 + (int)((double)CustomCreateBirthStarPlugin.DarkFogLv.Value * 0.8);
				__result.hivePatternLevel = 1 + (int)((double)CustomCreateBirthStarPlugin.DarkFogLv.Value * 0.8);
				__result.maxHiveCount = 8;
				Util.OutputStarData(__result);
				break;
			case 28:
				__result.mass = 300.57f + (float)(num * 100.0);
				__result.lifetime = 1000.0017f + (float)(num * 200.0);
				__result.age = 1001.12213f + (float)(num * 100.0);
				__result.type = (EStarType)4;
				__result.temperature = 0f;
				__result.spectr = (ESpectrType)7;
				__result.classFactor = 2f;
				__result.color = 1f;
				__result.luminosity = 1E-06f;
				__result.radius = 48.73534f + (float)(num * 2.5);
				__result.acdiskRadius = 243.6767f;
				__result.habitableRadius = 0f;
				__result.lightBalanceRadius = 3.178286f;
				__result.dysonRadius = 0f;
				__result.orbitScaler = 3.321507f;
				__result.level = 1f;
				__result.resourceCoef = CustomCreateBirthStarPlugin.resourceCoef.Value;
				__result.name = "墓地";
				__result.safetyFactor = 0.001f;
				__result.initialHiveCount = CustomCreateBirthStarPlugin.DarkFogLv.Value;
				__result.hivePatternLevel = CustomCreateBirthStarPlugin.DarkFogLv.Value;
				__result.maxHiveCount = 8;
				Util.OutputStarData(__result);
				break;
			}
		}
	}

	public static bool CreatePlanet(ref double[] ___pGas, ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc)
	{
		if (!CustomCreateBirthStarPlugin.NewSuperMassBlackHole)
		{
			return true;
		}
		if (star.id == 28)
		{
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		}
		if (star.id == 29)
		{
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		}
		if (star.id == 30)
		{
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		}
		if (star.id == 31)
		{
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		}
		if (star.id == 32)
		{
			CreateStarPlanets(ref ___pGas, ref galaxy, ref star, ref gameDesc);
			return false;
		}
		return true;
	}

	private static void CreateStarPlanets(ref double[] ___pGas, ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Invalid comparison between Unknown and I4
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Invalid comparison between Unknown and I4
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Invalid comparison between Unknown and I4
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Invalid comparison between Unknown and I4
		//IL_0f24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2a: Invalid comparison between Unknown and I4
		//IL_0976: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a12: Invalid comparison between Unknown and I4
		//IL_0abf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac5: Invalid comparison between Unknown and I4
		//IL_0b54: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5a: Invalid comparison between Unknown and I4
		//IL_07be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0921: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bef: Invalid comparison between Unknown and I4
		//IL_0c7e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c84: Invalid comparison between Unknown and I4
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d1d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d23: Invalid comparison between Unknown and I4
		//IL_127d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1283: Expected O, but got Unknown
		//IL_1304: Unknown result type (might be due to invalid IL or missing references)
		//IL_1309: Unknown result type (might be due to invalid IL or missing references)
		//IL_1318: Unknown result type (might be due to invalid IL or missing references)
		//IL_131d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1322: Unknown result type (might be due to invalid IL or missing references)
		//IL_1327: Unknown result type (might be due to invalid IL or missing references)
		//IL_1336: Unknown result type (might be due to invalid IL or missing references)
		//IL_134a: Unknown result type (might be due to invalid IL or missing references)
		//IL_134f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1354: Unknown result type (might be due to invalid IL or missing references)
		//IL_1358: Unknown result type (might be due to invalid IL or missing references)
		//IL_135d: Unknown result type (might be due to invalid IL or missing references)
		DotNet35Random val = new DotNet35Random(star.seed);
		val.Next();
		val.Next();
		val.Next();
		DotNet35Random val2 = new DotNet35Random(val.Next());
		double num = val2.NextDouble();
		val2.NextDouble();
		val2.NextDouble();
		double num2 = val2.NextDouble();
		double num3 = val2.NextDouble();
		double num4 = val2.NextDouble() * 0.2 + 0.9;
		double num5 = val2.NextDouble() * 0.2 + 0.9;
		DotNet35Random val3 = new DotNet35Random(val.Next());
		AccessTools.Method(typeof(StarGen), "SetHiveOrbitsConditionsTrue", (Type[])null, (Type[])null).Invoke(null, new object[0]);
		if ((int)star.type == 4)
		{
			int[] themeIDs = new int[4] { 7, 10, 20, 24 };
			int[] themeIDs2 = new int[5] { 2, 3, 4, 5, 21 };
			star.planetCount = 8;
			star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
			star.planets[0] = Util.CreatePlanet(galaxy, star, themeIDs, 0, 0, 3, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[1] = Util.CreatePlanet(galaxy, star, themeIDs, 1, 0, 4, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[2] = Util.CreatePlanet(galaxy, star, themeIDs, 2, 0, 5, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[3] = Util.CreatePlanet(galaxy, star, themeIDs, 3, 0, 6, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[4] = Util.CreatePlanet(galaxy, star, themeIDs, 4, 0, 7, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[5] = Util.CreatePlanet(galaxy, star, themeIDs, 5, 0, 10, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[6] = Util.CreatePlanet(galaxy, star, themeIDs, 6, 0, 12, 1, gasGiant: false, val2.Next(), val2.Next());
			star.planets[7] = Util.CreatePlanet(galaxy, star, themeIDs2, 7, 0, 13, 1, gasGiant: true, val2.Next(), val2.Next());
		}
		else if ((int)star.type != 3 && (int)star.type != 2)
		{
			if ((int)star.type == 1)
			{
				if (star.id == 29)
				{
					int[] array = new int[6] { 6, 12, 17, 19, 20, 23 };
					star.planetCount = 5;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, array, 0, 0, 1, 1, false, val2.Next(), val2.Next());
					star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, array, 1, 0, 3, 1, false, val2.Next(), val2.Next());
					star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, array, 2, 0, 4, 1, false, val2.Next(), val2.Next());
					star.planets[3] = PlanetGen.CreatePlanet(galaxy, star, array, 3, 0, 5, 1, false, val2.Next(), val2.Next());
					star.planets[4] = PlanetGen.CreatePlanet(galaxy, star, array, 4, 0, 7, 1, false, val2.Next(), val2.Next());
				}
				else if (star.id == 30)
				{
					int[] array2 = new int[6] { 8, 15, 16, 18, 22, 25 };
					int[] array3 = array2;
					foreach (int num6 in array3)
					{
						((ProtoSet<ThemeProto>)(object)LDB.themes).Select(num6).PlanetType = (EPlanetType)3;
					}
					star.planetCount = 6;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, array2, 0, 0, 1, 1, false, val2.Next(), val2.Next());
					star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, array2, 1, 0, 3, 1, false, val2.Next(), val2.Next());
					star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, array2, 2, 0, 4, 1, false, val2.Next(), val2.Next());
					star.planets[3] = PlanetGen.CreatePlanet(galaxy, star, array2, 3, 0, 6, 1, false, val2.Next(), val2.Next());
					star.planets[4] = PlanetGen.CreatePlanet(galaxy, star, array2, 4, 0, 8, 1, false, val2.Next(), val2.Next());
					star.planets[5] = PlanetGen.CreatePlanet(galaxy, star, array2, 5, 0, 9, 1, false, val2.Next(), val2.Next());
					array3 = array2;
					foreach (int num7 in array3)
					{
						((ProtoSet<ThemeProto>)(object)LDB.themes).Select(num7).PlanetType = (EPlanetType)2;
					}
				}
				else if (star.id == 31)
				{
					int[] themeIDs3 = new int[5] { 2, 3, 4, 5, 21 };
					int[] array4 = new int[7] { 1, 8, 14, 15, 18, 22, 25 };
					int[] savedThemeIds = gameDesc.savedThemeIds;
					if (CustomCreateBirthStarPlugin.MorePlanet)
					{
						star.planetCount = 13;
					}
					else
					{
						star.planetCount = 8;
					}
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					star.planets[0] = Util.CreatePlanet(galaxy, star, themeIDs3, 0, 0, 1, 1, gasGiant: true, val2.Next(), val2.Next());
					star.planets[1] = Util.CreatePlanet(galaxy, star, savedThemeIds, 1, 1, 1, 0, gasGiant: false, val2.Next(), val2.Next());
					star.planets[2] = Util.CreatePlanet(galaxy, star, savedThemeIds, 2, 1, 2, 0, gasGiant: false, val2.Next(), val2.Next());
					star.planets[3] = Util.CreatePlanet(galaxy, star, savedThemeIds, 3, 1, 4, 0, gasGiant: false, val2.Next(), val2.Next());
					star.planets[4] = Util.CreatePlanet(galaxy, star, savedThemeIds, 4, 1, 5, 0, gasGiant: false, val2.Next(), val2.Next());
					star.planets[5] = Util.CreatePlanet(galaxy, star, themeIDs3, 5, 0, 3, 3, gasGiant: true, val2.Next(), val2.Next());
					star.planets[6] = Util.CreatePlanet(galaxy, star, savedThemeIds, 6, 3, 2, 0, gasGiant: false, val2.Next(), val2.Next());
					if (CustomCreateBirthStarPlugin.BirthStarAtSuperMassBlackHole.Value)
					{
						CustomCreateBirthStarPlugin.BirthStarId = star.id;
						CustomCreateBirthStarPlugin.BirthPlanetId = star.planets[6].id;
					}
					star.planets[7] = Util.CreatePlanet(galaxy, star, themeIDs3, 7, 0, 7, 7, gasGiant: true, val2.Next(), val2.Next());
					if (CustomCreateBirthStarPlugin.MorePlanet)
					{
						star.planets[8] = Util.CreatePlanet(galaxy, star, themeIDs3, 8, 0, 8, 8, gasGiant: true, val2.Next(), val2.Next());
						Util.ModifyPlanetTheme(array4, (EPlanetType)3);
						star.planets[9] = Util.CreatePlanet(galaxy, star, array4, 9, 8, 1, 0, gasGiant: false, val2.Next(), val2.Next());
						star.planets[10] = Util.CreatePlanet(galaxy, star, array4, 10, 8, 3, 0, gasGiant: false, val2.Next(), val2.Next());
						Util.ModifyPlanetTheme(array4, (EPlanetType)2);
						if (CustomCreateBirthStarPlugin.BirthStarAtSuperMassBlackHole.Value)
						{
							CustomCreateBirthStarPlugin.BirthStarId = star.id;
							CustomCreateBirthStarPlugin.BirthPlanetId = star.planets[10].id;
						}
						star.planets[11] = Util.CreatePlanet(galaxy, star, savedThemeIds, 11, 0, 9, 9, gasGiant: false, val2.Next(), val2.Next());
						star.planets[12] = Util.CreatePlanet(galaxy, star, themeIDs3, 12, 0, 13, 13, gasGiant: true, val2.Next(), val2.Next());
					}
				}
				else if (star.id == 32)
				{
					((ProtoSet<ThemeProto>)(object)LDB.themes).Select(9).PlanetType = (EPlanetType)3;
					int[] array5 = new int[1] { 9 };
					star.planetCount = 8;
					star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
					star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, array5, 0, 0, 1, 1, false, val2.Next(), val2.Next());
					star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, array5, 1, 0, 2, 1, false, val2.Next(), val2.Next());
					star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, array5, 2, 0, 3, 1, false, val2.Next(), val2.Next());
					star.planets[3] = PlanetGen.CreatePlanet(galaxy, star, array5, 3, 0, 4, 1, false, val2.Next(), val2.Next());
					star.planets[4] = PlanetGen.CreatePlanet(galaxy, star, array5, 4, 0, 5, 1, false, val2.Next(), val2.Next());
					star.planets[5] = PlanetGen.CreatePlanet(galaxy, star, array5, 5, 0, 7, 1, false, val2.Next(), val2.Next());
					star.planets[6] = PlanetGen.CreatePlanet(galaxy, star, array5, 6, 0, 8, 1, false, val2.Next(), val2.Next());
					star.planets[7] = PlanetGen.CreatePlanet(galaxy, star, array5, 7, 0, 9, 1, false, val2.Next(), val2.Next());
					((ProtoSet<ThemeProto>)(object)LDB.themes).Select(9).PlanetType = (EPlanetType)1;
				}
			}
			else
			{
				Array.Clear(___pGas, 0, ___pGas.Length);
				if (star.index == 0)
				{
					star.planetCount = 4;
					___pGas[0] = 0.0;
					___pGas[1] = 0.0;
					___pGas[2] = 0.0;
				}
				else if ((int)star.spectr == 0)
				{
					star.planetCount = ((!(num >= 0.1)) ? 1 : ((!(num >= 0.3)) ? 2 : ((num >= 0.8) ? 4 : 3)));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.2;
						___pGas[2] = 0.3;
					}
				}
				else if ((int)star.spectr == 1)
				{
					star.planetCount = ((!(num >= 0.1)) ? 1 : ((!(num >= 0.2)) ? 2 : ((!(num >= 0.7)) ? 3 : ((num >= 0.95) ? 5 : 4))));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.18;
						___pGas[1] = 0.18;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.18;
						___pGas[2] = 0.28;
						___pGas[3] = 0.28;
					}
				}
				else if ((int)star.spectr == 2)
				{
					star.planetCount = ((!(num >= 0.4)) ? 3 : ((num >= 0.9) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.18;
						___pGas[1] = 0.18;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.2;
						___pGas[2] = 0.3;
						___pGas[3] = 0.3;
					}
				}
				else if ((int)star.spectr == 3)
				{
					star.planetCount = ((!(num >= 0.35)) ? 3 : ((num >= 0.8) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.0;
						___pGas[1] = 0.22;
						___pGas[2] = 0.31;
						___pGas[3] = 0.31;
					}
				}
				else if ((int)star.spectr == 4)
				{
					star.planetCount = ((!(num >= 0.3)) ? 3 : ((num >= 0.75) ? 5 : 4));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.1;
						___pGas[1] = 0.28;
						___pGas[2] = 0.3;
						___pGas[3] = 0.35;
					}
				}
				else if ((int)star.spectr == 5)
				{
					star.planetCount = ((!(num >= 0.3)) ? 4 : ((num >= 0.75) ? 6 : 5));
					if (star.planetCount <= 3)
					{
						___pGas[0] = 0.2;
						___pGas[1] = 0.2;
					}
					else
					{
						___pGas[0] = 0.1;
						___pGas[1] = 0.22;
						___pGas[2] = 0.28;
						___pGas[3] = 0.35;
						___pGas[4] = 0.35;
					}
				}
				else if ((int)star.spectr == 6)
				{
					star.planetCount = ((num >= 0.5) ? 6 : 5);
					___pGas[0] = 0.1;
					___pGas[1] = 0.2;
					___pGas[2] = 0.25;
					___pGas[3] = 0.3;
					___pGas[4] = 0.32;
					___pGas[5] = 0.35;
				}
				else
				{
					star.planetCount = 1;
				}
				star.planets = (PlanetData[])(object)new PlanetData[star.planetCount];
				int num8 = 0;
				int num9 = 0;
				int num10 = 0;
				int num11 = 1;
				for (int j = 0; j < star.planetCount; j++)
				{
					int num12 = val2.Next();
					int num13 = val2.Next();
					double num14 = val2.NextDouble();
					double num15 = val2.NextDouble();
					bool flag = false;
					if (num10 == 0)
					{
						num8++;
						if (j < star.planetCount - 1 && num14 < ___pGas[j])
						{
							flag = true;
							if (num11 < 3)
							{
								num11 = 3;
							}
						}
						while (true)
						{
							if (star.index != 0 || num11 != 3)
							{
								int num16 = star.planetCount - j;
								int num17 = 9 - num11;
								if (num17 <= num16)
								{
									break;
								}
								float num18 = (float)num16 / (float)num17;
								float num19 = ((num11 <= 3) ? (Mathf.Lerp(num18, 1f, 0.15f) + 0.01f) : (Mathf.Lerp(num18, 1f, 0.45f) + 0.01f));
								if (val2.NextDouble() < (double)num19)
								{
									break;
								}
								num11++;
								continue;
							}
							flag = true;
							break;
						}
					}
					else
					{
						num9++;
						flag = false;
					}
					star.planets[j] = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, j, num10, (num10 == 0) ? num11 : num9, (num10 == 0) ? num8 : num9, flag, num12, num13);
					num11++;
					if (flag)
					{
						num10 = num8;
						num9 = 0;
					}
					if (num9 >= 1 && num15 < 0.8)
					{
						num10 = 0;
						num9 = 0;
					}
				}
			}
		}
		int num20 = 0;
		int num21 = 0;
		int num22 = 0;
		for (int k = 0; k < star.planetCount; k++)
		{
			if ((int)star.planets[k].type == 5)
			{
				num20 = star.planets[k].orbitIndex;
				break;
			}
		}
		for (int l = 0; l < star.planetCount; l++)
		{
			if (star.planets[l].orbitAround == 0)
			{
				num21 = star.planets[l].orbitIndex;
			}
		}
		if (num20 > 0)
		{
			int num23 = num20 - 1;
			bool flag2 = true;
			for (int m = 0; m < star.planetCount; m++)
			{
				if (star.planets[m].orbitAround == 0 && star.planets[m].orbitIndex == num20 - 1)
				{
					flag2 = false;
					break;
				}
			}
			if (flag2 && num2 < 0.2 + (double)num23 * 0.2)
			{
				num22 = num23;
			}
		}
		int num24 = ((!(num3 >= 0.2)) ? (num21 + 3) : ((!(num3 >= 0.4)) ? (num21 + 2) : ((!(num3 >= 0.8)) ? (num21 + 1) : 0)));
		if (num24 != 0 && num24 < 5)
		{
			num24 = 5;
		}
		star.asterBelt1OrbitIndex = num22;
		star.asterBelt2OrbitIndex = num24;
		if (num22 > 0)
		{
			star.asterBelt1Radius = StarGen.orbitRadius[num22] * (float)num4 * star.orbitScaler;
		}
		if (num24 > 0)
		{
			star.asterBelt2Radius = StarGen.orbitRadius[num24] * (float)num5 * star.orbitScaler;
		}
		for (int n = 0; n < star.planetCount; n++)
		{
			PlanetData val4 = star.planets[n];
			AccessTools.Method(typeof(StarGen), "SetHiveOrbitConditionFalse", (Type[])null, (Type[])null).Invoke(null, new object[4]
			{
				val4.orbitIndex,
				(val4.orbitAroundPlanet != null) ? val4.orbitAroundPlanet.orbitIndex : 0,
				val4.sunDistance / star.orbitScaler,
				star.index
			});
		}
		star.hiveAstroOrbits = (AstroOrbitData[])(object)new AstroOrbitData[8];
		AstroOrbitData[] hiveAstroOrbits = star.hiveAstroOrbits;
		int num25 = 0;
		for (int num26 = 0; num26 < StarGen.hiveOrbitCondition.Length; num26++)
		{
			if (StarGen.hiveOrbitCondition[num26])
			{
				num25++;
			}
		}
		for (int num27 = 0; num27 < 8; num27++)
		{
			double value = val3.NextDouble() * 2.0 - 1.0;
			double num28 = val3.NextDouble();
			double num29 = val3.NextDouble();
			double num30 = (double)Math.Sign(value) * Math.Pow(Math.Abs(value), 0.7) * 90.0;
			double num31 = num28 * 360.0;
			double num32 = num29 * 360.0;
			float num33 = 0.3f;
			Assert.Positive(num25);
			if (num25 > 0)
			{
				int num34 = ((star.index != 0) ? 5 : 2);
				int num35 = ((num25 > num34) ? num34 : num25) * 100;
				int num36 = num35 * 100;
				int num37 = val3.Next(num35);
				int num38 = num37 * num37 / num36;
				for (int num39 = 0; num39 < StarGen.hiveOrbitCondition.Length; num39++)
				{
					if (StarGen.hiveOrbitCondition[num39])
					{
						if (num38 == 0)
						{
							num33 = StarGen.hiveOrbitRadius[num39];
							StarGen.hiveOrbitCondition[num39] = false;
							num25--;
							break;
						}
						num38--;
					}
				}
			}
			hiveAstroOrbits[num27] = new AstroOrbitData();
			hiveAstroOrbits[num27].orbitRadius = num33 * star.orbitScaler;
			hiveAstroOrbits[num27].orbitInclination = (float)num30;
			hiveAstroOrbits[num27].orbitLongitude = (float)num31;
			hiveAstroOrbits[num27].orbitPhase = (float)num32;
			hiveAstroOrbits[num27].orbitalPeriod = Math.Sqrt(39.47841760435743 * (double)num33 * (double)num33 * (double)num33 / (1.3538551990520382E-06 * (double)star.mass));
			hiveAstroOrbits[num27].orbitRotation = Quaternion.AngleAxis(hiveAstroOrbits[num27].orbitLongitude, Vector3.up) * Quaternion.AngleAxis(hiveAstroOrbits[num27].orbitInclination, Vector3.forward);
			AstroOrbitData obj = hiveAstroOrbits[num27];
			VectorLF3 val5 = Maths.QRotateLF(hiveAstroOrbits[num27].orbitRotation, new VectorLF3(0f, 1f, 0f));
			obj.orbitNormal = ((VectorLF3)(ref val5)).normalized;
		}
	}

	public static void AddPlantTraits(GalaxyData galaxy, StarData star, int[] themeIds, int index, int orbitAround, int orbitIndex, int number, bool gasGiant, int info_seed, int gen_seed, ref PlanetData __result)
	{
		if (!CustomCreateBirthStarPlugin.NewSuperMassBlackHole || star.id == 28)
		{
			return;
		}
		if (star.id == 29)
		{
			if (__result.theme == 6)
			{
				__result.windStrength = 5f;
				__result.luminosity = 2f;
			}
			else if (__result.theme == 19)
			{
				__result.windStrength = 9.8f;
				__result.luminosity = 3f;
			}
			else if (__result.theme == 23)
			{
				__result.windStrength = 7f;
				__result.luminosity = 4f;
			}
		}
		else if (star.id != 30 && star.id != 31)
		{
			_ = star.id;
			_ = 32;
		}
	}

	public static void OnMine(ref PlanetFactory __instance, int id)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (!CustomCreateBirthStarPlugin.NewSuperMassBlackHole || !CustomCreateBirthStarPlugin.Relics || __instance.vegePool[id].id == 0 || !Util.IsStone(__instance.vegePool[id].protoId) || __instance.planet.star.id != 28)
		{
			return;
		}
		int num = 0;
		int count = 0;
		double num2 = new DotNet35Random().NextDouble();
		if (((ProtoSet<ItemProto>)(object)LDB.items).Select(9448) == null)
		{
			return;
		}
		bool flag = false;
		if (__instance.planet.star.planets.Length != 0)
		{
			flag = __instance.planet.star.planets[0].id == __instance.planet.id;
		}
		if (num2 > 1E-05 && num2 <= 0.01001)
		{
			if (!__instance.gameData.history.TechUnlocked(8000))
			{
				num = 9448;
				count = ((!flag) ? 1 : 5);
			}
		}
		else if (num2 > 0.01 && num2 <= 0.018)
		{
			if (flag)
			{
				if (!__instance.gameData.history.TechUnlocked(8000))
				{
					__instance.gameData.history.UnlockTech(8000);
					num = 9448;
					count = 10;
				}
				else if (!__instance.gameData.history.TechUnlocked(8001))
				{
					__instance.gameData.history.UnlockTech(8001);
					num = 9449;
					count = 5;
				}
			}
		}
		else if (num2 > 0.201 && num2 <= 0.211)
		{
			num = 9446;
			count = (flag ? 50 : 5);
		}
		else if (num2 > 0.211 && num2 <= 0.231)
		{
			num = 9446;
			count = (flag ? 20 : 2);
		}
		else if (num2 > 0.231 && num2 <= 0.271)
		{
			num = 9446;
			count = ((!flag) ? 1 : 10);
		}
		if (num >= 1)
		{
			GainTechAwards(num, count);
		}
	}

	public static void GainTechAwards(int itemId, int count)
	{
		if (GameMain.mainPlayer.TryAddItemToPackage(itemId, count, count, true, 0, false) < count)
		{
			UIRealtimeTip.Popup(Localization.Translate("无法获得科技奖励"), true, 0);
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法获得科技奖励");
		}
		else
		{
			UIItemup.Up(itemId, count);
			UIRealtimeTip.Popup(Localization.Translate("?!!"), true, 0);
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "添加物品至背包");
		}
	}
}
[HarmonyPatch]
public static class CustomCreateBirthStarPatch
{
	[HarmonyPrefix]
	[HarmonyPatch(typeof(StarGen), "CreateStar")]
	public static void CreateStarPatch(ref GalaxyData galaxy, ref VectorLF3 pos, int id, int seed, ref EStarType needtype, ref ESpectrType needSpectr)
	{
		Stellar4Stars.Prepare(ref galaxy, ref pos, ref id, ref seed, ref needtype, ref needSpectr);
		SuperMassBlackHole.Prepare(ref galaxy, ref pos, ref id, ref seed, ref needtype, ref needSpectr);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(StarGen), "CreateStar")]
	public static void CreateStarPatch(ref StarData __result, int id, int seed)
	{
		Stellar4Stars.Create(ref __result, id, seed);
		SuperMassBlackHole.Create(ref __result, id, seed);
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(StarGen), "CreateStarPlanets")]
	public static bool CreateStarPlanetsPatch(ref double[] ___pGas, GalaxyData galaxy, ref StarData star, GameDesc gameDesc)
	{
		if (!Stellar4Stars.CreatePlanet(ref ___pGas, ref galaxy, ref star, ref gameDesc))
		{
			return false;
		}
		if (!SuperMassBlackHole.CreatePlanet(ref ___pGas, ref galaxy, ref star, ref gameDesc))
		{
			return false;
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlanetGen), "CreatePlanet")]
	public static void CreatePlanetPatch(GalaxyData galaxy, StarData star, int[] themeIds, int index, int orbitAround, int orbitIndex, int number, bool gasGiant, int info_seed, int gen_seed, ref PlanetData __result)
	{
		Stellar4Stars.AddPlantTraits(galaxy, star, themeIds, index, orbitAround, orbitIndex, number, gasGiant, info_seed, gen_seed, ref __result);
		SuperMassBlackHole.AddPlantTraits(galaxy, star, themeIds, index, orbitAround, orbitIndex, number, gasGiant, info_seed, gen_seed, ref __result);
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PlanetFactory), "RemoveVegeWithComponents")]
	public static void RemoveVegeWithComponents(ref PlanetFactory __instance, int id)
	{
		SuperMassBlackHole.OnMine(ref __instance, id);
	}

	[HarmonyTranspiler]
	[HarmonyPatch(typeof(StationComponent), "InternalTickRemote")]
	public static IEnumerable<CodeInstruction> InternalTickRemoteTranspiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Expected O, but got Unknown
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Expected O, but got Unknown
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Expected O, but got Unknown
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Expected O, but got Unknown
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Expected O, but got Unknown
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Expected O, but got Unknown
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Expected O, but got Unknown
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Expected O, but got Unknown
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Expected O, but got Unknown
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Expected O, but got Unknown
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Br), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("ShipData")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld && instruction.operand.ToString().Equals("System.Int32 stage")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Brtrue), (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到代码 if (shipData.stage == 0) 的位置");
			return instructions;
		}
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_I4_S && (sbyte)instruction.operand == 10), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Add), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Blt), (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到第一处形如 A < B + 10 的代码");
			return instructions;
		}
		val.Advance(2);
		val.SetOperandAndAdvance((object)100);
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_I4_S && (sbyte)instruction.operand == 10), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Add), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Blt), (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到第二处形如 A < B + 10 的代码");
			return instructions;
		}
		val.Advance(2);
		val.SetOperandAndAdvance((object)100);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[8]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_I4_S && (sbyte)instruction.operand == 100), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Rem), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Brtrue), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Single")), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 2.5f), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Mul), (string)null),
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Stloc_S && instruction.operand.ToString().StartsWith("System.Single")), (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到形如 if (A % 100 == 0) B *= 2.5f 的代码");
			return instructions;
		}
		val.Advance(-2);
		val.SetOperandAndAdvance((object)1f);
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "物流系统修正完成");
		return val.InstructionEnumeration();
	}

	[HarmonyTranspiler]
	[HarmonyPatch(typeof(TrashSystem), "Gravity")]
	private static IEnumerable<CodeInstruction> TrashSystem_Gravity_Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
		{
			new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)600.0, (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到数字 600.0");
			return instructions;
		}
		val.Set(OpCodes.Ldc_R8, (object)800.0);
		val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
		{
			new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && ((LocalBuilder)instruction.operand).LocalIndex == 6), (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_8, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ble, (object)null, (string)null)
		});
		if (val.IsInvalid)
		{
			Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "无法找到第形如 A <= B + 8 的代码");
			return instructions;
		}
		val.Advance(2);
		val.Set(OpCodes.Ldc_I4_S, (object)99);
		Util.Log(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, "重力系统修正完成");
		return val.InstructionEnumeration();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UniverseGen), "CreateGalaxy")]
	private static void UniverseGen_CreateGalaxy_Postfix(GalaxyData __result)
	{
		if (CustomCreateBirthStarPlugin.BirthStarId != -1 && CustomCreateBirthStarPlugin.BirthPlanetId != -1)
		{
			__result.birthStarId = CustomCreateBirthStarPlugin.BirthStarId;
			__result.birthPlanetId = CustomCreateBirthStarPlugin.BirthPlanetId;
		}
	}
}
[BepInPlugin("kumor.plugin.CustomCreateBirthStar", "夺取回我们的遗产", "1.3.1.0")]
[BepInProcess("DSPGAME.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "CustomDescSystem" })]
internal class CustomCreateBirthStarPlugin : BaseUnityPlugin
{
	public const string GUID = "kumor.plugin.CustomCreateBirthStar";

	public const string NAME = "夺取回我们的遗产";

	public const string VERSION = "1.3.1.0";

	public const string GAME_VERSION = "0.10.28.20856";

	public const string GAME_PROCESS = "DSPGAME.exe";

	public static ManualLogSource logger;

	public static bool StarTypePatch = true;

	public static bool NewSuperMassBlackHole = true;

	public static bool Relics = false;

	public static bool NanoTech = false;

	public static ConfigEntry<bool> Debug;

	public static ConfigEntry<float> resourceCoef;

	public static ConfigEntry<int> DarkFogLv;

	public static int BirthStarId = -1;

	public static int BirthPlanetId = -1;

	public static ConfigEntry<bool> BirthStarAtOStar;

	public static ConfigEntry<bool> BirthStarAtSuperMassBlackHole;

	public static bool MorePlanet = false;

	private void Awake()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Expected O, but got Unknown
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Expected O, but got Unknown
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Expected O, but got Unknown
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Expected O, but got Unknown
		string text = "星区参数(不兼容旧存档|重启生效)";
		StarTypePatch = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "圣地星系群", true, new ConfigDescription("是否在母星系附近生成黑洞,中子星,O星,蓝巨星(圣地星系群,一个远古文明供奉的圣地,拥有丰富的资源,但它的主人却已不在,在遗留的数据里发现了*雾,纳*,天灾...)", (AcceptableValueBase)null, new object[0])).Value;
		NewSuperMassBlackHole = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "超重黑洞星系群", true, new ConfigDescription("是否在星系边缘生成一个超重黑洞及其星系群,请存档并带够燃料再前往探索,祝你好运", (AcceptableValueBase)null, new object[0])).Value;
		MorePlanet = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "更多的行星", false, new ConfigDescription("是否在往模组生成的星系中添加更多行星", (AcceptableValueBase)null, new object[0])).Value;
		string text2 = "设置母星系位置(不兼容旧存档|重启生效)";
		BirthStarAtOStar = ((BaseUnityPlugin)this).Config.Bind<bool>(text2, "将圣地星系群设为母星·二选一", false, new ConfigDescription("开局建议选跳过,运气不好可能需要重开", (AcceptableValueBase)null, new object[0]));
		BirthStarAtSuperMassBlackHole = ((BaseUnityPlugin)this).Config.Bind<bool>(text2, "将黑洞星系群设为母星·二选一", false, new ConfigDescription("开局建议选跳过,运气不好可能需要重开(当更多的行星开启时,保证出生在一颗宜居固态星球上)", (AcceptableValueBase)null, new object[0]));
		string text3 = "资源参数(不兼容旧存档|生成种子前生效)";
		resourceCoef = ((BaseUnityPlugin)this).Config.Bind<float>(text3, "遗产倍率", 1000f, new ConfigDescription("遗产的资源倍率,此倍率 * 星区资源倍率不要超过10000,否则资源数量会异常", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100000f), new object[0]));
		DarkFogLv = ((BaseUnityPlugin)this).Config.Bind<int>(text3, "防守力度", 8, new ConfigDescription("遗产的防守力度,1 - 8对应弱 - 强", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), new object[0]));
		string text4 = "科技参数(不兼容旧存档|重启生效)";
		Relics = ((BaseUnityPlugin)this).Config.Bind<bool>(text4, "遗落科技", true, new ConfigDescription("是否开启遗落科技(会增加几个额外建筑,科技,如果不喜欢可关闭),在特定行星挖掘零散矿石有概率获得稀有物品", (AcceptableValueBase)null, new object[0])).Value;
		NanoTech = ((BaseUnityPlugin)this).Config.Bind<bool>(text4, "黑雾科技", true, new ConfigDescription("是否开启黑雾科技", (AcceptableValueBase)null, new object[0])).Value;
		Debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug(离我远点)", "Debug(不要点)", false, new ConfigDescription("开发人员调试模式", (AcceptableValueBase)null, new object[0]));
		logger = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("kumor.plugin.CustomCreateBirthStar");
		Harmony.CreateAndPatchAll(typeof(CustomCreateBirthStarPatch), val.Id);
		Harmony.CreateAndPatchAll(typeof(GalaxyStarCountPatch), val.Id);
		if (Relics)
		{
			ItemManage.AddString();
			ItemManage.AddTech0();
			ItemManage.AddTech1();
			ItemPowerCore.AddItem();
			ItemPowerCoreFull.AddItem();
			ItemPowerExchange.AddItem();
			ItemPowerExchangeMK2.AddItem();
			Harmony.CreateAndPatchAll(typeof(ItemPowerCore), val.Id);
			Harmony.CreateAndPatchAll(typeof(ItemPowerCoreFull), val.Id);
			Harmony.CreateAndPatchAll(typeof(ItemPowerExchange), val.Id);
			Harmony.CreateAndPatchAll(typeof(ItemPowerExchangeMK2), val.Id);
		}
		if (NanoTech)
		{
			ItemStationSolt.Create();
			Harmony.CreateAndPatchAll(typeof(ItemStationSolt), val.Id);
		}
		Util.Log("初始化完毕");
	}
}
[HarmonyPatch]
public static class GalaxyStarCountPatch
{
	private const int starCountmax = 250;

	private const int starCountmin = 32;

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIGalaxySelect), "_OnInit")]
	public static void _OnInitPatch(UIGalaxySelect __instance, ref Slider ___starCountSlider, ref InputField ___seedInput)
	{
		___starCountSlider.maxValue = 250f;
		___starCountSlider.minValue = 32f;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIGalaxySelect), "OnStarCountSliderValueChange")]
	public static bool OnStarCountSliderValueChangePatch(UIGalaxySelect __instance, ref Slider ___starCountSlider, ref GameDesc ___gameDesc, float val)
	{
		int num = (int)((double)__instance.starCountSlider.value + 0.100000001490116);
		if (num < 32)
		{
			num = 32;
		}
		else if (num > 250)
		{
			num = 250;
		}
		if (num == ___gameDesc.starCount)
		{
			return false;
		}
		___gameDesc.starCount = num;
		__instance.SetStarmapGalaxy();
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIGalaxySelect), "UpdateUIDisplay")]
	public static void UIPrefix(UIGalaxySelect __instance, ref Slider ___starCountSlider)
	{
		((UnityEvent<float>)(object)___starCountSlider.onValueChanged).RemoveListener((UnityAction<float>