Decompiled source of RedsSoundPack v1.0.1

RedsSoundsPack.dll

Decompiled 7 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BellOverride;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using PatchBug;
using PatchCandy;
using RedsSoundsPack;
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("RedsSoundsPack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RedsSoundsPack")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a02fd565-f5d0-48c5-b41e-5f16cf6766dc")]
[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 PatchCandy
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class CandyPatch
	{
		[HarmonyPatch("GrabObject")]
		[HarmonyPostfix]
		private static void OverrideCandy(PlayerControllerB __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			ManualLogSource val = Logger.CreateLogSource("redHD_soundpack.Candy");
			if ((Object)__instance != (Object)null && (int)(Object)__instance.currentlyHeldObjectServer != 0 && (Object)__instance.currentlyHeldObjectServer.itemProperties != (Object)null && ((Object)__instance.currentlyHeldObjectServer.itemProperties).name == "Candy")
			{
				val.LogMessage((object)"A Candy has been grabbed!");
				PlayerControllerB component = ((Component)__instance).GetComponent<PlayerControllerB>();
				if ((Object)component != (Object)null)
				{
					component.currentlyHeldObjectServer.itemProperties.grabSFX = SoundsPack.SoundFX[2];
					val.LogMessage((object)("New grab sound set: " + ((Object)component.currentlyHeldObjectServer.itemProperties.grabSFX).name));
				}
				else
				{
					val.LogMessage((object)"Item component not found!");
				}
			}
		}
	}
}
namespace PatchBug
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class BugPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void OverrideBug(HoarderBugAI __instance)
		{
			__instance.chitterSFX = SoundsPack.MineMineSound;
		}
	}
}
namespace BellOverride
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class BrassBellPatch
	{
		[HarmonyPatch("PlayDropSFX")]
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideBell(GrabbableObject __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			ManualLogSource val = Logger.CreateLogSource("redHD_soundpack.Bell");
			if ((Object)__instance != (Object)null && (Object)__instance.itemProperties != (Object)null && ((Object)__instance.itemProperties).name == "Bell")
			{
				val.LogMessage((object)"A Brass Bell has been located!");
				GrabbableObject component = ((Component)__instance).GetComponent<GrabbableObject>();
				if ((Object)component != (Object)null)
				{
					component.itemProperties.dropSFX = SoundsPack.SoundFX[0];
					val.LogMessage((object)("New drop sound set: " + ((Object)component.itemProperties.dropSFX).name));
				}
				else
				{
					val.LogMessage((object)"Item component not found!");
				}
			}
		}
	}
}
namespace RedsSoundsPack
{
	[BepInPlugin("redHD_soundpack", "Red's Soundpack", "1.0.1")]
	public class SoundsPack : BaseUnityPlugin
	{
		private const string modGUID = "redHD_soundpack";

		private const string modName = "Red's Soundpack";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("redHD_soundpack");

		private static SoundsPack Instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		internal static AudioClip[] MineMineSound;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("redHD_soundpack");
			mls.LogInfo((object)"Reds Soundpack has awakened :)");
			harmony.PatchAll(typeof(SoundsPack));
			harmony.PatchAll(typeof(BrassBellPatch));
			harmony.PatchAll(typeof(CandyPatch));
			harmony.PatchAll(typeof(BugPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("RedsSoundsPack.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "audios");
			if ((Object)(object)Bundle != (Object)null)
			{
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
				mls.LogInfo((object)"Bundle loaded successfully!");
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle");
			}
			MineMineSound = Bundle.LoadAssetWithSubAssets<AudioClip>("Assets/2.Mine.wav");
		}
	}
}