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 AutoMusician v1.0.0
REPO_AutoMusician.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("REPO_AutoMusician")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("REPO_AutoMusician")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3b97065c-7efe-4237-a4c4-4f995698c041")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace REPOssessed.MusicianMod; [BepInPlugin("com.yourname.repo.automusician", "Auto Musician Mod", "1.0.0")] public class AutoMusicianPlugin : BaseUnityPlugin { public bool modEnabled = true; public bool isLooping = true; public float loopInterval = 2f; private string[] songNames = new string[5]; private string[] songContents = new string[5]; private float[] songSpeeds = new float[5]; public int currentSongIndex; private bool isPlaying; private int currentNoteIndex; private float nextPlayTime; public bool showMenu; private MusicalValuableLogic cachedInstrument; private float checkInstrumentTimer; private FieldInfo grabbedField; private FieldInfo grabbedObjField; private PropertyInfo grabbedObjProp; private readonly Dictionary<char, int> noteMapping = new Dictionary<char, int> { { 'a', 24 }, { 'b', 26 }, { 'c', 28 }, { 'd', 29 }, { 'e', 31 }, { 'f', 33 }, { 'g', 35 }, { '1', 36 }, { '2', 38 }, { '3', 40 }, { '4', 41 }, { '5', 43 }, { '6', 45 }, { '7', 47 }, { 'A', 48 }, { 'B', 50 }, { 'C', 52 }, { 'D', 53 }, { 'E', 55 }, { 'F', 57 }, { 'G', 59 } }; private Rect windowRect; private Vector2 scrollPosition = Vector2.zero; private bool stylesInitialized; private GUIStyle windowStyle; private GUIStyle tabNormalStyle; private GUIStyle tabActiveStyle; private GUIStyle resetBtnStyle; private GUIStyle editAreaStyle; private GUIStyle textAreaStyle; private GUIStyle labelStyle; private GUIStyle nameFieldStyle; private GUIStyle floatingTipStyle; private GUIStyle toggleStyle; private Texture2D texBlack; private Texture2D texSkyBlue; private Texture2D texDarkBlue; private Texture2D texDarkGrey; private void Awake() { try { Type typeFromHandle = typeof(PhysGrabber); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; grabbedField = typeFromHandle.GetField("grabbed", bindingAttr); grabbedObjField = typeFromHandle.GetField("grabbedPhysGrabObject", bindingAttr); grabbedObjProp = typeFromHandle.GetProperty("grabbedPhysGrabObject", bindingAttr); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Reflection Failed: " + ex.Message)); } ResetToDefaults(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"====================================="); ((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83c\udfb5 Auto Musician V1.0.0 Loaded! (Stable Release)"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"====================================="); } public void ResetToDefaults() { isLooping = true; loopInterval = 2f; currentSongIndex = 0; songNames[0] = "Jingle Bells"; songSpeeds[0] = 0.22f; songContents[0] = "3 3 3 0 3 3 3 0 3 5 1 2 3 0 0 0 \n4 4 4 4 4 3 3 3 3 2 2 3 2 0 5 0 \n3 3 3 0 3 3 3 0 3 5 1 2 3 0 0 0 \n4 4 4 4 4 3 3 3 5 5 4 2 1 0 0 0 \n\n5 3 2 1 e 0 0 0 e e 3 2 1 f 0 0 0 \nf 4 3 2 g 0 0 0 5 5 4 2 3 0 0 0 \n5 3 2 1 e 0 0 0 e e 3 2 1 f 0 0 0 \nf 4 3 2 5 5 5 5 6 5 4 2 1 0 5 0 \n\n3 3 3 0 3 3 3 0 3 5 1 2 3 0 0 0 \n4 4 4 4 4 3 3 3 3 2 2 3 2 0 5 0 \n3 3 3 0 3 3 3 0 3 5 1 2 3 0 0 0 \n4 4 4 4 4 3 3 3 5 5 4 2 1 0 0 0 "; songNames[1] = "Little Star"; songSpeeds[1] = 0.5f; songContents[1] = "1 1 5 5 6 6 5 0\n 4 4 3 3 2 2 1 0 \n5 5 4 4 3 3 2 0 \n5 5 4 4 3 3 2 0 \n1 1 5 5 6 6 5 0 \n4 4 3 3 2 2 1 0 "; songNames[2] = "Funny Circus"; songSpeeds[2] = 0.13f; songContents[2] = "5 5 5 0 3 3 3 0 5 5 3 3 1 0 0 0 \n2 2 2 0 4 4 4 0 6 6 4 4 3 0 0 0 \n5 5 5 0 3 3 3 0 5 5 3 3 1 0 0 0 \n2 2 4 4 5 5 7 7 A 0 A 0 A 0 0 0 \n\na 0 A 0 a 0 A 0 b 0 B 0 b 0 B 0 \nc 0 C 0 c 0 C 0 d 0 D 0 d 0 D 0 \nE E D D C C B B A A 7 7 6 6 5 5 \n4 4 3 3 2 2 1 1 g g f f e 0 0 0 \n\n1 2 3 4 5 6 7 A B C D E F G F E \nD C B A 7 6 5 4 3 2 1 g f e d c \nc d e f g 1 2 3 4 5 6 7 A B C D \nE 0 C 0 A 0 6 0 4 0 2 0 a 0 0 0 \n\n1 0 1 0 1 0 0 0 5 0 5 0 5 0 0 0 \nA 0 G 0 F 0 E 0 D 0 C 0 B 0 A 0 \n5 0 0 0 5 0 0 0 C 0 0 0 0 0 0 0 "; for (int i = 3; i < 5; i++) { songNames[i] = $"Custom Song {i + 1}"; songSpeeds[i] = 0.25f; songContents[i] = ""; } } private void ToggleMenu() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) showMenu = !showMenu; if (showMenu) { windowRect = new Rect((float)((Screen.width - 875) / 2), (float)((Screen.height - 625) / 2), 875f, 625f); return; } GUIUtility.keyboardControl = 0; if ((Object)(object)PhysGrabber.instance != (Object)null) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } private void Update() { if (!modEnabled) { return; } if (Time.time > checkInstrumentTimer) { checkInstrumentTimer = Time.time + 0.25f; cachedInstrument = GetHeldInstrumentFast(); } if ((Object)(object)cachedInstrument != (Object)null) { if (Input.GetKeyDown((KeyCode)101) && !showMenu) { isPlaying = !isPlaying; if (isPlaying) { currentNoteIndex = 0; nextPlayTime = Time.time; } } if (isPlaying && Time.time >= nextPlayTime) { PlayNextNote(cachedInstrument); } } else if (isPlaying) { isPlaying = false; } } private void LateUpdate() { if (showMenu && (Object)(object)PhysGrabber.instance != (Object)null) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private MusicalValuableLogic GetHeldInstrumentFast() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if ((Object)(object)PhysGrabber.instance == (Object)null || grabbedField == null) { return null; } if (!(bool)grabbedField.GetValue(PhysGrabber.instance)) { return null; } PhysGrabObject val = null; if (grabbedObjField != null) { val = (PhysGrabObject)grabbedObjField.GetValue(PhysGrabber.instance); } else if (grabbedObjProp != null) { val = (PhysGrabObject)grabbedObjProp.GetValue(PhysGrabber.instance, null); } if ((Object)(object)val != (Object)null) { string text = ((Object)val).name.ToLower(); if (text.Contains("guitar") || text.Contains("piano") || text.Contains("harp")) { return ((Component)val).GetComponent<MusicalValuableLogic>(); } } return null; } private void PlayNextNote(MusicalValuableLogic instrument) { string text = songContents[currentSongIndex]; if (currentNoteIndex >= text.Length) { if (isLooping) { currentNoteIndex = 0; nextPlayTime = Time.time + loopInterval; } else { isPlaying = false; } return; } char c = text[currentNoteIndex]; currentNoteIndex++; if (c == ' ' || c == ',' || c == '\n' || c == '\r') { PlayNextNote(instrument); return; } nextPlayTime = Time.time + songSpeeds[currentSongIndex]; if (c != '0' && noteMapping.ContainsKey(c)) { int num = noteMapping[c]; PhotonView component = ((Component)instrument).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && PhotonNetwork.IsConnected && PhotonNetwork.InRoom) { component.RPC("MusicKeyPressedRPC", (RpcTarget)0, new object[2] { num, -1 }); } else { instrument.MusicKeyPressedRPC(num, -1); } } } private void OnGUI() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_00ac: 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_00cd: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) InitializeStyles(); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 284) { ToggleMenu(); Event.current.Use(); return; } if ((Object)(object)cachedInstrument != (Object)null && !showMenu) { string text = (isPlaying ? "" : "[E] Play Auto-Music"); if (!string.IsNullOrEmpty(text)) { GUI.Label(new Rect((float)(Screen.width / 2 - 200), (float)(Screen.height - 220), 400f, 50f), text, floatingTipStyle); } } if (showMenu) { windowRect = GUI.Window(999, windowRect, new WindowFunction(DrawModernMenu), "Auto Musician Menu", windowStyle); } } private void DrawModernMenu(int windowID) { //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(15f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) }); isLooping = GUILayout.Toggle(isLooping, " Loop Song\n<size=12>【循环播放】</size>", toggleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(15f); GUILayout.Label("Delay(s):\n<size=12>【循环间隔】</size>", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); if (float.TryParse(GUILayout.TextField(loopInterval.ToString("F1"), nameFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }), out var result)) { loopInterval = Mathf.Clamp(result, 0f, 10f); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset Defaults\n<size=12>【重置默认】</size>", resetBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(50f) })) { GUIUtility.keyboardControl = 0; ResetToDefaults(); } GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < 5; i++) { GUIStyle val = ((currentSongIndex == i) ? tabActiveStyle : tabNormalStyle); if (GUILayout.Button($"{i + 1}. {songNames[i]}", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(45f) })) { GUIUtility.keyboardControl = 0; currentSongIndex = i; } } GUILayout.EndHorizontal(); GUILayout.BeginVertical(editAreaStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Speed:\n<size=12>【播放速度】</size>", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); if (float.TryParse(GUILayout.TextField(songSpeeds[currentSongIndex].ToString("F2"), nameFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }), out var result2)) { songSpeeds[currentSongIndex] = Mathf.Clamp(result2, 0.05f, 2f); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.Label("Rename:\n<size=12>【歌单命名】</size>", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); songNames[currentSongIndex] = GUILayout.TextField(songNames[currentSongIndex], nameFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10f); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, Array.Empty<GUILayoutOption>()); songContents[currentSongIndex] = GUILayout.TextArea(songContents[currentSongIndex], textAreaStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.DragWindow(); } private void InitializeStyles() { //IL_0021: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Expected O, but got Unknown //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Expected O, but got Unknown //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Expected O, but got Unknown //IL_0457: Unknown result type (might be due to invalid IL or missing references) if (!stylesInitialized) { texBlack = MakeTex(2, 2, new Color(0.12f, 0.12f, 0.12f, 0.95f)); texDarkGrey = MakeTex(2, 2, new Color(0.18f, 0.18f, 0.18f, 1f)); texSkyBlue = MakeTex(2, 2, new Color(0.53f, 0.81f, 0.92f, 1f)); texDarkBlue = MakeTex(2, 2, new Color(0.25f, 0.65f, 0.85f, 1f)); windowStyle = new GUIStyle(GUI.skin.window) { richText = true }; windowStyle.normal.background = texBlack; windowStyle.onNormal.background = texBlack; windowStyle.normal.textColor = Color.white; windowStyle.fontSize = 22; windowStyle.fontStyle = (FontStyle)1; windowStyle.padding = new RectOffset(15, 15, 35, 15); labelStyle = new GUIStyle(GUI.skin.label) { richText = true }; labelStyle.normal.textColor = Color.white; labelStyle.fontSize = 20; labelStyle.fontStyle = (FontStyle)1; toggleStyle = new GUIStyle(GUI.skin.toggle) { richText = true }; toggleStyle.normal.textColor = Color.white; toggleStyle.onNormal.textColor = Color.white; toggleStyle.fontSize = 20; toggleStyle.fontStyle = (FontStyle)1; resetBtnStyle = new GUIStyle(GUI.skin.button) { richText = true }; resetBtnStyle.normal.background = texDarkGrey; resetBtnStyle.hover.background = texBlack; resetBtnStyle.normal.textColor = new Color(1f, 0.3f, 0.3f); resetBtnStyle.fontSize = 18; resetBtnStyle.fontStyle = (FontStyle)1; tabNormalStyle = new GUIStyle(GUI.skin.button) { richText = true }; tabNormalStyle.normal.background = texSkyBlue; tabNormalStyle.normal.textColor = Color.black; tabNormalStyle.fontSize = 18; tabNormalStyle.fontStyle = (FontStyle)1; tabNormalStyle.margin = new RectOffset(2, 2, 0, 0); tabActiveStyle = new GUIStyle(tabNormalStyle); tabActiveStyle.normal.background = texDarkBlue; tabActiveStyle.normal.textColor = Color.white; editAreaStyle = new GUIStyle(); editAreaStyle.normal.background = texDarkGrey; editAreaStyle.padding = new RectOffset(15, 15, 15, 15); editAreaStyle.margin = new RectOffset(0, 0, 10, 0); nameFieldStyle = new GUIStyle(GUI.skin.textField); nameFieldStyle.fontSize = 18; nameFieldStyle.fontStyle = (FontStyle)1; textAreaStyle = new GUIStyle(GUI.skin.textArea); textAreaStyle.normal.background = texBlack; textAreaStyle.normal.textColor = Color.white; textAreaStyle.fontSize = 20; textAreaStyle.padding = new RectOffset(12, 12, 12, 12); textAreaStyle.wordWrap = true; floatingTipStyle = new GUIStyle(GUI.skin.label); floatingTipStyle.alignment = (TextAnchor)4; floatingTipStyle.fontSize = 28; floatingTipStyle.fontStyle = (FontStyle)1; floatingTipStyle.normal.textColor = new Color(1f, 0.6f, 0f, 1f); stylesInitialized = true; } } private Texture2D MakeTex(int width, int height, Color col) { //IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } }