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; using UnityEngine.Networking; [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("Kart Arena")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Kart Arena")] [assembly: AssemblyTitle("Kart Arena")] [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; } } } namespace ArenaMusicTest { [BepInPlugin("com.dgdarel.kartarenamusic", "Kart Arena Music", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private MonoBehaviour[] 5__1; private bool 5__2; private MonoBehaviour[] <>s__3; private int <>s__4; private MonoBehaviour 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>s__3 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; 5__1 = Object.FindObjectsOfType(); 5__2 = false; <>s__3 = 5__1; for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++) { 5__5 = <>s__3[<>s__4]; if (!((Object)(object)5__5 == (Object)null)) { if (((object)5__5).GetType().Name == "ArenaRace") { 5__2 = true; break; } 5__5 = null; } } <>s__3 = null; if (5__2) { <>4__this.StartMusic(); } else { <>4__this.StopMusic(); } 5__1 = null; break; } <>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 Plugin <>4__this; private string 5__1; private UnityWebRequest 5__2; 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() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Invalid comparison between Unknown and I4 bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; 5__1 = Path.Combine(Paths.PluginPath, "DgDarel-Night_And_Day", "Night&Day.wav"); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)("Loading audio: " + 5__1)); if (!File.Exists(5__1)) { ((BaseUnityPlugin)<>4__this).Logger.LogError((object)"FILE NOT FOUND"); result = false; break; } 5__2 = UnityWebRequestMultimedia.GetAudioClip("file://" + 5__1, (AudioType)20); <>1__state = -3; <>2__current = 5__2.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; if ((int)5__2.result != 1) { ((BaseUnityPlugin)<>4__this).Logger.LogError((object)5__2.error); result = false; } else { <>4__this.clip = DownloadHandlerAudioClip.GetContent(5__2); if (!((Object)(object)<>4__this.clip == (Object)null)) { ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"AUDIO LOADED"); <>m__Finally1(); 5__2 = null; result = false; break; } ((BaseUnityPlugin)<>4__this).Logger.LogError((object)"CLIP IS NULL"); result = false; } <>m__Finally1(); 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 (5__2 != null) { ((IDisposable)5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private AudioSource source; private AudioClip clip; private bool playing = false; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Kart Arena Music loaded!"); CreateAudioSource(); ((MonoBehaviour)this).StartCoroutine(LoadAudio()); ((MonoBehaviour)this).StartCoroutine(CheckArena()); } private void CreateAudioSource() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)source != (Object)null)) { GameObject val = new GameObject("CUSTOM_ARENA_AUDIO"); Object.DontDestroyOnLoad((Object)(object)val); source = val.AddComponent(); source.loop = true; source.playOnAwake = false; source.spatialBlend = 0f; source.volume = 1f; source.ignoreListenerPause = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"AudioSource created"); } } [IteratorStateMachine(typeof(d__5))] private IEnumerator LoadAudio() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__6))] private IEnumerator CheckArena() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { <>4__this = this }; } private void StartMusic() { if ((Object)(object)clip == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"CLIP NULL"); return; } if ((Object)(object)source == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"AudioSource destroyed. Recreating..."); CreateAudioSource(); } if ((Object)(object)source == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"FAILED TO CREATE AUDIOSOURCE"); } else if (!playing) { source.clip = clip; source.Play(); playing = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"PLAYING CUSTOM ARENA MUSIC"); } } private void StopMusic() { if (!((Object)(object)source == (Object)null) && playing) { source.Stop(); playing = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)"STOPPED MUSIC"); } } } }