Decompiled source of NeckSnapSFX v2.1.0

NeckSnap.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 HarmonyLib;
using NeckSnapSFX.Patches;
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("NeckSnap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NeckSnap")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a5834dd7-7fb0-42f1-a3c5-d7c56ceee62f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NeckSnapSFX
{
	[BepInPlugin("Ex.NeckSnapSFXMod", "Ex NeckSnap SFX Mod", "1.0.0")]
	public class NeckSnapSFXBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.NeckSnapSFXMod";

		private const string modName = "Ex NeckSnap SFX Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Ex.NeckSnapSFXMod");

		private static NeckSnapSFXBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip newCrackNeckSFX;

		internal static AudioClip newPullPinSFX;

		internal static AudioClip newExplodeSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.NeckSnapSFXMod");
			mls.LogInfo((object)"Necksnap has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "NeckSnap.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "NeckSnapSFX";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			newCrackNeckSFX = val.LoadAsset<AudioClip>("Assets/bitcheat.mp3");
			newPullPinSFX = val.LoadAsset<AudioClip>("Assets/Before.mp3");
			newExplodeSFX = val.LoadAsset<AudioClip>("Assets/JojoRef.mp3");
			harmony.PatchAll(typeof(NeckSnapSFXBase));
			harmony.PatchAll(typeof(NeckSnapPatch));
			harmony.PatchAll(typeof(JojoPatch));
			mls.LogInfo((object)"Necksnap SFX mod has loaded.");
		}
	}
}
namespace NeckSnapSFX.Patches
{
	[HarmonyPatch(typeof(StunGrenadeItem))]
	internal class JojoPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void JojoPinPatch(ref AudioClip ___pullPinSFX)
		{
			___pullPinSFX = NeckSnapSFXBase.newPullPinSFX;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void JojoRefPatch(ref AudioClip ___explodeSFX)
		{
			___explodeSFX = NeckSnapSFXBase.newExplodeSFX;
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class NeckSnapPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void NeckSnapSFXPatch(ref AudioClip ___crackNeckSFX)
		{
			___crackNeckSFX = NeckSnapSFXBase.newCrackNeckSFX;
		}
	}
}