using System; using System.Collections; 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.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+42df602b97968b4c7debf52ea84a5d6bad5dcbfa")] [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.bossActive = false; ostplugin.afterBossPhase = true; ostplugin.hasshuffled = false; ostplugin.listtracker = 0; ostplugin.PickOutMusic(); } [HarmonyPatch(typeof(StartingUp), "OnEnter")] [HarmonyPostfix] private static void PatchOnEnter2() { if (!ostplugin.bossActive) { Debug.Log((object)"====================== JUDGEMENT TRIAl START ======================"); 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 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; } } [CompilerGenerated] private sealed class <>c__DisplayClass32_0 { public string file; internal bool b__0(Music m) { return m.fullName == file; } } [CompilerGenerated] private sealed class d__32 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private WaitForSeconds <>2__current; public string file; public float volume; public OriginalSoundTrack <>4__this; private <>c__DisplayClass32_0 <>8__1; private Music 5__2; private LoopStream 5__3; WaitForSeconds IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; <>4__this.outputDevice.Stop(); <>4__this.currentSong = null; } else { <>1__state = -1; <>8__1 = new <>c__DisplayClass32_0(); <>8__1.file = file; <>4__this.currentMusicVolume = volume; if (!(<>8__1.file != <>4__this.currentSongFullName)) { Debug.Log((object)("PlayMusic: Already playing: " + <>8__1.file)); goto IL_0207; } <>4__this.currentSongFullName = <>8__1.file; if ((int)<>4__this.outputDevice.PlaybackState == 1) { <>4__this.fader.BeginFadeOut(1500.0); <>2__current = new WaitForSeconds(1.5f); <>1__state = 1; return true; } } <>4__this.currentSong = new AudioFileReader(<>8__1.file); <>4__this.UpdateVolume(); 5__2 = <>4__this.musics.First((Music m) => m.fullName == <>8__1.file); 5__3 = new LoopStream((WaveStream)(object)<>4__this.currentSong, 5__2.loop); <>4__this.fader = new FadeInOutSampleProvider((ISampleProvider)new WaveToSampleProvider((IWaveProvider)(object)5__3), false); WaveExtensionMethods.Init((IWavePlayer)(object)<>4__this.outputDevice, (ISampleProvider)(object)<>4__this.fader, false); Debug.Log((object)("====== Now Playing: " + <>8__1.file)); <>4__this.outputDevice.Play(); <>4__this.songPaused = false; 5__2 = null; 5__3 = null; goto IL_0207; IL_0207: return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } 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 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_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Expected O, but got Unknown //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Expected O, but got Unknown //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Expected O, but got Unknown //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Expected O, but got Unknown //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Expected O, but got Unknown //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Expected O, but got Unknown //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Expected O, but got Unknown //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Expected O, but got Unknown //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Expected O, but got Unknown //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Expected O, but got Unknown //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Expected O, but got Unknown //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Expected O, but got Unknown //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Expected O, but got Unknown //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Expected O, but got Unknown //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Expected O, but got Unknown //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Expected O, but got Unknown //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Expected O, but got Unknown //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: 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 (Enum.TryParse(settings["aftertptracks"].InnerText, ignoreCase: true, out var result)) { postbossmusic = result; } if (Enum.TryParse(settings["randomization"].InnerText, ignoreCase: true, out var result2)) { randomizationmode = result2; } if (settings["music-path"] != null) { text = settings["music-path"].InnerText; } soundFiles = SearchForAudioFiles(text); 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"; if (float.TryParse(GetAttribute(childNode, "volume"), out var result3)) { music.volume = result3; } 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) { orig.Invoke(self); Debug.Log((object)"====================== ARTIFACT TRIAL START ======================"); bossActive = true; hasshuffled = false; listtracker = 0; PickOutMusic(isForTeleporter: true); } }; Death.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, Death self) { orig.Invoke(self); Debug.Log((object)"====================== ARTIFACT TRIAL END ======================"); 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) 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") { lastStageIndex = sceneDefIndex; afterBossPhase = true; bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); } else if (sceneDefIndex != lastStageIndex) { lastStageIndex = sceneDefIndex; afterBossPhase = false; bossActive = false; hasshuffled = false; listtracker = 0; PickOutMusic(); } else if (!bossActive) { hasshuffled = false; listtracker = 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 music) { bool flag = sceneMostlyMatches(music.scenes); if (afterBossPhase) { return music.afterboss && flag && music.fullName != null; } if (simulacrumactive) { return music.simulacrum == simulacrumactive && flag && music.fullName != null; } bool flag2 = isForTeleporter == music.boss; return music.fullName != null && flag2 && flag && !music.afterboss && !music.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 music2 in array2) { Debug.Log((object)music2.name); } Debug.Log((object)""); string fullName = currentSongFullName; Music music3 = null; int num = 0; if (array.Length != 0) { while (fullName == currentSongFullName && num < 10) { switch (randomizationmode) { case randomizationmodelist.off: music3 = array[listtracker % array.Length]; fullName = music3.fullName; num++; listtracker++; break; case randomizationmodelist.shuffle: music3 = array[rnd.Next(array.Length)]; fullName = music3.fullName; num++; hasshuffled = true; break; case randomizationmodelist.shuffleonce: if (!hasshuffled) { listtracker = rnd.Next(array.Length); music3 = array[listtracker % array.Length]; fullName = music3.fullName; num++; hasshuffled = true; } else { music3 = array[listtracker % array.Length]; fullName = music3.fullName; num++; listtracker++; } break; } } ((MonoBehaviour)this).StartCoroutine((IEnumerator)PlayMusic(fullName, music3.volume)); } else { Debug.Log((object)"======= MUSIC PICK FAILED! ======="); Debug.Log((object)"choosing random song..."); num = 0; while (fullName == currentSongFullName && num < 10) { fullName = soundFiles[rnd.Next(soundFiles.Length)].FullName; num++; } ((MonoBehaviour)this).StartCoroutine((IEnumerator)PlayMusic(fullName)); } } [IteratorStateMachine(typeof(d__32))] private IEnumerator PlayMusic(string file, float volume = 1f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__32(0) { <>4__this = this, file = file, volume = volume }; } 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); } } }