Decompiled source of DSPBigFormingSize v0.1.1

DSPBigFormingSize.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace DSPBigFormingSize;

[BepInPlugin("Appun.DSP.plugin.BigFormingSize", "DSPBigFormingSize", "0.1.0")]
[BepInProcess("DSPGAME.exe")]
public class DSPBigFormingSize : BaseUnityPlugin
{
	[HarmonyPatch(typeof(BuildTool_Reform), "ReformAction")]
	private class Transpiler_replace1
	{
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_I4_S && (sbyte)list[i].operand == 10)
				{
					list[i].opcode = OpCodes.Ldsfld;
					list[i].operand = AccessTools.Field(typeof(DSPBigFormingSize), "formSize");
				}
			}
			return list.AsEnumerable();
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private class Transpiler_replace2
	{
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_I4_S && (sbyte)list[i].operand == 100)
				{
					list[i].opcode = OpCodes.Ldsfld;
					list[i].operand = AccessTools.Field(typeof(DSPBigFormingSize), "formSizeSquare");
				}
			}
			return list.AsEnumerable();
		}
	}

	public static ConfigEntry<int> maxFormSize;

	public static int formSize;

	public static int formSizeSquare;

	public void Start()
	{
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		maxFormSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "maxFormSize", 20, "Maximum size of form brush");
		formSize = maxFormSize.Value;
		formSizeSquare = maxFormSize.Value * maxFormSize.Value;
	}
}
public class LogManager
{
	public static ManualLogSource Logger;
}