Decompiled source of WellRoundedBep v1.3.0

WellRoundedBep.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WellRoundedBep")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Flexible Games")]
[assembly: AssemblyProduct("WellRoundedBep")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c6aa57d6-9bc4-4a69-aba5-20f7129f1e2b")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
namespace WellRoundedBep;

[BepInPlugin("com.FlexibleGames.WellRoundedBep", "Well Rounded", "1.3.0")]
public class WellRoundedBepMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "Create")]
	private class Patch_PlayerSoil
	{
		[HarmonyPostfix]
		public static void HarmonyPostfix(Player __instance)
		{
			if (__instance != null)
			{
				__instance.SetSandCount(100000000000L);
			}
		}
	}

	[HarmonyPatch(typeof(PowerGeneratorComponent), "EnergyCap_PV")]
	private class Patch_SolarGenerators
	{
		[HarmonyPostfix]
		public static void Postfix(ref long __result, ref PowerGeneratorComponent __instance)
		{
			if (i_solarpowermulti.Value > 1)
			{
				__instance.capacityCurrentTick *= i_solarpowermulti.Value;
				__result *= i_solarpowermulti.Value;
			}
		}
	}

	[HarmonyPatch(typeof(PowerGeneratorComponent), "EnergyCap_Wind")]
	private class Patch_WindGenerators
	{
		[HarmonyPostfix]
		public static void Postfix(ref long __result, ref PowerGeneratorComponent __instance)
		{
			if (i_windpowermulti.Value > 1)
			{
				__instance.capacityCurrentTick *= i_windpowermulti.Value;
				__result *= i_windpowermulti.Value;
			}
		}
	}

	[HarmonyPatch(typeof(PowerGeneratorComponent), "EnergyCap_Fuel")]
	private class Patch_FuelGenerators
	{
		[HarmonyPostfix]
		public static void Postfix(ref long __result, ref PowerGeneratorComponent __instance)
		{
			if (i_genpowermulti.Value > 1)
			{
				__instance.capacityCurrentTick *= i_genpowermulti.Value;
				__result *= i_genpowermulti.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Mecha), "UseEnergy")]
	private class Patch_InfiniteEnergy
	{
		[HarmonyPrefix]
		public static bool Prefix(ref double energyUse)
		{
			if (b_infiniteenergy.Value)
			{
				energyUse = 0.0;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "SetSandCount")]
	private class Patch_InfiniteSoil
	{
		[HarmonyPrefix]
		public static bool Prefix(ref long newSandCount)
		{
			if (b_infinitesoil.Value)
			{
				newSandCount = 100000000000L;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Mecha), "SetForNewGame")]
	private class Patch_NewGameOverrides
	{
		[HarmonyPostfix]
		public static void Postfix(ref Mecha __instance)
		{
			if (__instance != null)
			{
				if (b_instantmining.Value)
				{
					Mecha obj = __instance;
					obj.miningSpeed *= 100f;
					__instance.miningPower = 0.0;
				}
				if (b_instantcrafting.Value)
				{
					Mecha obj2 = __instance;
					obj2.replicateSpeed *= 100f;
					__instance.replicatePower = 0.0;
				}
				if (f_movespeed.Value > 1f)
				{
					Mecha obj3 = __instance;
					obj3.walkSpeed *= f_movespeed.Value;
					__instance.walkPower = 0.0;
				}
				if (f_jumpheight.Value > 1f)
				{
					Mecha obj4 = __instance;
					obj4.jumpSpeed *= f_jumpheight.Value;
					__instance.jumpEnergy = 0.0;
				}
				if (f_longreach.Value > 1f)
				{
					Mecha obj5 = __instance;
					obj5.buildArea *= f_longreach.Value;
				}
				if (b_powereddrones.Value)
				{
					__instance.droneEjectEnergy = 0.0;
					__instance.droneEnergyPerMeter = 0.0;
				}
			}
			else
			{
				logger.LogWarning((object)"Instance was Null in New Game Override Patch");
			}
		}
	}

	[HarmonyPatch(typeof(Mecha), "Import")]
	private class Patch_SavedGameOverride
	{
		[HarmonyPostfix]
		public static void Postfix(ref Mecha __instance)
		{
			if (__instance != null)
			{
				if (b_instantmining.Value)
				{
					if (__instance.miningSpeed < 60f)
					{
						Mecha obj = __instance;
						obj.miningSpeed *= 100f;
					}
					if (__instance.miningPower != 0.0)
					{
						__instance.miningPower = 0.0;
					}
				}
				if (b_instantcrafting.Value)
				{
					if (__instance.replicateSpeed < 40f)
					{
						Mecha obj2 = __instance;
						obj2.replicateSpeed *= 100f;
					}
					if (__instance.replicatePower != 0.0)
					{
						Mecha obj3 = __instance;
						obj3.replicatePower *= 0.0;
					}
				}
				if (f_movespeed.Value > 1f)
				{
					if (__instance.walkSpeed < 12f && f_movespeed.Value == 2f)
					{
						Mecha obj4 = __instance;
						obj4.walkSpeed *= f_movespeed.Value;
					}
					else if (__instance.walkSpeed <= 16f && f_movespeed.Value > 2f)
					{
						Mecha obj5 = __instance;
						obj5.walkSpeed *= f_movespeed.Value;
					}
					if (__instance.walkPower != 0.0)
					{
						__instance.walkPower = 0.0;
					}
				}
				if (f_jumpheight.Value > 1f)
				{
					if (__instance.jumpSpeed < 40f)
					{
						Mecha obj6 = __instance;
						obj6.jumpSpeed *= f_jumpheight.Value;
					}
					if (__instance.jumpEnergy != 0.0)
					{
						__instance.jumpEnergy = 0.0;
					}
				}
				if (f_longreach.Value > 1f && __instance.buildArea < 100f)
				{
					Mecha obj7 = __instance;
					obj7.buildArea *= f_longreach.Value;
				}
				if (b_powereddrones.Value)
				{
					__instance.droneEjectEnergy = 0.0;
					__instance.droneEnergyPerMeter = 0.0;
				}
			}
			else
			{
				logger.LogWarning((object)"Instance was Null in Patch Saved Game Overrides.");
			}
		}
	}

	public static ManualLogSource logger;

	private Harmony _harmony;

	public static ConfigEntry<bool> b_infiniteenergy;

	public static ConfigEntry<bool> b_instantmining;

	public static ConfigEntry<bool> b_instantcrafting;

	public static ConfigEntry<float> f_movespeed;

	public static ConfigEntry<float> f_jumpheight;

	public static ConfigEntry<float> f_longreach;

	public static ConfigEntry<int> i_windpowermulti;

	public static ConfigEntry<int> i_solarpowermulti;

	public static ConfigEntry<int> i_fuelamountmulti;

	public static ConfigEntry<int> i_genpowermulti;

	public static ConfigEntry<int> i_stacksizemulti;

	public static ConfigEntry<bool> b_moddebugmode;

	public static ConfigEntry<int> i_extrastorage_per;

	public static ConfigEntry<float> f_solarlossrate_per;

	public static ConfigEntry<int> i_extrastackcount_per;

	public static ConfigEntry<int> i_extradronecapacity_per;

	public static ConfigEntry<int> i_extradroneshipcap_per;

	public static ConfigEntry<int> i_extradronespeed_per;

	public static ConfigEntry<float> f_extradroneshipspeed_per;

	public static ConfigEntry<float> f_mininigcostrate_per;

	public static ConfigEntry<float> f_miningspeedscale_per;

	public static ConfigEntry<int> i_extratechspeed_per;

	public static ConfigEntry<float> f_extrawalkspeed_per;

	public static ConfigEntry<float> f_hashesneededmulti_per;

	public static ConfigEntry<bool> b_infinitesoil;

	public static ConfigEntry<int> i_solarsaillife;

	public static ConfigEntry<int> i_maxsailspeed;

	public static ConfigEntry<float> f_mechacraftspeed;

	public static ConfigEntry<bool> b_powereddrones;

	public static ConfigEntry<bool> b_ironmanmode;

	public static ConfigEntry<float> f_mechpowermult;

	public static ConfigEntry<int> i_dronetasks;

	public static ConfigEntry<int> i_extrawarpspeed_per;

	public static ConfigEntry<float> f_extrakineticdamage_per;

	public static ConfigEntry<float> f_extraenergydamage_per;

	public static ConfigEntry<float> f_extrablastdamage_per;

	public static ConfigEntry<float> f_extramagneticdamage_per;

	public static ConfigEntry<long> l_extraenergyshield_per;

	public static ConfigEntry<float> f_extracombatdronedamage_per;

	public static ConfigEntry<float> f_extracombatdronehealth_per;

	public static ConfigEntry<float> f_extracombatdronespeed_per;

	public static ConfigEntry<float> f_extracombatshipdamage_per;

	public static ConfigEntry<float> f_extracombatshiphealth_per;

	public static ConfigEntry<int> i_proliferatorProdMult;

	public static ConfigEntry<int> i_proliferatorSpeedMult;

	public void BindConfigs()
	{
		b_powereddrones = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnablePoweredDrones", true, "Drones have their own power source, they don't use Mechas power.");
		b_ironmanmode = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnableIronMan", true, "Iron man is an army unto themself, here there be dragons. Sets EnablePoweredDrones to true.");
		b_infiniteenergy = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnableInfiniteEnergy", false, "Enable Infinite Energy");
		b_instantmining = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnableInstantMining", false, "Enable Infinite Mining");
		b_instantcrafting = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnableInstantCrafting", false, "Enable Instant Crafting");
		b_infinitesoil = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "EnableInfiniteSoil", true, "Enable Infinite Soil");
		i_stacksizemulti = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StackSizeMultiplier", 4, "Stack Size Multiplier; 1 = no change");
		f_movespeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "MoveSpeedMultiplier", 6f, "Movement Speed Multiplier; 1 = no change");
		f_jumpheight = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "JumpHeightMultiplier", 1.5f, "Jump Height Multiplier; 1 = no change");
		f_longreach = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "ReachMultiplier", 3f, "Build Reach Multiplier; 1 = no change");
		i_windpowermulti = ((BaseUnityPlugin)this).Config.Bind<int>("Power", "WindPowerMultiplier", 2, "Wind Power Multiplier; 1 = no change");
		i_solarpowermulti = ((BaseUnityPlugin)this).Config.Bind<int>("Power", "SolarPowerMultiplier", 3, "Solar Power Multiplier; 1 = no change");
		i_fuelamountmulti = ((BaseUnityPlugin)this).Config.Bind<int>("Power", "FuelDensityMultiplier", 2, "Fuel Density Multiplier; 1 = no change");
		i_genpowermulti = ((BaseUnityPlugin)this).Config.Bind<int>("Power", "GeneratorPowerMultiplier", 4, "Fuel Generator Power Multiplier; 1 = no change");
		f_hashesneededmulti_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "HashNeededReduction", 0.25f, "Reduce Hashes by 1-this value; i.e. 0.75 will cut Hash costs 75%, 0 = no change; 1 = free research");
		i_extrastorage_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraStoragePer", 0, "Extra Mech Storage rows per research, 0 = no change");
		f_solarlossrate_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraSolarLossPer", 0.15f, "Extra Solar Efficiency Boost, 0.0 = no change; 0.15 = 25% More Efficient Per Research (Vanilla is already 0.9)");
		i_extrastackcount_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraSortStackPer", 1, "Extra Sorter Stacks per research, 0 = no change");
		i_extradronecapacity_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraDroneCapPer", 8, "Extra Mecha Drone Cap per research, recommend enabling EnablePoweredDrones, 0 = no change");
		i_extradroneshipcap_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraShipCapPer", 100, "Extra Drone SHIP Cap per research, 0 = no change");
		i_extradronespeed_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraDroneSpeedPer", 6, "Extra Mech Drone Speed per research, 0 = no change");
		f_extradroneshipspeed_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraShipSpeedPer", 0.5f, "Extra Ship Speed, 0.0 = no change in % gain");
		f_mininigcostrate_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraMineEfficiencyPer", 0.09f, "Extra Mining Efficiency Gain, 0.0 = no change; 0.09 = 15% More Efficient Per Research (Vanilla is already 0.94)");
		f_miningspeedscale_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraMineSpeedPer", 0.1f, "Extra Mining Speed, 0.0 = no change; 0.1 = 20% Faster Per Research (Vanilla is already 0.1)");
		i_extratechspeed_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraResearchSpeedPer", 1, "Extra Research Speed per research, 0 = no change");
		f_extrawalkspeed_per = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraWalkSpeedPer", 1f, "Extra Walk Speed per research, 0 = no change; 1 = 200% Faster Per Research (Vanilla is already 1-2)");
		i_solarsaillife = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraSolarSailLifePer", 2, "Solar Sail Life Tech Multiplier; 1 = no change; 2 = 100% more than vanilla");
		i_maxsailspeed = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraSailSpeedPer", 2000, "Extra Mecha Sail Speed per Research (in m/s) 0 = no change; 1000 = 100% more than vanilla");
		f_mechacraftspeed = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "ExtraMechCraftSpeedPer", 1.5f, "Extra Mech Crafting Speed per research; 0 = no change; 0.5 = Extra 50% boost to crafting speed.");
		f_mechpowermult = ((BaseUnityPlugin)this).Config.Bind<float>("Research", "MechaPowerResearchMult", 2f, "Multiplier for each tier of mecha power research. 1 = no change ");
		i_dronetasks = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "AdditionalDroneTasks", 2, "Additional Drone tasks per research.");
		i_extrawarpspeed_per = ((BaseUnityPlugin)this).Config.Bind<int>("Research", "ExtraWarpSpeedPer", 2, "Additional 40k speed bumps to max warp speed per level.");
		f_extrakineticdamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraKineticDamage", 0.5f, "Extra % damage per research.");
		f_extraenergydamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraEnergyDamage", 0.5f, "Extra % damage per research.");
		f_extrablastdamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraBlastDamage", 0.5f, "Extra % damage per research.");
		f_extramagneticdamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraMagneticDamage", 0.5f, "Extra % damage per research.");
		l_extraenergyshield_per = ((BaseUnityPlugin)this).Config.Bind<long>("CombatResearch", "ExtraShield", 10000000L, "Extra Shields per research.");
		f_extracombatdronedamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraCombatDroneDamage", 0.5f, "Extra % damage per research.");
		f_extracombatdronehealth_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraCombatDroneHealth", 0.5f, "Extra % health per research.");
		f_extracombatdronespeed_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraCombatDroneSpeed", 0.5f, "Extra % speed per research.");
		f_extracombatshipdamage_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraCombatShipDamage", 0.5f, "Extra % damage per research.");
		f_extracombatshiphealth_per = ((BaseUnityPlugin)this).Config.Bind<float>("CombatResearch", "ExtraCombatShipHealth", 0.5f, "Extra % health per research.");
		i_proliferatorProdMult = ((BaseUnityPlugin)this).Config.Bind<int>("ProliferatorBoost", "ProliferatorProdMult", 4, "Multiplier for Extra Proliferator Production, 1 = no change.");
		i_proliferatorSpeedMult = ((BaseUnityPlugin)this).Config.Bind<int>("ProliferatorBoost", "ProliferatorSpeedMult", 2, "Multiplier for Extra Proliferator Speed, 1 = no change");
		b_moddebugmode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugMode", false, "Enable Debug Mode, spams Log Files.");
	}

	public void Start()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		logger = ((BaseUnityPlugin)this).Logger;
		BindConfigs();
		if (b_ironmanmode.Value)
		{
			b_powereddrones.Value = true;
		}
		_harmony = new Harmony("com.FlexibleGames.WellRoundedBep");
		try
		{
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Starting Patches");
			}
			if (b_infinitesoil.Value)
			{
				if (b_moddebugmode.Value)
				{
					logger.LogDebug((object)"Patching Player Soil");
				}
				_harmony.PatchAll(typeof(Patch_PlayerSoil));
				if (b_moddebugmode.Value)
				{
					logger.LogDebug((object)"Patching Infinite Soil");
				}
				_harmony.PatchAll(typeof(Patch_InfiniteSoil));
			}
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching Solar");
			}
			_harmony.PatchAll(typeof(Patch_SolarGenerators));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching Wind");
			}
			_harmony.PatchAll(typeof(Patch_WindGenerators));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching Fuel Gen");
			}
			_harmony.PatchAll(typeof(Patch_FuelGenerators));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching Energy");
			}
			_harmony.PatchAll(typeof(Patch_InfiniteEnergy));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching New Game");
			}
			_harmony.PatchAll(typeof(Patch_NewGameOverrides));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Patching Saved Game");
			}
			_harmony.PatchAll(typeof(Patch_SavedGameOverride));
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"All Patched, processing Game Data");
			}
			ProcessGameData();
		}
		catch (Exception ex)
		{
			logger.LogError((object)ex.ToString());
		}
	}

	internal static void ParseItems(ref ItemProtoSet ItemSet)
	{
		ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)ItemSet).dataArray;
		foreach (ItemProto val in dataArray)
		{
			if (val.HeatValue > 0 && i_fuelamountmulti.Value > 1)
			{
				val.HeatValue *= i_fuelamountmulti.Value;
			}
			if (i_stacksizemulti.Value > 1 && val.StackSize != 1)
			{
				val.StackSize *= i_stacksizemulti.Value;
			}
		}
	}

	internal static void ParseTechTree(ref TechProtoSet TechSet)
	{
		TechProto[] dataArray = ((ProtoSet<TechProto>)(object)TechSet).dataArray;
		foreach (TechProto val in dataArray)
		{
			if (f_hashesneededmulti_per.Value > 0f)
			{
				val.HashNeeded = (long)((float)val.HashNeeded * (1f - f_hashesneededmulti_per.Value));
				if (val.LevelCoef1 != 0)
				{
					val.LevelCoef1 = (int)((float)val.LevelCoef1 * (1f - f_hashesneededmulti_per.Value));
				}
				if (val.LevelCoef2 != 0)
				{
					val.LevelCoef2 = (int)((float)val.LevelCoef2 * (1f - f_hashesneededmulti_per.Value));
				}
			}
			if (val.UnlockFunctions.Length == 0)
			{
				continue;
			}
			bool flag = false;
			for (int j = 0; j < val.UnlockFunctions.Length; j++)
			{
				switch (val.UnlockFunctions[j])
				{
				case 1:
					val.UnlockValues[j] += i_extradronecapacity_per.Value;
					break;
				case 2:
					val.UnlockValues[j] *= f_mechpowermult.Value;
					break;
				case 3:
					val.UnlockValues[j] += f_extrawalkspeed_per.Value;
					break;
				case 5:
					val.UnlockValues[j] += i_extrastorage_per.Value;
					break;
				case 6:
					val.UnlockValues[j] *= f_mechpowermult.Value;
					break;
				case 7:
					val.UnlockValues[j] += f_mechacraftspeed.Value;
					break;
				case 9:
					val.UnlockValues[j] += i_dronetasks.Value;
					break;
				case 10:
					val.UnlockValues[j] += i_extradronespeed_per.Value;
					break;
				case 11:
					val.UnlockValues[j] += i_maxsailspeed.Value;
					break;
				case 12:
					val.UnlockValues[j] *= i_solarsaillife.Value;
					break;
				case 13:
					val.UnlockValues[j] -= f_solarlossrate_per.Value;
					break;
				case 14:
					val.UnlockValues[j] += i_extrastackcount_per.Value;
					break;
				case 15:
					val.UnlockValues[j] += f_extradroneshipspeed_per.Value;
					break;
				case 16:
					val.UnlockValues[j] += f_extradroneshipspeed_per.Value;
					break;
				case 18:
					val.UnlockValues[j] += i_extradroneshipcap_per.Value;
					break;
				case 19:
					val.UnlockValues[j] += i_extradroneshipcap_per.Value;
					break;
				case 20:
					val.UnlockValues[j] -= f_mininigcostrate_per.Value;
					break;
				case 21:
					val.UnlockValues[j] += f_miningspeedscale_per.Value;
					break;
				case 22:
					val.UnlockValues[j] += i_extratechspeed_per.Value;
					break;
				case 27:
					val.UnlockValues[j] += i_extrawarpspeed_per.Value;
					break;
				case 34:
					val.UnlockValues[j] += f_extradroneshipspeed_per.Value;
					break;
				case 61:
					val.UnlockValues[j] += f_extrakineticdamage_per.Value;
					break;
				case 62:
					val.UnlockValues[j] += f_extraenergydamage_per.Value;
					break;
				case 63:
					val.UnlockValues[j] += f_extrablastdamage_per.Value;
					break;
				case 64:
					val.UnlockValues[j] += f_extramagneticdamage_per.Value;
					break;
				case 66:
					val.UnlockValues[j] += l_extraenergyshield_per.Value;
					break;
				case 67:
					val.UnlockValues[j] += f_extracombatshipdamage_per.Value;
					break;
				case 69:
					val.UnlockValues[j] += f_extracombatdronehealth_per.Value;
					break;
				case 70:
					val.UnlockValues[j] += f_extracombatdronespeed_per.Value;
					break;
				case 71:
					val.UnlockValues[j] += f_extracombatshipdamage_per.Value;
					break;
				case 73:
					val.UnlockValues[j] += f_extracombatshiphealth_per.Value;
					break;
				case 83:
					val.UnlockValues[j] += f_extraenergydamage_per.Value;
					break;
				}
			}
			if (flag)
			{
				val.UnlockFunctions = new int[2] { 4, 11 };
				val.UnlockValues = new double[2]
				{
					3.0,
					1000 + i_maxsailspeed.Value
				};
			}
		}
	}

	internal static void ProcessGameData()
	{
		if (i_fuelamountmulti.Value > 1 || i_stacksizemulti.Value > 1)
		{
			ItemProtoSet ItemSet = LDB.items;
			if ((Object)(object)LDB.items == (Object)null)
			{
				logger.LogWarning((object)"Item Set was Null!");
			}
			if (((ProtoSet<ItemProto>)(object)ItemSet).dataArray.Length != 0)
			{
				if (b_moddebugmode.Value)
				{
					logger.LogDebug((object)"Parsing Items");
				}
				ParseItems(ref ItemSet);
				ItemProtoSet value = ItemSet;
				try
				{
					if (b_moddebugmode.Value)
					{
						logger.LogDebug((object)"Items Parsed, Attempting Push...");
					}
					Traverse.Create(typeof(LDB)).Field("_items").SetValue((object)value);
					if (b_moddebugmode.Value)
					{
						logger.LogDebug((object)"Modded ItemSet Pushed.");
					}
				}
				catch (Exception ex)
				{
					logger.LogError((object)("Exception while pushing Item set into LDB: " + ex.ToString()));
				}
			}
		}
		if (b_powereddrones.Value)
		{
			Traverse.Create(typeof(ModeConfig)).Field("droneEjectEnergy").SetValue((object)0);
			Traverse.Create(typeof(ModeConfig)).Field("droneEnergyPerMeter").SetValue((object)0);
			Traverse.Create(typeof(ModeConfig)).Field("droneRepairEnergyCostPerHP").SetValue((object)0);
		}
		if (b_ironmanmode.Value)
		{
			Traverse.Create(typeof(ModeConfig)).Field("mechaHpMax").SetValue((object)400000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaHpRecover").SetValue((object)250);
			Traverse.Create(typeof(ModeConfig)).Field("mechaBulletEnergyCost").SetValue((object)1800);
			Traverse.Create(typeof(ModeConfig)).Field("mechaCannonEnergyCost").SetValue((object)9000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaMissileEnergyCost").SetValue((object)12000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaPlasmaEnergyCost").SetValue((object)12000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaBulletDamageScale").SetValue((object)4);
			Traverse.Create(typeof(ModeConfig)).Field("mechaCannonDamageScale").SetValue((object)4);
			Traverse.Create(typeof(ModeConfig)).Field("mechaMissileDamageScale").SetValue((object)4);
			Traverse.Create(typeof(ModeConfig)).Field("mechaPlasmaDamageScale").SetValue((object)4);
			Traverse.Create(typeof(ModeConfig)).Field("mechaLocalLaserEnergyCost").SetValue((object)50000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaLocalLaserDamage").SetValue((object)49000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaSpaceLaserEnergyCost").SetValue((object)60000);
			Traverse.Create(typeof(ModeConfig)).Field("mechaSpaceLaserDamage").SetValue((object)49000);
		}
		if (i_proliferatorProdMult.Value > 1)
		{
			double[] array = new double[Cargo.incTableMilli.Length];
			Array.Copy(Cargo.incTableMilli, array, array.Length);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] *= i_proliferatorProdMult.Value;
			}
			Traverse.Create(typeof(Cargo)).Field("incTableMilli").SetValue((object)array);
		}
		if (i_proliferatorSpeedMult.Value > 1)
		{
			double[] array2 = new double[Cargo.accTableMilli.Length];
			Array.Copy(Cargo.incTableMilli, array2, array2.Length);
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j] *= i_proliferatorSpeedMult.Value;
			}
			Traverse.Create(typeof(Cargo)).Field("accTableMilli").SetValue((object)array2);
		}
		if ((Object)(object)LDB.techs == (Object)null)
		{
			logger.LogWarning((object)"Tech Set was Null");
			return;
		}
		TechProtoSet TechSet = LDB.techs;
		if (((ProtoSet<TechProto>)(object)TechSet).dataArray.Length == 0)
		{
			return;
		}
		try
		{
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Parsing Tech Tree");
			}
			ParseTechTree(ref TechSet);
		}
		catch (Exception ex2)
		{
			logger.LogError((object)("Exception while parsing Techs: " + ex2.ToString()));
		}
		try
		{
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Tech Tree Parsed, Attempting Push...");
			}
			Traverse.Create(typeof(LDB)).Field("_techs").SetValue((object)TechSet);
			if (b_moddebugmode.Value)
			{
				logger.LogDebug((object)"Modded Tech Tree pushed.");
			}
		}
		catch (Exception ex3)
		{
			logger.LogError((object)("Exception while Pushing tech into LDB: " + ex3.ToString()));
		}
	}

	private void OnDestroy()
	{
		_harmony.UnpatchSelf();
	}
}