Decompiled source of BrackenPlus v1.0.34

Bracken+.dll

Decompiled 3 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.Configuration;
using BepInEx.Logging;
using Bracken_.Patches;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
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("Bracken+")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("Bracken+")]
[assembly: AssemblyCopyright("Copyright © HP 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7e6ebc3d-10bc-455d-8f3d-f2ef428da16a")]
[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 Bracken_
{
	[BepInPlugin("NickBracken", "Bracken+", "1.0.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BrackenBase : BaseUnityPlugin
	{
		private const string modGUID = "NickBracken";

		private const string modName = "Bracken+";

		private const string modVersion = "1.0.0.0";

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

		private static BrackenBase Instance;

		internal ManualLogSource mls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private ConfigEntry<bool> enableJesterRickroll;

		private ConfigEntry<bool> enableShipRickroll;

		private void Awake2()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			mls = Logger.CreateLogSource("NickBracken");
			mls.LogInfo((object)"Started Config files.");
			mls = ((BaseUnityPlugin)this).Logger;
			enableJesterRickroll = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Toggle custom Jester music", true, "Turns the custom jester music on/off. Does not require a restart.");
			enableShipRickroll = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Toggle custom Ship music", true, "Enable or disable custom ship music at the start of a new file/game. Does not require a restart");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(enableJesterRickroll));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(enableShipRickroll));
			if (enableJesterRickroll.Value)
			{
				harmony.PatchAll(typeof(JesterPatch));
			}
			if (enableShipRickroll.Value)
			{
				harmony.PatchAll(typeof(StartOfRoundPatch));
			}
			mls.LogInfo((object)"Finished loading Config files");
		}

		private void Update()
		{
			if (enableJesterRickroll.Value)
			{
				harmony.PatchAll(typeof(JesterPatch));
			}
			if (enableShipRickroll.Value)
			{
				harmony.PatchAll(typeof(StartOfRoundPatch));
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("NickBracken");
			mls.LogInfo((object)"Loading Bracken+");
			mls.LogInfo((object)"This mod requires LethalConfig for configuration files.");
			harmony.PatchAll(typeof(BrackenBase));
			harmony.PatchAll(typeof(BrackenPatch));
			Awake2();
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("Bracken+.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "rick");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Successfully loaded asset bundle");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle");
			}
		}
	}
}
namespace Bracken_.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideAudio(FlowermanAI __instance)
		{
			__instance.crackNeckSFX = BrackenBase.SoundFX[0];
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideAudio(JesterAI __instance)
		{
			__instance.popGoesTheWeaselTheme = BrackenBase.SoundFX[0];
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = BrackenBase.SoundFX[0];
		}
	}
}