using System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using PluginConfig.API; using PluginConfig.API.Fields; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ultradistortion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ultradistortion")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4ebdf745-dbb2-45b8-bab5-77e6d26d51ed")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.1.0")] namespace ultradistortion; public static class TransformExtensions { public static Transform ForceGetChild(this Transform t, int index) { try { Transform[] array = (from t1 in ((Component)t).GetComponentsInChildren(true) where (Object)(object)t1.parent == (Object)(object)t select t1).ToArray(); return array[index]; } catch (Exception) { return null; } } } public static class a { public static PluginConfiguratorIntegrator integrator = new PluginConfiguratorIntegrator(); public static void CallPluginConfigurator() { if (!integrator.PluginConfigulatorIntegration()) { Plugin.log.LogError((object)"[ERROR] Failed to Initialize config manager!"); } } } [BepInPlugin("susinopo.ULTRADistortion", "ULTRADistortion", "1.0.2")] public class Plugin : BaseUnityPlugin { public static ManualLogSource log = Logger.CreateLogSource("ULTRADistortion"); public static ConfigEntry audiodistortionlevel; public static ConfigEntry onlymusic; public static float audioIntensityValue = 1f; public static bool isOnlyMusicValue = false; public static bool isthereconfigManager; private const string Guid = "susinopo.ULTRADistortion"; private const string InternalName = "ULTRADistortion"; private const string InternalVersion = "1.0.2"; public void SetConfig() { audioIntensityValue = audiodistortionlevel.Value; isOnlyMusicValue = onlymusic.Value; } private void Start() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown log.LogInfo((object)"UltraDistortion Loading... | Version v.1.0.2"); if (isthereconfigManager = Chainloader.PluginInfos.ContainsKey("com.eternalUnion.pluginConfigurator")) { log.LogInfo((object)"PluginConfigurator Detected!"); a.CallPluginConfigurator(); } else { audiodistortionlevel = ((BaseUnityPlugin)this).Config.Bind("Audio", "AudioDistortionLevel", 0.5f, "Intensity. a.k.a Earrape Amount"); onlymusic = ((BaseUnityPlugin)this).Config.Bind("Audio", "OnlyMusic", false, "Only music to be distorted."); SetConfig(); } try { Harmony val = new Harmony("ULTRADistortion"); val.PatchAll(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogFatal((object)"ERROR ERROR ERROR"); ((BaseUnityPlugin)this).Logger.LogFatal((object)ex.ToString()); } } public static void DistortApply(AudioSource aus) { float distortionLevel = (isOnlyMusicValue ? audioIntensityValue : 0f); if ((Object)(object)aus != (Object)null) { if ((Object)(object)((Component)aus).GetComponent() != (Object)null) { Object.Destroy((Object)(object)((Component)aus).GetComponent()); } if ((Object)(object)((Component)aus).GetComponent() == (Object)null) { AudioDistortionFilter val = ((Component)aus).gameObject.AddComponent(); val.distortionLevel = distortionLevel; } else { ((Component)aus).GetComponent().distortionLevel = distortionLevel; } } } public static void EarRapeApply(GameObject[] rootObjects) { log.LogDebug((object)"Current Config Value"); log.LogDebug((object)("OnlyMusic: " + isOnlyMusicValue)); log.LogDebug((object)("Intensity: " + audioIntensityValue)); string currentScene = SceneHelper.CurrentScene; log.LogDebug((object)("CurrentScene: |" + currentScene + "|")); foreach (GameObject val in rootObjects) { if (isOnlyMusicValue) { MusicDistort(val, currentScene); } AudioListener componentInChildren = val.GetComponentInChildren(); try { if ((Object)(object)componentInChildren != (Object)null) { float distortionLevel = audioIntensityValue; if (isOnlyMusicValue) { distortionLevel = 0f; } if ((Object)(object)((Component)componentInChildren).GetComponent() == (Object)null) { AudioDistortionFilter val2 = ((Component)componentInChildren).gameObject.AddComponent(); val2.distortionLevel = distortionLevel; } else { ((Component)componentInChildren).GetComponent().distortionLevel = distortionLevel; } } } catch (Exception ex) { log.LogError((object)("Failed to Add AudioDistortionFilter!" + ex.Message)); } } } private static void MusicDistort(GameObject obj, string scenename) { try { if (scenename == "" || scenename == "Bootstrap" || scenename == "Intro") { return; } if (((Object)obj).name == "Beats") { AudioSource[] componentsInChildren = obj.GetComponentsInChildren(true); if (componentsInChildren != null) { AudioSource[] array = componentsInChildren; foreach (AudioSource aus in array) { DistortApply(aus); } } } if (scenename != null) { if (scenename.Contains("Main Menu")) { if (((Object)obj).name == "Music" || ((Object)obj).name.Contains("Seasonal")) { AudioSource[] componentsInChildren2 = obj.GetComponentsInChildren(true); AudioSource[] array2 = componentsInChildren2; foreach (AudioSource val in array2) { if ((Object)(object)val != (Object)null) { DistortApply(val); } } } } else { string text = scenename; if (text.Contains("2-S")) { if (((Object)obj).name == "Canvas") { Transform val2 = obj.transform.ForceGetChild(2)?.ForceGetChild(0); if ((Object)(object)val2 != (Object)null) { AudioSource[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren(true); AudioSource[] array3 = componentsInChildren3; foreach (AudioSource val3 in array3) { if ((Object)(object)val3 == (Object)null) { break; } if (((Object)((Component)val3).gameObject).name.Contains("Music")) { DistortApply(val3); } } } } } else { string text2 = scenename; if (text2.Contains("4-S")) { if (((Object)obj).name == "Music") { AudioSource[] componentsInChildren4 = obj.GetComponentsInChildren(true); AudioSource[] array4 = componentsInChildren4; foreach (AudioSource aus2 in array4) { DistortApply(aus2); } } } else { string text3 = scenename; if (text3.Contains("5-S")) { if (((Object)obj).name == "Time of Day") { AudioSource[] componentsInChildren5 = obj.GetComponentsInChildren(true); AudioSource[] array5 = componentsInChildren5; foreach (AudioSource val4 in array5) { if (((Object)((Component)val4).gameObject).name.Contains("Jingle") || ((Object)((Component)val4).gameObject).name == "Music") { DistortApply(val4); } } } else if (((Object)obj).name == "Exit Lobby Interior") { AudioSource[] componentsInChildren6 = obj.GetComponentsInChildren(true); AudioSource[] array6 = componentsInChildren6; foreach (AudioSource val5 in array6) { if (((Object)((Component)val5).transform.parent).name.Contains("Screen")) { DistortApply(val5); } } } } else { string text4 = scenename; if (text4.Contains("6-2")) { if (((Object)obj).name == "IntroSounds" || ((Object)obj).name == "BossMusic") { AudioSource[] componentsInChildren7 = obj.GetComponentsInChildren(true); AudioSource[] array7 = componentsInChildren7; foreach (AudioSource val6 in array7) { if (!((Object)((Component)val6).gameObject).name.Contains("Speech")) { DistortApply(val6); } } } } else { string text5 = scenename; if (text5.Contains("7-S")) { if (((Object)obj).name == "Music") { AudioSource component = obj.GetComponent(); DistortApply(component); } } else { string text6 = scenename; if (text6.Contains("8-2")) { if ((((Object)obj).name.Contains("Intro") && ((Object)obj).name.Contains("Music")) || ((Object)obj).name == "Boss Music") { AudioSource[] componentsInChildren8 = obj.GetComponentsInChildren(true); AudioSource[] array8 = componentsInChildren8; foreach (AudioSource aus3 in array8) { DistortApply(aus3); } } if (((Object)obj).name == "Exteriors") { AudioSource[] componentsInChildren9 = obj.GetComponentsInChildren(true); AudioSource[] array9 = componentsInChildren9; foreach (AudioSource val7 in array9) { if (((Object)val7).name == "Undernap") { DistortApply(val7); } } } } else { string text7 = scenename; if (text7.Contains("8-3")) { if (((Object)obj).name.Contains("IntroMusic") || ((Object)obj).name == "Space") { AudioSource[] componentsInChildren10 = obj.GetComponentsInChildren(true); AudioSource[] array10 = componentsInChildren10; foreach (AudioSource val8 in array10) { if ((Object)(object)((Component)val8).transform.parent == (Object)null || ((Object)((Component)val8).gameObject).name.ToLower().Contains("romusic") || ((Object)((Component)val8).transform.parent).name.Contains("Music")) { DistortApply(val8); } } } if (((Object)obj).name == "Pre-Space") { Transform[] componentsInChildren11 = ((Component)obj.transform.GetChild(1)).GetComponentsInChildren(true); Transform[] array11 = componentsInChildren11; foreach (Transform val9 in array11) { if (((Object)val9).name.Contains("Starts")) { continue; } AudioSource[] componentsInChildren12 = ((Component)val9).GetComponentsInChildren(true); AudioSource[] array12 = componentsInChildren12; foreach (AudioSource val10 in array12) { if (((Object)((Component)val10).gameObject).name.Contains("Music")) { DistortApply(val10); } } } } } else { string text8 = scenename; if (text8.Contains("8-4")) { if (((Object)obj).name.Contains("Music") || ((Object)obj).name.Contains("Intro") || ((Object)obj).name.Contains("The End")) { AudioSource[] componentsInChildren13 = obj.GetComponentsInChildren(true); AudioSource[] array13 = componentsInChildren13; foreach (AudioSource val11 in array13) { if (((Object)((Component)val11).gameObject).name.Contains("Music") || ((Object)((Component)val11).gameObject).name.Contains("Drone") || ((Object)((Component)val11).gameObject).name.Contains("Spot Light") || ((Object)((Component)val11).gameObject).name.Contains("Impact")) { DistortApply(val11); } } } } else { string text9 = scenename; if (text9.Contains("P-1")) { if (((Object)obj).name.ToLower().Contains("music")) { AudioSource[] componentsInChildren14 = obj.GetComponentsInChildren(true); AudioSource[] array14 = componentsInChildren14; foreach (AudioSource aus4 in array14) { DistortApply(aus4); } } } else { string text10 = scenename; if (text10.Contains("P-2")) { if (((Object)obj).name == "BossMusics") { AudioSource[] componentsInChildren15 = obj.GetComponentsInChildren(true); AudioSource[] array15 = componentsInChildren15; foreach (AudioSource aus5 in array15) { DistortApply(aus5); } } if (((Object)obj).name == "Rain" && obj.transform.childCount >= 5) { AudioSource[] componentsInChildren16 = ((Component)obj.transform.GetChild(5)).GetComponentsInChildren(true); AudioSource[] array16 = componentsInChildren16; foreach (AudioSource aus6 in array16) { DistortApply(aus6); } } } else { string text11 = scenename; if (text11.Contains("Intermission")) { if (((Object)obj).name == "Canvas") { AudioSource[] componentsInChildren17 = obj.GetComponentsInChildren(true); AudioSource[] array17 = componentsInChildren17; foreach (AudioSource val12 in array17) { if (((Object)((Component)val12).gameObject).name.Contains("Music")) { DistortApply(val12); } } } } else { string text12 = scenename; if (text12.Contains("Endless")) { if (((Object)obj).name == "Everything") { AudioSource[] componentsInChildren18 = obj.GetComponentsInChildren(true); AudioSource[] array18 = componentsInChildren18; foreach (AudioSource aus7 in array18) { DistortApply(aus7); } } } else { string text13 = scenename; if (text13.Contains("CreditsMuseum2") && (((Object)obj).name == "Music" || ((Object)obj).name == "__Room_Theater")) { AudioSource[] componentsInChildren19 = obj.GetComponentsInChildren(true); AudioSource[] array19 = componentsInChildren19; foreach (AudioSource val13 in array19) { if (((Object)((Component)val13).gameObject).name.Contains("Music Player") || ((Object)((Component)val13).gameObject).name.Contains("VideoAudioSource")) { DistortApply(val13); } } } } } } } } } } } } } } } } } MusicManager componentInChildren = obj.GetComponentInChildren(true); AudioSource[] array20 = ((componentInChildren != null) ? ((Component)componentInChildren).GetComponentsInChildren(true) : null); if (array20 != null) { AudioSource[] array21 = array20; foreach (AudioSource aus8 in array21) { DistortApply(aus8); } } } catch (Exception ex) { log.LogError((object)"Failed to Apply Distortion to Music! "); log.LogError((object)ex.Message); } } } [HarmonyPatch(typeof(SceneHelper), "OnSceneLoaded")] public class OSLpatch { [HarmonyPostfix] public static void Postfix() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); if (Plugin.isthereconfigManager) { Plugin.audioIntensityValue = PluginConfiguratorIntegrator.intensityField.value; Plugin.isOnlyMusicValue = PluginConfiguratorIntegrator.isMusicOnlyField.value; } Plugin.EarRapeApply(rootGameObjects); } } [HarmonyPatch(typeof(AudioCopyVolumeAndTime), "Update")] public class ACVATpatch { [HarmonyPostfix] public static void Postfix(AudioCopyVolumeAndTime __instance, AudioSource ___aud) { if ((Object)(object)((Component)__instance).GetComponent() != (Object)null && (Object)(object)((Component)__instance.target).GetComponent() != (Object)null) { if ((Object)(object)((Component)___aud).GetComponent() == (Object)null) { AudioDistortionFilter val = ((Component)___aud).gameObject.AddComponent(); val.distortionLevel = (Plugin.isOnlyMusicValue ? Plugin.audioIntensityValue : 0f); } ((Component)___aud).GetComponent().distortionLevel = (Plugin.isOnlyMusicValue ? Plugin.audioIntensityValue : 0f); } } } public class PluginConfiguratorIntegrator { public static BoolField isMusicOnlyField; public static FloatSliderField intensityField; private PluginConfigurator config; public bool PluginConfigulatorIntegration() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (Plugin.isthereconfigManager) { config = PluginConfigurator.Create("UltraDistortion", "ultra_distortion"); isMusicOnlyField = new BoolField(config.rootPanel, "OnlyMusic", "enabler", false); intensityField = new FloatSliderField(config.rootPanel, "AudioDistortionLevel (Earrape Amount)", "intensity", new Tuple(0f, 1f), 1f, 3, true, true); isMusicOnlyField.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent evt) { Config_postConfigChange(null, evt.value); }; intensityField.postValueChangeEvent += (PostFloatSliderValueChangeEvent)delegate(float value, Tuple bounds) { Config_postConfigChange(value); }; Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); Plugin.EarRapeApply(rootGameObjects); return true; } return false; } private void Config_postConfigChange(float? a = null, bool? b = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Plugin.audioIntensityValue = ((!a.HasValue) ? intensityField.value : a.Value); Plugin.isOnlyMusicValue = ((!b.HasValue) ? isMusicOnlyField.value : b.Value); Plugin.log.LogDebug((object)"Attempting to apply config value."); Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); Plugin.EarRapeApply(rootGameObjects); } }