Decompiled source of HoarderhitPSFX v1.2.1

HoarderhitPSFX.dll

Decompiled 6 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 HoarderhitPSFX.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("HoarderhitPSFX")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HoarderhitPSFX")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("72ddf884-757d-428b-a239-8a97dff6e55b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HoarderhitPSFX
{
	[BepInPlugin("Ex.HoarderSFXMod", "Ex Hoarder SFX Mod", "1.0.0")]
	public class HoarderhitPSFXBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.HoarderSFXMod";

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

		private const string modVersion = "1.0.0";

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

		private static HoarderhitPSFXBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip newhitPlayerSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.HoarderSFXMod");
			mls.LogInfo((object)"Hoarder SFX mod has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "HoarderhitPSFX.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "HoarderSFX";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			newhitPlayerSFX = val.LoadAsset<AudioClip>("Assets/Grunt.mp3");
			harmony.PatchAll(typeof(HoarderhitPSFXBase));
			harmony.PatchAll(typeof(HoarderHitPatch));
			mls.LogInfo((object)"Hoarder SFX mod has loaded.");
		}
	}
}
namespace HoarderhitPSFX.Patches
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderHitPatch
	{
		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		public static void HoarderHitSFXPatch(EnemyAI __instance)
		{
			__instance.dieSFX = HoarderhitPSFXBase.newhitPlayerSFX;
			__instance.creatureVoice.PlayOneShot(__instance.dieSFX);
		}
	}
}