using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Xml; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using EnemiesReturns.ModdedEntityStates.Judgement.Arraign.Phase1; using EnemiesReturns.ModdedEntityStates.Judgement.WaveInteractable; using EntityStates.ArtifactShell; using EntityStates.FalseSonBoss; using EntityStates.Missions.BrotherEncounter; using EntityStates.SolusHeart; using EntityStates.SolusHeart.Death; using EntityStates.SolusWing; using EntityStates.VoidRaidCrab; using HarmonyLib; using NAudio.Wave; using NAudio.Wave.SampleProviders; using On.EntityStates.ArtifactShell; using On.EntityStates.FalseSonBoss; using On.EntityStates.Missions.BrotherEncounter; using On.EntityStates.SolusHeart; using On.EntityStates.SolusHeart.Death; using On.EntityStates.SolusWing; using On.EntityStates.VoidRaidCrab; using On.RoR2; using On.RoR2.UI; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ConVar; using RoR2.UI; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OriginalSoundTrack")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f89a466f755ce116e62d20703f40ae83029d385a")] [assembly: AssemblyProduct("OriginalSoundTrack")] [assembly: AssemblyTitle("OriginalSoundTrack")] [assembly: AssemblyVersion("1.0.0.0")] namespace OriginalSoundTrack; internal static class enemiesreturnswrapper { private static OriginalSoundTrack ostplugin; private static bool? _Present; public static bool Present { get { if (!_Present.HasValue) { _Present = Chainloader.PluginInfos.ContainsKey("com.Viliger.EnemiesReturns"); } return _Present.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Init(OriginalSoundTrack instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Debug.Log((object)"hey i loaded correctly"); ostplugin = instance; Harmony val = new Harmony("com.jasoncreatesblep.moreostsmodplus"); val.PatchAll(typeof(enemiesreturnswrapper)); } [HarmonyPatch(typeof(Spawn), "OnEnter")] [HarmonyPostfix] private static void PatchOnEnter() { Debug.Log((object)"====================== JUDGEMENT BOSS FIGHT START ======================"); ostplugin.extratracksfrfr = false; ostplugin.bossActive = false; ostplugin.afterBossPhase = true; ostplugin.hasshuffled = false; ostplugin.listtracker = 0; ostplugin.JudgementWaveCounter = 0; ostplugin.PickOutMusic(); } [HarmonyPatch(typeof(StartingUp), "OnEnter")] [HarmonyPostfix] private static void PatchOnEnter2() { ostplugin.JudgementWaveCounter++; if (!ostplugin.bossActive) { Debug.Log((object)"====================== JUDGEMENT TRIAl START ======================"); ostplugin.bossActive = true; ostplugin.hasshuffled = false; ostplugin.listtracker = 0; ostplugin.PickOutMusic(isForTeleporter: true); } if (ostplugin.JudgementWaveCounter == 5 && ostplugin.extratracksenabled) { Debug.Log((object)"====================== LAST 2 WAVES REMAINING ======================"); ostplugin.extratracksfrfr = true; ostplugin.bossActive = true; ostplugin.hasshuffled = false; ostplugin.listtracker = 0; ostplugin.PickOutMusic(isForTeleporter: true); } } } internal class NetworkCompatibilityAttribute : Attribute { private CompatibilityLevel noNeedForSync; private VersionStrictness differentModVersionsAreOk; public NetworkCompatibilityAttribute(CompatibilityLevel noNeedForSync, VersionStrictness differentModVersionsAreOk) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) this.noNeedForSync = noNeedForSync; this.differentModVersionsAreOk = differentModVersionsAreOk; } } [BepInPlugin("com.jasoncreatesblep.moreostsmodplus", "MoreOSTsModPlus", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class OriginalSoundTrack : BaseUnityPlugin { private enum postbossmusicmode { silence, alttrack, normaltrack } private enum randomizationmodelist { off, shuffle, shuffleonce } public class Music { public string name; public string fullName; public string[] scenes; public bool boss = false; public float volume = 1f; public bool loop = false; public bool afterboss = false; public bool simulacrum = false; public bool postloopvariant = false; public bool isextratrack = false; } public class LoopStream : WaveStream { private WaveStream sourceStream; private bool EnableLooping = true; public override WaveFormat WaveFormat => sourceStream.WaveFormat; public override long Position { get { return ((Stream)(object)sourceStream).Position; } set { ((Stream)(object)sourceStream).Position = value; } } public override long Length => ((Stream)(object)sourceStream).Length; public LoopStream(WaveStream sourceStream, bool shouldLoop) { this.sourceStream = sourceStream; EnableLooping = shouldLoop; } public override int Read(byte[] buffer, int offset, int count) { int i; int num2; for (i = 0; i < count; i += num2) { int num = count - i; num2 = ((Stream)(object)sourceStream).Read(buffer, offset + i, num); if (num2 < num || ((Stream)(object)sourceStream).Position >= ((Stream)(object)sourceStream).Length) { if (!EnableLooping) { break; } ((Stream)(object)sourceStream).Position = 0L; } } return i; } } private FadeInOutSampleProvider fader; private WaveOutEvent outputDevice; private FileInfo[] soundFiles; private List musics = new List(); private AudioFileReader currentSong; private string currentSongFullName = ""; private bool songPaused = false; private float currentMusicVolume; private ConfigEntry globalMusicVolume; private bool shouldLoop = true; public bool hasshuffled = false; private string oldMusicVolume = ""; private string currentScene = ""; private Random rnd = new Random(); private postbossmusicmode postbossmusic = postbossmusicmode.silence; private randomizationmodelist randomizationmode = randomizationmodelist.off; private XmlElement settings; private Texture2D modIconTexture; private SceneIndex lastStageIndex = (SceneIndex)(-1); public bool bossActive = false; public bool afterBossPhase = false; public bool simulacrumactive = false; public bool playerhaslooped = false; private string[] storedloopstages = null; private int postloopamount = 0; public bool extratracksenabled = false; public bool extratracksfrfr = false; public int JudgementWaveCounter = 0; public int listtracker = 0; public void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0063: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Expected O, but got Unknown //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Expected O, but got Unknown //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Expected O, but got Unknown //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Expected O, but got Unknown //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Expected O, but got Unknown //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Expected O, but got Unknown //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Expected O, but got Unknown //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Expected O, but got Unknown //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Expected O, but got Unknown //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Expected O, but got Unknown //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Expected O, but got Unknown //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Expected O, but got Unknown //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Expected O, but got Unknown //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Expected O, but got Unknown //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Expected O, but got Unknown //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Expected O, but got Unknown //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Expected O, but got Unknown TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterFinished; string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = directoryName; globalMusicVolume = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("General", "Volume"), 40f, new ConfigDescription("The volume of the More OSTs Mod music. KEEP THE GAME'S MUSIC VOLUME AT 0!!!", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(globalMusicVolume, new StepSliderConfig { min = 0f, max = 100f, increment = 1f, formatString = "{0:0}%" })); globalMusicVolume.SettingChanged += delegate { UpdateVolume(); }; modIconTexture = new Texture2D(0, 0); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OriginalSoundTrack.ror2_more_osts_mod_clean.png")) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); ImageConversion.LoadImage(modIconTexture, array); } Sprite modIcon = Sprite.Create(modIconTexture, new Rect(0f, 0f, (float)((Texture)modIconTexture).width, (float)((Texture)modIconTexture).height), new Vector2(0f, 0f)); ModSettingsManager.SetModIcon(modIcon); try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(directoryName + "/settings.xml"); settings = xmlDocument["settings"]; shouldLoop = settings["loop"].InnerText.ToLower() == "true"; if (bool.TryParse(settings["playextratracks"].InnerText, out var result)) { extratracksenabled = result; } if (Enum.TryParse(settings["aftertptracks"].InnerText, ignoreCase: true, out var result2)) { postbossmusic = result2; } if (Enum.TryParse(settings["randomization"].InnerText, ignoreCase: true, out var result3)) { randomizationmode = result3; } if (settings["music-path"] != null) { text = settings["music-path"].InnerText; } soundFiles = SearchForAudioFiles(text); foreach (XmlNode setting in settings) { if (setting.Name == "postloopstagetracksettings") { storedloopstages = settings["postloopstagetracksettings"].GetAttribute("loopscenes").Split(','); if (int.TryParse(settings["postloopstagetracksettings"].GetAttribute("enableatloop"), out var result4)) { postloopamount = result4; } } } foreach (XmlNode childNode in settings["music"].ChildNodes) { if (childNode.NodeType == XmlNodeType.Comment) { continue; } Music music = new Music(); music.name = GetAttribute(childNode, "name"); music.scenes = (from str in GetAttribute(childNode, "scenes").Split(',') select str.Trim()).ToArray(); music.boss = GetAttribute(childNode, "boss").ToLower() == "true"; music.afterboss = GetAttribute(childNode, "afterboss").ToLower() == "true"; music.simulacrum = GetAttribute(childNode, "simulacrum").ToLower() == "true"; music.postloopvariant = GetAttribute(childNode, "postloopvariant").ToLower() == "true"; music.isextratrack = GetAttribute(childNode, "isextratrack").ToLower() == "true"; if (float.TryParse(GetAttribute(childNode, "volume"), NumberStyles.Any, CultureInfo.InvariantCulture, out var result5)) { music.volume = result5; } music.loop = GetAttribute(childNode, "loop").ToLower() == "true"; FileInfo[] array2 = soundFiles; foreach (FileInfo fileInfo in array2) { if (fileInfo.Name == music.name) { music.fullName = fileInfo.FullName; break; } } musics.Add(music); } } catch (Exception ex) { Debug.LogWarning((object)"!!!!! OriginalSoundTrack Mod: Failed to parse settings.xml !!!!!"); Debug.Log((object)"OriginalSoundTrack Mod: Music will be randomly selected from what is found in the plugin dir."); Debug.Log((object)ex); } if (soundFiles == null) { text = directoryName; soundFiles = SearchForAudioFiles(text); } if (soundFiles.Length == 0) { Debug.LogError((object)"!!!!! OriginalSoundTrack Mod: No audio files found. Exiting. !!!!!"); Debug.LogError((object)("OriginalSoundTrack Mod: Looked for .mp3 and .wav files in: " + text)); return; } if (outputDevice == null) { outputDevice = new WaveOutEvent(); } TeleporterInteraction.OnInteractionBegin += (hook_OnInteractionBegin)delegate(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator) { orig.Invoke(self, activator); if (!bossActive) { bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); } }; TeleporterInteraction.RpcClientOnActivated += (hook_RpcClientOnActivated)delegate(orig_RpcClientOnActivated orig, TeleporterInteraction self, GameObject activator) { orig.Invoke(self, activator); if (!bossActive) { bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); } }; PauseScreenController.OnEnable += (hook_OnEnable)delegate(orig_OnEnable orig, PauseScreenController self) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 orig.Invoke(self); if (outputDevice != null && (int)outputDevice.PlaybackState == 1) { outputDevice.Pause(); songPaused = true; } }; PauseScreenController.OnDisable += (hook_OnDisable)delegate(orig_OnDisable orig, PauseScreenController self) { orig.Invoke(self); if (outputDevice != null && songPaused) { outputDevice.Play(); songPaused = false; } }; InfiniteTowerRun.Start += (hook_Start)delegate(orig_Start orig, InfiniteTowerRun self) { orig.Invoke(self); simulacrumactive = true; hasshuffled = false; listtracker = 0; PickOutMusic(); }; InfiniteTowerRun.OnDestroy += (hook_OnDestroy)delegate(orig_OnDestroy orig, InfiniteTowerRun self) { orig.Invoke(self); simulacrumactive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); }; Phase1.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, Phase1 self) { orig.Invoke(self); Debug.Log((object)"====================== MITHRIX BOSS FIGHT START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); }; EncounterFinished.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, EncounterFinished self) { orig.Invoke(self); Debug.Log((object)"====================== MITHRIX BOSS FIGHT DONE ======================"); bossActive = false; afterBossPhase = true; hasshuffled = false; listtracker = 0; PickOutMusic(); }; HeartSpawnState.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, HeartSpawnState self) { orig.Invoke(self); Debug.Log((object)"====================== FALSE SON BOSS FIGHT START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); }; SkyJumpDeathState.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, SkyJumpDeathState self) { orig.Invoke(self); Debug.Log((object)"====================== FALSE SON BOSS FIGHT DONE ======================"); bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); }; CutsceneTransformation.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, CutsceneTransformation self) { orig.Invoke(self); Debug.Log((object)"====================== SOLUS HEART BOSS FIGHT START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); }; Offering.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, Offering self) { orig.Invoke(self); Debug.Log((object)"====================== SOLUS HEART BOSS FIGHT DONE ======================"); bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); }; SpawnState.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, SpawnState self) { orig.Invoke(self); Debug.Log((object)"====================== SOLUS WING BOSS FIGHT START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); }; DeathState.OnExit += (hook_OnExit)delegate(orig_OnExit orig, DeathState self) { orig.Invoke(self); Debug.Log((object)"====================== SOLUS WING BOSS FIGHT DONE ======================"); bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); }; SpawnState.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, SpawnState self) { if (!bossActive) { orig.Invoke(self); Debug.Log((object)"====================== VOIDLING BOSS FIGHT START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); } }; DeathState.OnExit += (hook_OnExit)delegate(orig_OnExit orig, DeathState self) { orig.Invoke(self); Debug.Log((object)"====================== VOIDLING BOSS FIGHT DONE ======================"); bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); }; StartHurt.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, StartHurt self) { if (!bossActive && extratracksenabled) { orig.Invoke(self); Debug.Log((object)"====================== ARTIFACT TRIAL START ======================"); extratracksfrfr = true; bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); } }; Death.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, Death self) { if (extratracksenabled) { orig.Invoke(self); Debug.Log((object)"====================== ARTIFACT TRIAL END ======================"); extratracksfrfr = false; bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); } }; if (enemiesreturnswrapper.Present) { enemiesreturnswrapper.Init(this); } SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"====================== CHANGE SCENE, GD REFERENCE ========================"); Debug.Log((object)((Scene)(ref scene)).name); currentScene = ((Scene)(ref scene)).name; SceneIndex sceneDefIndex = SceneCatalog.mostRecentSceneDef.sceneDefIndex; if (currentScene == "enemiesreturns_judgementoutro") { extratracksfrfr = false; lastStageIndex = sceneDefIndex; afterBossPhase = true; bossActive = false; hasshuffled = false; listtracker = 0; JudgementWaveCounter = 0; PickOutMusic(); } else if (sceneDefIndex != lastStageIndex) { if ((Object)(object)Run.instance != (Object)null) { playerhaslooped = Run.instance.loopClearCount >= postloopamount; } lastStageIndex = sceneDefIndex; afterBossPhase = false; extratracksfrfr = false; bossActive = false; hasshuffled = false; listtracker = 0; JudgementWaveCounter = 0; PickOutMusic(); } else if (!bossActive) { extratracksfrfr = false; hasshuffled = false; listtracker = 0; JudgementWaveCounter = 0; PickOutMusic(); } }; } private void OnTeleporterFinished(TeleporterInteraction tp) { switch (postbossmusic) { case postbossmusicmode.silence: Debug.Log((object)"==================== Play Nothing Once This Song Finishes? COMING RIGHT UP!! ===================="); break; case postbossmusicmode.alttrack: Debug.Log((object)"==================== Alt Stage Track Post-Tp ENABLED!!!!!!!!!!!! ===================="); bossActive = false; afterBossPhase = true; hasshuffled = false; listtracker = 0; PickOutMusic(); break; case postbossmusicmode.normaltrack: Debug.Log((object)"==================== Normal Stage Track Post-Tp ENABLED!!!!!!!!!!!! ===================="); bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); break; } } private void UpdateVolume() { currentSong.Volume = currentMusicVolume * globalMusicVolume.Value / 100f; } private FileInfo[] SearchForAudioFiles(string path) { DirectoryInfo directoryInfo = new DirectoryInfo(path); if (directoryInfo.Exists) { return (from f in directoryInfo.GetFiles() where Path.GetExtension(f.Name) == ".mp3" || Path.GetExtension(f.Name) == ".wav" select f).ToArray(); } return new FileInfo[0]; } private string GetAttribute(XmlNode node, string attribute) { if (node.Attributes != null) { XmlNode namedItem = node.Attributes.GetNamedItem(attribute); if (namedItem != null) { return namedItem.Value; } } return ""; } private bool sceneMostlyMatches(string[] scenes) { foreach (string value in scenes) { if (currentScene.Contains(value)) { return true; } } return false; } public void PickOutMusic(bool isForTeleporter = false) { Music[] array = musics.Where(delegate(Music music3) { bool flag = sceneMostlyMatches(music3.scenes); bool flag2 = isForTeleporter == music3.boss; bool flag3 = playerhaslooped && storedloopstages != null && storedloopstages.Contains(currentScene); bool flag4 = extratracksfrfr; if (simulacrumactive) { return music3.simulacrum == simulacrumactive && flag && music3.fullName != null; } return afterBossPhase ? (music3.afterboss && flag && music3.postloopvariant == flag3 && music3.fullName != null) : (music3.fullName != null && flag2 && flag && music3.postloopvariant == flag3 && music3.isextratrack == flag4 && !music3.afterboss && !music3.simulacrum); }).ToArray(); Debug.Log((object)"====== Selecting Music ======"); Debug.Log((object)("Current Scene: " + currentScene)); Debug.Log((object)("Is For Teleporter: " + isForTeleporter)); Debug.Log((object)"Choices: "); Music[] array2 = array; foreach (Music music in array2) { Debug.Log((object)music.name); } Debug.Log((object)""); string fullName = currentSongFullName; Music music2 = null; int num2 = 0; if (array.Length != 0) { while (fullName == currentSongFullName && num2 < 10) { switch (randomizationmode) { case randomizationmodelist.off: music2 = array[listtracker % array.Length]; fullName = music2.fullName; num2++; listtracker++; break; case randomizationmodelist.shuffle: music2 = array[rnd.Next(array.Length)]; fullName = music2.fullName; num2++; hasshuffled = true; break; case randomizationmodelist.shuffleonce: if (!hasshuffled) { listtracker = rnd.Next(array.Length); music2 = array[listtracker % array.Length]; fullName = music2.fullName; num2++; hasshuffled = true; } else { music2 = array[listtracker % array.Length]; fullName = music2.fullName; num2++; listtracker++; } break; } } ((MonoBehaviour)this).StartCoroutine((IEnumerator)PlayMusic(fullName, music2.volume)); } else { Debug.Log((object)"======= MUSIC PICK FAILED! ======="); Debug.Log((object)"choosing random song..."); num2 = 0; while (fullName == currentSongFullName && num2 < 10) { fullName = soundFiles[rnd.Next(soundFiles.Length)].FullName; num2++; } ((MonoBehaviour)this).StartCoroutine((IEnumerator)PlayMusic(fullName)); } } private IEnumerator PlayMusic(string file, float volume = 1f) { currentMusicVolume = volume; if (file != currentSongFullName) { currentSongFullName = file; if ((int)outputDevice.PlaybackState == 1) { fader.BeginFadeOut(1500.0); yield return new WaitForSeconds(1.5f); outputDevice.Stop(); currentSong = null; } currentSong = new AudioFileReader(file); UpdateVolume(); LoopStream looper = new LoopStream(shouldLoop: musics.First((Music m) => m.fullName == file).loop, sourceStream: (WaveStream)(object)currentSong); fader = new FadeInOutSampleProvider((ISampleProvider)new WaveToSampleProvider((IWaveProvider)(object)looper), false); WaveExtensionMethods.Init((IWavePlayer)(object)outputDevice, (ISampleProvider)(object)fader, false); Debug.Log((object)("====== Now Playing: " + file)); outputDevice.Play(); songPaused = false; } else { Debug.Log((object)("PlayMusic: Already playing: " + file)); } } public void Update() { if (oldMusicVolume == "" && (Object)(object)Console.instance != (Object)null) { BaseConVar val = Console.instance.FindConVar("volume_music"); if (val != null) { oldMusicVolume = val.GetString(); val.SetString("0"); } } } private void FixedUpdate() { if (currentSong != null && ((Stream)(object)currentSong).Position >= ((Stream)(object)currentSong).Length && !shouldLoop) { outputDevice.Stop(); ((Stream)(object)currentSong).Position = ((Stream)(object)currentSong).Length - 1; PickOutMusic(bossActive); } } private void OnDestroy() { BaseConVar val = Console.instance.FindConVar("volume_music"); if (val != null) { val.SetString(oldMusicVolume); } } }