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 PirateRadioInShop v1.0.1
PirateRadioPlugin.dll
Decompiled a day agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Kuabaczek")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PirateRadioPlugin")] [assembly: AssemblyTitle("PirateRadioPlugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PirateRadioPlugin { [HarmonyPatch(typeof(PlayerController))] internal static class ExamplePlayerControllerPatch { [HarmonyPrefix] [HarmonyPatch("Start")] private static void Start_Prefix(PlayerController __instance) { PirateRadioPlugin.Logger.LogDebug((object)$"{__instance} Start Prefix"); } [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(PlayerController __instance) { PirateRadioPlugin.Logger.LogDebug((object)$"{__instance} Start Postfix"); } } [BepInPlugin("Kuabaczek.PirateRadioPlugin", "PirateRadioPlugin", "1.0.0")] public class PirateRadioPlugin : BaseUnityPlugin { internal static PirateRadioPlugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private string OldPathToRemove => Path.Combine(Paths.PluginPath, "Kuabaczek-PirateRadioPlugin"); private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Instance = this; Harmony = new Harmony("Kuabaczek.PirateRadioPlugin"); Harmony.PatchAll(); try { if (Directory.Exists(OldPathToRemove)) { Directory.Delete(OldPathToRemove, recursive: true); Logger.LogInfo((object)("Removed folder " + OldPathToRemove + " from previous version")); } } catch (Exception ex) { Logger.LogError((object)("Failed to remove folder " + OldPathToRemove + ": " + ex.Message)); } } } [HarmonyPatch(typeof(ShopRadio), "Start")] internal class ShopRadioPatch { private static void Postfix(ShopRadio __instance) { if (!((Object)(object)PirateRadioPlugin.Instance == (Object)null)) { ((MonoBehaviour)PirateRadioPlugin.Instance).StartCoroutine(LoadCustomMusic(__instance)); } } private static IEnumerator LoadCustomMusic(ShopRadio radio) { string musicFolder = Path.Combine(Paths.PluginPath, "Kuabaczek-PirateRadioInShop"); if (!Directory.Exists(musicFolder)) { PirateRadioPlugin.Logger.LogWarning((object)("Music folder not found: " + musicFolder)); yield break; } string[] files = Directory.GetFiles(musicFolder, "*.wav"); if (files.Length == 0) { PirateRadioPlugin.Logger.LogWarning((object)"No .wav files found in music folder."); yield break; } string[] array = files; foreach (string file in array) { string url = "file:///" + file.Replace("\\", "/"); UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)20); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { PirateRadioPlugin.Logger.LogError((object)("Failed loading " + Path.GetFileName(file) + ": " + req.error)); continue; } AudioClip clip = DownloadHandlerAudioClip.GetContent(req); ((Object)clip).name = Path.GetFileNameWithoutExtension(file); if (radio.shopMusicClips == null) { PirateRadioPlugin.Logger.LogWarning((object)"shopMusicClips is null, cannot add tracks."); yield break; } radio.shopMusicClips.Add(clip); PirateRadioPlugin.Logger.LogInfo((object)("Added custom radio track: " + ((Object)clip).name)); } finally { ((IDisposable)req)?.Dispose(); } } PirateRadioPlugin.Logger.LogInfo((object)$"Radio now contains {radio.shopMusicClips.Count} tracks."); } } }