Decompiled source of TheyComeFromVoid v3.2.6

DSP_Battle.dll

Decompiled 3 days ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using MoreMegaStructure;
using NGPT;
using NebulaAPI;
using NebulaAPI.GameState;
using NebulaAPI.Interfaces;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using crecheng.DSPModSave;
using xiaoye97;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DSP_Battle")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("DSP_Battle")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a125458e-bfa2-40ee-96b3-e461903e8c67")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DSP_Battle
{
	public static class AssaultController
	{
		public enum EAssaultModifier
		{
			DamageResist,
			Evade,
			AdditionalArmor,
			ShieldDamageBuff,
			DropletKiller,
			NoExp,
			KineticDamageSuppressor,
			EnergyDamageSuppressor,
			BlastDamageSuppressor,
			MagneticDamageSuppressor,
			SpaceJammer,
			DamageBuffSteal,
			QuickHeal,
			SuperSpeed
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Response <>9__53_0;

			public static Response <>9__55_0;

			internal void <TryEnableVoidInvasion>b__53_0()
			{
				voidInvasionEnabled = true;
			}

			internal void <AskEnableVoidInvasion>b__55_0()
			{
				voidInvasionEnabled = true;
			}
		}

		public static bool voidInvasionEnabled = false;

		public static int difficulty = 2;

		public static List<AssaultHive> assaultHives = new List<AssaultHive>();

		public static bool modifierEnabled;

		public static List<int> modifier;

		public static bool timeChangedByRelic = false;

		public static int nextRollVoidEcho = 1;

		public static int[] invincibleHives;

		public static int[] modifierHives;

		public static int[] alertHives;

		public static bool assaultActive;

		public static int quickTickHive = -1;

		public static int quickTickFactor = 1;

		public static int testLvlSet = -1;

		public static List<int> oriAstroId = new List<int>();

		public static List<int> time = new List<int>();

		public static List<int> state = new List<int>();

		public static List<int> level = new List<int>();

		public static int count = 0;

		public const int DamageReduction = 0;

		public const int Dodge = 1;

		public const int DamageToShield = 2;

		public const int DropletInvincible = 3;

		public const int AddtionalArmor = 4;

		public const int SpeedUp = 5;

		public const int HardenedStructure = 6;

		public static int lancerModelIndex = 285;

		public static int oriLancerMarchMovementSpeed = 400;

		public static int oriLancerMaxMovementAcceleration = 500;

		public static int oriLancerMaxMovementSpeed = 1500;

		public static int basicInhibitPoint = 1000;

		public static List<int> modifierPoolEarly = new List<int> { 0, 1, 2, 3, 5, 11 };

		public static List<int> modifierPoolMid = new List<int> { 0, 1, 2, 3, 5, 8, 10, 11, 13 };

		public static List<int> modifierPoolLate = new List<int>
		{
			0, 1, 2, 3, 4, 5, 7, 8, 10, 11,
			12, 13
		};

		public static List<int> modifierValueMinEarly = new List<int>
		{
			10, 10, 3, 50, 1, 1, 30, 30, 30, 30,
			1, 10, 60, 50
		};

		public static List<int> modifierValueMinMid = new List<int>
		{
			20, 15, 30, 75, 2, 1, 100, 100, 100, 100,
			1, 30, 180, 100
		};

		public static List<int> modifierValueMinLate = new List<int>
		{
			30, 20, 120, 100, 5, 1, 300, 300, 300, 300,
			1, 40, 600, 200
		};

		public static List<int> modifierMaxActiveCount = new List<int>
		{
			1, 1, 2, 2, 2, 3, 3, 3, 3, 3,
			4, 4, 4, 5, 5, 5
		};

		public static int modifierTypeCount = 14;

		public static void InitWhenLoad()
		{
			voidInvasionEnabled = false;
			difficulty = 2;
			assaultHives = new List<AssaultHive>();
			invincibleHives = new int[GameMain.spaceSector.maxHiveCount];
			modifierHives = new int[GameMain.spaceSector.maxHiveCount];
			alertHives = new int[GameMain.spaceSector.maxHiveCount];
			modifier = new List<int>
			{
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0
			};
			timeChangedByRelic = false;
			nextRollVoidEcho = 1;
			ClearDataArrays();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameData), "GameTick")]
		public static void LogicTick(long time)
		{
			MMSCPU.BeginSample(TCFVPerformanceMonitor.MainLogic);
			MMSCPU.BeginSample(TCFVPerformanceMonitor.Assault);
			if (voidInvasionEnabled && assaultHives.Count == 0 && time % 3600 == 0)
			{
				int num = -1;
				bool flag = false;
				if (GameMain.data.dysonSpheres != null)
				{
					for (int i = 0; i < GameMain.data.dysonSpheres.Length; i++)
					{
						if (GameMain.data.dysonSpheres[i] != null && (GameMain.data.dysonSpheres[i].energyGenCurrentTick_Swarm > 0 || GameMain.data.dysonSpheres[i].energyGenCurrentTick > 0))
						{
							flag = true;
							num = GameMain.data.dysonSpheres[i].starData.index;
							break;
						}
					}
				}
				if (flag)
				{
					InitNewAssault();
				}
			}
			for (int j = 0; j < assaultHives.Count; j++)
			{
				assaultHives[j].LogicTick();
			}
			CalcCombatState();
			if (modifierEnabled && Configs.combatState == 3)
			{
				if (modifier[10] != 0)
				{
					Player mainPlayer = GameMain.mainPlayer;
					CombatModuleComponent val = ((mainPlayer == null) ? null : mainPlayer.mecha?.spaceCombatModule);
					if (val != null)
					{
						ModuleFleet[] moduleFleets = val.moduleFleets;
						for (int k = 0; k < moduleFleets.Length; k++)
						{
							if (moduleFleets[k].protoId != DropletFleetPatchers.fleetConfigId1 && moduleFleets[k].protoId != DropletFleetPatchers.fleetConfigId2)
							{
								moduleFleets[k].fleetEnabled = false;
							}
						}
					}
				}
				if (modifier[13] > 0)
				{
					SpaceSector.PrefabDescByModelIndex[lancerModelIndex].unitMarchMovementSpeed = (float)oriLancerMarchMovementSpeed * ((float)modifier[13] * 1f / 100f);
					SpaceSector.PrefabDescByModelIndex[lancerModelIndex].unitMaxMovementAcceleration = (float)oriLancerMaxMovementAcceleration * ((float)modifier[13] * 1f / 100f);
				}
			}
			PostLogicTick(time);
			MMSCPU.EndSample(TCFVPerformanceMonitor.Assault);
			MMSCPU.EndSample(TCFVPerformanceMonitor.MainLogic);
		}

		public static void PostLogicTick(long time)
		{
			bool flag = assaultHives != null && assaultHives.Count > 0;
			for (int i = 0; i < assaultHives.Count; i++)
			{
				if (assaultHives[i].state == EAssaultHiveState.Remove)
				{
					invincibleHives[assaultHives[i].byAstroIndex] = -1;
					modifierHives[assaultHives[i].byAstroIndex] = -1;
					alertHives[assaultHives[i].byAstroIndex] = -1;
				}
				else
				{
					flag = false;
				}
			}
			if (flag && !MP.clientBlocker)
			{
				OnAssaultEnd();
			}
		}

		public static void CalcCombatState()
		{
			if (assaultHives == null || assaultHives.Count == 0)
			{
				Configs.combatState = 0;
				return;
			}
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			for (int i = 0; i < assaultHives.Count; i++)
			{
				if (assaultHives[i].state == EAssaultHiveState.Assault)
				{
					flag3 = true;
					break;
				}
				if (assaultHives[i].timeTillAssault <= 18000)
				{
					flag2 = true;
				}
				else if (assaultHives[i].state != EAssaultHiveState.End && assaultHives[i].state != EAssaultHiveState.Remove)
				{
					flag = true;
				}
			}
			if (flag3)
			{
				Configs.combatState = 3;
			}
			else if (flag2)
			{
				Configs.combatState = 2;
			}
			else if (flag)
			{
				Configs.combatState = 1;
			}
		}

		public static void ClearDataArrays()
		{
			if (invincibleHives == null)
			{
				invincibleHives = new int[GameMain.spaceSector.maxHiveCount];
			}
			else
			{
				for (int i = 0; i < invincibleHives.Length; i++)
				{
					invincibleHives[i] = -1;
				}
			}
			if (modifierHives == null)
			{
				modifierHives = new int[GameMain.spaceSector.maxHiveCount];
			}
			else
			{
				for (int j = 0; j < modifierHives.Length; j++)
				{
					modifierHives[j] = -1;
				}
			}
			if (alertHives == null)
			{
				alertHives = new int[GameMain.spaceSector.maxHiveCount];
			}
			else
			{
				for (int k = 0; k < alertHives.Length; k++)
				{
					alertHives[k] = -1;
				}
			}
			if (modifier == null)
			{
				modifier = new List<int>
				{
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0
				};
			}
			else
			{
				for (int l = 0; l < modifier.Count; l++)
				{
					modifier[l] = 0;
				}
			}
			bool flag = true;
			SpaceSector.PrefabDescByModelIndex[lancerModelIndex].unitMarchMovementSpeed = oriLancerMarchMovementSpeed;
			SpaceSector.PrefabDescByModelIndex[lancerModelIndex].unitMaxMovementAcceleration = oriLancerMaxMovementAcceleration;
			modifierEnabled = false;
			assaultHives.Clear();
		}

		public static void InitNewAssault(int starIndex = -1)
		{
			if (MP.clientBlocker)
			{
				return;
			}
			if (starIndex < 0)
			{
				long num = (long)((float)((long)SkillPoints.skillLevelR[8] * 1000000L) * SkillPoints.skillValuesR[8]);
				List<long> list = new List<long>();
				for (int i = 0; i < GameMain.galaxy.starCount; i++)
				{
					list.Add(0L);
					if (GameMain.galaxy.stars[i] == null)
					{
						continue;
					}
					PlanetData[] planets = GameMain.galaxy.stars[i].planets;
					for (int j = 0; j < GameMain.galaxy.stars[i].planetCount; j++)
					{
						if (planets[j] == null || planets[j].factory == null)
						{
							continue;
						}
						PlanetFactory factory = planets[j].factory;
						PowerSystem powerSystem = factory.powerSystem;
						if (powerSystem == null)
						{
							continue;
						}
						for (int k = 1; k < powerSystem.netCursor; k++)
						{
							PowerNetwork val = powerSystem.netPool[k];
							if (val != null)
							{
								list[i] += val.energyServed;
							}
						}
					}
					if (list[i] * 60 <= num)
					{
						list[i] = 0L;
					}
				}
				long num2 = list.Sum();
				if (num2 <= 0)
				{
					num2 = 1L;
				}
				List<double> list2 = new List<double>();
				if (list.Count > 1)
				{
					list2.Add((double)list[0] * 1.0 / (double)num2);
				}
				for (int l = 1; l < list.Count; l++)
				{
					list2.Add(list2[l - 1] + (double)list[l] * 1.0 / (double)num2);
				}
				double num3 = Utils.RandDouble();
				for (int m = 0; m < list2.Count; m++)
				{
					if (list2[m] >= num3)
					{
						starIndex = m;
						break;
					}
				}
			}
			ClearDataArrays();
			if (starIndex < 0)
			{
				return;
			}
			int num4 = Configs.wavePerStar[starIndex];
			int totalWave = Configs.totalWave;
			bool flag = totalWave % 5 == 4;
			int assaultTotalNum = GetAssaultTotalNum(num4);
			int val2 = assaultTotalNum / 1440 + 1;
			int val3 = Math.Min(assaultTotalNum / 1440 + 4, assaultTotalNum / 10 + 1) + 1;
			val3 = Math.Min(val3, 9);
			val2 = Math.Min(val2, 8);
			int num5 = Utils.RandInt(val2, val3);
			int num6 = assaultTotalNum / num5;
			int hiveLevel = GetHiveLevel(num4);
			for (int n = 0; n < num5; n++)
			{
				int num7 = (int)(((Utils.RandDouble() - 0.5) / 2.5 + 1.0) * (double)num6) + 1;
				if (num7 > 1440)
				{
					num7 = 1440;
				}
				AssaultHive assaultHive = new AssaultHive(starIndex, n, assaultHives.Count);
				assaultHive.assaultNumTotal = num7;
				assaultHive.level = Math.Min(100, hiveLevel + (flag ? 20 : 0));
				assaultHive.hive.evolve.level = Math.Max(assaultHive.hive.evolve.level, assaultHive.level);
				float num8 = (float)Math.Max(assaultHive.level, 1) * 1f / 20f;
				if (num8 > 1f)
				{
					num8 = 1f + (num8 - 1f) / 4f;
				}
				assaultHive.inhibitPointsTotalInit = (int)(num8 * (float)basicInhibitPoint);
				assaultHive.inhibitPointsLimit = assaultHive.inhibitPointsTotalInit;
				if (n == num5 - 1)
				{
					assaultHive.inhibitPointsLimit = (int)((double)assaultHive.inhibitPointsLimit * 0.8) + 1;
				}
				assaultHive.time = n * 5;
				assaultHive.timeTillAssault = GetAssembleTime(num4) + 5 * n;
				assaultHive.timeTotalInit = assaultHive.timeTillAssault;
				if (flag)
				{
					assaultHive.isSuper = flag;
					assaultHive.timeTillAssault += 18000;
					assaultHive.timeTotalInit += 18000;
				}
				assaultHives.Add(assaultHive);
			}
			if (flag)
			{
				InitModifiers(totalWave, num4);
			}
			assaultActive = true;
			timeChangedByRelic = false;
			Configs.wavePerStar[starIndex]++;
			MP.Sync(EDataType.CallOnAssaultInited);
		}

		public static void InitModifiers(int waveCountTotal, int waveCountCur)
		{
			int num = waveCountTotal / 5;
			List<int> list = new List<int>();
			List<int> list2 = modifierPoolEarly;
			List<int> list3 = modifierValueMinEarly;
			if (num >= 10)
			{
				list2 = modifierPoolLate;
				list3 = modifierValueMinLate;
			}
			else if (num >= 5)
			{
				list2 = modifierPoolMid;
				list3 = modifierValueMinMid;
			}
			for (int i = 0; i < list2.Count; i++)
			{
				list.Add(list2[i]);
			}
			int modifierCount = GetModifierCount(num);
			for (int j = 0; j < modifierCount; j++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				int index = Utils.RandInt(0, list.Count);
				int index2 = list[index];
				int value = Utils.RandInt(list3[index2], 2 * list3[index2] + 1);
				modifier[index2] = value;
				list.RemoveAt(index);
			}
		}

		public static void NotifyAssaultDetected()
		{
			if (assaultHives != null && assaultHives.Count != 0 && assaultHives[0] != null)
			{
				bool isSuper = assaultHives[0].isSuper;
				int starIndex = assaultHives[0].starIndex;
				string text = "";
				if (!isSuper)
				{
					string text2 = text;
					string format = Localization.Translate("侦测到虚空入侵提示");
					StarData obj = GameMain.galaxy.StarById(starIndex + 1);
					text = text2 + string.Format(format, (obj != null) ? obj.displayName : null);
				}
				else
				{
					string text3 = text;
					string format2 = Localization.Translate("侦测到虚空入侵提示");
					StarData obj2 = GameMain.galaxy.StarById(starIndex + 1);
					text = text3 + string.Format(format2, (obj2 != null) ? obj2.displayName : null);
					text += Localization.Translate("虚空入侵额外特性提示");
					text += GetModifierDesc();
				}
				UIDialogPatch.ShowUIDialog(Localization.Translate("虚空入侵"), text);
			}
		}

		public static string GetModifierDesc()
		{
			string text = "";
			for (int i = 0; i < modifier.Count; i++)
			{
				if (modifier[i] > 0)
				{
					int value = modifier[i];
					text += "\n<color=#ffa800dd>";
					text += string.Format(Localization.Translate($"额外特性描述{i}"), Math.Abs(value));
					text += "</color>";
				}
			}
			return text;
		}

		public static void OnAssaultEnd()
		{
			MP.Sync(EDataType.CallOnAssaultEndSettleStart);
			assaultActive = false;
			modifierEnabled = false;
			if (modifier[6] < 0)
			{
				GameHistoryData history = GameMain.data.history;
				history.kineticDamageScale -= (float)modifier[6] * 1f / 100f;
			}
			if (modifier[7] < 0)
			{
				GameHistoryData history2 = GameMain.data.history;
				history2.energyDamageScale -= (float)modifier[7] * 1f / 100f;
			}
			if (modifier[8] < 0)
			{
				GameHistoryData history3 = GameMain.data.history;
				history3.blastDamageScale -= (float)modifier[8] * 1f / 100f;
			}
			if (modifier[9] < 0)
			{
				GameHistoryData history4 = GameMain.data.history;
				history4.magneticDamageScale -= (float)modifier[9] * 1f / 100f;
			}
			if (modifier[10] != 0)
			{
				Player mainPlayer = GameMain.mainPlayer;
				CombatModuleComponent val = ((mainPlayer == null) ? null : mainPlayer.mecha?.spaceCombatModule);
				if (val != null)
				{
					ModuleFleet[] moduleFleets = val.moduleFleets;
					for (int i = 0; i < moduleFleets.Length; i++)
					{
						if (moduleFleets[i].protoId != DropletFleetPatchers.fleetConfigId1 && moduleFleets[i].protoId != DropletFleetPatchers.fleetConfigId2)
						{
							moduleFleets[i].fleetEnabled = true;
						}
					}
				}
			}
			int num = 0;
			int num2 = 0;
			bool flag = false;
			for (int j = 0; j < assaultHives.Count; j++)
			{
				num += assaultHives[j].enemyKilled;
				num2 += assaultHives[j].assaultNum;
				if (!flag)
				{
					flag = assaultHives[j].isSuper;
				}
			}
			if (num2 <= 0)
			{
				num2 = 1;
			}
			float num3 = (float)num * 1f / (float)num2;
			if (num3 > 1f)
			{
				num3 = 1f;
			}
			int num4 = GiveReward(num3);
			string text = "";
			text += string.Format(Localization.Translate("虚空入侵结束提示"), num, num2, num4);
			if (flag)
			{
				if (EventSystem.recorder != null && EventSystem.recorder.protoId > 0 && Relic.GetRelicCount() < Relic.relicHoldMax)
				{
					if (EventSystem.recorder.modifier != null)
					{
						EventSystem.recorder.modifier[4] += 50;
					}
					text = text + "\n\n" + Localization.Translate("虚空入侵结束提示元驱动解译");
				}
				else if (EventSystem.recorder == null || EventSystem.recorder.protoId == 0)
				{
					if (Relic.GetRelicCount() <= 0)
					{
						if (EventSystem.neverStartTheFirstEvent > 0)
						{
							EventSystem.InitNewEvent();
						}
						else
						{
							EventSystem.TransferTo(9997);
							EventSystem.recorder.decodeType = 24;
							EventSystem.recorder.decodeTimeNeed = 3600;
							EventSystem.recorder.decodeTimeSpend = 0;
						}
					}
					else
					{
						EventSystem.TransferTo(9998);
					}
					text = text + "\n\n" + Localization.Translate("虚空入侵结束提示元驱动发现");
				}
			}
			UIDialogPatch.ShowUIDialog(Localization.Translate("虚空入侵结束"), text);
			assaultHives.Clear();
			ClearDataArrays();
			Configs.combatState = 0;
			BattleBGMController.SetWaveFinished();
		}

		public static int GiveReward(float factor)
		{
			int totalWave = Configs.totalWave;
			int num = 0;
			num = ((totalWave < Configs.rewardSPMap.Count && totalWave >= 0) ? Configs.rewardSPMap[totalWave] : Configs.rewardSPMap.Last());
			if (num > 2 && timeChangedByRelic)
			{
				num = 2;
			}
			int num2 = (int)(factor * (float)num);
			SkillPoints.totalPoints += num2;
			return num2;
		}

		public static int GetAssaultTotalNum(int waveCount)
		{
			float num = ((CombatSettings)(ref GameMain.data.history.combatSettings)).difficulty;
			float num2 = 4f;
			if (num < 0.05f)
			{
				num = 0.05f;
			}
			else if (num > num2)
			{
				num = num2;
			}
			int num3 = 36;
			int num4 = Configs.totalAssaultNumMap.Count - 1;
			int num5 = num4 - 36;
			int num6 = num3;
			if (num > 1f)
			{
				num6 += (int)(((double)num - 1.0) / ((double)num2 - 1.0) * (double)num5);
			}
			if (num6 > num4)
			{
				num6 = num4;
			}
			int num7 = ((waveCount < num6 && waveCount >= 0) ? Configs.totalAssaultNumMap[waveCount] : Configs.totalAssaultNumMap[num6]);
			if (num < 1f)
			{
				num7 = Math.Max((int)((float)num7 * num), 1);
			}
			if (Configs.developerMode)
			{
				Utils.Log($"dif{num}, realMaxlen{num6}, got result {num7}");
			}
			return num7;
		}

		public static int GetHiveLevel(int waveCount)
		{
			float num = ((CombatSettings)(ref GameMain.data.history.combatSettings)).difficulty;
			if (num < 0.125f)
			{
				num = 0.125f;
			}
			int num2 = ((waveCount < Configs.levelMap.Count && waveCount >= 0) ? Configs.levelMap[waveCount] : Configs.levelMap.Last());
			if (num < 1f)
			{
				num2 = (int)((float)num2 * num);
			}
			return num2;
		}

		public static int GetAssembleTime(int waveCount)
		{
			if (Configs.totalWave > 20)
			{
				int num = Configs.totalWave / 10;
				if (num > 10)
				{
					num = 10;
				}
				waveCount += num;
			}
			float num2 = ((CombatSettings)(ref GameMain.data.history.combatSettings)).difficulty;
			int num3 = 8 - (int)num2;
			if (num3 < 0)
			{
				num3 = 0;
			}
			if (num3 > 6)
			{
				num3 = 6;
			}
			int num4 = Configs.assembleTimeMap.Count - 1 - num3;
			if (num4 < 0)
			{
				num4 = 0;
			}
			if (num4 >= Configs.assembleTimeMap.Count)
			{
				num4 = Configs.assembleTimeMap.Count - 1;
			}
			if (DspBattlePlugin.voidInvasionMaxFrequency.Value >= 2)
			{
				num4 = Configs.assembleTimeMap.Count - 1;
			}
			if (waveCount >= num4 || waveCount < 0)
			{
				waveCount = num4;
			}
			if (DspBattlePlugin.voidInvasionMaxFrequency.Value >= 3 || waveCount == num4)
			{
				return 18000;
			}
			return Configs.assembleTimeMap[waveCount];
		}

		public static int GetModifierCount(int superWaveCount)
		{
			int num = 0;
			if (superWaveCount >= modifierMaxActiveCount.Count())
			{
				num = modifierMaxActiveCount.Last();
			}
			else if (superWaveCount >= 0)
			{
				num = modifierMaxActiveCount[superWaveCount];
			}
			int min = num;
			if (num >= 4)
			{
				min = num - 2;
			}
			else if (num >= 2)
			{
				min = num - 1;
			}
			return Utils.RandInt(min, num + 1);
		}

		public static void CheckHiveStatus(int starIndex)
		{
			for (int i = 1; i < 9; i++)
			{
				EnemyDFHiveSystem val = GameMain.spaceSector.dfHivesByAstro[starIndex * 8 + i];
				if (val != null)
				{
					int instId = val.pbuilders[1].instId;
					Utils.Log($"instId is {instId}");
				}
				else
				{
					Utils.Log($"null hive at{i}");
				}
			}
		}

		public static void BuildHiveAlreadyInited(int starIndex)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 1; i < 9; i++)
			{
				EnemyDFHiveSystem val = GameMain.spaceSector.dfHivesByAstro[starIndex * 8 + i];
				if (val == null)
				{
					continue;
				}
				ref Builder reference = ref val.pbuilders[1];
				if (reference.instId <= 0)
				{
					int protoId = reference.protoId;
					EnemyProto val2 = ((ProtoSet<EnemyProto>)(object)LDB.enemies).Select(protoId);
					if (val2 != null)
					{
						EnemyData val3 = default(EnemyData);
						val3.protoId = (short)protoId;
						val3.modelIndex = (short)val2.ModelIndex;
						val3.astroId = val.hiveAstroId;
						val3.originAstroId = val.hiveAstroId;
						val3.owner = 0;
						val3.port = 0;
						val3.dynamic = !val2.IsBuilding;
						val3.isSpace = true;
						val3.localized = true;
						val3.stateFlags = 0;
						val3.pos = VectorLF3.op_Implicit(reference.pos);
						val3.rot = reference.rot;
						GameMain.spaceSector.AddEnemyDataWithComponents(ref val3, val, 1, false);
					}
					val.isEmpty = false;
				}
			}
		}

		public static bool hasCore(this EnemyDFHiveSystem hive)
		{
			if (hive == null)
			{
				return false;
			}
			return hive.pbuilders[1].instId > 0;
		}

		public static void BuildCore(this EnemyDFHiveSystem hive)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (hive == null)
			{
				return;
			}
			ref Builder reference = ref hive.pbuilders[1];
			if (reference.instId <= 0)
			{
				int protoId = reference.protoId;
				EnemyProto val = ((ProtoSet<EnemyProto>)(object)LDB.enemies).Select(protoId);
				if (val != null)
				{
					EnemyData val2 = default(EnemyData);
					val2.protoId = (short)protoId;
					val2.modelIndex = (short)val.ModelIndex;
					val2.astroId = hive.hiveAstroId;
					val2.originAstroId = hive.hiveAstroId;
					val2.owner = 0;
					val2.port = 0;
					val2.dynamic = !val.IsBuilding;
					val2.isSpace = true;
					val2.localized = true;
					val2.stateFlags = 0;
					val2.pos = VectorLF3.op_Implicit(reference.pos);
					val2.rot = reference.rot;
					GameMain.spaceSector.AddEnemyDataWithComponents(ref val2, hive, 1, false);
				}
				hive.isEmpty = false;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyDFHiveSystem), "InitFormations")]
		public static bool InitDFSHivePrePatch(ref EnemyDFHiveSystem __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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
			__instance.forms = (EnemyFormation[])(object)new EnemyFormation[3];
			__instance.forms[0] = new EnemyFormation();
			__instance.forms[1] = new EnemyFormation();
			__instance.forms[2] = new EnemyFormation();
			__instance.forms[0].SetPortCount(1440);
			__instance.forms[1].SetPortCount(120);
			__instance.forms[2].SetPortCount(6);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EvolveData), "AddExp")]
		public static bool EvolveDataAddExpPrefix(ref EvolveData __instance, int _addexp)
		{
			if (__instance.level >= 100)
			{
				if (__instance.expf != 0 || __instance.expp != 0 || __instance.level != 100)
				{
					__instance.level = 100;
					__instance.expf = 0;
					__instance.expp = 0;
					__instance.expl = EvolveData.LevelCummulativeExp(100);
				}
				return false;
			}
			__instance.expf += _addexp;
			bool flag = __instance.level < 30;
			while (__instance.expf >= EvolveData.levelExps[__instance.level] && flag)
			{
				int num = EvolveData.levelExps.Length - 1;
				__instance.expf -= EvolveData.levelExps[__instance.level];
				__instance.expl += EvolveData.levelExps[__instance.level];
				__instance.level++;
				if (__instance.level >= num)
				{
					__instance.level = num;
					__instance.expf = 0;
					return false;
				}
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EvolveData), "AddExpPoint")]
		public static bool EvolveDataAddExpPointPrefix(ref EvolveData __instance, int _addexpp)
		{
			if (__instance.level >= 100)
			{
				if (__instance.expf != 0 || __instance.expp != 0 || __instance.level != 100)
				{
					__instance.level = 30;
					__instance.expf = 0;
					__instance.expp = 0;
					__instance.expl = EvolveData.LevelCummulativeExp(100);
				}
				return false;
			}
			if (_addexpp > 0)
			{
				__instance.expp += _addexpp;
				if (__instance.expp >= 10000)
				{
					__instance.expf += __instance.expp / 10000;
					__instance.expp %= 10000;
					bool flag = __instance.level < 30;
					while (__instance.expf >= EvolveData.levelExps[__instance.level] && flag)
					{
						int num = EvolveData.levelExps.Length - 1;
						__instance.expf -= EvolveData.levelExps[__instance.level];
						__instance.expl += EvolveData.levelExps[__instance.level];
						__instance.level++;
						if (__instance.level >= num)
						{
							__instance.level = num;
							__instance.expf = 0;
							__instance.expp = 0;
							return false;
						}
					}
				}
			}
			return false;
		}

		public static void TryEnableVoidInvasion()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			string text = Localization.Translate("开启虚空入侵");
			string text2 = Localization.Translate("虚空入侵提示");
			string text3 = Localization.Translate("否");
			string text4 = Localization.Translate("是");
			Response val = RegretEnable;
			object obj = <>c.<>9__53_0;
			if (obj == null)
			{
				Response val2 = delegate
				{
					voidInvasionEnabled = true;
				};
				<>c.<>9__53_0 = val2;
				obj = (object)val2;
			}
			UIMessageBox.Show(text, text2, text3, text4, 1, val, (Response)obj);
		}

		public static void RegretEnable()
		{
		}

		public static void AskEnableVoidInvasion()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			if (!Configs.enableVoidInvasionUpdate)
			{
				return;
			}
			string text = Localization.Translate("开启虚空入侵");
			string text2 = Localization.Translate("虚空入侵版本更新提示");
			string text3 = Localization.Translate("否");
			string text4 = Localization.Translate("是");
			Response val = RegretEnable;
			object obj = <>c.<>9__55_0;
			if (obj == null)
			{
				Response val2 = delegate
				{
					voidInvasionEnabled = true;
				};
				<>c.<>9__55_0 = val2;
				obj = (object)val2;
			}
			UIMessageBox.Show(text, text2, text3, text4, 1, val, (Response)obj);
		}

		public static bool CheckCasterOrTargetHasModifier(ref SkillTarget caster)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			if (modifierEnabled && caster.astroId > 1000000 && (int)caster.type == 4)
			{
				int num = caster.astroId - 1000000;
				if (num < modifierHives.Length && modifierHives[num] >= 0)
				{
					return true;
				}
			}
			return false;
		}

		public static bool CheckHiveHasModifier(ref EnemyDFHiveSystem hive)
		{
			return CheckHiveHasModifier(hive.hiveAstroId);
		}

		public static bool CheckHiveHasModifier(int oriAstroId)
		{
			if (modifierEnabled && oriAstroId > 1000000)
			{
				int num = oriAstroId - 1000000;
				if (num < modifierHives.Length && modifierHives[num] >= 0)
				{
					return true;
				}
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CombatStat), "TickSkillLogic")]
		public static void HpRecoverBuff(ref CombatStat __instance)
		{
			if (CheckHiveHasModifier(__instance.originAstroId) && modifierEnabled && modifier[12] > 0)
			{
				__instance.hp += modifier[12] * 100 / 60;
				if (__instance.hp > __instance.hpMax)
				{
					__instance.hp = __instance.hpMax;
				}
			}
		}

		public static void Import(BinaryReader r)
		{
			InitWhenLoad();
			if (Configs.versionWhenImporting >= 30240716)
			{
				voidInvasionEnabled = r.ReadBoolean();
				difficulty = r.ReadInt32();
				int num = r.ReadInt32();
				for (int i = 0; i < num; i++)
				{
					AssaultHive assaultHive = new AssaultHive(0, i, i);
					assaultHive.Import(r);
					assaultHives.Add(assaultHive);
				}
				modifierEnabled = r.ReadBoolean();
				int num2 = r.ReadInt32();
				for (int j = 0; j < num2; j++)
				{
					int value = r.ReadInt32();
					if (j < modifier.Count)
					{
						modifier[j] = value;
					}
				}
				timeChangedByRelic = r.ReadBoolean();
			}
			UIEscMenuPatch.Init();
			if (Configs.versionWhenImporting < 30240703)
			{
				AskEnableVoidInvasion();
			}
			if (Configs.versionWhenImporting >= 30240716 && Configs.versionWhenImporting < 30240825)
			{
				voidInvasionEnabled = false;
			}
			if (Configs.versionWhenImporting >= 30240830)
			{
				nextRollVoidEcho = r.ReadInt32();
			}
		}

		public static void Export(BinaryWriter w)
		{
			w.Write(voidInvasionEnabled);
			w.Write(difficulty);
			w.Write(assaultHives.Count);
			for (int i = 0; i < assaultHives.Count; i++)
			{
				assaultHives[i].Export(w);
			}
			w.Write(modifierEnabled);
			w.Write(modifier.Count);
			for (int j = 0; j < modifier.Count; j++)
			{
				w.Write(modifier[j]);
			}
			w.Write(timeChangedByRelic);
			w.Write(nextRollVoidEcho);
		}

		public static void IntoOtherSave()
		{
			InitWhenLoad();
		}

		public static EnemyDFHiveSystem TryCreateNewHiveAndCore(int starIndex)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			EnemyDFHiveSystem val = GameMain.spaceSector.TryCreateNewHive(GameMain.galaxy.StarById(starIndex + 1));
			if (val != null)
			{
				ref Builder reference = ref val.pbuilders[1];
				if (reference.instId > 0)
				{
					return val;
				}
				int protoId = reference.protoId;
				EnemyProto val2 = ((ProtoSet<EnemyProto>)(object)LDB.enemies).Select(protoId);
				if (val2 != null)
				{
					EnemyData val3 = default(EnemyData);
					val3.protoId = (short)protoId;
					val3.modelIndex = (short)val2.ModelIndex;
					val3.astroId = val.hiveAstroId;
					val3.originAstroId = val.hiveAstroId;
					val3.owner = 0;
					val3.port = 0;
					val3.dynamic = !val2.IsBuilding;
					val3.isSpace = true;
					val3.localized = true;
					val3.stateFlags = 0;
					val3.pos = VectorLF3.op_Implicit(reference.pos);
					val3.rot = reference.rot;
					GameMain.spaceSector.AddEnemyDataWithComponents(ref val3, val, 1, false);
				}
				val.isEmpty = false;
			}
			return val;
		}
	}
	public class AssaultHive
	{
		public int listIndex;

		public int starIndex;

		public int oriAstroId;

		public int orbitIndex;

		public int byAstroIndex;

		public int strength;

		public EAssaultHiveState state;

		public int time;

		public int timeTillAssault;

		public int timeTotalInit;

		public int timeDelayedByRelic;

		public int level;

		public int oriLevel;

		public int assaultNumTotal;

		public int inhibitPoints;

		public int inhibitPointsLimit;

		public int inhibitPointsTotalInit;

		public bool canFullyStopped;

		public bool isSuper;

		public int enemyKilled;

		public EnemyDFHiveSystem hive;

		public bool isCreated;

		public static int timeDelayedMax = 72000;

		public int assembleNum => Math.Min(1440, (int)((double)assaultNum * 1.5) + 1);

		public int assaultNum
		{
			get
			{
				if (inhibitPoints >= inhibitPointsTotalInit || inhibitPointsTotalInit <= 0)
				{
					return 0;
				}
				return Math.Max(1, (int)((double)(assaultNumTotal * (inhibitPointsTotalInit - inhibitPoints)) * 1.0 / (double)inhibitPointsTotalInit));
			}
		}

		public AssaultHive(int starIndex, int orbitIndex, int listIndex)
		{
			oriAstroId = 1000000 + starIndex * 8 + orbitIndex + 1;
			this.starIndex = starIndex;
			this.orbitIndex = orbitIndex;
			this.listIndex = listIndex;
			byAstroIndex = oriAstroId - 1000000;
			state = EAssaultHiveState.Idle;
			time = 0;
			timeDelayedByRelic = 0;
			inhibitPoints = 0;
			isCreated = false;
			isSuper = false;
			enemyKilled = 0;
			CreateOrGetHive();
		}

		public void CreateOrGetHive()
		{
			hive = GameMain.data.spaceSector.dfHivesByAstro[byAstroIndex];
			if (MP.clientBlocker)
			{
				return;
			}
			if (hive == null)
			{
				int num = 8;
				while (hive == null && num > 0)
				{
					GameMain.spaceSector.TryCreateNewHive(GameMain.galaxy.StarById(starIndex + 1));
					hive = GameMain.data.spaceSector.dfHivesByAstro[byAstroIndex];
					num--;
				}
			}
			if (hive != null)
			{
				if (!hive.hasCore())
				{
					isCreated = true;
					hive.BuildCore();
				}
				if (!hive.realized)
				{
					hive.Realize();
				}
				oriLevel = hive.evolve.level;
			}
			else
			{
				Debug.Log((object)$"hive is null when init assault hives with {starIndex} - {listIndex}, now removing");
				state = EAssaultHiveState.Remove;
			}
		}

		public void LogicTick()
		{
			if (hive == null)
			{
				if (!MP.clientBlocker)
				{
					state = EAssaultHiveState.Remove;
					time = 0;
				}
				else
				{
					Utils.Log("null hive, but not removing because you are client.");
				}
			}
			else if (!hive.isAlive && state != EAssaultHiveState.End && state != EAssaultHiveState.Remove)
			{
				state = EAssaultHiveState.End;
				time = 120;
			}
			switch (state)
			{
			case EAssaultHiveState.Idle:
				LogicTickIdle();
				break;
			case EAssaultHiveState.Expand:
				LogicTickExpand();
				break;
			case EAssaultHiveState.Assemble:
				LogicTickAssemble();
				break;
			case EAssaultHiveState.Assault:
				LogicTickAssault();
				break;
			case EAssaultHiveState.End:
				LogicTickEnd();
				break;
			case EAssaultHiveState.Remove:
				LogicTickRemove();
				break;
			}
			if (state == EAssaultHiveState.Idle || state == EAssaultHiveState.Expand || state == EAssaultHiveState.Assemble)
			{
				AssaultController.invincibleHives[byAstroIndex] = listIndex;
			}
			else
			{
				AssaultController.invincibleHives[byAstroIndex] = -1;
			}
			if (state == EAssaultHiveState.Assault && AssaultController.modifierEnabled)
			{
				AssaultController.modifierHives[byAstroIndex] = listIndex;
			}
			else
			{
				AssaultController.modifierHives[byAstroIndex] = -1;
			}
			if (state == EAssaultHiveState.Assemble || state == EAssaultHiveState.Assault)
			{
				AssaultController.alertHives[byAstroIndex] = listIndex;
			}
			else
			{
				AssaultController.alertHives[byAstroIndex] = -1;
			}
		}

		public void LogicTickIdle()
		{
			timeTillAssault--;
			time--;
			if (hive != null)
			{
				hive.evolve.threat = 0;
			}
			if (time <= 0)
			{
				state = EAssaultHiveState.Expand;
				time = 5400;
			}
		}

		public void LogicTickExpand()
		{
			timeTillAssault--;
			time--;
			if (hive != null)
			{
				hive.evolve.threat = 0;
			}
			QuickBuild(5);
			hive.evolve.threat = 0;
			hive.evolve.waveTicks = 0;
			hive.evolve.waveAsmTicks = 0;
			if (time <= 0)
			{
				state = EAssaultHiveState.Assemble;
				time = timeTillAssault;
				if (listIndex == 0)
				{
					AssaultController.NotifyAssaultDetected();
				}
				if (CheckIfAllHiveReachedState(EAssaultHiveState.Assemble))
				{
					MP.Sync(EDataType.CallOnAssaultStateSwitch);
				}
			}
		}

		public void LogicTickAssemble()
		{
			if (Relic.playerIdleTime < Relic.playerIdleTimeMax)
			{
				timeTillAssault--;
				time--;
			}
			if (hive != null)
			{
				hive.evolve.threat = 0;
			}
			QuickAssemble();
			hive.evolve.threat = 1;
			hive.evolve.waveTicks = 0;
			hive.evolve.waveAsmTicks = 0;
			if (time > 0 || MP.clientBlocker)
			{
				return;
			}
			LaunchAssault();
			state = EAssaultHiveState.Assault;
			if (!AssaultController.modifierEnabled && AssaultController.modifier.Sum() > 0)
			{
				AssaultController.modifierEnabled = true;
			}
			time = 0;
			if (AssaultController.modifierEnabled)
			{
				int num = AssaultController.modifier[6];
				if (num > 0)
				{
					float num2 = (float)num * 1f / 100f;
					if (num2 > GameMain.data.history.kineticDamageScale)
					{
						num2 = GameMain.data.history.kineticDamageScale;
					}
					int num3 = (int)(num2 * 100f);
					num2 = (float)num3 * 1f / 100f;
					GameHistoryData history = GameMain.data.history;
					history.kineticDamageScale -= num2;
					AssaultController.modifier[6] = -num3;
				}
				num = AssaultController.modifier[7];
				if (num > 0)
				{
					float num4 = (float)num * 1f / 100f;
					if (num4 > GameMain.data.history.energyDamageScale)
					{
						num4 = GameMain.data.history.energyDamageScale;
					}
					int num5 = (int)(num4 * 100f);
					num4 = (float)num5 * 1f / 100f;
					GameHistoryData history2 = GameMain.data.history;
					history2.energyDamageScale -= num4;
					AssaultController.modifier[7] = -num5;
				}
				num = AssaultController.modifier[8];
				if (num > 0)
				{
					float num6 = (float)num * 1f / 100f;
					if (num6 > GameMain.data.history.blastDamageScale)
					{
						num6 = GameMain.data.history.blastDamageScale;
					}
					int num7 = (int)(num6 * 100f);
					num6 = (float)num7 * 1f / 100f;
					GameHistoryData history3 = GameMain.data.history;
					history3.blastDamageScale -= num6;
					AssaultController.modifier[8] = -num7;
				}
				num = AssaultController.modifier[9];
				if (num > 0)
				{
					float num8 = (float)num * 1f / 100f;
					if (num8 > GameMain.data.history.magneticDamageScale)
					{
						num8 = GameMain.data.history.magneticDamageScale;
					}
					int num9 = (int)(num8 * 100f);
					num8 = (float)num9 * 1f / 100f;
					GameHistoryData history4 = GameMain.data.history;
					history4.magneticDamageScale -= num8;
					AssaultController.modifier[9] = -num9;
				}
			}
			if (CheckIfAllHiveReachedState(EAssaultHiveState.Assault))
			{
				MP.Sync(EDataType.CallOnLaunchAllVoidAssault);
			}
		}

		public void LogicTickAssault()
		{
			timeTillAssault--;
			time--;
			if (hive == null)
			{
				state = EAssaultHiveState.End;
				time = 120;
			}
			if (!MP.clientBlocker)
			{
				if (!hive.hasIncomingAssaultingUnit)
				{
					state = EAssaultHiveState.End;
					time = 120;
				}
				if (time == 1)
				{
					state = EAssaultHiveState.End;
					time = 120;
				}
			}
		}

		public void LogicTickEnd()
		{
			timeTillAssault--;
			time--;
			if (hive != null)
			{
				int num = 100;
				int num2 = hive.pbuilders.Length;
				int num3 = num2 / num * (time % num);
				int num4 = num2 / num * (time % num + 1);
				if (num4 > num2)
				{
					num4 = num2;
				}
				if (time % num == num - 1)
				{
					num4 = num2;
				}
				for (int i = num3; i < num4; i++)
				{
					int instId = hive.pbuilders[i].instId;
					if (instId > 0)
					{
						KillHiveStrcuture(instId);
					}
				}
			}
			if (hive.evolve.level > oriLevel)
			{
				hive.evolve.level--;
				hive.evolve.expf = 0;
				hive.evolve.expp = 0;
			}
			if (time <= 0)
			{
				if (hive.evolve.level > oriLevel)
				{
					hive.evolve.level = oriLevel;
				}
				state = EAssaultHiveState.Remove;
			}
		}

		public void LogicTickRemove()
		{
		}

		private void QuickBuild(int speedFactor)
		{
			if (hive == null)
			{
				return;
			}
			ref AnimData[] enemyAnimPool = ref hive.sector.enemyAnimPool;
			if (!hive.realized)
			{
				return;
			}
			int cursor = hive.cores.cursor;
			int cursor2 = hive.builders.cursor;
			EnemyBuilderComponent[] buffer = hive.builders.buffer;
			DFSCoreComponent[] buffer2 = hive.cores.buffer;
			while (speedFactor > 0)
			{
				speedFactor--;
				for (int i = 1; i < cursor2; i++)
				{
					ref EnemyBuilderComponent reference = ref buffer[i];
					if (reference.id == i)
					{
						int enemyId = reference.enemyId;
						reference.energy = reference.maxEnergy;
						reference.matter = reference.maxMatter;
						((EnemyBuilderComponent)(ref reference)).LogicTick();
						if (reference.state >= 3)
						{
							((EnemyBuilderComponent)(ref reference)).BuildLogic_Space(hive, buffer, hive.pbuilders);
						}
						if (speedFactor == 0)
						{
							((EnemyBuilderComponent)(ref reference)).RefreshAnimation_Space(hive.pbuilders, ref enemyAnimPool[enemyId]);
						}
					}
				}
			}
		}

		private void QuickAssemble()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			EnemyFormation val = hive.forms[0];
			if (val.vacancyCount > 0 && val.unitCount < assembleNum)
			{
				int num = val.AddUnit();
				if (hive.isLocal && num > 0)
				{
					hive.InitiateUnitDeferred(0, num, new Vector3(0f, 0f, 0f), new Quaternion(0f, 0f, 0f, 0f), new Vector3(0f, 0f, 0f), 0);
				}
			}
		}

		private void LaunchAssault()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Invalid comparison between Unknown and I4
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Invalid comparison between Unknown and I4
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Invalid comparison between Unknown and I4
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Invalid comparison between Unknown and I4
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			if (MP.clientBlocker || hive == null)
			{
				return;
			}
			((HatredList)(ref hive.hatredAstros)).Sort();
			ref HatredTarget reference = ref hive.hatredAstros.max;
			bool flag = false;
			int num = 0;
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.zero;
			for (int i = 0; i < 8; i++)
			{
				switch (i)
				{
				case 0:
					reference = ref hive.hatredAstros.max;
					break;
				case 1:
					reference = ref hive.hatredAstros.h1;
					break;
				case 2:
					reference = ref hive.hatredAstros.h2;
					break;
				case 3:
					reference = ref hive.hatredAstros.h3;
					break;
				case 4:
					reference = ref hive.hatredAstros.h4;
					break;
				case 5:
					reference = ref hive.hatredAstros.h5;
					break;
				case 6:
					reference = ref hive.hatredAstros.h6;
					break;
				case 7:
					reference = ref hive.hatredAstros.min;
					break;
				}
				if (((HatredTarget)(ref reference)).isNull)
				{
					continue;
				}
				int objectId = ((HatredTarget)(ref reference)).objectId;
				PlanetData val3 = hive.sector.galaxy.PlanetById(objectId);
				if (val3 == null || (int)val3.type == 5)
				{
					continue;
				}
				PlanetFactory factory = val3.factory;
				if (factory == null)
				{
					continue;
				}
				PowerSystem powerSystem = factory.powerSystem;
				int consumerCursor = powerSystem.consumerCursor;
				int nodeCursor = powerSystem.nodeCursor;
				PowerConsumerComponent[] consumerPool = powerSystem.consumerPool;
				PowerNodeComponent[] nodePool = powerSystem.nodePool;
				EntityData[] entityPool = factory.entityPool;
				TurretComponent[] buffer = factory.defenseSystem.turrets.buffer;
				double num2 = 0.0;
				Vector3 val4 = Vector3.zero;
				if (hive._assaultPosByQuadrant == null)
				{
					hive._assaultPosByQuadrant = (Vector3[])(object)new Vector3[8];
				}
				else
				{
					for (int j = 0; j < 8; j++)
					{
						hive._assaultPosByQuadrant[j] = Vector3.zero;
					}
				}
				bool flag2 = false;
				for (int k = 1; k < consumerCursor; k++)
				{
					ref PowerConsumerComponent reference2 = ref consumerPool[k];
					if (reference2.id != k)
					{
						continue;
					}
					double num3 = 0.01;
					int networkId = reference2.networkId;
					PowerNetwork val5 = powerSystem.netPool[networkId];
					ref Vector3 plugPos = ref reference2.plugPos;
					if (val5 != null)
					{
						long num4 = val5.energyServed / 4 + val5.energyCapacity / 80 + (long)((double)reference2.requiredEnergy * val5.consumerRatio);
						num3 += Math.Sqrt((double)num4 / 500000.0);
						int turretId = entityPool[reference2.entityId].turretId;
						if (turretId > 0)
						{
							ref TurretComponent reference3 = ref buffer[turretId];
							if ((int)reference3.type == 5)
							{
								num3 *= 10.0;
							}
							else if ((int)reference3.type == 4)
							{
								num3 *= 100.0;
							}
						}
						int num5 = ((plugPos.x >= 0f) ? 1 : 0) + ((plugPos.y >= 0f) ? 2 : 0) + ((plugPos.z >= 0f) ? 4 : 0);
						ref Vector3 reference4 = ref hive._assaultPosByQuadrant[num5];
						reference4 += plugPos * (float)num3;
					}
					if (num3 > num2)
					{
						num2 = num3;
						val4 = plugPos;
						flag2 = true;
					}
				}
				for (int l = 1; l < nodeCursor; l++)
				{
					ref PowerNodeComponent reference5 = ref nodePool[l];
					if (reference5.id == l)
					{
						double num6 = 0.01;
						int networkId2 = reference5.networkId;
						PowerNetwork val6 = powerSystem.netPool[networkId2];
						ref Vector3 powerPoint = ref reference5.powerPoint;
						if (val6 != null)
						{
							int powerGenId = entityPool[reference5.entityId].powerGenId;
							long num7 = ((powerGenId > 0) ? powerSystem.genPool[powerGenId].generateCurrentTick : 0);
							long num8 = (val6.energyServed / 4 + val6.energyCapacity / 80 + reference5.idleEnergyPerTick / 2 + num7 / 20) / 2;
							num6 += Math.Sqrt((double)num8 / 500000.0);
							int num9 = ((powerPoint.x >= 0f) ? 1 : 0) + ((powerPoint.y >= 0f) ? 2 : 0) + ((powerPoint.z >= 0f) ? 4 : 0);
							ref Vector3 reference6 = ref hive._assaultPosByQuadrant[num9];
							reference6 += reference5.powerPoint * (float)num6;
						}
						if (num6 > num2)
						{
							num2 = num6;
							val4 = reference5.powerPoint;
							flag2 = true;
						}
					}
				}
				if (!flag2)
				{
					continue;
				}
				flag = true;
				num = ((HatredTarget)(ref reference)).objectId;
				float num10 = 0f;
				for (int m = 0; m < 8; m++)
				{
					float magnitude = ((Vector3)(ref hive._assaultPosByQuadrant[m])).magnitude;
					if (magnitude > num10)
					{
						num10 = magnitude;
						val = hive._assaultPosByQuadrant[m];
					}
				}
				val2 = val4;
				break;
			}
			if (!flag && hive.gameData.localPlanet != null && (int)hive.gameData.localPlanet.type != 5 && hive.gameData.localPlanet.star == hive.starData)
			{
				flag = true;
				num = hive.gameData.localPlanet.astroId;
				val2 = (val = hive.sector.skillSystem.playerSkillTargetL);
			}
			if (flag)
			{
				int num11 = 5;
				int num12 = 100 / (num11 * 4 / 5);
				if (hive.evolve.waves < 3)
				{
					num12 = 1;
				}
				int num13 = 100 - num12 * num11;
				hive.evolve.threat = 0;
				hive.LaunchLancerAssault((EAggressiveLevel)20, val, val2, num, assaultNum, num12);
				hive.evolve.threat = 0;
				hive.evolve.threatshr = 0;
				hive.evolve.maxThreat = EvolveData.GetSpaceThreatMaxByWaves(hive.evolve.waves, (EAggressiveLevel)20);
				EnemyDFHiveSystem obj = hive;
				obj.lancerAssaultCountBase += hive.GetLancerAssaultCountIncrement((EAggressiveLevel)20);
			}
		}

		private void KillHiveStrcuture(int pbuilderInstId)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!MP.clientBlocker)
			{
				CombatStat val = default(CombatStat);
				val.objectId = pbuilderInstId;
				GameMain.spaceSector.KillEnemyFinal(pbuilderInstId, ref val);
			}
		}

		public static bool CheckIfAllHiveReachedState(EAssaultHiveState state)
		{
			int count = AssaultController.assaultHives.Count;
			for (int num = count - 1; num >= 0; num--)
			{
				if (AssaultController.assaultHives[num] != null)
				{
					EAssaultHiveState eAssaultHiveState = AssaultController.assaultHives[num].state;
					if (eAssaultHiveState < state)
					{
						return false;
					}
				}
			}
			return true;
		}

		public void Import(BinaryReader r)
		{
			listIndex = r.ReadInt32();
			starIndex = r.ReadInt32();
			oriAstroId = r.ReadInt32();
			orbitIndex = r.ReadInt32();
			byAstroIndex = r.ReadInt32();
			strength = r.ReadInt32();
			state = (EAssaultHiveState)r.ReadInt32();
			time = r.ReadInt32();
			timeTillAssault = r.ReadInt32();
			timeTotalInit = r.ReadInt32();
			timeDelayedByRelic = r.ReadInt32();
			level = r.ReadInt32();
			oriLevel = r.ReadInt32();
			assaultNumTotal = r.ReadInt32();
			inhibitPoints = r.ReadInt32();
			inhibitPointsLimit = r.ReadInt32();
			inhibitPointsTotalInit = r.ReadInt32();
			canFullyStopped = r.ReadBoolean();
			isSuper = r.ReadBoolean();
			enemyKilled = r.ReadInt32();
			isCreated = r.ReadBoolean();
			hive = GameMain.data.spaceSector.GetHiveByAstroId(oriAstroId);
		}

		public void Export(BinaryWriter w)
		{
			w.Write(listIndex);
			w.Write(starIndex);
			w.Write(oriAstroId);
			w.Write(orbitIndex);
			w.Write(byAstroIndex);
			w.Write(strength);
			w.Write((int)state);
			w.Write(time);
			w.Write(timeTillAssault);
			w.Write(timeTotalInit);
			w.Write(timeDelayedByRelic);
			w.Write(level);
			w.Write(oriLevel);
			w.Write(assaultNumTotal);
			w.Write(inhibitPoints);
			w.Write(inhibitPointsLimit);
			w.Write(inhibitPointsTotalInit);
			w.Write(canFullyStopped);
			w.Write(isSuper);
			w.Write(enemyKilled);
			w.Write(isCreated);
		}

		public void IntoOtherSave()
		{
			state = EAssaultHiveState.Remove;
		}
	}
	public static class AssaultHiveCreator
	{
		public static void SetStrength(this AssaultHive _this, int strength)
		{
			_this.strength = strength;
		}
	}
	public enum EAssaultHiveState
	{
		Idle = 0,
		Expand = 1,
		Assemble = 2,
		Assault = 3,
		End = 4,
		Remove = 99
	}
	public class BattleBGMController
	{
		public static int musicState = 0;

		public static int musicCnt = 0;

		public static bool isOverriding = false;

		public static int currentGroup = -1;

		public static int lastMusic = -1;

		public static int currentMusic = -1;

		public static int nextMusic = -1;

		public static float fadeOutTime = 0f;

		public static float fadeInTime = 0f;

		public static string[] index2NameMap = new string[25]
		{
			"pre_1", "loop_1", "fin_1", "pre_2", "loop_2", "pre_3", "loop_3", "fin_3", "pre_4", "loop_4",
			"fin_4", "pre_5", "loop_5", "fin_5", "pre_6", "loop_6", "fin_6", "Track7", "Track9", "Track10",
			"Track39", "TrackA1", "TrackE1", "TrackU1", "TrackU2"
		};

		public static Dictionary<string, int> name2IndexMap = new Dictionary<string, int>();

		public static List<int> finMusics = new List<int> { 2, 7, 10, 13, 16 };

		public static AssetBundle bgmAB;

		public static List<AudioSource> battleMusics = new List<AudioSource>();

		public static List<float> musicBPM = new List<float> { 100f, 176f, 180f, 180f, 180f, 200f, 200f };

		public static int beforeBattleBgmBeginNum = 17;

		public static bool nextPlayFinishMusic = false;

		public static int takeDamageCountdown = 0;

		public static float volumeBasic = 0.4f;

		public static float volumeFactor = 0.4f;

		public static void InitAudioSources()
		{
			if (!Configs.enableBattleBGM)
			{
				return;
			}
			Transform transform = GameObject.Find("Audios/BGM").transform;
			GameObject val = GameObject.Find("Audios/BGM/universe-1");
			bgmAB = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("DSP_Battle.battlebgm"));
			if ((Object)(object)bgmAB == (Object)null)
			{
				Configs.enableBattleBGM = false;
				return;
			}
			musicCnt = index2NameMap.Length;
			for (int i = 0; i < index2NameMap.Length; i++)
			{
				GameObject val2 = Object.Instantiate<GameObject>(val, transform);
				((Object)val2).name = index2NameMap[i];
				AudioSource component = val2.GetComponent<AudioSource>();
				component.clip = bgmAB.LoadAsset<AudioClip>(index2NameMap[i]);
				name2IndexMap.Add(index2NameMap[i], i);
				if (index2NameMap[i] == "fin_1")
				{
					name2IndexMap.Add("fin_2", i);
				}
				battleMusics.Add(component);
			}
		}

		public static void InitWhenLoad()
		{
			if (Configs.enableBattleBGM)
			{
				if (currentMusic >= 0 && currentMusic < musicCnt)
				{
					battleMusics[currentMusic].Stop();
				}
				if (lastMusic >= 0 && lastMusic < musicCnt)
				{
					battleMusics[lastMusic].Stop();
				}
				currentGroup = -1;
				lastMusic = -1;
				currentMusic = -1;
				nextMusic = -1;
				fadeOutTime = 0f;
				fadeInTime = 0f;
				isOverriding = false;
				nextPlayFinishMusic = false;
				takeDamageCountdown = 0;
			}
		}

		public static void BGMLogicUpdate()
		{
			if (!Configs.enableBattleBGM)
			{
				return;
			}
			if (Configs.combatState <= 1 || (Configs.combatState != 3 && nextPlayFinishMusic))
			{
				if (nextPlayFinishMusic)
				{
					if (currentGroup < 0 || currentMusic < 0)
					{
						nextPlayFinishMusic = false;
						lastMusic = -1;
						currentMusic = -1;
						nextMusic = -1;
						fadeOutTime = 0f;
						fadeInTime = 0f;
						isOverriding = false;
						BGMController.Playback(0, 1f, 1f, (EPlaybackOrigin)0, 0f);
					}
					else if (atBarEnd(battleMusics[currentMusic].time, musicBPM[currentGroup]) && name2IndexMap.ContainsKey("fin_" + currentGroup))
					{
						nextPlayFinishMusic = false;
						nextMusic = name2IndexMap["fin_" + currentGroup];
					}
				}
				else if (currentMusic >= 0 && battleMusics[currentMusic].time >= battleMusics[currentMusic].clip.length - 0.05f)
				{
					lastMusic = -1;
					currentMusic = -1;
					nextMusic = -1;
					fadeOutTime = 0f;
					fadeInTime = 0f;
					isOverriding = false;
					currentGroup = Utils.RandInt(1, 7);
					BGMController.Playback(0, 1f, 1f, (EPlaybackOrigin)0, 0f);
				}
			}
			else if (Configs.combatState == 2)
			{
				if (!isOverriding)
				{
					currentGroup = Utils.RandInt(1, 7);
				}
				if (currentMusic < 0)
				{
					nextMusic = Utils.RandInt(beforeBattleBgmBeginNum, battleMusics.Count);
				}
				else if (battleMusics[currentMusic].time >= battleMusics[currentMusic].clip.length - 0.05f)
				{
					nextMusic = Utils.RandInt(beforeBattleBgmBeginNum, battleMusics.Count);
					if (nextMusic == currentMusic)
					{
						nextMusic = ((currentMusic + 1 < musicCnt) ? (currentMusic + 1) : (currentMusic - 1));
					}
				}
			}
			else if (Configs.combatState == 3)
			{
				if (currentGroup < 0)
				{
					Random random = new Random();
					currentGroup = random.Next(1, 7);
				}
				if (currentMusic >= beforeBattleBgmBeginNum || currentMusic < 0)
				{
					nextMusic = name2IndexMap["pre_" + currentGroup];
				}
				else if (finMusics.Contains(currentMusic) && atBarEnd(battleMusics[currentMusic].time, musicBPM[currentGroup]))
				{
					nextMusic = name2IndexMap["loop_" + currentGroup];
				}
				else if (index2NameMap[currentMusic][0] == 'p' && battleMusics[currentMusic].time >= battleMusics[currentMusic].clip.length - 0.05f)
				{
					nextMusic = name2IndexMap["loop_" + currentGroup];
				}
			}
			if (currentMusic != nextMusic)
			{
				PlayNext();
			}
			if (isOverriding)
			{
				if (fadeOutTime > 0f && lastMusic >= 0 && lastMusic < musicCnt)
				{
					AudioSource obj = battleMusics[lastMusic];
					obj.volume -= 0.01666667f / fadeOutTime;
					if (battleMusics[lastMusic].volume <= 0f)
					{
						fadeOutTime = 0f;
						battleMusics[lastMusic].volume = 0f;
						battleMusics[lastMusic].loop = false;
					}
				}
				else if (fadeOutTime <= 0f && lastMusic >= 0 && lastMusic < musicCnt)
				{
					battleMusics[lastMusic].volume = 0f;
					battleMusics[lastMusic].loop = false;
					battleMusics[lastMusic].Stop();
				}
				if (fadeInTime > 0f && currentMusic >= 0 && currentMusic < musicCnt)
				{
					AudioSource obj2 = battleMusics[currentMusic];
					obj2.volume += 0.01666667f / fadeInTime;
					if (battleMusics[currentMusic].volume >= VFAudio.audioVolume * VFAudio.musicVolume * volumeFactor)
					{
						fadeOutTime = 0f;
						battleMusics[currentMusic].volume = VFAudio.audioVolume * VFAudio.musicVolume * volumeFactor;
					}
				}
				else if (fadeInTime <= 0f && currentMusic >= 0 && currentMusic < musicCnt)
				{
					AudioSource val = battleMusics[currentMusic];
					val.volume = VFAudio.audioVolume * VFAudio.musicVolume * volumeFactor;
				}
			}
			if (takeDamageCountdown > 0)
			{
				Interlocked.Add(ref takeDamageCountdown, -1);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameData), "GameTick")]
		public static void GameData_GameTick(ref GameData __instance, long time)
		{
			if (time % 5 == 0L && isOverriding)
			{
				MuteGameOriBgm();
			}
		}

		public static void PlayerTakeDamage()
		{
			Interlocked.Exchange(ref takeDamageCountdown, 2700);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SkillSystem), "DeterminePlanetATFieldRaytestInStar")]
		public static void VerifyPlayerPlanetWillTakeDamage(int __result)
		{
			if (GameMain.data.localPlanet != null && __result == GameMain.data.localPlanet.id)
			{
				Interlocked.Exchange(ref takeDamageCountdown, 2700);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerAction_Combat), "ShootTarget")]
		public static void PlayerDoDamage()
		{
			Interlocked.Add(ref takeDamageCountdown, 240);
			if (takeDamageCountdown > 1800)
			{
				Interlocked.Exchange(ref takeDamageCountdown, 2700);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerAction_Combat), "Shoot_Missile")]
		public static void ShootMissileCompensation()
		{
			if (takeDamageCountdown < 1800)
			{
				Interlocked.Add(ref takeDamageCountdown, -30);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerAction_Combat), "Shoot_Cannon_Local")]
		public static void ShootCannonLocalCompensation()
		{
			if (takeDamageCountdown < 1800)
			{
				Interlocked.Add(ref takeDamageCountdown, -30);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerAction_Combat), "Shoot_Cannon_Space")]
		public static void ShootCannonSpaceCompensation()
		{
			if (takeDamageCountdown < 1800)
			{
				Interlocked.Add(ref takeDamageCountdown, -30);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BGMController), "Playback")]
		public static void PlaybackPostPatch(int bgmIndex, float fadeOutTime, float fadeInTime, EPlaybackOrigin origin = 0, float offset = 0f)
		{
			if (Configs.enableBattleBGM && isOverriding)
			{
				if (!BGMController.HasBGM(bgmIndex))
				{
					bgmIndex = 0;
				}
				if ((Object)(object)BGMController.instance != (Object)null && BGMController.instance.musics != null && bgmIndex >= 0 && bgmIndex < BGMController.instance.musics.Length && (Object)(object)BGMController.instance.musics[bgmIndex] != (Object)null)
				{
					BGMController.instance.musics[bgmIndex].Stop();
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BGMController), "UpdateLogic")]
		public static void BGMPassFilterPatch()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if (Configs.enableBattleBGM && isOverriding && (int)UIGame.viewMode == 4)
			{
				VFListener.SetPassFilter(100f);
			}
		}

		public static void PlayNext(float fade = 0f)
		{
			if (nextMusic >= 0 && nextMusic < musicCnt)
			{
				if (lastMusic < 0 && (Object)(object)BGMController.instance != (Object)null && BGMController.instance.musics != null && BGMController.HasBGM(BGMController.instance.playbackIndex))
				{
					BGMController.instance.fadeOutTimes[BGMController.instance.playbackIndex] = 1f;
					BGMController.instance.volsTar[BGMController.instance.playbackIndex] = 0f;
				}
				fadeOutTime = fade;
				fadeInTime = fade;
				isOverriding = true;
				lastMusic = currentMusic;
				currentMusic = nextMusic;
				AudioSource val = battleMusics[nextMusic];
				val.time = ((currentMusic >= beforeBattleBgmBeginNum) ? 0.3f : 0f);
				val.Play();
				val.loop = index2NameMap[currentMusic][0] == 'l';
				val.volume = 0f;
			}
		}

		public static void SetWaveFinished()
		{
			if (currentMusic >= 0 && currentMusic < musicCnt)
			{
				battleMusics[currentMusic].loop = false;
			}
			nextPlayFinishMusic = true;
		}

		public static void MuteGameOriBgm()
		{
			if (lastMusic < 0 && (Object)(object)BGMController.instance != (Object)null && BGMController.instance.musics != null && BGMController.HasBGM(BGMController.instance.playbackIndex))
			{
				BGMController.instance.fadeOutTimes[BGMController.instance.playbackIndex] = 0f;
				BGMController.instance.volsTar[BGMController.instance.playbackIndex] = 0f;
			}
		}

		public static bool atBarEnd(float time, float bpm)
		{
			float num = 60f / bpm * 4f;
			float num2 = time / num - (float)(int)(time / num);
			return num2 <= 0.02f || num2 >= num - 0.03f;
		}
	}
	internal class BattleProtos
	{
		public static int pageBias;

		private static void RegisterString(string key, string enTrans, string cnTrans)
		{
			LocalizationModule.RegisterTranslation(key, enTrans, cnTrans, enTrans);
		}

		public static void AddProtos()
		{
			AddTutorialProtos();
			AddNormalProtos();
		}

		public static void AddNormalProtos()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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)
			int num = (MoreMegaStructure.GenesisCompatibility ? (-200) : 0);
			int num2 = (MoreMegaStructure.GenesisCompatibility ? (-8) : 0);
			TechProto val = ProtoRegistry.RegisterTech(1999, "玻色子操控", "玻色子操控描述", "玻色子操控结论", "Assets/DSPBattle/bosontech", new int[0], new int[1] { 5201 }, new int[1] { 400 }, 72000L, new int[5]
			{
				573 + num,
				567 + num,
				568 + num,
				569 + num,
				566 + num
			}, new Vector2((float)(65 + num2), -7f));
			val.PreTechsImplicit = new int[1] { 1823 };
			val.IsHiddenTech = true;
			val.PreItem = new int[1] { 5201 };
			TechProto val2 = ProtoRegistry.RegisterTech(1998, "提供算力名称", "提供算力描述", "提供算力结论", "Assets/DSPBattle/rank10", new int[0], new int[1] { 6006 }, new int[1] { 2 }, 2997924580L, new int[0], new Vector2((float)(65 + num2), -11f));
			val2.PreTechsImplicit = new int[0];
			val2.IsHiddenTech = true;
			val2.PreItem = new int[1] { 9513 };
			ItemProto val3 = ProtoRegistry.RegisterItem(9513, "星河卫士奖章", "星河卫士奖章描述", "Assets/DSPBattle/rank10", 9998, 1, (EItemType)7, ProtoRegistry.GetDefaultIconDesc(Color.white, new Color(0.7f, 0.4f, 0.1f)));
			val3.UnlockKey = -2;
			ProtoRegistry.RegisterRecipe(382, (ERecipeType)1, 60, new int[1] { 1104 }, new int[1] { 2 }, new int[1] { 9513 }, new int[1] { 1 }, "星河卫视奖章描述", 0, 9998, "Assets/DSPBattle/rank10");
		}

		public static void AddTranslate()
		{
			RegisterString("轨道防御", "TCFV", "深空来敌");
			RegisterString("恒星炮gm2", "Star cannon", "恒星炮");
			RegisterString("水滴gm2", "Droplet", "水滴");
			RegisterString("即将到来gm", "Coming soon", "即将推出");
			RegisterString("恒星要塞", "Star Fortress", "恒星要塞");
			RegisterString("恒星要塞描述", "Plan additional defense modules on any mega structure to strengthen the defense capabilities of the star system, and the energy to support the star fortress comes entirely from the stars. This can also save a significant amount of planetary area.", "在任何巨构上规划额外的防御模块来强化星系的防御能力,支持恒星要塞的能量完全来自于恒星。这还能节约大量地表的可建造面积。");
			RegisterString("恒星要塞结论", "You have unlocked the star fortress.", "你解锁了武装巨构来构建恒星要塞的能力。");
			RegisterString("玻色子操控", "Boson control", "玻色子操控");
			RegisterString("玻色子操控描述", "Create powerful materials by manipulating various interacting forces.", "通过操控各种相互作用力来制造强大的材料。");
			RegisterString("玻色子操控结论", "You have unlocked the Boson control.", "你解锁了玻色子操控。");
			RegisterString("水滴科技描述", "A powerful Droplet controlled by the mecha.", "一个由机甲控制的强大水滴");
			RegisterString("水滴科技结论", "You have unlocked the Droplet.", "你解锁了水滴技术。");
			RegisterString("UI快捷键提示", "Press Backspace to hide/open this window. Press \"Ctrl\" + \"-\" to advance the attack time by 1 min.", "按下退格键开启或关闭此窗口,按下Ctrl+减号键使敌军进攻时间提前1分钟");
			RegisterString("快速开局", "Fast Start", "快速开局");
			RegisterString("快速开局提示", "Unlock some techs at the begining, and start with additional items.", "开局立即解锁额外科技,并提供额外物品。");
			RegisterString("mod版本信息", "Current version: " + Configs.versionString + "                Contact me in Discord: ckcz123#3576", "当前版本:" + Configs.versionString + "          欢迎加入mod交流群:" + Configs.qq);
			RegisterString("约gm", "about", "约");
			RegisterString("小时gm", "h", "小时");
			RegisterString("分gm", "m", "分");
			RegisterString("秒gm", "s", "秒");
			RegisterString("已歼灭gm", "Eliminated", "已歼灭");
			RegisterString("已产生gm", "Total", "已产生");
			RegisterString("占比gm", "Percentage", "占比");
			RegisterString("游戏提示gm", "Message", "游戏提示");
			RegisterString("gmRank0", "<color=#ffffff80>Icarus</color>", "<color=#ffffff80>伊卡洛斯</color>");
			RegisterString("gmRank1", "<color=#61d8ffb4>Explorer I</color>", "<color=#61d8ffb4>探索者 I</color>");
			RegisterString("gmRank2", "<color=#61d8ffb4>Explorer II</color>", "<color=#61d8ffb4>探索者 II</color>");
			RegisterString("gmRank3", "<color=#61d8ffb4>Explorer III</color>", "<color=#61d8ffb4>探索者 III</color>");
			RegisterString("gmRank4", "<color=#d238ffb4>Pioneer I</color>", "<color=#d238ffb4>开拓者 I</color>");
			RegisterString("gmRank5", "<color=#d238ffb4>Pioneer II</color>", "<color=#d238ffb4>开拓者 II</color>");
			RegisterString("gmRank6", "<color=#d238ffb4>Pioneer III</color>", "<color=#d238ffb4>开拓者 III</color>");
			RegisterString("gmRank7", "<color=#fd9620c0>Conqueror I</color>", "<color=#fd9620c0>征服者 I</color>");
			RegisterString("gmRank8", "<color=#fd9620c0>Conqueror II</color>", "<color=#fd9620c0>征服者 II</color>");
			RegisterString("gmRank9", "<color=#fd9620c0>Conqueror III</color>", "<color=#fd9620c0>征服者 III</color>");
			RegisterString("gmRank10", "<color=#ffc620c8>Galaxy Guardian</color>", "<color=#ffc620da>星河卫士</color>");
			RegisterString("gmRankNoColor0", "Icarus", "伊卡洛斯");
			RegisterString("gmRankNoColor1", "Explorer I", "探索者 I");
			RegisterString("gmRankNoColor2", "Explorer II", "探索者 II");
			RegisterString("gmRankNoColor3", "Explorer III", "探索者 III");
			RegisterString("gmRankNoColor4", "Pioneer I", "开拓者 I");
			RegisterString("gmRankNoColor5", "Pioneer II", "开拓者 II");
			RegisterString("gmRankNoColor6", "Pioneer III", "开拓者 III");
			RegisterString("gmRankNoColor7", "Conqueror I", "征服者 I");
			RegisterString("gmRankNoColor8", "Conqueror II", "征服者 II");
			RegisterString("gmRankNoColor9", "Conqueror III", "征服者 III");
			RegisterString("gmRankNoColor10", "Galaxy Guardian", "星河卫士");
			RegisterString("gmRankUnlockText0", "", "");
			RegisterString("gmRankUnlockText1", "Enhanced core energy generation", "获得额外的核心发电");
			RegisterString("gmRankUnlockText2", "Energy shield gains 25% damage reduction", "能量盾获得25%伤害减免");
			RegisterString("gmRankUnlockText3", "Walk speed increases", "步行移动速度增加");
			RegisterString("gmRankUnlockText4", "Ore loss per mining operation -20%", "采矿消耗 -20%");
			RegisterString("gmRankUnlockText5", "EM effect +20%", "电磁武器效果 +20%");
			RegisterString("gmRankUnlockText6", "Droplets can quickly approach distant target", "水滴能够快速接近远距离的目标");
			RegisterString("gmRankUnlockText7", "Ore loss per mining operation -20%", "采矿消耗 -20%");
			RegisterString("gmRankUnlockText8", "Star cannon charging speed +50%", "恒星炮充能速度 +50%");
			RegisterString("gmRankUnlockText9", "Droplet damage +100%", "水滴伤害 +100%");
			RegisterString("gmRankUnlockText10", "Ore loss per mining operation -40%", "采矿消耗 -40%");
			RegisterString("gmRankUnlockText10Add", "You are allowed to provide computing power to the COSMO Technology Ethics Committee in exchange for merit points", "你被允许向COSMO技术伦理委员会提供算力以换取功勋点数");
			RegisterString("gmRankReward1", "Core power generation +1 MW", "核心发电 +1MW");
			RegisterString("gmRankReward2", "Energy shield damage reduction +25%", "能量盾伤害减免 +25%");
			RegisterString("gmRankReward3", "Walk speed +4 m/s", "步行移动速度 +4 m/s");
			RegisterString("gmRankReward4", "Ore loss per mining operation -20%", "采矿消耗 -20%");
			RegisterString("gmRankReward5", "EM effect +20%", "电磁武器效果 +20%");
			RegisterString("gmRankReward6", "Droplets can quickly approach distant target", "水滴能够快速接近远距离的目标");
			RegisterString("gmRankReward7", "Ore loss per mining operation -40%", "采矿消耗 -40%");
			RegisterString("gmRankReward8", "Star cannon charging speed +50%", "恒星炮充能速度 +50%");
			RegisterString("gmRankReward9", "Droplet damage +100%", "水滴伤害 +100%");
			RegisterString("gmRankReward10", "Ore loss per mining operation  -80%", "采矿消耗 -80%");
			RegisterString("功勋阶级", "Merit Rank", "功勋阶级");
			RegisterString("当前阶级", "Current Rank", "当前等级");
			RegisterString("功勋点数", "Merit points", "功勋点数");
			RegisterString("已解锁gm", "Unlocked", "已解锁");
			RegisterString("下一功勋等级解锁", "Next rank unlocked", "下一功勋等级解锁");
			RegisterString("剩余复活币", "Resurrection Coin", "剩余复活币");
			RegisterString("真实伤害已启用", "❈ True damage activated", "❈真实伤害已启用");
			RegisterString("伤害类型特殊", " (Special)", " (特殊)");
			RegisterString("护盾承受伤害", "Shield damage taken", "护盾承受伤害");
			RegisterString("护盾造成伤害", "Shield damage dealed", "护盾造成伤害");
			RegisterString("护盾伤害减免与规避", "Shield dmg. alleviated / evaded", "护盾减免和规避伤害");
			RegisterString("护盾战时回复", "Shield restored", "护盾战时回复");
			RegisterString("水滴伤害", "Droplet damage", "水滴伤害");
			RegisterString("最小发射能量", "Launch Energy Threshold", "发射能量阈值");
			RegisterString("水滴发射耗能", "Launch Consumption", "发射耗能");
			RegisterString("水滴工作功率", "Work Consumption", "工作功率");
			RegisterString("巨构伤害", "Megastructure damage", "巨构伤害");
			RegisterString("恒星要塞导弹伤害", "StarFortress Missile dmg.", "恒星要塞导弹伤害");
			RegisterString("恒星要塞光矛伤害", "StarFortress LightSpear dmg.", "恒星要塞光矛伤害");
			RegisterString("物质解压器科技描述", "Decoding a method from the alien matrices to build a Matter Decompressor.", "从异星矩阵中解码建造物质解压器的方法。");
			RegisterString("科学枢纽科技描述", "Decoding a method from the alien matrices to build a Science Nexus.", "从异星矩阵中解码建造科学枢纽的方法。");
			RegisterString("折跃场广播阵列科技描述", "Decoding a method from the alien matrices to build a Warp Field Broadcast Array.", "从异星矩阵中解码建造折跃场广播阵列的方法。");
			RegisterString("星际组装厂科技描述", "Decoding a method from the alien matrices to build an Interstellar Assembly.", "从异星矩阵中解码建造星际组装厂的方法。");
			RegisterString("晶体重构器科技描述", "Decoding a method from the alien matrices to build a Crystal Reconstructor.", "从异星矩阵中解码建造晶体重构器的方法。");
			RegisterString("物质解压器科技结论", "You have successfully decoded the blueprint of Matter decompressor carrier rocket.", "你成功解码了物质解压器运载火箭的制造蓝图。");
			RegisterString("科学枢纽科技结论", "You have successfully decoded the blueprint of Science nexus carrier rocket.", "你成功解码了科学枢纽运载火箭的制造蓝图。");
			RegisterString("折跃场广播阵列科技结论", "You have successfully decoded the blueprint of Resonant generator carrier rocket.", "你成功解码了谐振发射器运载火箭的制造蓝图。");
			RegisterString("星际组装厂科技结论", "You have successfully decoded the blueprint of Interstellar assembly component and its carrier rocket.", "你成功解码了星际组装厂组件和运载火箭的制造蓝图。");
			RegisterString("晶体重构器科技结论", "You have successfully decoded the blueprint of Crystal reconstructor carrier rocket.", "你成功解码了晶体重构器运载火箭的制造蓝图。");
			RegisterString("多功能集成组件描述gm2", "The high level of integration makes it possible to quickly assemble a variety of production building and logistics components, while occupying very little space. Can only be produced in megastructure <color=#c2853d>Interstellar assembly</color>.", "超高集成度使其可以迅速地组装成多种生产建筑和物流组件,却仅占用极小的空间。仅能在巨构<color=#c2853d>星际组装厂</color>中制作。");
			RegisterString("被深空来敌mod禁止", "Banned by mod They Come From Void", "被深空来敌mod禁止");
			RegisterString("发现异星圣物", "Meta-drive Interpretation Complete", "元驱动解译完毕");
			RegisterString("解译异星圣物提示", "Select one decoding track from the following three to finish the interpret procedure and enable the meta driver.\nYou can use dark fog matrix to seek new decoding track with different effects.", "从以下三个亚稳态解码轨中选取一个,并完成解译的最后阶段,从而启用该元驱动。\n可以使用黑雾矩阵重随解码轨来发现新的可用效果。");
			RegisterString("重新随机", "Roll", "重新随机");
			RegisterString("重新随机可以长", "Re-roll", "重新随机");
			RegisterString("免费", "free", "免费");
			RegisterString("移除遗物", "Remove", "移除");
			RegisterString("放弃解译", "   Abort This           +", "放弃解译         +");
			RegisterString("放弃解译居中", "Abort Interpret", "放弃解译");
			RegisterString("删除遗物名称", "Remove Meta Driver", "移除元驱动");
			RegisterString("删除遗物描述", "Randomly remove a [common] meta-drive, and return the slot occupied by the meta-drive. \nIf there is no [common] meta-drive, then randomly remove a [rare] meta-drive.", "随机移除一个已拥有的[普通]稀有度的元驱动,并返还该元驱动所占用的元驱动槽位\n如果没有[普通]元驱动,则随机移除一个已拥有的[稀有]元驱动");
			RegisterString("删除遗物确认标题", "Confirm Remove Meta Driver", "确认移除元驱动");
			RegisterString("删除遗物确认警告", "This will remove {0} and return the slot occupied by the meta driver!", "这将移除圣物 {0},并返还该圣物所占用的圣物槽位!");
			RegisterString("成功移除!", "Meta driver removed", "成功移除元驱动");
			RegisterString("已移除遗物描述", "You've removed meta driver ", "你已移除");
			RegisterString("未能移除!", "No mate drive can be removed", "没有可移除的元驱动");
			RegisterString("未能移除遗物描述", "No matched meta driver can be removed", "你没有稀有度匹配的元驱动可供移除");
			RegisterString("未获取遗物标题", "Unknown mata drive", "未知元驱动");
			RegisterString("未获取遗物描述", "This slot can place a decrypted meta driver", "此位置可供已解译的元驱动放置");
			RegisterString("水滴伤害增加", "Droplet Bonus Damage", "水滴额外伤害");
			RegisterString("当前加成gm", "Current bonus damage", "当前伤害加成");
			RegisterString("已充能gm", "Charged", "已充能");
			RegisterString("女神之怒充能中", "Wrath of Goddess Charging", "女神之怒充能中");
			RegisterString("女神之怒", "† Wrath of Goddess †", "† 女神之怒 †");
			RegisterString("圣物稀有度0", "<color=#d2853d>Mensural</color>", "<color=#d2853d>定律级</color>");
			RegisterString("圣物稀有度1", "<color=#9040d0>Framed</color>", "<color=#9040d0>框架级</color>");
			RegisterString("圣物稀有度2", "<color=#2080d0>Packaged</color>", "<color=#2080d0>封装级</color>");
			RegisterString("圣物稀有度3", "<color=#30b530>Regular</color>", "<color=#30b530>常规级</color>");
			RegisterString("圣物稀有度4", "<color=#00c560>Axiomatic</color>", "<color=#00c560>公理级</color>");
			RegisterString("诅咒", "Editing Universal Axioms", "编辑宇宙公理");
			RegisterString("诅咒描述", "Attempting to touch and edit Cosmological Axioms is extremely dangerous, every time you enable an axiomatic level meta-drive, the disrupted Cosmological Axioms will cause the Dark Fog units to gain 50% extra experience and 5% damage resistence.\nYou can not remove an axiomatic meta driver once you enable it.\n\nNegative effect: ", "尝试触碰并编辑宇宙公理是极其危险的,你每启用一个公理级的元驱动,被扰乱的宇宙公理会使黑雾单位获得的经验+50%,以及5%伤害抵抗。\n公理级元驱动无法被移除。\n\n负面效果:");
			RegisterString("诅咒描述独立", "Axiomatic meta drivers have different <color=#d00000>negative effects</color>. Besides, for each axiomatic meta driver you have, dark fog units gain 50% extra experience, and 5% damage resistence.\nYou can not remove an axiomatic meta driver once you enable it.", "公理级元驱动均具有各不相同的<color=#d00000>负面效果</color>,且你每拥有一个公理级元驱动,所有黑雾单位获得50%经验获取加成,以及5%伤害抵抗。\n公理级元驱动无法被移除。");
			RegisterString("诅咒描述短", "This meta driver can not be removed.\nDark fog units experience +50%, damage resistence +5%. ", "此元驱动无法被移除\n黑雾单位经验获取+50%,伤害抵抗+5%。");
			RegisterString("负面效果警告", "<color=#ff0000>Warning! This meta driver has negative effect!</color>", "<color=#ff0000>警告!此元驱动具有负面效果!</color>");
			RegisterString("已记载", "Recorded: ", "已记载:");
			RegisterString("遗物名称0-0", "Swallower\n<size=18>- Mensural -</size>", "吞噬者\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-1", "Blue Buff\n<size=18>- Mensural -</size>", "蓝buff\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-2", "Tear of the Goddess\n<size=18>- Mensural -</size>", "女神之泪\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-3", "The Eternal Ring\n<size=18>- Mensural -</size>", "永恒之环\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-4", "Widowmaker\n<size=18>- Mensural -</size>", "黑百合\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-5", "Thornmail\n<size=18>- Mensural -</size>", "虚空荆棘\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-6", "Stars Seal\n<size=18>- Mensural -</size>", "星辰封印\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-7", "Tearing Field\n<size=18>- Mensural -</size>", "撕裂力场\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-8", "Void Impact\n<size=18>- Mensural -</size>", "虚空冲击\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-9", "Holy ****?! Spatula!\n<size=18>- Mensural -</size>", "我超!铲!\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称0-10", "Energy Siphon\n<size=18>- Mensural -</size>", "能量虹吸\n<size=18>- 定律级 -</size>");
			RegisterString("遗物名称1-0", "Triumph\n<size=18>- Framed -</size>", "凯旋\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-1", "Energy Cycle\n<size=18>- Framed -</size>", "能量循环\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-2", "Power Surge\n<size=18>- Framed -</size>", "能量涌动\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-3", "Vigilance Space\n<size=18>- Framed -</size>", "敌对海域\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-4", "3\n<size=18>- Framed -</size>", "三体\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-5", "Echo II\n<size=18>- Framed -</size>", "回声 II\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-6", "Energy Burst\n<size=18>- Framed -</size>", "能量迸发\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-7", "Activated Carbon II\n<size=18>- Framed -</size>", "活性炭 II\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-8", "Banshee's Veil\n<size=18>- Framed -</size>", "女妖面纱\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-9", "Knight's Vow\n<size=18>- Framed -</size>", "骑士之誓\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-10", "True Damage\n<size=18>- Framed -</size>", "真实伤害\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-11", "Frozen Tomb\n<size=18>- Framed -</size>", "冰封陵墓\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称1-12", "Quiet Death\n<size=18>- Framed -</size>", "衰寂\n<size=18>- 框架级 -</size>");
			RegisterString("遗物名称2-0", "Super Charger\n<size=18>- Packaged -</size>", "超充能器\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-1", "Honorary Promotion\n<size=18>- Packaged -</size>", "荣誉晋升\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-2", "Not Lose\n<size=18>- Packaged -</size>", "极限一换一\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-3", "Echo I\n<size=18>- Packaged -</size>", "回声 I\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-4", "Hyyyydrogen!\n<size=18>- Packaged -</size>", "听说有人缺氢\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-5", "Hyperactivity II\n<size=18>- Packaged -</size>", "多动症 II\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-6", "Swift Seeker\n<size=18>- Packaged -</size>", "高效索敌\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-7", "Foe\n<size=18>- Packaged -</size>", "仇敌\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-8", "Diraac Invrsooon\n<size=18>- Packaged -</size>", "狄拉克辶辶变\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-9", "Light Saver II\n<size=18>- Packaged -</size>", "聚能环 II\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-10", "Matrix Charging\n<size=18>- Packaged -</size>", "矩阵充能\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-11", "By-product Refining\n<size=18>- Packaged -</size>", "副产物提炼\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-12", "Last Breath\n<size=18>- Packaged -</size>", "强攻\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-13", "Infinity Edge\n<size=18>- Packaged -</size>", "无尽之刃\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-14", "Kleptomancy\n<size=18>- Packaged -</size>", "行窃预兆\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-15", "Void Burst\n<size=18>- Packaged -</size>", "虚空爆发\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-16", "Hardened Shield\n<size=18>- Packaged -</size>", "刚毅护盾\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称2-17", "Aegis of the Immortal\n<size=18>- Packaged -</size>", "不朽之守护\n<size=18>- 封装级 -</size>");
			RegisterString("遗物名称3-0", "Inferior Processing\n<size=18>- Regular -</size>", "劣质加工\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-1", "Spelltheif's Edge\n<size=18>- Regular -</size>", "窃法之刃\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-2", "Ark Reactor\n<size=18>- Regular -</size>", "方舟反应堆\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-3", "Shepherd of Souls\n<size=18>- Regular -</size>", "掘墓人\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-4", "Ctrl 6\n<size=18>- Regular -</size>", "装\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-5", "Resurrection Coin\n<size=18>- Regular -</size>", "复活币\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-6", "Upload\n<size=18>- Regular -</size>", "上传\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-7", "Void Refraction\n<size=18>- Regular -</size>", "虚空折射\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-8", "Matrix Rain\n<size=18>- Regular -</size>", "矩阵雨\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-9", "Tanking\n<size=18>- Regular -</size>", "开摆\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-10", "Hyperactivity I\n<size=18>- Regular -</size>", "多动症 I\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-11", "Activated Carbon I\n<size=18>- Regular -</size>", "活性炭 I\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-12", "Dynamic Giant\n<size=18>- Regular -</size>", "灵动巨物\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-13", "Light Saver I\n<size=18>- Regular -</size>", "聚能环 I\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-14", "Lovely motor\n<size=18>- Regular -</size>", "阳间马达\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-15", "Super Mind\n<size=18>- Regular -</size>", "超级大脑\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-16", "Void Lens\n<size=18>- Regular -</size>", "虚空棱镜\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-17", "Level Up!\n<size=18>- Regular -</size>", "升级咯!\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称3-18", "Secondary Hardened Shield\n<size=18>- Regular -</size>", "次级刚毅护盾\n<size=18>- 常规级 -</size>");
			RegisterString("遗物名称4-0", "The Weaver\n<size=18>- Axiomatic -</size>", "编织者\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-1", "Contract of Misfortune\n<size=18>- Axiomatic -</size>", "厄运契约\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-2", "Crown of Rule\n<size=18>- Axiomatic -</size>", "统治之冠\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-3", "Precision Echo\n<size=18>- Axiomatic -</size>", "精密回响\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-4", "Enlightenment Echo\n<size=18>- Axiomatic -</size>", "启迪回响\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-5", "Aftershock Echo\n<size=18>- Axiomatic -</size>", "余震回响\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-6", "Rune Book\n<size=18>- Axiomatic -</size>", "符文之书\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称4-7", "Void Echo\n<size=18>- Axiomatic -</size>", "虚空回响\n<size=18>- 公理级 -</size>");
			RegisterString("遗物名称带颜色0-0", "<color=#d2853d>Swallower  [Mensural]</color>", "<color=#d2853d>吞噬者  [定律级]</color>");
			RegisterString("遗物名称带颜色0-1", "<color=#d2853d>Blue Buff  [Mensural]</color>", "<color=#d2853d>蓝buff  [定律级]</color>");
			RegisterString("遗物名称带颜色0-2", "<color=#d2853d>Tear of the Goddess  [Mensural]</color> ", "<color=#d2853d>女神之泪  [定律级]</color>");
			RegisterString("遗物名称带颜色0-3", "<color=#d2853d>The Eternal Ring  [Mensural]</color>", "<color=#d2853d>永恒之环  [定律级]</color>");
			RegisterString("遗物名称带颜色0-4", "<color=#d2853d>Widowmaker  [Mensural]</color>", "<color=#d2853d>黑百合  [定律级]</color>");
			RegisterString("遗物名称带颜色0-5", "<color=#d2853d>Thornmail  [Mensural]</color>", "<color=#d2853d>虚空荆棘  [定律级]</color>");
			RegisterString("遗物名称带颜色0-6", "<color=#d2853d>Stars Seal  [Mensural]</color>", "<color=#d2853d>星辰封印  [定律级]</color>");
			RegisterString("遗物名称带颜色0-7", "<color=#d2853d>Tearing Field  [Mensural]</color>", "<color=#d2853d>撕裂力场  [定律级]</color>");
			RegisterString("遗物名称带颜色0-8", "<color=#d2853d>Void Impact  [Mensural]</color>", "<color=#d2853d>虚空冲击  [定律级]</color>");
			RegisterString("遗物名称带颜色0-9", "<color=#d2853d>Holy ****?! Spatula!  [Mensural]</color>", "<color=#d2853d>我超!铲!  [定律级]</color>");
			RegisterString("遗物名称带颜色0-10", "<color=#d2853d>Energy Siphon  [Mensural]</color>", "<color=#d2853d>能量虹吸  [定律级]</color>");
			RegisterString("遗物名称带颜色1-0", "<color=#9040d0>Triumph  [Framed]</color>", "<color=#9040d0>凯旋  [框架级]</color>");
			RegisterString("遗物名称带颜色1-1", "<color=#9040d0>Energy Cycle  [Framed]</color>", "<color=#9040d0>能量循环  [框架级]</color>");
			RegisterString("遗物名称带颜色1-2", "<color=#9040d0>Power Surge  [Framed]</color>", "<color=#9040d0>能量涌动  [框架级]</color>");
			RegisterString("遗物名称带颜色1-3", "<color=#9040d0>Vigilance Space  [Framed]</color>", "<color=#9040d0>敌对海域  [框架级]</color>");
			RegisterString("遗物名称带颜色1-4", "<color=#9040d0>3  [Framed]</color>", "<color=#9040d0>三体  [框架级]</color>");
			RegisterString("遗物名称带颜色1-5", "<color=#9040d0>Echo II  [Framed]</color>", "<color=#9040d0>回声 II  [框架级]</color>");
			RegisterString("遗物名称带颜色1-6", "<color=#9040d0>Energy Burst  [Framed]</color>", "<color=#9040d0>能量迸发  [框架级]</color>");
			RegisterString("遗物名称带颜色1-7", "<color=#9040d0>Activated Carbon II  [Framed]</color>", "<color=#9040d0>活性炭 II  [框架级]</color>");
			RegisterString("遗物名称带颜色1-8", "<color=#9040d0>Banshee's Veil  [Framed]</color>", "<color=#9040d0>女妖面纱  [框架级]</color>");
			RegisterString("遗物名称带颜色1-9", "<color=#9040d0>Knight's Vow  [Framed]</color>", "<color=#9040d0>骑士之誓  [框架级]</color>");
			RegisterString("遗物名称带颜色1-10", "<color=#9040d0>True Damage  [Framed]</color>", "<color=#9040d0>真实伤害  [框架级]</color>");
			RegisterString("遗物名称带颜色1-11", "<color=#9040d0>Frozen Tomb  [Framed]</color>", "<color=#9040d0>冰封陵墓  [框架级]</color>");
			RegisterString("遗物名称带颜色1-12", "<color=#9040d0>Quiet Death  [Framed]</color>", "<color=#9040d0>衰寂  [框架级]</color>");
			RegisterString("遗物名称带颜色1-12+", "<color=#d2853d>Hide on Bush  [Fakered]</color>", "<color=#d2853d>隐形的翅膀  [定律级?]</color>");
			RegisterString("遗物名称带颜色2-0", "<color=#2080d0>Super Charger  [Packaged]</color>", "<color=#2080d0>超充能器  [封装级]</color>");
			RegisterString("遗物名称带颜色2-1", "<color=#2080d0>Honorary Promotion  [Packaged]</color>", "<color=#2080d0>荣誉晋升  [封装级]</color>");
			RegisterString("遗物名称带颜色2-2", "<color=#2080d0>Not Lose  [Packaged]</color>", "<color=#2080d0>极限一换一  [封装级]</color>");
			RegisterString("遗物名称带颜色2-3", "<color=#2080d0>Echo I  [Packaged]</color>", "<color=#2080d0>回声 I  [封装级]</color>");
			RegisterString("遗物名称带颜色2-4", "<color=#2080d0>Hyyyydrogen!  [Packaged]</color>", "<color=#2080d0>听说有人缺氢  [封装级]</color>");
			RegisterString("遗物名称带颜色2-5", "<color=#2080d0>Hyperactivity II  [Packaged]</color>", "<color=#2080d0>多动症 II  [封装级]</color>");
			RegisterString("遗物名称带颜色2-6", "<color=#2080d0>Swift Seeker  [Packaged]</color>", "<color=#2080d0>高效索敌  [封装级]</color>");
			RegisterString("遗物名称带颜色2-7", "<color=#2080d0>Foe  [Packaged]</color>", "<color=#2080d0>仇敌  [封装级]</color>");
			RegisterString("遗物名称带颜色2-8", "<color=#2080d0>Diraac Invrsooon  [Packaged]</color>", "<color=#2080d0>狄拉克辶辶变  [封装级]</color>");
			RegisterString("遗物名称带颜色2-9", "<color=#2080d0>Light Saver II  [Packaged]</color>", "<color=#2080d0>聚能环 II  [封装级]</color>");
			RegisterString("遗物名称带颜色2-10", "<color=#2080d0>Matrix Charging  [Packaged]</color>", "<color=#2080d0>矩阵充能  [封装级]</color>");
			RegisterString("遗物名称带颜色2-11", "<color=#2080d0>By-product Refining  [Packaged]</color>", "<color=#2080d0>副产物提炼  [封装级]</color>");
			RegisterString("遗物名称带颜色2-12", "<color=#2080d0>Last Breath  [Packaged]</color>", "<color=#2080d0>强攻  [封装级]</color>");
			RegisterString("遗物名称带颜色2-13", "<color=#2080d0>Infinity Edge  [Packaged]</color>", "<color=#2080d0>无尽之刃  [封装级]</color>");
			RegisterString("遗物名称带颜色2-14", "<color=#2080d0>Kleptomancy  [Packaged]</color>", "<color=#2080d0>行窃预兆  [封装级]</color>");
			RegisterString("遗物名称带颜色2-15", "<color=#2080d0>Gravitational Fragmentation  [Packaged]</color>", "<color=#2080d0>引力碎裂  [封装级]</color>");
			RegisterString("遗物名称带颜色2-16", "<color=#2080d0>Hardened Shield  [Packaged]</color>", "<color=#2080d0>刚毅护盾  [封装级]</color>");
			RegisterString("遗物名称带颜色2-17", "<color=#2080d0>Aegis of the Immortal  [Packaged]</color>", "<color=#2080d0>不朽之守护  [封装级]</color>");
			RegisterString("遗物名称带颜色3-0", "<color=#30b530>Inferior processing  [Regular]</color>", "<color=#30b530>劣质加工  [常规级]</color>");
			RegisterString("遗物名称带颜色3-1", "<color=#30b530>Spelltheif's Edge  [Regular]</color>", "<color=#30b530>窃法之刃  [常规级]</color>");
			RegisterString("遗物名称带颜色3-2", "<color=#30b530>Ark Reactor  [Regular]</color>", "<color=#30b530>方舟反应堆  [常规级]</color>");
			RegisterString("遗物名称带颜色3-3", "<color=#30b530>Shepherd of souls  [Regular]</color>", "<color=#30b530>掘墓人  [常规级]</color>");
			RegisterString("遗物名称带颜色3-4", "<color=#30b530>Ctrl 6  [Regular]</color>", "<color=#30b530>装  [常规级]</color>");
			RegisterString("遗物名称带颜色3-5", "<color=#30b530>Resurrection Coin  [Regular]</color>", "<color=#30b530>复活币  [常规级]</color>");
			RegisterString("遗物名称带颜色3-6", "<color=#30b530>Upload  [Regular]</color>", "<color=#30b530>上传  [常规级]</color>");
			RegisterString("遗物名称带颜色3-7", "<color=#30b530>Void Refraction  [Regular]</color>", "<color=#30b530>虚空折射  [常规级]</color>");
			RegisterString("遗物名称带颜色3-8", "<color=#30b530>Matrix Rain  [Regular]</color>", "<color=#30b530>矩阵雨  [常规级]</color>");
			RegisterString("遗物名称带颜色3-9", "<color=#30b530>Tanking  [Regular]</color>", "<color=#30b530>开摆  [常规级]</color>");
			RegisterString("遗物名称带颜色3-10", "<color=#30b530>Hyperactivity I  [Regular]</color>", "<color=#30b530>多动症 I  [常规级]</color>");
			RegisterString("遗物名称带颜色3-11", "<color=#30b530>Activated Carbon I  [Regular]</color>", "<color=#30b530>活性炭 I  [常规级]</color>");
			RegisterString("遗物名称带颜色3-12", "