Decompiled source of kaching quieter v1.0.0

KachingQuieter/KachingQuieter.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("KachingQuieter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KachingQuieter")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("33427d30-4ebb-4a79-bbfc-15e595aabd3d")]
[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")]
[BepInPlugin("com.yourname.kachingquieter", "KachingQuieter", "1.0.0")]
public class KachingQuieter : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Expected O, but got Unknown
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Expected O, but got Unknown
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Expected O, but got Unknown
		Harmony val = new Harmony("com.yourname.kachingquieter");
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "Play", Type.EmptyTypes, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "Play_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayDelayed", new Type[1] { typeof(float) }, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "Play_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayScheduled", new Type[1] { typeof(double) }, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "Play_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayOneShot", new Type[1] { typeof(AudioClip) }, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "PlayOneShot1_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayOneShot", new Type[2]
		{
			typeof(AudioClip),
			typeof(float)
		}, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "PlayOneShot2_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayClipAtPoint", new Type[2]
		{
			typeof(AudioClip),
			typeof(Vector3)
		}, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "PlayClipAtPoint1_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayClipAtPoint", new Type[3]
		{
			typeof(AudioClip),
			typeof(Vector3),
			typeof(float)
		}, (Type[])null), new HarmonyMethod(typeof(KachingQuieter), "PlayClipAtPoint2_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static bool IsKaching(AudioClip clip)
	{
		return (Object)(object)clip != (Object)null && ((Object)clip).name.Equals("Kaching", StringComparison.OrdinalIgnoreCase);
	}

	private static void Play_Prefix(AudioSource __instance)
	{
		if (IsKaching(__instance.clip))
		{
			__instance.volume *= 0.1f;
		}
	}

	private static bool PlayOneShot1_Prefix(AudioSource __instance, AudioClip clip)
	{
		if (IsKaching(clip))
		{
			__instance.PlayOneShot(clip, 0.1f);
			return false;
		}
		return true;
	}

	private static void PlayOneShot2_Prefix(AudioSource __instance, AudioClip clip, ref float volumeScale)
	{
		if (IsKaching(clip))
		{
			volumeScale *= 0.1f;
		}
	}

	private static bool PlayClipAtPoint1_Prefix(AudioClip clip, Vector3 position)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		if (IsKaching(clip))
		{
			AudioSource.PlayClipAtPoint(clip, position, 0.1f);
			return false;
		}
		return true;
	}

	private static bool PlayClipAtPoint2_Prefix(AudioClip clip, Vector3 position, float volume)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		if (IsKaching(clip))
		{
			AudioSource.PlayClipAtPoint(clip, position, volume * 0.1f);
			return false;
		}
		return true;
	}
}