Decompiled source of JBL Go Speaker v1.2.0

JBLGoSpeaker.dll

Decompiled 2 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("JBLGoSpeaker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JBLGoSpeaker")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1cca7a19-4d71-4af1-a1e1-54cf7ca9f683")]
[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 JBLMod;

[BepInPlugin("com.michelle.jblmod", "JBL Speaker Mod", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"¡El Mod JBL con Partículas de Michelle está listo!");
	}
}
public class JBLSpeaker : MonoBehaviour
{
	[Header("Configuración Básica")]
	public AudioSource speakerAudio;

	public float interactionDistance = 2f;

	public KeyCode interactKey = (KeyCode)103;

	[Header("Efectos Visuales")]
	public ParticleSystem musicParticles;

	[Header("Lista de Canciones")]
	public List<AudioClip> musicTracks = new List<AudioClip>();

	[Header("Vibración")]
	public float pulseIntensity = 20f;

	public float smoothSpeed = 15f;

	private int currentTrackIndex = -1;

	private string screenMessage = "";

	private float messageTimer = 0f;

	private Vector3 originalScale;

	private float[] audioSpectrum = new float[64];

	private void Start()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		originalScale = ((Component)this).transform.localScale;
		if ((Object)(object)speakerAudio == (Object)null)
		{
			speakerAudio = ((Component)this).GetComponent<AudioSource>();
			if ((Object)(object)speakerAudio == (Object)null)
			{
				speakerAudio = ((Component)this).GetComponentInChildren<AudioSource>();
			}
		}
		if ((Object)(object)musicParticles != (Object)null)
		{
			musicParticles.Stop();
		}
	}

	private void Update()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		if (messageTimer > 0f)
		{
			messageTimer -= Time.deltaTime;
		}
		if (Input.GetKeyDown(interactKey) && IsPlayerClose())
		{
			CycleMusic();
		}
		if (currentTrackIndex != -1 && (Object)(object)speakerAudio != (Object)null && speakerAudio.isPlaying)
		{
			speakerAudio.GetSpectrumData(audioSpectrum, 0, (FFTWindow)0);
			float num = (audioSpectrum[0] + audioSpectrum[1] + audioSpectrum[2]) / 3f;
			Vector3 val = originalScale + Vector3.one * num * pulseIntensity;
			((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, val, Time.deltaTime * smoothSpeed);
		}
		else
		{
			((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, originalScale, Time.deltaTime * 5f);
		}
	}

	private void CycleMusic()
	{
		if ((Object)(object)speakerAudio == (Object)null || musicTracks.Count == 0)
		{
			return;
		}
		currentTrackIndex++;
		if (currentTrackIndex >= musicTracks.Count)
		{
			currentTrackIndex = -1;
			speakerAudio.Stop();
			if ((Object)(object)musicParticles != (Object)null)
			{
				musicParticles.Stop();
			}
			ShowMessage("¡ APAGADO !", 2f);
		}
		else
		{
			speakerAudio.clip = musicTracks[currentTrackIndex];
			speakerAudio.Play();
			if ((Object)(object)musicParticles != (Object)null && !musicParticles.isPlaying)
			{
				musicParticles.Play();
			}
			ShowMessage("♪ " + ((Object)musicTracks[currentTrackIndex]).name + " ♪", 3f);
		}
	}

	private void ShowMessage(string text, float time)
	{
		screenMessage = text;
		messageTimer = time;
	}

	private bool IsPlayerClose()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Camera.main != (Object)null)
		{
			return Vector3.Distance(((Component)this).transform.position, ((Component)Camera.main).transform.position) <= interactionDistance;
		}
		return false;
	}

	private void OnGUI()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		if (messageTimer > 0f)
		{
			GUIStyle val = new GUIStyle();
			val.fontSize = 40;
			val.normal.textColor = Color.white;
			val.fontStyle = (FontStyle)1;
			val.alignment = (TextAnchor)4;
			float num = Screen.width / 2 - 200;
			float num2 = Screen.height / 2 - 100;
			GUIStyle val2 = new GUIStyle(val);
			val2.normal.textColor = Color.black;
			GUI.Label(new Rect(num + 2f, num2 + 2f, 400f, 200f), screenMessage, val2);
			GUI.Label(new Rect(num, num2, 400f, 200f), screenMessage, val);
		}
	}
}