Decompiled source of BangerMenuMusic v1.0.0

BangerMenuMusic.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BangerMenuMusic.AssetManager;
using BangerMenuMusic.Patches;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("BangerMenuMusic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BangerMenuMusic")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4b613c6b-0df2-47cd-b155-7969f1d97aa9")]
[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 BangerMenuMusic
{
	[BepInPlugin("BangerMenuMusic", "BangerMenuMusic", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public Harmony harmony;

		private static Plugin Instance;

		internal static ManualLogSource mls;

		private void Awake()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("BangerMenuMusic");
			mls.LogInfo((object)"BangerMenuMusic has awakened");
			harmony = new Harmony("BangerMenuMusic");
			harmony.PatchAll(typeof(Plugin));
			Assets.LoadAssets();
			harmony.PatchAll(typeof(SoundPatches));
			mls.LogInfo((object)"patched soundpatches");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BangerMenuMusic";

		public const string PLUGIN_NAME = "BangerMenuMusic";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string ASSET_BUNDLE_NAME = "bangermenumusic";
	}
}
namespace BangerMenuMusic.Patches
{
	[HarmonyPatch]
	internal class SoundPatches
	{
		private static ManualLogSource mls33;

		[HarmonyPatch(typeof(MenuManager), "Start")]
		[HarmonyPostfix]
		public static void ReplaceMusic(MenuManager __instance)
		{
			mls33 = Plugin.mls;
			mls33.LogInfo((object)"Replacing audio");
			AudioClip[] array = Assets.ReplacementAudio.ToArray();
			int num = array.Length;
			int num2 = Random.Range(0, num + 1) - 1;
			mls33.LogInfo((object)("Chose number " + num2));
			if (num2 != -1)
			{
				AudioClip menuMusic = array[num2];
				__instance.menuMusic = menuMusic;
			}
			mls33.LogInfo((object)"Crashed?");
		}
	}
}
namespace BangerMenuMusic.AssetManager
{
	public static class Assets
	{
		public static List<AudioClip> ReplacementAudio = new List<AudioClip>();

		public static List<string> FileNames = new List<string>();

		private static ManualLogSource mls33;

		public static AssetBundle AssetBundle { get; private set; }

		public static void LoadAssets()
		{
			mls33 = Plugin.mls;
			mls33.LogInfo((object)"Attempting to start importing assetbundle");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bangermenumusic");
			mls33.LogInfo((object)("Loading AssetBundle " + text));
			AssetBundle = AssetBundle.LoadFromFile(text);
			mls33.LogInfo((object)"Starting to load banger menu music");
			FileNames.Add("Assets/AudioClip/bangermenumusic/bladerunner.mp3");
			FileNames.Add("Assets/AudioClip/bangermenumusic/remember.mp3");
			FileNames.Add("Assets/AudioClip/bangermenumusic/fnafvr.mp3");
			mls33.LogInfo((object)"Crashed?");
			mls33.LogInfo((object)("Loaded " + ReplacementAudio.Count));
			foreach (string fileName in FileNames)
			{
				mls33.LogInfo((object)("Trying to load " + fileName));
				AudioClip item = AssetBundle.LoadAsset<AudioClip>(fileName);
				int num = 1;
				if (fileName == "Assets/AudioClip/bangermenumusic/bladerunner.mp3")
				{
					num = 3;
				}
				for (int i = 0; i < num; i++)
				{
					ReplacementAudio.Add(item);
				}
			}
			mls33.LogInfo((object)"Crashed?");
		}
	}
}