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 BoomboxHanestad v1.0.4
plugins/BoomboxHanestad.dll
Decompiled 4 days agousing System; using System.Collections; using System.Collections.Generic; 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 UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BoomboxHanestad")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BoomboxHanestad")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("91c78e1f-f773-4633-b5ba-3698bfab2d97")] [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 BoomboxHanestad; [BepInPlugin("no.hanestad.boomboxhanestad", "Boombox Hanestad", "1.0.2")] public class Plugin : BaseUnityPlugin { public static AudioClip[] HanestadClips = (AudioClip[])(object)new AudioClip[0]; public static int[] SongNumbers = new int[0]; public static ManualLogSource Log; public static int NextSong = 0; public static bool MusicReady = false; private void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"================================="); Log.LogInfo((object)"BOOMBOX HANESTAD ER LASTET!"); Log.LogInfo((object)"Versjon 1.0.2"); Log.LogInfo((object)"================================="); Harmony val = new Harmony("no.hanestad.boomboxhanestad"); val.PatchAll(); ((MonoBehaviour)this).StartCoroutine(LoadAllMusic()); } private IEnumerator LoadAllMusic() { string pluginFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string musicFolder = Path.Combine(pluginFolder, "Music"); MusicReady = false; HanestadClips = (AudioClip[])(object)new AudioClip[0]; SongNumbers = new int[0]; NextSong = 0; if (!Directory.Exists(musicFolder)) { Log.LogError((object)("Music-mappen finnes ikke: " + musicFolder)); yield break; } SortedDictionary<int, string> musicFiles = new SortedDictionary<int, string>(); string[] files = Directory.GetFiles(musicFolder, "*.mp3"); foreach (string filePath in files) { string name = Path.GetFileNameWithoutExtension(filePath); if (name.StartsWith("song", StringComparison.OrdinalIgnoreCase) && int.TryParse(name.Substring(4), out var songNumber) && songNumber >= 1) { if (musicFiles.ContainsKey(songNumber)) { Log.LogWarning((object)("Duplikat sangnummer " + songNumber + ": " + filePath)); } else { musicFiles.Add(songNumber, filePath); } } } List<AudioClip> loadedClips = new List<AudioClip>(); List<int> loadedNumbers = new List<int>(); foreach (KeyValuePair<int, string> song in musicFiles) { int number = song.Key; string musicFile = song.Value; string fileName = Path.GetFileName(musicFile); Log.LogInfo((object)("Laster " + fileName + " fra " + musicFolder + "...")); string fileUrl = new Uri(musicFile).AbsoluteUri; UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(fileUrl, (AudioType)13); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { Log.LogError((object)("Kunne ikke laste " + fileName + ": " + request.error)); continue; } AudioClip clip = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)clip == (Object)null) { Log.LogError((object)("Kunne ikke opprette AudioClip for " + fileName)); continue; } ((Object)clip).name = "Boombox Hanestad - " + fileName; loadedClips.Add(clip); loadedNumbers.Add(number); Log.LogInfo((object)(fileName + " LASTET! Lengde: " + clip.length.ToString("0.0") + " sekunder")); } finally { ((IDisposable)request)?.Dispose(); } } HanestadClips = loadedClips.ToArray(); SongNumbers = loadedNumbers.ToArray(); MusicReady = HanestadClips.Length != 0; Log.LogInfo((object)("Hanestad-sanger lastet: " + HanestadClips.Length + "/" + musicFiles.Count)); if (MusicReady) { BoomboxItem[] boomboxes = Object.FindObjectsOfType<BoomboxItem>(); BoomboxItem[] array = boomboxes; foreach (BoomboxItem boombox in array) { if ((Object)(object)boombox != (Object)null) { ApplyPlaylist(boombox); } } } else { Log.LogWarning((object)"Ingen nummererte songN.mp3-filer ble lastet."); } } public static void ApplyPlaylist(BoomboxItem boombox) { if (!((Object)(object)boombox == (Object)null) && MusicReady) { boombox.musicAudios = HanestadClips; } } public static void MakeBoomboxPink(BoomboxItem boombox) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.95f, 0.12f, 0.45f, 1f); Renderer[] componentsInChildren = ((Component)boombox).GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] materials = val.materials; Material[] array2 = materials; foreach (Material val2 in array2) { if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.Contains("BlueBoomboxPlastic") && val2.HasProperty("_Color")) { val2.color = color; } } } Log.LogInfo((object)"Rosa Hanestad-kabinett aktivt."); } } [HarmonyPatch(typeof(BoomboxItem), "Start")] public static class BoomboxStartPatch { [HarmonyPostfix] public static void Postfix(BoomboxItem __instance) { Plugin.ApplyPlaylist(__instance); Plugin.MakeBoomboxPink(__instance); Plugin.Log.LogInfo((object)"BOOMBOX HANESTAD KLAR!"); } } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] public static class BoomboxMusicPatch { [HarmonyPrefix] public static void Prefix(BoomboxItem __instance, bool startMusic) { if (startMusic && Plugin.MusicReady && Plugin.HanestadClips.Length != 0) { int nextSong = Plugin.NextSong; Plugin.NextSong = (nextSong + 1) % Plugin.HanestadClips.Length; AudioClip val = Plugin.HanestadClips[nextSong]; __instance.musicAudios = (AudioClip[])(object)new AudioClip[1] { val }; Plugin.Log.LogInfo((object)("Boombox starter song" + Plugin.SongNumbers[nextSong] + ".mp3")); } } }