The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of OnlyTrumpetSongs v1.1.7
BepInEx/plugins/OnlyTrumpetSongs/com.github.ChuMenschis.OnlyTrumpetSongs.dll
Decompiled 18 hours agousing 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.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.github.ChuMenschis.OnlyTrumpetSongs")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("com.github.ChuMenschis.OnlyTrumpetSongs")] [assembly: AssemblyTitle("OnlyTrumpetSongs")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("OnlyTrumpetSongs", "OnlyTrumpetSongs", "1.1.2")] public class OnlyTrumpetSongs : BaseUnityPlugin { [CompilerGenerated] private sealed class <LoadSongsCoroutine>d__21 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public OnlyTrumpetSongs <>4__this; private string <soundPath>5__1; private List<string> <files>5__2; private string <globalSounds>5__3; private List<string>.Enumerator <>s__4; private string <file>5__5; private UnityWebRequest <req>5__6; private AudioClip <clip>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSongsCoroutine>d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if ((uint)(num - -4) <= 1u || num == 1) { try { if (num == -4 || num == 1) { try { } finally { <>m__Finally2(); } } } finally { <>m__Finally1(); } } <soundPath>5__1 = null; <files>5__2 = null; <globalSounds>5__3 = null; <>s__4 = default(List<string>.Enumerator); <file>5__5 = null; <req>5__6 = null; <clip>5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Invalid comparison between Unknown and I4 try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <soundPath>5__1 = Path.Combine(<>4__this.pluginFolder, "Sounds"); if (!Directory.Exists(<soundPath>5__1)) { <globalSounds>5__3 = Path.Combine(Paths.PluginPath, "Sounds"); if (Directory.Exists(<globalSounds>5__3)) { <soundPath>5__1 = <globalSounds>5__3; } <globalSounds>5__3 = null; } if (!Directory.Exists(<soundPath>5__1)) { Log.LogWarning((object)("Sounds folder not found: " + <soundPath>5__1)); return false; } <files>5__2 = Directory.GetFiles(<soundPath>5__1, "*.ogg").OrderBy(delegate(string f) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(f); string s = new string(fileNameWithoutExtension.TakeWhile(char.IsDigit).ToArray()); int result; return int.TryParse(s, out result) ? result : int.MaxValue; }).ThenBy<string, string>((string f) => f, StringComparer.OrdinalIgnoreCase) .ToList(); <>s__4 = <files>5__2.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -4; if ((int)<req>5__6.result != 1) { Log.LogError((object)("Failed to load '" + <file>5__5 + "': " + <req>5__6.error)); } else { <clip>5__7 = DownloadHandlerAudioClip.GetContent(<req>5__6); if (!((Object)(object)<clip>5__7 == (Object)null)) { ((Object)<clip>5__7).name = Path.GetFileNameWithoutExtension(<file>5__5); CustomSongs.Add(<clip>5__7); Log.LogInfo((object)("Loaded song: " + ((Object)<clip>5__7).name)); <clip>5__7 = null; <>m__Finally2(); <req>5__6 = null; <file>5__5 = null; break; } Log.LogError((object)("Null clip for '" + <file>5__5 + "'")); } <>m__Finally2(); break; } if (<>s__4.MoveNext()) { <file>5__5 = <>s__4.Current; <req>5__6 = UnityWebRequestMultimedia.GetAudioClip("file://" + <file>5__5, (AudioType)14); <>1__state = -4; <>2__current = <req>5__6.SendWebRequest(); <>1__state = 1; return true; } <>m__Finally1(); <>s__4 = default(List<string>.Enumerator); IsInitialized = true; Log.LogInfo((object)$"Loaded {CustomSongs.Count} custom songs."); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__4).Dispose(); } private void <>m__Finally2() { <>1__state = -3; if (<req>5__6 != null) { ((IDisposable)<req>5__6).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource Log; private Harmony harmony; private string pluginFolder; internal static readonly List<AudioClip> CustomSongs = new List<AudioClip>(); internal static bool IsInitialized = false; internal static int GlobalSongIndex = 0; internal static string CurrentSongName = ""; internal static float TitleStartTime = -999f; private static Font customFont; private static GUIStyle titleStyle; private const float TITLE_DURATION = 3f; private const float FADE_DURATION = 0.5f; private const int TITLE_FONT_SIZE = 36; private const int TITLE_Y_OFFSET = 60; private const int TITLE_HEIGHT = 40; private static readonly Color OUTLINE_COLOR = Color.black; private const float OUTLINE_STRENGTH = 2f; private void Start() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; string location = ((BaseUnityPlugin)this).Info.Location; pluginFolder = Path.GetDirectoryName(location); harmony = new Harmony("OnlyTrumpetSongs"); harmony.PatchAll(); LoadFont(); ((MonoBehaviour)this).StartCoroutine(LoadSongsCoroutine()); } private void LoadFont() { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown try { string text = Path.Combine(pluginFolder, "Fonts", "DarumadropOne-Regular.ttf"); if (!File.Exists(text)) { string text2 = Path.Combine(Paths.PluginPath, "Fonts", "DarumadropOne-Regular.ttf"); if (File.Exists(text2)) { text = text2; } } if (File.Exists(text)) { customFont = new Font(text); Log.LogInfo((object)("Custom font loaded: " + text)); } else { Log.LogWarning((object)"Custom font not found. Using default GUI font."); } GUIStyle val = new GUIStyle { font = (customFont ?? GUI.skin.label.font), fontSize = 36 }; val.normal.textColor = Color.white; val.alignment = (TextAnchor)7; titleStyle = val; } catch (Exception ex) { Log.LogError((object)("Error loading font: " + ex)); GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 36 }; val2.normal.textColor = Color.white; val2.alignment = (TextAnchor)7; titleStyle = val2; } } private void OnGUI() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(CurrentSongName) || titleStyle == null) { return; } float num = Time.time - TitleStartTime; if (!(num > 3f)) { if (titleStyle.fontSize != 36) { titleStyle.fontSize = 36; } float num2 = 1f; if (num < 0.5f) { num2 = Mathf.Lerp(0f, 1f, num / 0.5f); } else if (num > 2.5f) { num2 = Mathf.Lerp(1f, 0f, (num - 2.5f) / 0.5f); } Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, num2); DrawOutline(new Rect(0f, (float)(Screen.height - 60), (float)Screen.width, 40f), CurrentSongName, titleStyle, OUTLINE_COLOR, 2f); GUI.color = color; } } private void DrawOutline(Rect position, string text, GUIStyle style, Color outlineColor, float thickness) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Color textColor = style.normal.textColor; style.normal.textColor = outlineColor; GUI.Label(new Rect(((Rect)(ref position)).x - thickness, ((Rect)(ref position)).y, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, style); GUI.Label(new Rect(((Rect)(ref position)).x + thickness, ((Rect)(ref position)).y, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, style); GUI.Label(new Rect(((Rect)(ref position)).x, ((Rect)(ref position)).y - thickness, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, style); GUI.Label(new Rect(((Rect)(ref position)).x, ((Rect)(ref position)).y + thickness, ((Rect)(ref position)).width, ((Rect)(ref position)).height), text, style); style.normal.textColor = textColor; GUI.Label(position, text, style); } [IteratorStateMachine(typeof(<LoadSongsCoroutine>d__21))] private IEnumerator LoadSongsCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSongsCoroutine>d__21(0) { <>4__this = this }; } internal static bool CheckInput(string configValue) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (string.Equals(configValue, "MouseScrollUp", StringComparison.OrdinalIgnoreCase)) { return Input.GetAxis("Mouse ScrollWheel") > 0f; } if (string.Equals(configValue, "MouseScrollDown", StringComparison.OrdinalIgnoreCase)) { return Input.GetAxis("Mouse ScrollWheel") < 0f; } try { return Input.GetKeyDown((KeyCode)Enum.Parse(typeof(KeyCode), configValue, ignoreCase: true)); } catch { return false; } } } public class OnlyTrumpetSongsSync : MonoBehaviourPun { private BugleSFX bugle; private int currentIndex = 0; public void Init(BugleSFX sfx) { bugle = sfx; if (OnlyTrumpetSongs.IsInitialized && OnlyTrumpetSongs.CustomSongs.Count > 0) { bugle.bugle = OnlyTrumpetSongs.CustomSongs.ToArray(); } } public void SendSetSongIndex(int newIndex) { if (!((Object)(object)((MonoBehaviourPun)this).photonView == (Object)null) && OnlyTrumpetSongs.IsInitialized && OnlyTrumpetSongs.CustomSongs.Count != 0) { newIndex = Mod(newIndex, OnlyTrumpetSongs.CustomSongs.Count); AudioClip obj = OnlyTrumpetSongs.CustomSongs[newIndex]; string text = ((obj != null) ? ((Object)obj).name : null) ?? string.Empty; ((MonoBehaviourPun)this).photonView.RPC("RPC_SetSongByName", (RpcTarget)3, new object[1] { text }); } } [PunRPC] private void RPC_SetSongByName(string songName) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 string songName2 = songName; if (!OnlyTrumpetSongs.IsInitialized || OnlyTrumpetSongs.CustomSongs.Count == 0) { return; } int num = OnlyTrumpetSongs.CustomSongs.FindIndex((AudioClip c) => (Object)(object)c != (Object)null && string.Equals(((Object)c).name, songName2, StringComparison.OrdinalIgnoreCase)); if (num < 0) { num = 0; } currentIndex = num; if (bugle.bugle == null || bugle.bugle.Length == 0) { bugle.bugle = OnlyTrumpetSongs.CustomSongs.ToArray(); } AudioClip val = OnlyTrumpetSongs.CustomSongs[currentIndex]; bugle.buglePlayer.clip = val; bugle.buglePlayer.pitch = 1f; bugle.buglePlayer.loop = true; if ((Object)(object)bugle.item != (Object)null && (int)bugle.item.itemState == 1) { if (!bugle.buglePlayer.isPlaying) { bugle.buglePlayer.Play(); } if (((MonoBehaviourPun)this).photonView.IsMine) { OnlyTrumpetSongs.CurrentSongName = ((Object)val).name; OnlyTrumpetSongs.TitleStartTime = Time.time; } } else { bugle.buglePlayer.Stop(); bugle.buglePlayer.clip = null; } OnlyTrumpetSongs.GlobalSongIndex = currentIndex; } public int GetCurrentIndex() { return currentIndex; } private static int Mod(int x, int m) { return (x % m + m) % m; } } [HarmonyPatch(typeof(BugleSFX), "Start")] internal class Patch_Bugle_Start { private static void Postfix(BugleSFX __instance) { OnlyTrumpetSongsSync onlyTrumpetSongsSync = ((Component)__instance).gameObject.GetComponent<OnlyTrumpetSongsSync>(); if ((Object)(object)onlyTrumpetSongsSync == (Object)null) { onlyTrumpetSongsSync = ((Component)__instance).gameObject.AddComponent<OnlyTrumpetSongsSync>(); } onlyTrumpetSongsSync.Init(__instance); if (OnlyTrumpetSongs.IsInitialized && OnlyTrumpetSongs.CustomSongs.Count > 0) { __instance.bugle = OnlyTrumpetSongs.CustomSongs.ToArray(); __instance.buglePlayer.Stop(); __instance.buglePlayer.clip = null; __instance.buglePlayer.loop = true; __instance.buglePlayer.pitch = 1f; } __instance.pitchMin = 1f; __instance.pitchMax = 1f; __instance.volume = 0.5f; if (OnlyTrumpetSongs.GlobalSongIndex >= 0 && OnlyTrumpetSongs.GlobalSongIndex < OnlyTrumpetSongs.CustomSongs.Count) { onlyTrumpetSongsSync.SendSetSongIndex(OnlyTrumpetSongs.GlobalSongIndex); } } } [HarmonyPatch(typeof(BugleSFX), "Update")] internal class Patch_Bugle_Update { private static void Prefix(BugleSFX __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 if (!OnlyTrumpetSongs.IsInitialized || OnlyTrumpetSongs.CustomSongs.Count == 0) { return; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null || !component.IsMine || (Object)(object)__instance.item == (Object)null || (int)__instance.item.itemState != 1) { return; } OnlyTrumpetSongsSync component2 = ((Component)__instance).GetComponent<OnlyTrumpetSongsSync>(); if ((Object)(object)component2 == (Object)null) { return; } bool flag = OnlyTrumpetSongs.CheckInput("MouseScrollUp"); bool flag2 = OnlyTrumpetSongs.CheckInput("MouseScrollDown"); if (flag || flag2) { int num = (flag ? 1 : (-1)); int newIndex = component2.GetCurrentIndex() + num; component2.SendSetSongIndex(newIndex); } if (__instance.hold && (Object)(object)__instance.item != (Object)null && (int)__instance.item.itemState == 1) { if (!__instance.buglePlayer.isPlaying && (Object)(object)__instance.buglePlayer.clip != (Object)null) { __instance.buglePlayer.Play(); } } else if (__instance.buglePlayer.isPlaying) { __instance.buglePlayer.Stop(); } } } [HarmonyPatch(typeof(BugleSFX), "RPC_StartToot")] internal class Patch_Bugle_RPC_StartToot { private static void Prefix(BugleSFX __instance, ref int clip) { OnlyTrumpetSongsSync component = ((Component)__instance).GetComponent<OnlyTrumpetSongsSync>(); if (!((Object)(object)component == (Object)null) && OnlyTrumpetSongs.IsInitialized && OnlyTrumpetSongs.CustomSongs.Count > 0) { int currentIndex = component.GetCurrentIndex(); if (currentIndex >= 0 && currentIndex < OnlyTrumpetSongs.CustomSongs.Count) { clip = currentIndex; } } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }