Decompiled source of FreeBlueprintTech v1.0.3

FreeBlueprintTech.dll

Decompiled a year ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Free Blueprint Tech")]
[assembly: AssemblyDescription("Unlocks blueprint tech for free")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Killimataro")]
[assembly: AssemblyProduct("Free Blueprint Tech")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("BC46C949-593C-472D-9D9F-50500183676B")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: AssemblyVersion("1.0.3.0")]
namespace Killimataro.FreeBlueprintTech;

[BepInPlugin("killimataro.dsp.freeblueprinttech", "Free Blueprint Tech", "1.0.3")]
[BepInProcess("DSPGAME.exe")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(TechProto), "Preload")]
	public class TechProto_Preload
	{
		[HarmonyPostfix]
		public static void Postfix(TechProto __instance)
		{
			if (GetTechIDs().Contains(((Proto)__instance).ID))
			{
				__instance.PreTechsImplicit = new int[0];
			}
		}
	}

	[HarmonyPatch(typeof(GameMain), "Begin")]
	public class GameMain_Begin
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (GameMain.instance.isMenuDemo)
			{
				return;
			}
			int[] techIDs = GetTechIDs();
			foreach (int num in techIDs)
			{
				if (!GameMain.data.history.TechUnlocked(num))
				{
					GameMain.data.history.UnlockTech(num);
				}
			}
		}
	}

	public const string GUID = "killimataro.dsp.freeblueprinttech";

	public const string NAME = "Free Blueprint Tech";

	public const string VERSION = "1.0.3";

	private static ConfigEntry<int> configTechLevel;

	private static readonly int blueprintTechID = 2700;

	internal static ManualLogSource logger;

	internal void Awake()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		logger = ((BaseUnityPlugin)this).Logger;
		configTechLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Blueprint Tech Level", 6, new ConfigDescription("Number of tech levels to unlock for free", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, int.MaxValue), new object[0]));
		new Harmony("killimataro.dsp.freeblueprinttech").PatchAll();
		logger.LogInfo((object)$"Free Blueprint Tech loaded! {configTechLevel.Value} blueprint tech levels will be unlocked for free");
		logger.LogMessage((object)"Once a tech is unlocked, it will stay unlocked even if you remove this mod, unless you revert back to an old save");
	}

	private static int[] GetTechIDs()
	{
		int[] array = new int[configTechLevel.Value];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = blueprintTechID + 1 + i;
		}
		return array;
	}
}