Decompiled source of FastStart v1.1.2

FastStart.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using xiaoye97;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FastStart")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Gives you more starting gear to make beginning less manual.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+b8df6526b22acd02484674f056471dc260932e7b")]
[assembly: AssemblyProduct("FastStart")]
[assembly: AssemblyTitle("FastStart")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FastStart
{
	[BepInPlugin("com.Trol1face.dsp.FastStart", "FastStart", "1.1.2")]
	public class FastStart : BaseUnityPlugin
	{
		public class DefaultModePatch
		{
			[HarmonyTranspiler]
			[HarmonyPatch(typeof(Player), "SetForNewGame")]
			public static IEnumerable<CodeInstruction> Player_SetForNewGame_Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Expected O, but got Unknown
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
				MethodInfo method = typeof(FastStart).GetMethod("SuppliesDecider");
				MethodInfo anchorM = typeof(Configs).GetMethod("get_freeMode");
				FieldInfo anchorF = typeof(ModeConfig).GetField("items");
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && i.operand is MethodInfo methodInfo && methodInfo == anchorM), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && i.operand is FieldInfo fieldInfo && fieldInfo == anchorF), (string)null)
				});
				val.RemoveInstructions(2);
				val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)method)
				});
				return val.InstructionEnumeration();
			}
		}

		public const string __NAME__ = "FastStart";

		public const string __GUID__ = "com.Trol1face.dsp.FastStart";

		public static int matrixLabId = 2901;

		public static int minerId = 2301;

		public static int smelterId = 2302;

		public static int windTurbineId = 2203;

		public static int teslaTowerId = 2201;

		public static int sorterId = 2011;

		public static int beltId = 2001;

		public static int splitterId = 2020;

		public static int storageId = 2101;

		public static int assemblerId = 2303;

		public static int thermalStationId = 2204;

		public static int WirelessPowerTowerId = 2202;

		public static int circuitId = 1301;

		public static int gearId = 1201;

		public static int motorId = 1203;

		public static int blueMatrixId = 6001;

		public static int coilId = 1202;

		public static int beltMk1Id = 2001;

		public static int sorterk1Id = 2011;

		public static int storageMk1Id = 2101;

		public static int wirelessTowerId = 2202;

		public static int ILSId = 2104;

		public static int vesselId = 5002;

		public static int researchSpeedDenominator = 3;

		public static ConfigEntry<bool> researchMode;

		public static ConfigEntry<string> suppliesAmount;

		public static ConfigEntry<bool> giveBlueMatrix;

		public static ConfigEntry<bool> giveFreeILS;

		public static ConfigEntry<bool> speedUpItemTechs;

		private void Awake()
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			suppliesAmount = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Amount of supplies", "enough", "AVAILABLE OPTIONS (type in): few, enough, huge.\nDEFAULT: enough.");
			researchMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Research mode enabler", false, "IMPORTANT: playing with this enabled will surely fail abnormality check (fixes with mod) and disable upload to milky way.\nCheck thunderstore modpage for more info. Some options for research mode below");
			giveBlueMatrix = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Give 300 blue matrixes (only enough/huge)", false, "If enabled you will receive 300 blue cubes, mainly for drones speed+count upgrade.\nDEFAULT: false");
			giveFreeILS = ((BaseUnityPlugin)this).Config.Bind<bool>("Research mode options", "Free ILS (only enough/huge)", false, "If enabled completing Interplanetary Logistics research will award you with 2 ILS and 6 vessels.\nDEFAULT: false");
			speedUpItemTechs = ((BaseUnityPlugin)this).Config.Bind<bool>("Research mode options", "Speedup some techs research", false, "Lowers amount of hashes needed to research techs that use items as input, number of items needed remains the same.\nDEFAULT: false");
			if (!researchMode.Value && (suppliesAmount.Value == "few" || suppliesAmount.Value == "enough" || suppliesAmount.Value == "huge"))
			{
				new Harmony("com.Trol1face.dsp.FastStart").PatchAll(typeof(DefaultModePatch));
			}
			if (researchMode.Value && (suppliesAmount.Value == "few" || suppliesAmount.Value == "enough" || suppliesAmount.Value == "huge"))
			{
				ResearchModeModifyProtos();
			}
		}

		public static IDCNTINC[] SuppliesDecider()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: 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_0368: Unknown result type (might be due to invalid IL or missing references)
			string value = suppliesAmount.Value;
			List<IDCNTINC> list = new List<IDCNTINC>
			{
				new IDCNTINC(coilId, 30, 0),
				new IDCNTINC(gearId, 20, 0),
				new IDCNTINC(circuitId, 40, 0)
			};
			switch (value)
			{
			case "few":
				list.Add(new IDCNTINC(teslaTowerId, 10, 0));
				list.Add(new IDCNTINC(windTurbineId, 8, 0));
				list.Add(new IDCNTINC(minerId, 2, 0));
				list.Add(new IDCNTINC(smelterId, 3, 0));
				list.Add(new IDCNTINC(beltId, 100, 0));
				list.Add(new IDCNTINC(storageId, 1, 0));
				list.Add(new IDCNTINC(sorterId, 15, 0));
				list.Add(new IDCNTINC(assemblerId, 3, 0));
				break;
			case "enough":
				list.Add(new IDCNTINC(teslaTowerId, 60, 0));
				list.Add(new IDCNTINC(windTurbineId, 30, 0));
				list.Add(new IDCNTINC(thermalStationId, 2, 0));
				list.Add(new IDCNTINC(minerId, 14, 0));
				list.Add(new IDCNTINC(smelterId, 24, 0));
				list.Add(new IDCNTINC(beltId, 600, 0));
				list.Add(new IDCNTINC(storageId, 6, 0));
				list.Add(new IDCNTINC(sorterId, 120, 0));
				list.Add(new IDCNTINC(splitterId, 10, 0));
				list.Add(new IDCNTINC(assemblerId, 24, 0));
				list.Add(new IDCNTINC(matrixLabId, 12, 0));
				list.Add(new IDCNTINC(motorId, 60, 0));
				break;
			case "huge":
				list.Add(new IDCNTINC(teslaTowerId, 120, 0));
				list.Add(new IDCNTINC(windTurbineId, 40, 0));
				list.Add(new IDCNTINC(WirelessPowerTowerId, 20, 0));
				list.Add(new IDCNTINC(thermalStationId, 8, 0));
				list.Add(new IDCNTINC(minerId, 24, 0));
				list.Add(new IDCNTINC(smelterId, 48, 0));
				list.Add(new IDCNTINC(beltId, 1200, 0));
				list.Add(new IDCNTINC(sorterId, 300, 0));
				list.Add(new IDCNTINC(splitterId, 40, 0));
				list.Add(new IDCNTINC(storageId, 20, 0));
				list.Add(new IDCNTINC(assemblerId, 48, 0));
				list.Add(new IDCNTINC(matrixLabId, 24, 0));
				list.Add(new IDCNTINC(motorId, 60, 0));
				break;
			}
			if (giveBlueMatrix.Value && (value == "enough" || value == "huge"))
			{
				list.Add(new IDCNTINC(blueMatrixId, 300, 0));
			}
			return list.ToArray();
		}

		public static void ResearchModeModifyProtos()
		{
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifySpaceCapsuleLoot));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyElectromagnetismTech));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyAssemblyTech));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifySmeltingTech));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyMatrixTech));
			LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyLogisticsMk1Tech));
			if (speedUpItemTechs.Value)
			{
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyMechaCoreTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyMechanicalFrameTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyMechaFlightTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyEnergyCircuitTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyInventoryCapacityTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyMassConstructionTech));
			}
			if (suppliesAmount.Value != "few")
			{
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyLogisticsMk2Tech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyThermalPowerTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyPlasmaControlTech));
				LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyElectromagneticDriveTech));
				if (giveFreeILS.Value)
				{
					LDBTool.EditDataAction = (Action<Proto>)Delegate.Combine(LDBTool.EditDataAction, new Action<Proto>(ModifyInterplanetaryLogisticsTech));
				}
			}
		}

		public static void ModifySpaceCapsuleLoot(Proto proto)
		{
			VegeProto val = (VegeProto)(object)((proto is VegeProto) ? proto : null);
			if (val != null && proto.ID == 9999)
			{
				val.MiningTime = 150;
				val.MiningItem = new int[4] { 1801, coilId, circuitId, gearId };
				val.MiningCount = new int[4] { 3, 30, 40, 20 };
			}
		}

		public static void ModifyElectromagnetismTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1001)
			{
				if (value == "few")
				{
					val.AddItemCounts = new int[3] { 10, 10, 3 };
				}
				if (value == "enough")
				{
					val.AddItemCounts = new int[3] { 30, 60, 15 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[3] { 40, 100, 30 };
				}
				if (speedUpItemTechs.Value)
				{
					ModifyResearchSpeed(val, researchSpeedDenominator);
				}
			}
		}

		public static void ModifySmeltingTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1401)
			{
				if (value == "few")
				{
					val.AddItemCounts = new int[1] { 4 };
				}
				if (value == "enough")
				{
					val.AddItemCounts = new int[1] { 24 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[1] { 48 };
				}
				if (speedUpItemTechs.Value)
				{
					ModifyResearchSpeed(val, researchSpeedDenominator);
				}
			}
		}

		public static void ModifyAssemblyTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1201)
			{
				if (value == "few")
				{
					val.AddItemCounts = new int[1] { 4 };
				}
				if (value == "enough")
				{
					val.AddItemCounts = new int[1] { 24 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[1] { 48 };
				}
				if (speedUpItemTechs.Value)
				{
					ModifyResearchSpeed(val, researchSpeedDenominator);
				}
			}
		}

		public static void ModifyMatrixTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val == null || proto.ID != 1002)
			{
				return;
			}
			if (giveBlueMatrix.Value && value != "few")
			{
				val.AddItems = new int[2] { matrixLabId, blueMatrixId };
				if (value == "enough")
				{
					val.AddItemCounts = new int[2] { 12, 300 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[2] { 24, 300 };
				}
			}
			else
			{
				if (value == "few")
				{
					val.AddItemCounts = new int[1] { 2 };
				}
				if (value == "enough")
				{
					val.AddItemCounts = new int[1] { 12 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[1] { 24 };
				}
			}
			if (speedUpItemTechs.Value)
			{
				ModifyResearchSpeed(val, researchSpeedDenominator);
			}
		}

		public static void ModifyLogisticsMk1Tech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1601)
			{
				val.AddItems = new int[3] { beltMk1Id, sorterk1Id, storageMk1Id };
				if (value == "few")
				{
					val.AddItemCounts = new int[3] { 120, 20, 2 };
				}
				if (value == "enough")
				{
					val.AddItemCounts = new int[3] { 600, 120, 10 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[3] { 1200, 300, 30 };
				}
				if (speedUpItemTechs.Value)
				{
					ModifyResearchSpeed(val, researchSpeedDenominator);
				}
			}
		}

		public static void ModifyLogisticsMk2Tech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1602)
			{
				if (value == "enough")
				{
					val.AddItemCounts = new int[3] { 10, 20, 5 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[3] { 20, 40, 5 };
				}
			}
		}

		public static void ModifyThermalPowerTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1412)
			{
				if (value == "enough")
				{
					val.AddItemCounts = new int[1] { 4 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[1] { 9 };
				}
			}
		}

		public static void ModifyPlasmaControlTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1101)
			{
				val.AddItems = new int[1] { wirelessTowerId };
				if (value == "enough")
				{
					val.AddItemCounts = new int[1] { 5 };
				}
				if (value == "huge")
				{
					val.AddItemCounts = new int[1] { 20 };
				}
			}
		}

		public static void ModifyInterplanetaryLogisticsTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1605 && giveFreeILS.Value)
			{
				val.AddItems = new int[2] { ILSId, vesselId };
				val.AddItemCounts = new int[2] { 2, 6 };
			}
		}

		public static void ModifyElectromagneticDriveTech(Proto proto)
		{
			string value = suppliesAmount.Value;
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 1701)
			{
				val.AddItems = new int[1] { motorId };
				val.AddItemCounts = new int[1] { 60 };
			}
		}

		public static void ModifyMechaCoreTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2101)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyMechanicalFrameTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2201)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyInventoryCapacityTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2301)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyMassConstructionTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2701)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyEnergyCircuitTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2501)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyMechaFlightTech(Proto proto)
		{
			TechProto val = (TechProto)(object)((proto is TechProto) ? proto : null);
			if (val != null && proto.ID == 2901)
			{
				ModifyResearchSpeed(val, 2 * researchSpeedDenominator);
			}
		}

		public static void ModifyResearchSpeed(TechProto techProto, int denominator)
		{
			techProto.HashNeeded /= denominator;
			int[] itemPoints = techProto.ItemPoints;
			for (int i = 0; i < itemPoints.Length; i++)
			{
				itemPoints[i] *= denominator;
			}
		}
	}
}