Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Outpost31Music v1.0.3
BepinEx/Plugins/Outpost31Music/Outpost31Music.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using UnityEngine; using UnityEngine.Networking; 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("Outpost31Music")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Outpost31Music")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("826fec88-8098-4b33-bbe3-998272739417")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.haychicken.outpost31music", "Outpost 31 Music", "1.0.0")] public class Outpost31Music : BaseUnityPlugin { [CompilerGenerated] private sealed class <FadeOutAndStop>d__10 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Outpost31Music <>4__this; private float <startVolume>5__1; private float <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeOutAndStop>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <startVolume>5__1 = <>4__this.musicSource.volume; <t>5__2 = 0f; break; case 1: <>1__state = -1; <t>5__2 += Time.deltaTime; break; } if (<t>5__2 < <>4__this.fadeDuration) { <>4__this.musicSource.volume = Mathf.Lerp(<startVolume>5__1, 0f, <t>5__2 / <>4__this.fadeDuration); <>2__current = null; <>1__state = 1; return true; } <>4__this.musicSource.volume = 0f; <>4__this.musicSource.Stop(); Object.Destroy((Object)(object)((Component)<>4__this.musicSource).gameObject); <>4__this.musicSource = null; ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"Music faded out and stopped."); 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(); } } [CompilerGenerated] private sealed class <LoadAndPlayAudio>d__8 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string path; public Outpost31Music <>4__this; private string <url>5__1; private UnityWebRequest <www>5__2; private AudioClip <clip>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAndPlayAudio>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <url>5__1 = null; <www>5__2 = null; <clip>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; <url>5__1 = "file:///" + path.Replace("\\", "/"); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)("Loading audio from " + <url>5__1)); <www>5__2 = UnityWebRequestMultimedia.GetAudioClip(<url>5__1, (AudioType)14); <>1__state = -3; <>2__current = <www>5__2.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; if ((int)<www>5__2.result != 1) { ((BaseUnityPlugin)<>4__this).Logger.LogError((object)("Failed to load audio: " + <www>5__2.error)); result = false; <>m__Finally1(); break; } <clip>5__3 = DownloadHandlerAudioClip.GetContent(<www>5__2); <>4__this.musicSource.clip = <clip>5__3; <>4__this.musicSource.Play(); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"Music started playing!"); <clip>5__3 = null; <>m__Finally1(); <www>5__2 = null; result = false; 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 (<www>5__2 != null) { ((IDisposable)<www>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private AudioSource musicSource; private string targetLevel = "Outpost31_scene"; private float fadeDuration = 3f; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Outpost31Music loaded!"); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name)); if (((Scene)(ref scene)).name.Contains(targetLevel)) { PlayMusic(); } else { StopMusic(); } } private void OnSceneUnloaded(Scene scene) { if (((Scene)(ref scene)).name.Contains(targetLevel)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Target scene unloaded, fading out music..."); StopMusic(); } } private void PlayMusic() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)musicSource != (Object)null)) { GameObject val = new GameObject("Outpost31MusicPlayer"); musicSource = val.AddComponent<AudioSource>(); musicSource.loop = true; musicSource.volume = 0.4f; string path = Path.Combine(Paths.PluginPath, "Outpost31Music", "thing.ogg"); ((MonoBehaviour)this).StartCoroutine(LoadAndPlayAudio(path)); Object.DontDestroyOnLoad((Object)(object)val); } } [IteratorStateMachine(typeof(<LoadAndPlayAudio>d__8))] private IEnumerator LoadAndPlayAudio(string path) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAndPlayAudio>d__8(0) { <>4__this = this, path = path }; } private void StopMusic() { if (!((Object)(object)musicSource == (Object)null)) { ((MonoBehaviour)this).StartCoroutine(FadeOutAndStop()); } } [IteratorStateMachine(typeof(<FadeOutAndStop>d__10))] private IEnumerator FadeOutAndStop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeOutAndStop>d__10(0) { <>4__this = this }; } }