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 CowboySwaps v1.1.0
BepInEx/plugins/CowboySwaps.dll
Decompiled 2 years agousing System; 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.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("CowboySwaps")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CowboySwaps")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6e41ceaf-3ee8-46c0-8b82-d5c35b9fe849")] [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 CowboySwaps; public static class AudioPatcher { public static AudioClip BepInLoadClip(string itemName) { List<string> list = Directory.GetDirectories(Paths.PluginPath, "CowboySwapsSFX", SearchOption.AllDirectories).ToList(); foreach (string item in list) { string path = item + "\\" + itemName; if (File.Exists(path)) { return LoadClip(path); } } return null; } public static AudioClip LoadClip(string path) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)20); try { audioClip.SendWebRequest(); while (!audioClip.isDone) { } if ((int)audioClip.result == 1) { return DownloadHandlerAudioClip.GetContent(audioClip); } CowboySwaps.CustomLogger.LogError((object)("Failed to load WAV audio clip from " + path + ". Error: " + audioClip.error)); } finally { ((IDisposable)audioClip)?.Dispose(); } return null; } } [HarmonyPatch(typeof(JesterAI))] public class JesterSFXPatch : BaseUnityPlugin { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PatchJesterSFX(JesterAI __instance) { __instance.popGoesTheWeaselTheme = AudioPatcher.BepInLoadClip(CowboySwaps.files["JesterWindup"]); CowboySwaps.CustomLogger.LogWarning((object)"Daniel Jester Patched!"); } } [HarmonyPatch(typeof(ShipAlarmCord))] public class HornSourcePatch : BaseUnityPlugin { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PatchHorn(ShipAlarmCord __instance) { __instance.hornClose.clip = AudioPatcher.BepInLoadClip(CowboySwaps.files["HornClose"]); __instance.hornFar.clip = AudioPatcher.BepInLoadClip(CowboySwaps.files["HornFar"]); CowboySwaps.CustomLogger.LogWarning((object)"Horn Patched!"); } } [BepInPlugin("Theronguard.CowboySwaps", "CowboySwaps", "1.0.0")] public class CowboySwaps : BaseUnityPlugin { private const string modGUID = "Theronguard.CowboySwaps"; private const string modName = "CowboySwaps"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("Theronguard.CowboySwaps"); public static ManualLogSource CustomLogger; public static Dictionary<string, string> files = new Dictionary<string, string>(); private void Awake() { files.Add("HornClose", "ggn1.wav"); files.Add("HornFar", "ggn2.wav"); files.Add("JesterWindup", "jst.wav"); CustomLogger = Logger.CreateLogSource("Theronguard.CowboySwaps"); CustomLogger.LogInfo((object)"Daniel works!"); harmony.PatchAll(typeof(CowboySwaps)); harmony.PatchAll(typeof(HornSourcePatch)); harmony.PatchAll(typeof(JesterSFXPatch)); } }