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 McBowieExe v2.137.0
McBowieExe.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.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; 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-CSharp")] [assembly: AssemblyCompany("McBowie")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0-alpha.0.23+8b2da66df728d4504593eb40d1802a75a0321995")] [assembly: AssemblyProduct("Whatever")] [assembly: AssemblyTitle("McBowieExe")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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; } } } 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"); } } [HarmonyPatch(typeof(JesterAI))] internal class JesterAIPatch { [HarmonyPatch("Start")] [HarmonyPrefix] public static void JesterPatch(ref AudioClip ___screamingSFX, ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___popUpSFX) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if ((Object)Plugin.Instance.screaming != (Object)null) { ___screamingSFX = Plugin.Instance.screaming; } if ((Object)Plugin.Instance.windup != (Object)null) { ___popGoesTheWeaselTheme = Plugin.Instance.windup; } if ((Object)Plugin.Instance.popUp != (Object)null) { ___popUpSFX = Plugin.Instance.popUp; } } } public struct LinkedSongs { public string WindupName { get; set; } public string ScreamingName { get; set; } } [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(); } } [BepInPlugin("McBowieExe", "McBowieExe", "6.9.4.20")] 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("JesterMusic"); public static Config Config { get; internal set; } internal static Plugin Instance { get; private set; } internal List<LinkedSongs> LinkedSongs { get; set; } = new List<LinkedSongs>(); internal string ExecutingPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); private void Awake() { Config = new Config(((BaseUnityPlugin)this).Config); rand = new Random(); Instance = this; LoggerInstance = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogMessage((object)"Loading Audio Files"); if (Directory.Exists(ExecutingPath)) { IOrderedEnumerable<string> source = from f in Directory.GetFiles(ExecutingPath) where f.Contains("Screaming_") orderby f select f; screamingClips = source.ToArray(); IOrderedEnumerable<string> source2 = from f in Directory.GetFiles(ExecutingPath) where f.Contains("Windup_") orderby f select f; windupClips = source2.ToArray(); IOrderedEnumerable<string> source3 = from f in Directory.GetFiles(ExecutingPath) where f.Contains("Popup_") orderby f select f; popUpClips = source3.ToArray(); ((BaseUnityPlugin)this).Logger.LogMessage((object)$"{screamingClips.Count() + windupClips.Count() + popUpClips.Count()} sounds found!"); } GetLinkedSongs(); 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 Funni Jester Music is loaded!"); } public async void LoadNewClips() { int selectedScreaming = rand.Next(Config.IncludeDefaultScreaming.Value ? (-1) : 0, screamingClips.Length); int num = rand.Next(Config.IncludeDefaultWindup.Value ? (-1) : 0, windupClips.Length); int selectedPopup = rand.Next(Config.IncludeDefaultPopUp.Value ? (-1) : 0, popUpClips.Length); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"random number: {num}"); if (num >= 0 && windupClips.Length != 0) { int num2 = FindWindupInLinked(Path.GetFileName(windupClips[num])); if (num2 >= 0) { num2 = FindSongInScreaming(LinkedSongs[num2].ScreamingName); if (num2 >= 0) { selectedScreaming = num2; ((BaseUnityPlugin)this).Logger.LogMessage((object)"Found Link!"); } } windup = await LoadClip(windupClips[num]); } else { windup = null; } if (selectedScreaming >= 0 && screamingClips.Length != 0) { screaming = await LoadClip(screamingClips[selectedScreaming]); } else { screaming = null; } if (selectedPopup >= 0 && popUpClips.Length != 0) { popUp = await LoadClip(popUpClips[selectedPopup]); } else { popUp = null; } } public int FindWindupInLinked(string name) { for (int i = 0; i < LinkedSongs.Count; i++) { if (Path.GetFileName(LinkedSongs[i].WindupName) == name) { return i; } } return -1; } public int FindSongInScreaming(string name) { for (int i = 0; i < screamingClips.Length; i++) { if (Path.GetFileName(screamingClips[i]) == name) { return i; } } return -1; } public void GetLinkedSongs() { try { if (!File.Exists(ExecutingPath + "/linkedSongs.json")) { ((BaseUnityPlugin)this).Logger.LogMessage((object)"No linkfile found!"); return; } string text = File.ReadAllText(ExecutingPath + "/linkedSongs.json"); LinkedSongs = JsonConvert.DeserializeObject<List<LinkedSongs>>(text); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex.Message); } } public AudioType GetAudioType(string extension) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } int num = ((extension == ".mp3") ? 13 : ((!(extension == ".wav")) ? 14 : 20)); if (1 == 0) { } return (AudioType)num; } public async Task<AudioClip> LoadClip(string path) { AudioType audioType = GetAudioType(Path.GetExtension(path)); UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, audioType); 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(); } } } } namespace JesterMusic { public static class PluginInfo { public const string PLUGIN_GUID = "McBowieExe"; public const string PLUGIN_NAME = "Whatever"; public const string PLUGIN_VERSION = "2.13.7"; } } namespace YourThunderstoreTeam.service { public class TemplateService { public bool ReturnTrue() { return true; } public bool ReturnFalse() { return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }