Decompiled source of BonkHitSfxFixed v1.0.2

BonkHitSfxFixed.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BonkHitSfxFixed.Patches;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BonkHitSfxFixed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BonkHitSfxFixed")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ba2313ff-01f6-4363-962e-35251b690054")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BonkHitSfxFixed
{
	[BepInPlugin("rafl.BonkHitSfxFixed", "Bonk Hit SFX (Fixed)", "1.0.2")]
	public class BonkHitSfxFixedBase : BaseUnityPlugin
	{
		private const string modGUID = "rafl.BonkHitSfxFixed";

		private const string modName = "Bonk Hit SFX (Fixed)";

		private const string modVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("rafl.BonkHitSfxFixed");

		private static BonkHitSfxFixedBase instance;

		internal static ManualLogSource mls;

		internal static AudioClip[] newHitSfx;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("rafl.BonkHitSfxFixed");
			mls.LogInfo((object)string.Format("Initializing {0}", "Bonk Hit SFX (Fixed)"));
			newHitSfx = AssetBundle.LoadFromFile(((BaseUnityPlugin)instance).Info.Location.Replace("BonkHitSfxFixed.dll", "bonkhitsfxfixed")).LoadAssetWithSubAssets<AudioClip>("Assets/bonkhitsfx.mp3");
			foreach (Type item in new List<Type>
			{
				typeof(BonkHitSfxFixedBase),
				typeof(ShovelPatch)
			})
			{
				harmony.PatchAll(item);
				mls.LogInfo((object)$"Executed Patch '{item.Name}'");
			}
		}
	}
}
namespace BonkHitSfxFixed.Patches
{
	[HarmonyPatch(typeof(Shovel))]
	internal class ShovelPatch
	{
		[HarmonyPatch("HitShovelClientRpc")]
		[HarmonyPatch("HitShovel")]
		[HarmonyPrefix]
		private static void hitSFXPatch(ref AudioClip[] ___hitSFX)
		{
			___hitSFX = BonkHitSfxFixedBase.newHitSfx;
		}
	}
}