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 CoolSongArenaRock v1.0.2
BepInEx/plugins/CoolRandomArenaSound/CoolRandomArenaSound.dll
Decompiled a year agousing System; using System.Collections; 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.Logging; using HarmonyLib; using Photon.Pun; 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("CoolRandomArenaSound")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CoolRandomArenaSound")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9c631775-9d03-49e6-9a28-061df1b3025b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace CoolRandomArenaSound; [BepInPlugin("cool_random_arena_sound", "Cool Random Arena Sound", "1.8.0")] internal class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("cool_random_arena_sound"); internal static ManualLogSource logger; private void Awake() { logger = ((BaseUnityPlugin)this).Logger; logger.LogInfo((object)" Cool Random Arena Sound Plugin Loaded"); harmony.PatchAll(typeof(ArenaMusicAwakePatch)); } } [HarmonyPatch(typeof(Arena), "Awake")] internal static class ArenaMusicAwakePatch { [HarmonyPostfix] private static void ReplaceArenaMusic() { ((Component)Arena.instance).gameObject.AddComponent<ArenaMusicSync>().Init(); } } public class ArenaMusicSync : MonoBehaviourPun { private string[] oggFiles; public void Init() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Sound), "PlayLoop", (Type[])null, (Type[])null); if (methodInfo != null) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo != null) { Harmony val = new Harmony("cool_random_arena_sound_temp_disable_loaforc"); if (patchInfo.Prefixes != null) { foreach (Patch item in patchInfo.Prefixes.Where((Patch p) => p.owner.Contains("loaforc"))) { Plugin.logger.LogInfo((object)("Suppression Prefix de loaforcs: " + item.PatchMethod.Name)); val.Unpatch((MethodBase)methodInfo, item.PatchMethod); } } if (patchInfo.Transpilers != null) { foreach (Patch item2 in patchInfo.Transpilers.Where((Patch p) => p.owner.Contains("loaforc"))) { Plugin.logger.LogInfo((object)("Suppression Transpiler de loaforcs: " + item2.PatchMethod.Name)); val.Unpatch((MethodBase)methodInfo, item2.PatchMethod); } } } else { Plugin.logger.LogInfo((object)"Pas de patch loaforcsSoundAPI.REPO détecté sur Sound.PlayLoop."); } } string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ArenaSounds"); if (!Directory.Exists(text)) { Plugin.logger.LogError((object)(" Folder not found: " + text)); return; } oggFiles = Directory.GetFiles(text, "*.ogg"); if (oggFiles.Length == 0) { Plugin.logger.LogError((object)" No .ogg files found."); } else if (PhotonNetwork.InRoom) { if (PhotonNetwork.IsMasterClient) { string fileName = Path.GetFileName(oggFiles[Random.Range(0, oggFiles.Length)]); Plugin.logger.LogInfo((object)("Host selected: " + fileName)); ((MonoBehaviourPun)this).photonView.RPC("RPC_PlayArenaMusic", (RpcTarget)0, new object[1] { fileName }); } } else { string fileName2 = Path.GetFileName(oggFiles[Random.Range(0, oggFiles.Length)]); Plugin.logger.LogInfo((object)("Solo mode - selected: " + fileName2)); ((MonoBehaviour)this).StartCoroutine(LoadAndSetClip(fileName2)); } } [PunRPC] public void RPC_PlayArenaMusic(string fileName) { Plugin.logger.LogInfo((object)("RPC received - playing: " + fileName)); ((MonoBehaviour)this).StartCoroutine(LoadAndSetClip(fileName)); } private IEnumerator LoadAndSetClip(string fileName) { string folderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ArenaSounds"); string fullPath = Path.Combine(folderPath, fileName); if (!File.Exists(fullPath)) { Plugin.logger.LogError((object)(" File not found: " + fullPath)); yield break; } string uri = "file://" + fullPath.Replace("\\", "/"); WWW www = new WWW(uri); try { yield return www; if (!string.IsNullOrEmpty(www.error)) { Plugin.logger.LogError((object)(" WWW error: " + www.error)); yield break; } AudioClip clip = www.GetAudioClip(false, false, (AudioType)14); if ((Object)(object)clip == (Object)null) { Plugin.logger.LogError((object)(" Failed to load clip: " + fileName)); yield break; } Plugin.logger.LogInfo((object)(" Playing clip: " + ((Object)clip).name)); Arena.instance.soundArenaMusic.Sounds = (AudioClip[])(object)new AudioClip[1] { clip }; Arena.instance.soundArenaMusic.PlayLoop(true, 20f, 2f, 1f); Arena.instance.soundArenaMusic.Source.time = 0f; } finally { ((IDisposable)www)?.Dispose(); } } }