Decompiled source of FreeBlueprintTech v1.0.4

FreeBlueprintTech.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.4.0")]
namespace Killimataro.FreeBlueprintTech;

[BepInPlugin("killimataro.dsp.freeblueprinttech", "Free Blueprint Tech", "1.0.4")]
[BepInProcess("DSPGAME.exe")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(TechProto), "Preload")]
	public class TechProto_Preload
	{
		[HarmonyPostfix]
		public static void Postfix(TechProto __instance)
		{
			if (((Proto)__instance).ID > blueprintTechID && ((Proto)__instance).ID <= blueprintTechID + configTechLevel.Value)
			{
				__instance.PreTechsImplicit = new int[0];
			}
		}
	}

	[HarmonyPatch(typeof(GuideMissionStandardMode), "End")]
	public class GuideMissionStandardMode_End
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			unlockBlueprintTechs();
		}
	}

	[HarmonyPatch(typeof(GameMain), "Begin")]
	public class GameMain_Begin
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (!GameMain.instance.isMenuDemo && GameMain.logic.data.guideComplete)
			{
				unlockBlueprintTechs();
			}
		}
	}

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

	public const string NAME = "Free Blueprint Tech";

	public const string VERSION = "1.0.4";

	private static ConfigEntry<int> configTechLevel;

	private static readonly int blueprintTechID = 2700;

	internal static ManualLogSource logger;

	internal void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		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, 98), Array.Empty<object>()));
		Harmony val = new Harmony("killimataro.dsp.freeblueprinttech");
		val.PatchAll();
	}

	private static void unlockBlueprintTechs()
	{
		for (int i = blueprintTechID + 1; i <= blueprintTechID + configTechLevel.Value; i++)
		{
			if (!GameMain.data.history.TechUnlocked(i))
			{
				GameMain.data.history.UnlockTech(i);
			}
		}
	}
}