Decompiled source of MapScrollWheelZoomFactor v0.1.1

plugins\MapScrollWheelZoomFactor.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MapScrollWheelZoomFactor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MapScrollWheelZoomFactor")]
[assembly: AssemblyCopyright("Copyright © orax")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.1.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
namespace MapScrollWheelZoomFactor;

[BepInPlugin("orax.MapScrollWheelZoomFactor", "MapScrollWheelZoomFactor", "0.1.1")]
internal class MapScrollWheelZoomFactor : BaseUnityPlugin
{
	public const string PluginGUID = "orax.MapScrollWheelZoomFactor";

	public const string PluginName = "MapScrollWheelZoomFactor";

	public const string PluginVersion = "0.1.1";

	internal static ManualLogSource Log;

	public static ConfigEntry<float> ZoomFactor;

	private static Harmony _hi;

	private void Awake()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		ZoomFactor = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Zoom factor (game restart required)", 6f, "Adjust the speed at which you can zoom in and out of the map with the mouse scroll wheel. Game default: 2. Higher value = faster zoom in/out.");
		_hi = new Harmony("orax.MapScrollWheelZoomFactor");
		_hi.PatchAll();
	}

	private void OnDestroy()
	{
		Harmony hi = _hi;
		if (hi != null)
		{
			hi.UnpatchSelf();
		}
	}
}
[HarmonyPatch]
public static class Minimap_Patch
{
	[HarmonyPatch(typeof(Minimap), "UpdateMap")]
	public static class UpdateMap_Patch
	{
		private static readonly MethodInfo LargeZoomGetter = AccessTools.PropertyGetter(typeof(Minimap), "LargeZoom");

		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[10]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => (i.opcode == OpCodes.Call || i.opcode == OpCodes.Callvirt) && (MethodInfo)i.operand == LargeZoomGetter), (string)null),
				new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(-2);
				val.SetOperandAndAdvance((object)MapScrollWheelZoomFactor.ZoomFactor.Value);
			}
			else
			{
				MapScrollWheelZoomFactor.Log.LogError((object)"Unable to patch Minimap.UpdateMap(). Pattern not found.");
			}
			return val.InstructionEnumeration();
		}
	}
}