Decompiled source of NoLevellingSound v1.0.1

NoLevellingSound.dll

Decompiled 2 months ago
using System;
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.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoLevellingSound")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoLevellingSound")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e07e7a89-879b-48c2-a3d7-07dd593163ee")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NoLevellingSound;

public class HUDManagerPatch
{
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> disableLevellingSound(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Callvirt && (list[i].operand.ToString().Contains("Play()") || list[i].operand.ToString().Contains("Stop()")))
			{
				for (int j = 0; j < 3; j++)
				{
					list[i - j].opcode = OpCodes.Nop;
					list[i - j].operand = null;
				}
				NoLevellingSoundBase.Log.LogInfo((object)"Play/Stop call nulled");
			}
		}
		return list.AsEnumerable();
	}
}
[BepInPlugin("Zesa.NoLevellingSound", "NoLevellingSound", "1.0.1.0")]
public class NoLevellingSoundBase : BaseUnityPlugin
{
	private const string modGUID = "Zesa.NoLevellingSound";

	private const string modName = "NoLevellingSound";

	private const string modVersion = "1.0.1.0";

	private static NoLevellingSoundBase Instance;

	private readonly Harmony harmony = new Harmony("Zesa.NoLevellingSound");

	public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

	private void Awake()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		harmony.Patch((MethodBase)AccessTools.Method(typeof(HUDManager).GetNestedType("<SetPlayerLevelSmoothly>d__278", BindingFlags.Instance | BindingFlags.NonPublic), "MoveNext", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(HUDManagerPatch), "disableLevellingSound", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
		Log.LogInfo((object)"Patched levelling sound..");
	}
}