Decompiled source of CustomScrollSpeed v1.0.0

BepInEx/plugins/CustomScrollSpeed.dll

Decompiled a year ago
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CustomScrollSpeed.Patches;
using GameNetcodeStuff;
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("FastScrolling")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FastScrolling")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8d060420-bc91-44d4-8aeb-9c4ef14230b7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomScrollSpeed
{
	[BepInPlugin("CustomScrollSpeed", "Custom Scroll Speed", "1.0.0")]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "CustomScrollSpeed";

		private const string modName = "Custom Scroll Speed";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("CustomScrollSpeed");

		internal ManualLogSource mls;

		public static ConfigEntry<float> ScrollSpeedConfig { get; private set; }

		private void Awake()
		{
			ScrollSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScrollSpeed", 0.3f, "To change the speed when you scroll through the hotbar");
			mls = Logger.CreateLogSource("CustomScrollSpeed");
			mls.LogInfo((object)"The mod is working!");
			harmony.PatchAll(typeof(ModBase));
			harmony.PatchAll(typeof(ScrollBPatch));
		}
	}
}
namespace CustomScrollSpeed.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	[HarmonyPatch("SwitchItem_performed")]
	internal class ScrollBPatch
	{
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 0.3f)
				{
					instruction.operand = ModBase.ScrollSpeedConfig.Value;
				}
				yield return instruction;
			}
		}
	}
}