Decompiled source of MinecraftCaveSounds v1.0.0

MinecraftCaveSounds.dll

Decompiled 10 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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MinecraftCaveSounds.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("MinecraftCaveSounds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MinecraftCaveSounds")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("164802eb-4a80-44ec-9241-3c3bfcd42891")]
[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 MinecraftCaveSounds
{
	[BepInPlugin("BinglePringle.MinecraftCaveSounds", "Minecraft Cave Sounds", "1.0.0")]
	public class CaveSoundsBase : BaseUnityPlugin
	{
		private const string modGUID = "BinglePringle.MinecraftCaveSounds";

		private const string modName = "Minecraft Cave Sounds";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("BinglePringle.MinecraftCaveSounds");

		private static CaveSoundsBase instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("BinglePringle.MinecraftCaveSounds");
			mls.LogInfo((object)"Loaded MinecraftCaveSounds 1.0.0");
			harmony.PatchAll(typeof(CaveSoundsBase));
			harmony.PatchAll(typeof(LevelAmbiencePatch));
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)instance).Info.Location;
			location = location.TrimEnd("MinecraftCaveSounds.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "cavesounds");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Cave sounds loaded successfully.");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to load cave sounds.");
			}
		}
	}
}
namespace MinecraftCaveSounds.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class LevelAmbiencePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AddAudio(StartOfRound __instance)
		{
			List<AudioClip> list = __instance.currentLevel.levelAmbienceClips.insideAmbience.ToList();
			foreach (AudioClip item in CaveSoundsBase.SoundFX)
			{
				list.Add(item);
			}
			__instance.currentLevel.levelAmbienceClips.insideAmbience = list.ToArray();
		}
	}
}