Decompiled source of Play Next Boombox v1.0.0

BepInEx/Plugins/Play_Next_Boombox.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Play_Next_Boombox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Play_Next_Boombox")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("647635e7-e0b3-4309-8ad6-60b1262a6c86")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Play_Next_Boombox
{
	[BepInPlugin("Hackattack242.Play_Next_Boombox", "Play_Next_Boombox", "1.0.0")]
	public class Play_next_boombox_base : BaseUnityPlugin
	{
		private const string mod_GUID = "Hackattack242.Play_Next_Boombox";

		private const string mod_name = "Play_Next_Boombox";

		private const string mod_version = "1.0.0";

		private readonly Harmony harmony = new Harmony("Hackattack242.Play_Next_Boombox");

		private static Play_next_boombox_base Instance;

		private ManualLogSource logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("Play_Next_Boombox");
			logger.LogInfo((object)"Play Next Boombox has awoken");
			harmony.PatchAll();
		}

		internal static void LogDebug(string message)
		{
			Instance.Log(message, (LogLevel)32);
		}

		internal static void LogInfo(string message)
		{
			Instance.Log(message, (LogLevel)16);
		}

		internal static void LogWarning(string message)
		{
			Instance.Log(message, (LogLevel)4);
		}

		internal static void LogError(string message)
		{
			Instance.Log(message, (LogLevel)2);
		}

		internal static void LogError(Exception ex)
		{
			Instance.Log(ex.Message + "\n" + ex.StackTrace, (LogLevel)2);
		}

		private void Log(string message, LogLevel logLevel)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			logger.Log(logLevel, (object)message);
		}
	}
}
namespace Play_Next_Boombox.Patches
{
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class Play_next_patch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Patch_start(ref AudioSource ___boomboxAudio)
		{
			___boomboxAudio.loop = false;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void Patch_update(ref BoomboxItem __instance, ref AudioSource ___boomboxAudio, ref bool ___isPlayingMusic)
		{
			if (___isPlayingMusic && !___boomboxAudio.isPlaying)
			{
				((GrabbableObject)__instance).ItemActivate(false, true);
				((GrabbableObject)__instance).ItemActivate(true, true);
			}
		}
	}
}