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 BangerMusic.AssetManager;
using BangerMusic.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("BangerMusic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BangerMusic")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6ed3cfcd-c550-42ea-98d8-74abe071ff6d")]
[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 BangerMusic
{
[BepInPlugin("BangerMusic", "BangerMusic", "1.4.0")]
public class Plugin : BaseUnityPlugin
{
public Harmony harmony;
private static Plugin Instance;
internal ManualLogSource mls;
private void Awake()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("BangerMusic");
mls.LogInfo((object)"BangerMusic has awakened");
harmony = new Harmony("BangerMusic");
harmony.PatchAll(typeof(Plugin));
Assets.LoadAssets();
harmony.PatchAll(typeof(MusicPatches));
mls.LogInfo((object)"patched musicpatches");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BangerMusic";
public const string PLUGIN_NAME = "BangerMusic";
public const string PLUGIN_VERSION = "1.4.0";
public const string ASSET_BUNDLE_NAME = "bangermusic";
}
}
namespace BangerMusic.Patches
{
[HarmonyPatch]
internal class MusicPatches
{
private static ManualLogSource mls33;
[HarmonyPatch(typeof(BoomboxItem), "Start")]
[HarmonyPostfix]
public static void ReplaceMusic(BoomboxItem __instance)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Replacing audio");
mls33.LogInfo((object)("Adding first " + ((Object)Assets.ReplacementAudio[0]).name));
__instance.musicAudios = Assets.ReplacementAudio.ToArray();
mls33.LogInfo((object)"Crashed?");
}
[HarmonyPatch(typeof(MenuManager), "DisplayMenuNotification")]
[HarmonyPostfix]
public static void AddClownTheme(MenuManager __instance, string notificationText)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)("Notification played saying " + notificationText));
string text = "The server host disconnected.";
if (notificationText == text)
{
mls33.LogInfo((object)"This was a host disconnected");
((Component)__instance).gameObject.GetComponent<AudioSource>().PlayOneShot(Assets.ClownMusic);
mls33.LogInfo((object)"Crashed?");
}
}
[HarmonyPatch(typeof(StartOfRound), "ShipLeaveAutomatically")]
[HarmonyPostfix]
public static void NapoleonMusic(StartOfRound __instance)
{
if (__instance.allPlayersDead)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Playing sound");
HUDManager.Instance.UIAudio.PlayOneShot(Assets.NapoleonMusic);
mls33.LogInfo((object)"crashed?");
}
}
[HarmonyPatch(typeof(HUDManager), "rackUpNewQuotaText")]
[HarmonyPrefix]
public static void PlayGetMuchHigher(HUDManager __instance)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Playing can we get much higher");
__instance.UIAudio.PlayOneShot(Assets.GetMuchHigher);
mls33.LogInfo((object)"Played sound?");
}
[HarmonyPatch(typeof(JesterAI), "Start")]
[HarmonyPostfix]
public static void MusicBoxPatch(JesterAI __instance)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Replacing music box sounds");
__instance.popGoesTheWeaselTheme = Assets.MusicBox;
__instance.screamingSFX = Assets.HarHarHar;
__instance.killPlayerSFX = Assets.Jumpscare;
mls33.LogInfo((object)"Crashed?");
}
[HarmonyPatch(typeof(HUDManager), "ReadDialogue")]
[HarmonyPrefix]
public static void PlayFinalCountdown(HUDManager __instance, DialogueSegment[] dialogueArray)
{
mls33 = Logger.CreateLogSource("BangerMusic");
string text = dialogueArray[0].bodyText.Substring(0, 22);
if (text == "WARNING! Please return" || text == "WARNING!!! The autopil")
{
mls33.LogInfo((object)"Playing sound");
__instance.LevellingAudio.PlayOneShot(Assets.FinalCountdown);
mls33.LogInfo((object)"Crashed?");
}
}
[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
[HarmonyPostfix]
public static void DisableFinalCountdown(StartOfRound __instance)
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Attempting to stop levellingAudio");
HUDManager.Instance.LevellingAudio.Stop();
mls33.LogInfo((object)"Crash?");
}
[HarmonyPatch(typeof(ShotgunItem), "EquipItem")]
[HarmonyPostfix]
public static void PlayDoomMusic(ShotgunItem __instance)
{
AudioSource[] components = ((Component)__instance).gameObject.GetComponents<AudioSource>();
bool flag = false;
AudioSource[] array = components;
foreach (AudioSource val in array)
{
if ((Object)(object)val.clip == (Object)(object)Assets.DoomMusic)
{
flag = true;
val.volume = 0.35f;
}
}
if (!flag)
{
AudioSource val2 = ((Component)__instance).gameObject.AddComponent<AudioSource>();
val2.spatialBlend = 1f;
val2.clip = Assets.DoomMusic;
val2.loop = true;
val2.volume = 0.5f;
val2.Play();
}
}
[HarmonyPatch(typeof(ShotgunItem), "StopUsingGun")]
[HarmonyPostfix]
public static void StopUsingGunAudioPatch(ShotgunItem __instance)
{
AudioSource[] components = ((Component)__instance).gameObject.GetComponents<AudioSource>();
AudioSource[] array = components;
foreach (AudioSource val in array)
{
if ((Object)(object)val.clip == (Object)(object)Assets.DoomMusic)
{
val.volume = 0f;
}
}
}
}
}
namespace BangerMusic.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 AudioClip ClownMusic { get; private set; }
public static AudioClip NapoleonMusic { get; private set; }
public static AudioClip GetMuchHigher { get; private set; }
public static AudioClip FinalCountdown { get; private set; }
public static AudioClip DoomMusic { get; private set; }
public static AudioClip MusicBox { get; private set; }
public static AudioClip HarHarHar { get; private set; }
public static AudioClip Jumpscare { get; private set; }
public static void LoadAssets()
{
mls33 = Logger.CreateLogSource("BangerMusic");
mls33.LogInfo((object)"Attempting to start importing assetbundle");
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bangermusic");
mls33.LogInfo((object)("Loading AssetBundle " + text));
AssetBundle = AssetBundle.LoadFromFile(text);
mls33.LogInfo((object)"Loading music");
FileNames.Add("Assets/AudioClip/tmnt.wav");
FileNames.Add("Assets/AudioClip/hungergames.wav");
FileNames.Add("Assets/AudioClip/blacksheep.wav");
FileNames.Add("Assets/AudioClip/beggin.wav");
mls33.LogInfo((object)("Loaded " + ReplacementAudio.Count));
foreach (string fileName in FileNames)
{
mls33.LogInfo((object)("Trying to load " + fileName));
ReplacementAudio.Add(AssetBundle.LoadAsset<AudioClip>(fileName));
}
mls33.LogInfo((object)"Crashed after setting?");
mls33.LogInfo((object)"Loading clown music");
ClownMusic = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/clowntheme.wav");
mls33.LogInfo((object)"Loading napoleon music");
NapoleonMusic = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/napoleon.wav");
mls33.LogInfo((object)"Loading get much higher music");
GetMuchHigher = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/getmuchhigher.ogg");
mls33.LogInfo((object)"Loading final countdown");
FinalCountdown = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/finalcountdown2.wav");
mls33.LogInfo((object)"Loading doom music");
DoomMusic = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/d_e1m1export.mp3");
mls33.LogInfo((object)"Loading music box stuff");
MusicBox = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/fnafmusicbox.wav");
HarHarHar = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/harharhar.wav");
Jumpscare = AssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/jumpscare.wav");
mls33.LogInfo((object)"Crashed?");
}
}
}