Decompiled source of BetterBoomBox v1.0.0

BetterBoombox.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterBoombox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterBoombox")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("92a7f1fa-92be-43bd-8a38-03dd42709dbf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterBoombox;

[BepInPlugin("HarmlessTacos.BetterBoomBox", "Better Boombox", "1.0.0.0")]
public class BetterBoomboxBase : BaseUnityPlugin
{
	private const string modGUID = "HarmlessTacos.BetterBoomBox";

	private const string modName = "Better Boombox";

	private const string modVersion = "1.0.0.0";

	private readonly Harmony harmony = new Harmony("HarmlessTacos.BetterBoomBox");

	private static BetterBoomboxBase Instance;

	internal ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("HarmlessTacos.BetterBoomBox");
		mls.LogInfo((object)"INIT Better BoomBox");
		harmony.PatchAll(typeof(BoomboxPlugin));
	}
}
[HarmonyPatch(typeof(BoomboxItem))]
public class BoomboxPlugin
{
	private const string modGUID = "HarmlessTacos.BetterBoomBox";

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void PatchBattery(ref Item ___itemProperties)
	{
		___itemProperties.requiresBattery = false;
	}

	[HarmonyPatch("PocketItem")]
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		ManualLogSource val = Logger.CreateLogSource("HarmlessTacos.BetterBoomBox");
		int num = -1;
		int num2 = -1;
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		for (int i = 0; i < list.Count; i++)
		{
			try
			{
				if (!(list[i].opcode == OpCodes.Call))
				{
					continue;
				}
				string text = ((object)list[i]).ToString();
				if (!text.Contains("BoomboxItem::StartMusic"))
				{
					continue;
				}
				for (int num3 = i; num3 > 0; num3--)
				{
					if (list[num3].opcode == OpCodes.Ldarg_0)
					{
						num = num3;
					}
				}
				num2 = i;
			}
			catch (Exception)
			{
			}
		}
		if (num2 > -1 && num > -1)
		{
			list.RemoveRange(num, num2 - num + 1);
		}
		return list.AsEnumerable();
	}
}