using System; using System.Collections; using System.Collections.Concurrent; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using PluginConfig.API.Functionals; using UltraRankSounds.Components; using UltraRankSounds.Management; 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("UltraRankSounds")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: AssemblyInformationalVersion("1.0.6+1d9825ef973a1d0dedae781aff06b9e2f34fc064")] [assembly: AssemblyProduct("UltraRankSounds")] [assembly: AssemblyTitle("UltraRankSounds")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.6.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 UltraRankSounds { internal static class PluginInfo { public const string GUID = "gamingnoobdev.ultrakill.UltraRankSounds"; public const string NAME = "UltraRankSounds"; public const string VERSION = "1.0.7"; } [BepInProcess("ULTRAKILL.exe")] [BepInPlugin("gamingnoobdev.ultrakill.UltraRankSounds", "UltraRankSounds", "1.0.7")] public class UltraRankSounds : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static OnClick <0>__RefreshEntries; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static BoolValueChangeEventDelegate <>9__17_0; public static StringListValueChangeEventDelegate <>9__17_1; public static OnValueChangeEventDelegate <>9__17_2; public static OnValueChangeEventDelegate <>9__17_3; public static OnValueChangeEventDelegate <>9__17_4; public static OnClick <>9__17_5; public static OnClick <>9__17_6; internal void b__17_0(BoolValueChangeEvent e) { ((ConfigField)PlayIfDescended).interactable = e.value; ((ConfigField)PlaySoundsInLoadedOrder).interactable = e.value; ((ConfigField)EnableStyleBonusSounds).interactable = e.value; ((ConfigField)CurrentSoundPack).interactable = e.value; ((ConfigField)MasterVolumeSlider).interactable = e.value; ((ConfigField)StyleRankVolumeSlider).interactable = e.value; ((ConfigField)StyleBonusVolumeSlider).interactable = e.value; } internal void b__17_1(StringListValueChangeEvent e) { SoundConfig.SetSoundPack(e.value); QueuedCustomSoundPlayer.ClearAllSounds(); } internal void b__17_2(FloatSliderValueChangeEvent e) { CustomSoundPlayer.SetSoundVolumes(e.newValue * StyleRankVolumeSlider.value); QueuedCustomSoundPlayer.SetSoundVolumes(e.newValue * StyleBonusVolumeSlider.value); } internal void b__17_3(FloatSliderValueChangeEvent e) { CustomSoundPlayer.SetSoundVolumes(MasterVolumeSlider.value * e.newValue); } internal void b__17_4(FloatSliderValueChangeEvent e) { QueuedCustomSoundPlayer.SetSoundVolumes(MasterVolumeSlider.value * e.newValue); } internal void b__17_5() { Application.OpenURL(new Uri(SoundConfig.CurrentSoundPack.StyleRanksFolder).AbsoluteUri); } internal void b__17_6() { Application.OpenURL(new Uri(SoundConfig.defaultSoundPacksFolder).AbsoluteUri); } } private const float MAX_AUDIO_VOLUME = 10f; private static readonly Dictionary currentAvailableStylePointBonuses = new Dictionary(); private static PluginConfigurator config; private static ManualLogSource logger; public static BoolField PlaySoundsInLoadedOrder; public static BoolField EnableStyleBonusSounds; public static BoolField PlayIfDescended; public static BoolField EnableSounds; public static FloatSliderField MasterVolumeSlider; public static FloatSliderField StyleRankVolumeSlider; public static FloatSliderField StyleBonusVolumeSlider; public static ButtonField RefreshFiles; public static ButtonField OpenSoundPacksFolder; public static ButtonField OpenSoundPack; public static StringMultilineField CurrentAvailableStylePointBonusesText; public static StringListField CurrentSoundPack; public static readonly Random randomNumGen = new Random(); private static void InitConfig() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Expected O, but got Unknown //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown config = PluginConfigurator.Create("UltraRankSounds", "gamingnoobdev.ultrakill.UltraRankSounds"); config.SetIconWithURL("https://raw.githubusercontent.com/GAMINGNOOBdev/UltraRankSounds/refs/heads/master/icon.png"); new ConfigHeader(config.rootPanel, "Sound settings", 24); EnableSounds = new BoolField(config.rootPanel, "Enable rank sounds", "ultraranksounds.enabled", true); PlayIfDescended = new BoolField(config.rootPanel, "Play sound when rank descended", "ultraranksounds.playdescended", true); PlaySoundsInLoadedOrder = new BoolField(config.rootPanel, "Play sounds in loaded order", "ultraranksounds.playinloadedorder", false); EnableStyleBonusSounds = new BoolField(config.rootPanel, "Enable sounds for style bonuses", "ultraranksounds.playsoundsforstylebonuses", false); List list = new List(1) { "default" }; foreach (string key in SoundConfig.SoundPacks.Keys) { list.Add(key); } CurrentSoundPack = new StringListField(config.rootPanel, "Selected sound pack", "ultraranksounds.currentsoundpack", list.ToArray(), "default"); MasterVolumeSlider = new FloatSliderField(config.rootPanel, "Volume", "ultraranksounds.volume", new Tuple(0f, 10f), 1f, 2); StyleRankVolumeSlider = new FloatSliderField(config.rootPanel, "Style rank volume", "ultraranksounds.stylerankvolume", new Tuple(0f, 10f), 1f, 2); StyleBonusVolumeSlider = new FloatSliderField(config.rootPanel, "Style bonus volume", "ultraranksounds.stylebonusvolume", new Tuple(0f, 10f), 0.5f, 2); new ConfigHeader(config.rootPanel, "Management", 24); OpenSoundPack = new ButtonField(config.rootPanel, "Open sound pack", "ultraranksounds.opensoundpack"); OpenSoundPacksFolder = new ButtonField(config.rootPanel, "Open sound packs folder", "ultraranksounds.opensoundpacksfolder"); RefreshFiles = new ButtonField(config.rootPanel, "Refresh all files", "ultraranksounds.refreshall"); new ConfigHeader(config.rootPanel, "Currently Available Style Point Bonuses", 24); CurrentAvailableStylePointBonusesText = new StringMultilineField(config.rootPanel, "", "ultraranksounds.curravailablestylebonuses", "", true, false) { interactable = false }; BoolField enableSounds = EnableSounds; object obj = <>c.<>9__17_0; if (obj == null) { BoolValueChangeEventDelegate val = delegate(BoolValueChangeEvent e) { ((ConfigField)PlayIfDescended).interactable = e.value; ((ConfigField)PlaySoundsInLoadedOrder).interactable = e.value; ((ConfigField)EnableStyleBonusSounds).interactable = e.value; ((ConfigField)CurrentSoundPack).interactable = e.value; ((ConfigField)MasterVolumeSlider).interactable = e.value; ((ConfigField)StyleRankVolumeSlider).interactable = e.value; ((ConfigField)StyleBonusVolumeSlider).interactable = e.value; }; <>c.<>9__17_0 = val; obj = (object)val; } enableSounds.onValueChange += (BoolValueChangeEventDelegate)obj; StringListField currentSoundPack = CurrentSoundPack; object obj2 = <>c.<>9__17_1; if (obj2 == null) { StringListValueChangeEventDelegate val2 = delegate(StringListValueChangeEvent e) { SoundConfig.SetSoundPack(e.value); QueuedCustomSoundPlayer.ClearAllSounds(); }; <>c.<>9__17_1 = val2; obj2 = (object)val2; } currentSoundPack.onValueChange += (StringListValueChangeEventDelegate)obj2; FloatSliderField masterVolumeSlider = MasterVolumeSlider; object obj3 = <>c.<>9__17_2; if (obj3 == null) { OnValueChangeEventDelegate val3 = delegate(FloatSliderValueChangeEvent e) { CustomSoundPlayer.SetSoundVolumes(e.newValue * StyleRankVolumeSlider.value); QueuedCustomSoundPlayer.SetSoundVolumes(e.newValue * StyleBonusVolumeSlider.value); }; <>c.<>9__17_2 = val3; obj3 = (object)val3; } masterVolumeSlider.onValueChange += (OnValueChangeEventDelegate)obj3; FloatSliderField styleRankVolumeSlider = StyleRankVolumeSlider; object obj4 = <>c.<>9__17_3; if (obj4 == null) { OnValueChangeEventDelegate val4 = delegate(FloatSliderValueChangeEvent e) { CustomSoundPlayer.SetSoundVolumes(MasterVolumeSlider.value * e.newValue); }; <>c.<>9__17_3 = val4; obj4 = (object)val4; } styleRankVolumeSlider.onValueChange += (OnValueChangeEventDelegate)obj4; FloatSliderField styleBonusVolumeSlider = StyleBonusVolumeSlider; object obj5 = <>c.<>9__17_4; if (obj5 == null) { OnValueChangeEventDelegate val5 = delegate(FloatSliderValueChangeEvent e) { QueuedCustomSoundPlayer.SetSoundVolumes(MasterVolumeSlider.value * e.newValue); }; <>c.<>9__17_4 = val5; obj5 = (object)val5; } styleBonusVolumeSlider.onValueChange += (OnValueChangeEventDelegate)obj5; ButtonField openSoundPack = OpenSoundPack; object obj6 = <>c.<>9__17_5; if (obj6 == null) { OnClick val6 = delegate { Application.OpenURL(new Uri(SoundConfig.CurrentSoundPack.StyleRanksFolder).AbsoluteUri); }; <>c.<>9__17_5 = val6; obj6 = (object)val6; } openSoundPack.onClick += (OnClick)obj6; ButtonField openSoundPacksFolder = OpenSoundPacksFolder; object obj7 = <>c.<>9__17_6; if (obj7 == null) { OnClick val7 = delegate { Application.OpenURL(new Uri(SoundConfig.defaultSoundPacksFolder).AbsoluteUri); }; <>c.<>9__17_6 = val7; obj7 = (object)val7; } openSoundPacksFolder.onClick += (OnClick)obj7; ButtonField refreshFiles = RefreshFiles; object obj8 = <>O.<0>__RefreshEntries; if (obj8 == null) { OnClick val8 = SoundConfig.RefreshEntries; <>O.<0>__RefreshEntries = val8; obj8 = (object)val8; } refreshFiles.onClick += (OnClick)obj8; EnableSounds.TriggerValueChangeEvent(); CurrentSoundPack.TriggerValueChangeEvent(); MasterVolumeSlider.TriggerValueChangeEvent(); StyleRankVolumeSlider.TriggerValueChangeEvent(); StyleBonusVolumeSlider.TriggerValueChangeEvent(); } private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger = ((BaseUnityPlugin)this).Logger; SoundConfig.LoadSoundPacks(); SoundConfig.UpdateSoundEntries(); InitConfig(); new Harmony("gamingnoobdev.ultrakill.UltraRankSounds").PatchAll(); Log("Default sound pack folder: '" + SoundConfig.CurrentSoundPack.StyleRanksFolder + "'"); Log("Default sound pack style bonus folder: '" + SoundConfig.CurrentSoundPack.StyleBonusesFolder + "'"); Log("Sound packs folder: '" + SoundConfig.defaultSoundPacksFolder + "'"); } public static bool IsStyleBonus(string bonus) { return currentAvailableStylePointBonuses.ContainsKey(bonus); } public static void RegisterStylePointBonuses(Dictionary styleBonusses) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (styleBonusses == null) { Log("unable to register style point bonuses: no style bonuses dict found"); return; } currentAvailableStylePointBonuses.Clear(); FormattedStringBuilder val = new FormattedStringBuilder(); foreach (string key in styleBonusses.Keys) { string text = styleBonusses[key]; if (!Utility.IsNullOrWhiteSpace(text)) { currentAvailableStylePointBonuses.Add(key, text); val.Append(text + " - " + key + "\n"); } } CurrentAvailableStylePointBonusesText.value = val.Build().rawString; CurrentAvailableStylePointBonusesText.TriggerValueChangeEvent(); } public static void Log(string message, bool error = false) { if (logger != null) { if (error) { logger.LogError((object)message); } else { logger.LogInfo((object)message); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "UltraRankSounds"; public const string PLUGIN_NAME = "UltraRankSounds"; public const string PLUGIN_VERSION = "1.0.6"; } } namespace UltraRankSounds.Patches { [HarmonyPatch(typeof(StyleHUD))] public class StyleHUDPatch { private static CustomSoundPlayer styleRankSoundPlayer; private static QueuedCustomSoundPlayer styleBonusSoundPlayer; private static int lastRankIndex; [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "Start")] public static void StyleHUD_Start_Postfix(GameObject ___styleHud, StyleHUD __instance) { styleRankSoundPlayer = ___styleHud.AddComponent(); styleBonusSoundPlayer = ___styleHud.AddComponent(); } [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "Awake")] public static void StyleHUD_Awake_Postfix(Dictionary ___idNameDict) { UltraRankSounds.RegisterStylePointBonuses(___idNameDict); } [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "ComboStart")] public static void StyleHUD_ComboStart_Postfix() { if (UltraRankSounds.EnableSounds.value && UltraRankSounds.PlayIfDescended.value) { PlaySoundForRank(0, "RankD"); } } [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "AddPoints")] public static void StyleHUD_AddPoints_Postfix(string pointID, StyleHUD __instance) { if (UltraRankSounds.EnableSounds.value && UltraRankSounds.EnableStyleBonusSounds.value) { string localizedName = __instance.GetLocalizedName(pointID); if (!string.IsNullOrWhiteSpace(localizedName) && !string.IsNullOrWhiteSpace(pointID)) { UltraRankSounds.Log("got style bonus '" + localizedName + "' with id '" + pointID + "'"); PlaySoundForBonus(pointID); } } } [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "AscendRank")] public static void StyleHUD_AscendRank_Postfix(StyleHUD __instance) { int rankIndex = __instance.rankIndex; string name = ((Object)__instance.currentRank.sprite).name; PlaySoundForRank(rankIndex, name); lastRankIndex = rankIndex; } [HarmonyPostfix] [HarmonyPatch(typeof(StyleHUD), "DescendRank")] public static void StyleHUD_DescendRank_Postfix(bool ___comboActive, StyleHUD __instance) { if (UltraRankSounds.EnableSounds.value && UltraRankSounds.PlayIfDescended.value && ___comboActive) { int rankIndex = __instance.rankIndex; string name = ((Object)__instance.currentRank.sprite).name; UltraRankSounds.Log($"style rank [index: {rankIndex} oldindex: {lastRankIndex}] | name '{name}'"); PlaySoundForRank(rankIndex, name, ascended: false); lastRankIndex = rankIndex; } } private static void PlaySoundForRank(int index, string name, bool ascended = true) { if (UltraRankSounds.EnableSounds.value && !((Object)(object)styleRankSoundPlayer == (Object)null)) { string soundPathForRankIndex = GetSoundPathForRankIndex(index, ascended); string text = (ascended ? "ascended" : "descended"); UltraRankSounds.Log($"{text} style rank to '{name}' [index: {index} oldindex: {lastRankIndex}] | playing sound '{soundPathForRankIndex}'"); styleRankSoundPlayer.PlaySound(soundPathForRankIndex); } } private static void PlaySoundForBonus(string id) { if (UltraRankSounds.EnableSounds.value && !((Object)(object)styleBonusSoundPlayer == (Object)null)) { string pointBonusSound = SoundConfig.GetPointBonusSound(id); if (string.IsNullOrEmpty(pointBonusSound)) { UltraRankSounds.Log("Unable to find rank sound for point bonus '" + id + "'", error: true); return; } UltraRankSounds.Log(id + " style bonus registered | playing sound '" + pointBonusSound + "'"); styleBonusSoundPlayer.QueueSound(pointBonusSound); } } private static string GetSoundPathForRankIndex(int rank, bool ascended) { if (ascended) { return SoundConfig.GetAscensionRankSoundName(rank); } return SoundConfig.GetDescensionRankSoundName(rank); } } } namespace UltraRankSounds.Management { public class SoundCollection { private int cursor; public List Sounds { get; private set; } public SoundCollection() { Sounds = new List(); } public void AddSound(string soundfile) { Sounds.Add(soundfile); } public void Clear() { Sounds.Clear(); cursor = 0; } public string DecideSound() { if (Sounds.Count == 0) { return "none"; } if (UltraRankSounds.PlaySoundsInLoadedOrder.value) { cursor++; cursor %= Sounds.Count; return Sounds[cursor]; } return Sounds[UltraRankSounds.randomNumGen.Next(0, Sounds.Count)]; } } public class SoundConfig { public static readonly string defaultSoundParentFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ""; public static readonly string defaultSoundPacksFolder = Path.Combine(defaultSoundParentFolder, "soundpacks") ?? ""; private static readonly SoundPack defaultSoundPack = new SoundPack(Path.Combine(defaultSoundParentFolder, "sounds") ?? ""); public static readonly Dictionary SoundPacks = new Dictionary(); public static SoundPack CurrentSoundPack = defaultSoundPack; public static void RefreshEntries() { string value = UltraRankSounds.CurrentSoundPack.value; foreach (string key in SoundPacks.Keys) { _ = key; UltraRankSounds.CurrentSoundPack.RemoveAt(1); } LoadSoundPacks(); foreach (string key2 in SoundPacks.Keys) { UltraRankSounds.CurrentSoundPack.AddValue(key2); } if (SoundPacks.ContainsKey(value)) { UltraRankSounds.CurrentSoundPack.value = value; } UpdateSoundEntries(); } public static void LoadSoundPacks() { SoundPacks.Clear(); if (!Directory.Exists(defaultSoundPacksFolder)) { Directory.CreateDirectory(defaultSoundPacksFolder); return; } string[] directories = Directory.GetDirectories(defaultSoundPacksFolder, "*", new EnumerationOptions { RecurseSubdirectories = false }); if (directories.Length != 0) { string[] array = directories; foreach (string text in array) { string fileName = Path.GetFileName(text); SoundPacks.Add(fileName, new SoundPack(text)); } } } public static void SetSoundPack(string name) { if (name == "default") { CurrentSoundPack = defaultSoundPack; } else if (SoundPacks.ContainsKey(name)) { CurrentSoundPack = SoundPacks[name]; UpdateSoundEntries(); UltraRankSounds.Log("Changed sound pack to '" + name + "'"); } } public static string GetPointBonusSound(string id) { return CurrentSoundPack.GetPointBonusSound(id); } public static string GetAscensionRankSoundName(int rank) { return CurrentSoundPack.GetAscensionRankSoundName(rank); } public static string GetDescensionRankSoundName(int rank) { return CurrentSoundPack.GetDescensionRankSoundName(rank); } public static void UpdateSoundEntries() { CurrentSoundPack.UpdateSoundEntries(); } } public class SoundPack { private readonly StyleRankSoundCollection downrankSounds; private readonly StyleRankSoundCollection uprankSounds; private readonly Dictionary styleBonuses; public string StyleRanksFolder { get; private set; } public string StyleBonusesFolder { get; set; } public SoundPack(string packFolderPath) { StyleRanksFolder = packFolderPath; StyleBonusesFolder = Path.Combine(StyleRanksFolder, "stylebonuses") ?? ""; styleBonuses = new Dictionary(); uprankSounds = new StyleRankSoundCollection(null, "downrank-"); downrankSounds = new StyleRankSoundCollection("downrank-"); } public string GetAscensionRankSoundName(int rank) { return uprankSounds.DecideSound(rank); } public string GetDescensionRankSoundName(int rank) { return downrankSounds.DecideSound(rank); } public string GetPointBonusSound(string id) { if (!styleBonuses.ContainsKey(id)) { return null; } return styleBonuses[id]; } public void UpdateSoundEntries() { string[] files = Directory.GetFiles(StyleRanksFolder, "*", SearchOption.TopDirectoryOnly); if (files.Length == 0) { UltraRankSounds.Log("Cannot find any sound files for soundpack at '" + StyleRanksFolder + "'", error: true); } else { uprankSounds.RegisterSounds(ref files); downrankSounds.RegisterSounds(ref files); } styleBonuses.Clear(); if (!Directory.Exists(StyleBonusesFolder)) { UltraRankSounds.Log("no style bonus directory ('" + StyleBonusesFolder + "')"); return; } string[] files2 = Directory.GetFiles(StyleBonusesFolder, "*", SearchOption.TopDirectoryOnly); UltraRankSounds.Log($"found the desired style bonus directory with {files2.Length} items ('{StyleBonusesFolder}')"); string[] array = files2; foreach (string text in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); styleBonuses.Add(fileNameWithoutExtension, text); } UltraRankSounds.Log("Registered style bonuses '" + string.Join(",", styleBonuses.Keys.ToArray().ToArray()) + "'"); } } public class SoundRanks { public static readonly int DESTRUCTIVE = 0; public static readonly int CHAOTIC = 1; public static readonly int BRUTAL = 2; public static readonly int ANARCHIC = 3; public static readonly int SUPREME = 4; public static readonly int SSADISTIC = 5; public static readonly int SSSHITSTORM = 6; public static readonly int ULTRAKILL = 7; } public class StyleRankSoundCollection { private readonly string prefix; private readonly string discardPrefix; public SoundCollection DestructiveSound; public SoundCollection ChaoticSound; public SoundCollection BrutalSound; public SoundCollection AnarchicSound; public SoundCollection SupremeSound; public SoundCollection SSadisticSound; public SoundCollection SSShitstormSound; public SoundCollection ULTRAKILLSound; public StyleRankSoundCollection(string namePrefix, string discardNamePrefix = null) { DestructiveSound = new SoundCollection(); ChaoticSound = new SoundCollection(); BrutalSound = new SoundCollection(); AnarchicSound = new SoundCollection(); SupremeSound = new SoundCollection(); SSadisticSound = new SoundCollection(); SSShitstormSound = new SoundCollection(); ULTRAKILLSound = new SoundCollection(); prefix = namePrefix; discardPrefix = discardNamePrefix; if (prefix == null) { prefix = ""; } } public void RegisterSounds(ref string[] files) { DestructiveSound.Clear(); ChaoticSound.Clear(); BrutalSound.Clear(); AnarchicSound.Clear(); SupremeSound.Clear(); SSadisticSound.Clear(); SSShitstormSound.Clear(); ULTRAKILLSound.Clear(); string[] array = files; foreach (string text in array) { string fileName = Path.GetFileName(text); if ((discardPrefix == null || !fileName.StartsWith(discardPrefix)) && fileName.StartsWith(prefix)) { string text2 = fileName; int length = prefix.Length; fileName = text2.Substring(length, text2.Length - length); if (fileName.StartsWith("ULTR")) { ULTRAKILLSound.AddSound(text); } else if (fileName.StartsWith("SSS")) { SSShitstormSound.AddSound(text); } else if (fileName.StartsWith("SS")) { SSadisticSound.AddSound(text); } else if (fileName.StartsWith("S")) { SupremeSound.AddSound(text); } else if (fileName.StartsWith("D")) { DestructiveSound.AddSound(text); } else if (fileName.StartsWith("C")) { ChaoticSound.AddSound(text); } else if (fileName.StartsWith("B")) { BrutalSound.AddSound(text); } else if (fileName.StartsWith("A")) { AnarchicSound.AddSound(text); } } } UltraRankSounds.Log("Loaded Sounds"); UltraRankSounds.Log("ULTRAKILL '" + string.Join(",", ULTRAKILLSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("SSShitstorm '" + string.Join(",", SSShitstormSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("SSadistic '" + string.Join(",", SSadisticSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("Supreme '" + string.Join(",", SupremeSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("Destructive '" + string.Join(",", DestructiveSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("Chaotic '" + string.Join(",", ChaoticSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("Brutal '" + string.Join(",", BrutalSound.Sounds.ToArray()) + "'"); UltraRankSounds.Log("Anarchic '" + string.Join(",", AnarchicSound.Sounds.ToArray()) + "'"); } public string DecideSound(int rank) { if (rank == SoundRanks.DESTRUCTIVE) { return DestructiveSound.DecideSound(); } if (rank == SoundRanks.CHAOTIC) { return ChaoticSound.DecideSound(); } if (rank == SoundRanks.BRUTAL) { return BrutalSound.DecideSound(); } if (rank == SoundRanks.ANARCHIC) { return AnarchicSound.DecideSound(); } if (rank == SoundRanks.SUPREME) { return SupremeSound.DecideSound(); } if (rank == SoundRanks.SSADISTIC) { return SSadisticSound.DecideSound(); } if (rank == SoundRanks.SSSHITSTORM) { return SSShitstormSound.DecideSound(); } if (rank == SoundRanks.ULTRAKILL) { return ULTRAKILLSound.DecideSound(); } return ""; } } } namespace UltraRankSounds.Components { public class CustomSoundPlayer : MonoBehaviour { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CustomSoundPlayer <>4__this; private WaitUntil 5__2; private UnityWebRequest 5__3; private DownloadHandlerAudioClip 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) bool result; try { int num = <>1__state; CustomSoundPlayer CS$<>8__locals0 = <>4__this; switch (num) { default: result = false; break; case 0: { <>1__state = -1; 5__2 = new WaitUntil((Func)(() => Application.isFocused && !CS$<>8__locals0.source.isPlaying)); FileInfo fileInfo = new FileInfo(CS$<>8__locals0.soundPath); AudioType val = CustomMusicFileBrowser.extensionTypeDict[fileInfo.Extension.ToLower()]; 5__3 = UnityWebRequestMultimedia.GetAudioClip(new Uri(CS$<>8__locals0.soundPath).AbsoluteUri, val); <>1__state = -3; ref DownloadHandlerAudioClip reference = ref 5__4; DownloadHandler downloadHandler = 5__3.downloadHandler; reference = (DownloadHandlerAudioClip)(object)((downloadHandler is DownloadHandlerAudioClip) ? downloadHandler : null); 5__4.streamAudio = false; 5__3.SendWebRequest(); <>2__current = 5__3; <>1__state = 1; result = true; break; } case 1: <>1__state = -3; CS$<>8__locals0.source.PlayOneShot(5__4.audioClip, CS$<>8__locals0.soundVolume); <>2__current = 5__2; <>1__state = 2; result = true; break; case 2: <>1__state = -3; ((Component)CS$<>8__locals0).gameObject.SetActive(false); Object.Destroy((Object)(object)5__4.audioClip); result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (5__3 != null) { ((IDisposable)5__3).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly List instances = new List(); public AudioSource source; private float soundVolume; private string soundPath; public static void SetSoundVolumes(float volume) { foreach (CustomSoundPlayer instance in instances) { instance.SetSoundVolume(volume); } } private void Start() { instances.Add(this); source = ((Component)this).gameObject.AddComponent(); SetSoundVolume(1f); UltraRankSounds.MasterVolumeSlider.TriggerValueChangeEvent(); } public void SetSoundVolume(float volume) { soundVolume = volume; } public void PlaySound(string file) { if (!string.IsNullOrEmpty(file)) { if (!File.Exists(file)) { UltraRankSounds.Log("Could not find audio file '" + file + "'", error: true); return; } soundPath = file; ((Component)this).gameObject.SetActive(true); ((MonoBehaviour)this).StartCoroutine(PlaySoundRoutine()); } } [IteratorStateMachine(typeof(d__8))] private IEnumerator PlaySoundRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { <>4__this = this }; } } public class QueuedCustomSoundPlayer : MonoBehaviour { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public QueuedCustomSoundPlayer <>4__this; private WaitUntil 5__2; private UnityWebRequest 5__3; private DownloadHandlerAudioClip 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) bool result; try { int num = <>1__state; QueuedCustomSoundPlayer CS$<>8__locals0 = <>4__this; switch (num) { default: result = false; break; case 0: { <>1__state = -1; string result2 = null; while (!CS$<>8__locals0.sounds.TryDequeue(out result2) && !CS$<>8__locals0.sounds.IsEmpty) { } if (result2 == null) { result = false; break; } 5__2 = new WaitUntil((Func)(() => Application.isFocused && !CS$<>8__locals0.source.isPlaying)); FileInfo fileInfo = new FileInfo(result2); AudioType val = CustomMusicFileBrowser.extensionTypeDict[fileInfo.Extension.ToLower()]; 5__3 = UnityWebRequestMultimedia.GetAudioClip(new Uri(result2).AbsoluteUri, val); <>1__state = -3; ref DownloadHandlerAudioClip reference = ref 5__4; DownloadHandler downloadHandler = 5__3.downloadHandler; reference = (DownloadHandlerAudioClip)(object)((downloadHandler is DownloadHandlerAudioClip) ? downloadHandler : null); 5__4.streamAudio = false; 5__3.SendWebRequest(); <>2__current = 5__3; <>1__state = 1; result = true; break; } case 1: <>1__state = -3; CS$<>8__locals0.source.clip = 5__4.audioClip; CS$<>8__locals0.source.volume = CS$<>8__locals0.soundVolume; CS$<>8__locals0.source.Play(); <>2__current = 5__2; <>1__state = 2; result = true; break; case 2: <>1__state = -3; Object.Destroy((Object)(object)5__4.audioClip); result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (5__3 != null) { ((IDisposable)5__3).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly List instances = new List(); private readonly ConcurrentQueue sounds = new ConcurrentQueue(); private AudioSource source; private float soundVolume; public static void SetSoundVolumes(float volume) { foreach (QueuedCustomSoundPlayer instance in instances) { instance.SetSoundVolume(volume); } } public static void ClearAllSounds() { foreach (QueuedCustomSoundPlayer instance in instances) { instance.sounds.Clear(); } } private void Start() { instances.Add(this); source = ((Component)this).gameObject.AddComponent(); SetSoundVolumes(1f); UltraRankSounds.MasterVolumeSlider.TriggerValueChangeEvent(); } private void FixedUpdate() { if (!source.isPlaying && !sounds.IsEmpty) { ((MonoBehaviour)this).StartCoroutine(PlaySoundRoutine()); } } public void SetSoundVolume(float volume) { soundVolume = volume; } public void QueueSound(string file) { if (string.IsNullOrEmpty(file)) { return; } if (!File.Exists(file)) { UltraRankSounds.Log("Could not find audio file '" + file + "'", error: true); return; } sounds.Enqueue(file); ((Component)this).gameObject.SetActive(true); List list = new List(); foreach (string sound in sounds) { list.Add(Path.GetFileNameWithoutExtension(sound)); } UltraRankSounds.Log(string.Join(",", list)); } [IteratorStateMachine(typeof(d__10))] private IEnumerator PlaySoundRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { <>4__this = this }; } } }