Decompiled source of SoundpadMeme v1.1.0

SoundpadMeme.dll

Decompiled 21 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MemeSoundboard;
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("MemeSoundboardFixed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MemeSoundboardFixed")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("68459482-4055-424e-95d6-1c00967e6f08")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal static class WavLoader
{
	public static AudioClip LoadWav(string path)
	{
		if (!File.Exists(path))
		{
			Debug.LogError((object)("WAV no encontrado: " + path));
			return null;
		}
		byte[] array = File.ReadAllBytes(path);
		int num = array[22];
		int num2 = BitConverter.ToInt32(array, 24);
		int num3 = BitConverter.ToInt32(array, 40);
		float[] array2 = new float[num3 / 2];
		int num4 = 44;
		for (int i = 0; i < array2.Length; i++)
		{
			short num5 = BitConverter.ToInt16(array, num4);
			array2[i] = (float)num5 / 32768f;
			num4 += 2;
		}
		AudioClip val = AudioClip.Create(Path.GetFileNameWithoutExtension(path), array2.Length / num, num, num2, false);
		val.SetData(array2, 0);
		return val;
	}
}
namespace SoundpadMeme;

[BepInPlugin("tthirty.SoundpadMeme", "SoundpadMeme", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public ManualLogSource PluginLogger;

	public static Plugin Instance { get; private set; }

	private void Awake()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		Instance = this;
		PluginLogger = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("tthirty.SoundpadMeme");
		val.PatchAll();
		PluginLogger.LogInfo((object)"SoundpadMeme cargado correctamente.");
		LoadExternalSounds();
	}

	private void LoadExternalSounds()
	{
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string[] files = Directory.GetFiles(directoryName, "*.wav");
		foreach (string path in files)
		{
			AudioClip val = WavLoader.LoadWav(path);
			if (!((Object)(object)val == (Object)null))
			{
				string text = "[tthirty] " + Path.GetFileNameWithoutExtension(path);
				MemeSoundboardBase.AddNewSound(text, val);
				PluginLogger.LogInfo((object)("Sonido externo cargado: " + text));
			}
		}
	}
}