Decompiled source of ExtendedTechQueue v1.0.0

Extended.Tech.Queue.v.1.0.0.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Loki Moon Labs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Extended Tech Queue")]
[assembly: AssemblyTitle("ExtendedTechQueue")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ExtendedTechQueue
{
	internal static class ModInfo
	{
		internal const string Guid = "com.lokimoonlabs.extendedtechqueue";

		internal const string Name = "Extended Tech Queue";

		internal const string Version = "1.0.0";

		internal const string HarmonyId = "com.lokimoonlabs.extendedtechqueue.patches";
	}
	[BepInPlugin("com.lokimoonlabs.extendedtechqueue", "Extended Tech Queue", "1.0.0")]
	[BepInProcess("DSPGAME.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<int> TechQueueLength;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			TechQueueLength = ((BaseUnityPlugin)this).Config.Bind<int>("General", "TechQueueLength", 100, new ConfigDescription("Maximum research queue length. Vanilla is 8. Applied when a save is loaded or a new game is initialized.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 1000), Array.Empty<object>()));
			harmony = new Harmony("com.lokimoonlabs.extendedtechqueue.patches");
			harmony.PatchAll(typeof(TechQueuePatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Extended Tech Queue v1.0.0 loaded. Queue length: " + TechQueueLength.Value));
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			harmony = null;
		}
	}
	[HarmonyPatch]
	internal static class TechQueuePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameHistoryData), "SetForNewGame")]
		[HarmonyPatch(typeof(GameHistoryData), "Import")]
		private static void ResizeTechQueue(GameHistoryData __instance)
		{
			if (__instance?.techQueue == null || Plugin.TechQueueLength == null)
			{
				return;
			}
			int val = 0;
			for (int i = 0; i < __instance.techQueue.Length; i++)
			{
				if (__instance.techQueue[i] != 0)
				{
					val = i + 1;
				}
			}
			int num = Math.Max(8, Math.Max(Plugin.TechQueueLength.Value, val));
			if (__instance.techQueue.Length != num)
			{
				int[] array = new int[num];
				Array.Copy(__instance.techQueue, array, Math.Min(__instance.techQueue.Length, array.Length));
				__instance.techQueue = array;
			}
		}
	}
}