Decompiled source of HawkScreamSFX v1.0.2

HawkScream.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 HawkScreamSFX.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("HawkScream")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HawkScream")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f7d716ce-51c4-4220-be5f-9c25ee5740e5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HawkScreamSFX
{
	[BepInPlugin("Ex.HawkScreamSFXMod", "Ex Hawk Scream SFX Mod", "1.0.0")]
	public class HawkScreamSFXBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.HawkScreamSFXMod";

		private const string modName = "Ex Hawk Scream SFX Mod";

		private const string modVersion = "1.0.0";

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

		private static HawkScreamSFXBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip[] newHawkScreamSFX;

		internal static AudioClip[] newHawkLaughSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.HawkScreamSFXMod");
			mls.LogInfo((object)"HawkScream has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "HawkScream.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "HawkScreamSFX";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			newHawkScreamSFX = val.LoadAssetWithSubAssets<AudioClip>("Assets/RubCaw.mp3");
			newHawkLaughSFX = val.LoadAssetWithSubAssets<AudioClip>("Assets/Squeaky.mp3");
			harmony.PatchAll(typeof(HawkScreamSFXBase));
			harmony.PatchAll(typeof(HawkScreamPatch));
			harmony.PatchAll(typeof(HawkLaughPatch));
			mls.LogInfo((object)"HawkScream SFX mod has loaded.");
		}
	}
}
namespace HawkScreamSFX.Patches
{
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal class HawkLaughPatch
	{
		[HarmonyPatch("DoAIInterval")]
		[HarmonyPrefix]
		public static void HawkLaughSFXPatch(ref AudioClip[] ___cawLaughSFX)
		{
			___cawLaughSFX = HawkScreamSFXBase.newHawkLaughSFX;
		}
	}
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal class HawkScreamPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void HawkScreamSFXPatch(ref AudioClip[] ___cawScreamSFX)
		{
			___cawScreamSFX = HawkScreamSFXBase.newHawkScreamSFX;
		}
	}
}