Please disclose if your mod was created primarily 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 My edits for JesterSymphony v1.0.0
BepInEx/plugins/JesterSymphony.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JesterSymphony.Patches; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JesterSymphony")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Makes jester play a random song")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1dbc392386ee5bba2956875df9aadb0997edae9d")] [assembly: AssemblyProduct("JesterSymphony")] [assembly: AssemblyTitle("JesterSymphony")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 JesterSymphony { [BepInPlugin("JesterSymphony", "JesterSymphony", "1.0.0")] public class Plugin : BaseUnityPlugin { internal AudioClip screaming; internal AudioClip windup; internal AudioClip popUp; private string[] screamingClips; private string[] windupClips; private string[] popUpClips; internal Random rand; internal static ManualLogSource LoggerInstance; private Harmony harmony = new Harmony("JesterSymphony"); public static Config Config { get; internal set; } internal static Plugin Instance { get; private set; } private void Awake() { Config = new Config(((BaseUnityPlugin)this).Config); rand = new Random(0); Instance = this; LoggerInstance = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogMessage((object)"Loading Audio Files"); if (Directory.Exists(Paths.PluginPath + "/Sk737-JesterSymphony/Screaming")) { IOrderedEnumerable<string> source = from f in Directory.GetFiles(Paths.PluginPath + "/Sk737-JesterSymphony/Screaming") orderby f select f; screamingClips = source.ToArray(); } if (Directory.Exists(Paths.PluginPath + "/Sk737-JesterSymphony/Windup")) { IOrderedEnumerable<string> source2 = from f in Directory.GetFiles(Paths.PluginPath + "/Sk737-JesterSymphony/Windup") orderby f select f; windupClips = source2.ToArray(); } if (Directory.Exists(Paths.PluginPath + "/Sk737-JesterSymphony/Popup")) { IOrderedEnumerable<string> source3 = from f in Directory.GetFiles(Paths.PluginPath + "/Sk737-JesterSymphony/Popup") orderby f select f; popUpClips = source3.ToArray(); } LoadNewClips(); ((BaseUnityPlugin)this).Logger.LogMessage((object)"Patching"); harmony.PatchAll(typeof(JesterAIPatch)); harmony.PatchAll(typeof(RoundManagerPatch)); harmony.PatchAll(typeof(Plugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin JesterSymphony is loaded!"); } public async void LoadNewClips() { int num = rand.Next(Config.IncludeDefaultScreaming.Value ? (-1) : 0, screamingClips.Length); if (num >= 0 && screamingClips.Length != 0) { screaming = await LoadClip(screamingClips[num]); } else { screaming = null; } num = rand.Next(Config.IncludeDefaultWindup.Value ? (-1) : 0, windupClips.Length); if (num >= 0 && windupClips.Length != 0) { windup = await LoadClip(windupClips[num]); } else { windup = null; } num = rand.Next(Config.IncludeDefaultPopUp.Value ? (-1) : 0, popUpClips.Length); if (num >= 0 && popUpClips.Length != 0) { popUp = await LoadClip(popUpClips[num]); } else { popUp = null; } } public async Task<AudioClip> LoadClip(string path) { UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)14); try { request.SendWebRequest(); while (!request.isDone) { await Task.Delay(50); } if ((int)request.result != 1) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load file:" + path + ", + " + request.error)); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); ((BaseUnityPlugin)this).Logger.LogMessage((object)("Loaded file: " + path)); return content; } finally { if (request != null) { request.Dispose(); } } } } public class Config { public static ConfigEntry<bool> IncludeDefaultWindup; public static ConfigEntry<bool> IncludeDefaultScreaming; public static ConfigEntry<bool> IncludeDefaultPopUp; public Config(ConfigFile config) { IncludeDefaultWindup = config.Bind<bool>("General", "IncludeDefaultWindup", true, "Allows the randomiser to pick the games windup sound"); IncludeDefaultScreaming = config.Bind<bool>("General", "IncludeDefaultScreaming", true, "Allows the randomiser to pick the games screaming sound"); IncludeDefaultPopUp = config.Bind<bool>("General", "IncludeDefaultPopUp", true, "Allows the randomiser to pick the games PopUp sound"); } } public static class PluginInfo { public const string PLUGIN_GUID = "JesterSymphony"; public const string PLUGIN_NAME = "JesterSymphony"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace JesterSymphony.Patches { [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("InitializeRandomNumberGenerators")] [HarmonyPostfix] public static void SeedPatch(ref RoundManager __instance) { Plugin.LoggerInstance.LogInfo((object)"Loading new audio files!"); Plugin.LoggerInstance.LogInfo((object)$"Initializing random with seed {__instance.playersManager.randomMapSeed}"); Plugin.Instance.rand = new Random(__instance.playersManager.randomMapSeed); Plugin.Instance.LoadNewClips(); } } [HarmonyPatch(typeof(JesterAI))] internal class JesterAIPatch { [HarmonyPatch("Start")] [HarmonyPrefix] public static void JesterPatch(ref AudioClip ___screamingSFX, ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___popUpSFX) { if ((Object)(object)Plugin.Instance.screaming != (Object)null) { ___screamingSFX = Plugin.Instance.screaming; } if ((Object)(object)Plugin.Instance.windup != (Object)null) { ___popGoesTheWeaselTheme = Plugin.Instance.windup; } if ((Object)(object)Plugin.Instance.popUp != (Object)null) { ___popUpSFX = Plugin.Instance.popUp; } } } }