Decompiled source of BonkHit v1.0.0

BonkHit/BonkHit.dll

Decompiled 11 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BonkHit.Patches;
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("BonkHit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BonkHit")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("98e5a901-9b5b-4d84-84a5-740f47506bd4")]
[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 BonkHit
{
	[BepInPlugin("MythicalRev.BonkHit", "BonkHit", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "MythicalRev.BonkHit";

		private const string modName = "BonkHit";

		private const string modVersion = "1.0.0";

		private Harmony harmony = new Harmony("MythicalRev.BonkHit");

		private static Plugin Instance;

		internal ManualLogSource mls;

		internal static AudioClip[] hitSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("MythicalRev.BonkHit");
			mls.LogInfo((object)"BonkHit starting");
			mls.LogInfo((object)(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("BonkHit.dll".ToCharArray()) + "bonkhit"));
			AssetBundle val = AssetBundle.LoadFromFile(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("BonkHit.dll".ToCharArray()) + "bonkhit");
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			hitSFX = val.LoadAssetWithSubAssets<AudioClip>("assets/PlayerHitBonk.ogg");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(ExtensionLadderItemPatch));
			harmony.PatchAll(typeof(ShovelPatch));
		}
	}
}
namespace BonkHit.Patches
{
	[HarmonyPatch(typeof(Shovel))]
	internal class ShovelPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void BonkHitShovelPatch(ref AudioClip ___hitSFX)
		{
			AudioClip[] hitSFX = Plugin.hitSFX;
			if (hitSFX != null && hitSFX.Length != 0)
			{
				AudioClip val = hitSFX[0];
				___hitSFX = val;
			}
		}
	}
	[HarmonyPatch(typeof(ExtensionLadderItem))]
	internal class ExtensionLadderItemPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void BonkHitPatch(ref AudioClip ___ladderFallSFX)
		{
			AudioClip[] hitSFX = Plugin.hitSFX;
			if (hitSFX != null && hitSFX.Length != 0)
			{
				AudioClip val = hitSFX[0];
				___ladderFallSFX = val;
			}
		}
	}
}