using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using Microsoft.CodeAnalysis; using UnityEngine; [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("StereoLoveBoomBox")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("StereoLoveBoomBox")] [assembly: AssemblyTitle("StereoLoveBoomBox")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } [BepInPlugin("DgDarel.StereoLoveBoomBox", "StereoLoveBoomBox", "2.1.0")] public class StereoLoveBoomBox : BaseUnityPlugin { [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public StereoLoveBoomBox <>4__this; private string 5__1; private string 5__2; private byte[] 5__3; private WAV 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = Path.GetDirectoryName(((BaseUnityPlugin)<>4__this).Info.Location); 5__2 = Path.Combine(5__1, "StereoLoveBoomBox.wav"); if (!File.Exists(5__2)) { ((BaseUnityPlugin)<>4__this).Logger.LogError((object)"WAV not found"); return false; } 5__3 = File.ReadAllBytes(5__2); 5__4 = new WAV(5__3); <>4__this.customClip = AudioClip.Create("StereoLoveBoomBox", 5__4.SampleCount, 5__4.ChannelCount, 5__4.Frequency, false); <>4__this.customClip.SetData(5__4.Samples, 0); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"WAV loaded correctly"); 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 d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public StereoLoveBoomBox <>4__this; private AudioSource[] 5__1; private AudioSource[] <>s__2; private int <>s__3; private AudioSource 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>s__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((Object)(object)<>4__this.customClip != (Object)null) { 5__1 = Object.FindObjectsOfType(true); <>s__2 = 5__1; for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++) { 5__4 = <>s__2[<>s__3]; if (!((Object)(object)5__4 == (Object)null) && !<>4__this.hooked.Contains(5__4)) { <>4__this.hooked.Add(5__4); ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.WatchSource(5__4)); 5__4 = null; } } <>s__2 = null; 5__1 = null; } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } 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 d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AudioSource src; public StereoLoveBoomBox <>4__this; private bool 5__1; private Transform 5__2; private bool 5__3; private string 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = false; break; case 1: <>1__state = -1; break; } if ((Object)(object)src != (Object)null) { if (src.isPlaying) { if (!5__1) { 5__1 = true; 5__2 = ((Component)src).transform; 5__3 = false; while ((Object)(object)5__2 != (Object)null) { 5__4 = ((Object)5__2).name.ToLower(); if (5__4.Contains("boombox") || 5__4.Contains("boom") || 5__4.Contains("stereo")) { 5__3 = true; break; } 5__2 = 5__2.parent; 5__4 = null; } if (5__3) { src.Stop(); src.clip = <>4__this.customClip; src.loop = true; src.spatialBlend = 1f; src.rolloffMode = (AudioRolloffMode)1; src.minDistance = 4f; src.maxDistance = 18f; src.volume = 1f; src.pitch = 1f; src.Play(); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"Custom boombox music playing"); } 5__2 = null; } } else { 5__1 = false; } <>2__current = null; <>1__state = 1; return true; } 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 AudioClip customClip; private readonly HashSet hooked = new HashSet(); private void Start() { ((MonoBehaviour)this).StartCoroutine(LoadAudio()); ((MonoBehaviour)this).StartCoroutine(MonitorAudio()); } [IteratorStateMachine(typeof(d__3))] private IEnumerator LoadAudio() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__4))] private IEnumerator MonitorAudio() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__5))] private IEnumerator WatchSource(AudioSource src) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { <>4__this = this, src = src }; } } public class WAV { public float[] Samples; public int ChannelCount; public int SampleCount; public int Frequency; public WAV(byte[] wav) { ChannelCount = wav[22]; Frequency = wav[24] | (wav[25] << 8) | (wav[26] << 16) | (wav[27] << 24); int num = 12; while (wav[num] != 100 || wav[num + 1] != 97 || wav[num + 2] != 116 || wav[num + 3] != 97) { num += 4; int num2 = wav[num] | (wav[num + 1] << 8) | (wav[num + 2] << 16) | (wav[num + 3] << 24); num += 4 + num2; } num += 8; int num3 = 2; SampleCount = (wav.Length - num) / num3; Samples = new float[SampleCount]; int num4 = 0; while (num < wav.Length) { Samples[num4] = BytesToFloat(wav[num], wav[num + 1]); num += 2; num4++; } SampleCount /= ChannelCount; } private float BytesToFloat(byte first, byte second) { short num = (short)((second << 8) | first); return (float)num / 32768f; } }