Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of REPOpad v3.12.0
REPOpad.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 Photon.Pun; using Photon.Voice.Unity; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("REPOpad")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("REPOpad")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1950e5d2-7bce-414a-9e82-81c09d27e76c")] [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 REPOpad; [BepInPlugin("com.renat.customsoundboard", "Repopad", "3.12.0")] public class SoundboardPlugin : BaseUnityPlugin { public static SoundboardPlugin Instance; public static ManualLogSource Log; public ConfigEntry<KeyCode> openMenuKey; public ConfigEntry<KeyCode> stopSoundKey; public ConfigFile hiddenConfig; public ConfigEntry<float> globalVolume; public string pluginDirectory; public string soundsDirectory; private static bool managerCreated; private void Awake() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; pluginDirectory = Path.Combine(Paths.PluginPath, "FriloFril_Team-REPOpad"); soundsDirectory = Path.Combine(pluginDirectory, "Sounds"); if (!Directory.Exists(soundsDirectory)) { Directory.CreateDirectory(soundsDirectory); } hiddenConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "Repopad_HiddenSettings.cfg"), true); openMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("UI Settings", "Open Menu Key", (KeyCode)287, "Hotkey to open/close the soundboard menu"); stopSoundKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("UI Settings", "Stop Sound Key", (KeyCode)0, "Hotkey to force stop the currently playing sound"); globalVolume = hiddenConfig.Bind<float>("Audio Settings", "Global Volume", 1f, "Global volume multiplier"); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"Repopad initialized successfully!"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (!managerCreated) { GameObject val = new GameObject("R.E.P.O.SoundboardManager"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<SoundboardManager>(); managerCreated = true; } } } public class SoundboardManager : MonoBehaviour { private class SoundTrack { public string FileName { get; set; } public string FilePath { get; set; } public KeyCode Key { get; set; } public AudioClip OriginalClip { get; set; } public AudioClip ScaledClip { get; set; } public float Volume { get; set; } = 1f; public float LastAppliedVolume { get; set; } = -1f; public ConfigEntry<KeyCode> KeyConfig { get; set; } public ConfigEntry<float> VolConfig { get; set; } } private bool showMenu; private List<SoundTrack> tracks = new List<SoundTrack>(); private AudioSource audioSource; private SoundTrack bindingTrack; private Recorder cachedRecorder; private Vector2 scrollPosition = Vector2.zero; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("R.E.P.O.AudioSource"); audioSource = val.AddComponent<AudioSource>(); Object.DontDestroyOnLoad((Object)(object)val); ReloadSoundsFolder(); } public void ReloadSoundsFolder() { tracks.Clear(); string soundsDirectory = SoundboardPlugin.Instance.soundsDirectory; if (Directory.Exists(soundsDirectory)) { string[] files = (from f in Directory.GetFiles(soundsDirectory, "*.*") where f.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) select f).ToArray(); ((MonoBehaviour)this).StartCoroutine(LoadAudioFilesRoutine(files)); } } private IEnumerator LoadAudioFilesRoutine(string[] files) { int index = 0; foreach (string file in files) { string text = "file://" + file; AudioType val = (AudioType)(file.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) ? 13 : 20); UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text, val); try { yield return www.SendWebRequest(); if ((int)www.result != 1) { continue; } AudioClip content = DownloadHandlerAudioClip.GetContent(www); if ((Object)(object)content != (Object)null) { string text2 = (((Object)content).name = Path.GetFileName(file)); KeyCode val2 = (KeyCode)0; switch (index) { case 0: val2 = (KeyCode)257; break; case 1: val2 = (KeyCode)258; break; case 2: val2 = (KeyCode)259; break; case 3: val2 = (KeyCode)260; break; case 4: val2 = (KeyCode)261; break; } ConfigEntry<KeyCode> val3 = SoundboardPlugin.Instance.hiddenConfig.Bind<KeyCode>("Track Binds", text2, val2, "Hotkey for " + text2); ConfigEntry<float> val4 = SoundboardPlugin.Instance.hiddenConfig.Bind<float>("Track Volumes", text2, 1f, "Volume for " + text2); tracks.Add(new SoundTrack { FileName = text2, FilePath = file, Key = val3.Value, OriginalClip = content, Volume = val4.Value, LastAppliedVolume = -1f, KeyConfig = val3, VolConfig = val4 }); index++; } } finally { ((IDisposable)www)?.Dispose(); } } SoundboardPlugin.Instance.hiddenConfig.Save(); } private void PlayTrack(SoundTrack track) { if ((Object)(object)audioSource == (Object)null || (Object)(object)track.OriginalClip == (Object)null) { return; } float num = track.Volume * SoundboardPlugin.Instance.globalVolume.Value; if ((Object)(object)track.ScaledClip == (Object)null || Mathf.Abs(track.LastAppliedVolume - num) > 0.01f) { if ((Object)(object)track.ScaledClip != (Object)null) { Object.Destroy((Object)(object)track.ScaledClip); } float[] array = new float[track.OriginalClip.samples * track.OriginalClip.channels]; track.OriginalClip.GetData(array, 0); for (int i = 0; i < array.Length; i++) { array[i] *= num; } track.ScaledClip = AudioClip.Create(((Object)track.OriginalClip).name + "_scaled", track.OriginalClip.samples, track.OriginalClip.channels, track.OriginalClip.frequency, false); track.ScaledClip.SetData(array, 0); track.LastAppliedVolume = num; } audioSource.Stop(); audioSource.clip = track.ScaledClip; audioSource.volume = 1f; audioSource.Play(); if ((Object)(object)cachedRecorder == (Object)null) { Recorder[] array2 = Object.FindObjectsOfType<Recorder>(); Recorder[] array3 = array2; foreach (Recorder val in array3) { PhotonView component = ((Component)val).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && component.IsMine) { cachedRecorder = val; break; } } if ((Object)(object)cachedRecorder == (Object)null && array2.Length != 0) { cachedRecorder = array2[0]; } } if ((Object)(object)cachedRecorder != (Object)null) { cachedRecorder.SourceType = (InputSourceType)1; cachedRecorder.AudioClip = track.ScaledClip; cachedRecorder.TransmitEnabled = true; ((MonoBehaviour)this).CancelInvoke("RestoreMicrophone"); ((MonoBehaviour)this).Invoke("RestoreMicrophone", track.ScaledClip.length + 0.1f); } } private void StopCurrentSound() { if ((Object)(object)audioSource != (Object)null && audioSource.isPlaying) { audioSource.Stop(); ((MonoBehaviour)this).CancelInvoke("RestoreMicrophone"); RestoreMicrophone(); } } private void RestoreMicrophone() { if ((Object)(object)cachedRecorder != (Object)null) { cachedRecorder.SourceType = (InputSourceType)0; cachedRecorder.AudioClip = null; } } private void Update() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Invalid comparison between Unknown and I4 //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) int num = ((SoundboardPlugin.Instance.openMenuKey == null) ? 287 : ((int)SoundboardPlugin.Instance.openMenuKey.Value)); KeyCode val = (KeyCode)((SoundboardPlugin.Instance.stopSoundKey != null) ? ((int)SoundboardPlugin.Instance.stopSoundKey.Value) : 0); if (Input.GetKeyDown((KeyCode)num)) { showMenu = !showMenu; if (!showMenu) { SoundboardPlugin.Instance.hiddenConfig.Save(); } } if ((int)val != 0 && Input.GetKeyDown(val)) { StopCurrentSound(); } if (bindingTrack != null && Input.anyKeyDown) { foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(value)) { if ((int)value != 27) { bindingTrack.Key = value; bindingTrack.KeyConfig.Value = value; } bindingTrack = null; SoundboardPlugin.Instance.hiddenConfig.Save(); break; } } } if (showMenu || bindingTrack != null) { return; } foreach (SoundTrack track in tracks) { if ((int)track.Key != 0 && Input.GetKeyDown(track.Key)) { PlayTrack(track); } } } private void OnDestroy() { SoundboardPlugin.Instance.hiddenConfig.Save(); } private void OnGUI() { //IL_00c9: 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) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) if (!showMenu) { return; } KeyCode val = (KeyCode)((SoundboardPlugin.Instance.openMenuKey == null) ? 287 : ((int)SoundboardPlugin.Instance.openMenuKey.Value)); GUI.Box(new Rect((float)(Screen.width / 2 - 300), (float)(Screen.height / 2 - 250), 600f, 520f), "R.E.P.O. SOUNDBOARD"); float num = Screen.height / 2 - 210; if (GUI.Button(new Rect((float)(Screen.width / 2 - 280), num, 275f, 35f), "OPEN SOUNDS FOLDER")) { try { Process.Start("explorer.exe", SoundboardPlugin.Instance.soundsDirectory); } catch { } } if (GUI.Button(new Rect((float)(Screen.width / 2 + 5), num, 275f, 35f), "RELOAD SOUNDS")) { SoundboardPlugin.Instance.hiddenConfig.Save(); ReloadSoundsFolder(); } num += 45f; GUI.Label(new Rect((float)(Screen.width / 2 - 280), num, 120f, 30f), $"Global Vol: {(int)(SoundboardPlugin.Instance.globalVolume.Value * 100f)}%"); SoundboardPlugin.Instance.globalVolume.Value = GUI.HorizontalSlider(new Rect((float)(Screen.width / 2 - 150), num + 10f, 430f, 20f), SoundboardPlugin.Instance.globalVolume.Value, 0f, 1f); num += 35f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor((float)(Screen.width / 2 - 290), num, 580f, 340f); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, 0f, 550f, (float)(tracks.Count * 45)); scrollPosition = GUI.BeginScrollView(val2, scrollPosition, val3); for (int i = 0; i < tracks.Count; i++) { SoundTrack soundTrack = tracks[i]; float num2 = i * 45; GUI.Label(new Rect(5f, num2 + 5f, 200f, 30f), $"{i + 1}. {soundTrack.FileName}"); GUI.Label(new Rect(210f, num2 + 5f, 45f, 30f), $"{(int)(soundTrack.Volume * 100f)}%"); float num3 = GUI.HorizontalSlider(new Rect(255f, num2 + 10f, 120f, 20f), soundTrack.Volume, 0f, 1f); if (Mathf.Abs(num3 - soundTrack.Volume) > 0.001f) { soundTrack.Volume = num3; soundTrack.VolConfig.Value = num3; } string text = ((bindingTrack == soundTrack) ? "PRESS ANY KEY..." : $"[{soundTrack.Key}]"); if (GUI.Button(new Rect(385f, num2 + 5f, 160f, 30f), text)) { bindingTrack = soundTrack; } } GUI.EndScrollView(); GUI.Label(new Rect((float)(Screen.width / 2 - 280), (float)(Screen.height / 2 + 235), 560f, 30f), $"Press [{val}] to close. Click hotkey box to rebind."); } }