using System;
using System.Collections;
using System.Collections.Concurrent;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Instruments4Music;
using Jotunn.Utils;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;
[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: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("Instruments4Music")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Add instruments to play music.")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+3f7057c2e85c24d8ec85b96698392f0a0bb21a33")]
[assembly: AssemblyProduct("Instruments4Music")]
[assembly: AssemblyTitle("Instruments4Music")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.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;
}
}
}
public class MusicHUD : MonoBehaviour
{
public static MusicHUD instance;
private List<Image> frameRectangles = new List<Image>();
private List<Image> textRectangles = new List<Image>();
private static List<Text> buttonTips = new List<Text>();
private static List<Image> menuRectangles = new List<Image>();
private static List<Text> menuTips = new List<Text>();
private InputField inputField;
private bool isInputing = false;
private Dictionary<int, IEnumerator> currentCoroutines = new Dictionary<int, IEnumerator>();
private Dictionary<int, bool> rotateFinished = new Dictionary<int, bool>();
private void Awake()
{
if ((Object)(object)instance != (Object)null)
{
throw new Exception("More than one instance of UI!");
}
instance = this;
}
private void Start()
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: 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_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Expected O, but got Unknown
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Expected O, but got Unknown
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Expected O, but got Unknown
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_052d: Unknown result type (might be due to invalid IL or missing references)
//IL_0544: Unknown result type (might be due to invalid IL or missing references)
//IL_0576: Unknown result type (might be due to invalid IL or missing references)
//IL_057d: Expected O, but got Unknown
//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0610: Unknown result type (might be due to invalid IL or missing references)
//IL_0628: Unknown result type (might be due to invalid IL or missing references)
//IL_062d: Unknown result type (might be due to invalid IL or missing references)
//IL_0637: Unknown result type (might be due to invalid IL or missing references)
//IL_0654: Unknown result type (might be due to invalid IL or missing references)
//IL_065b: Expected O, but got Unknown
//IL_068c: Unknown result type (might be due to invalid IL or missing references)
//IL_06be: Unknown result type (might be due to invalid IL or missing references)
//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0703: Unknown result type (might be due to invalid IL or missing references)
GameObject hudInstance = Instruments4MusicPlugin.instance.hudInstance;
Button[] componentsInChildren = hudInstance.GetComponentsInChildren<Button>();
Image[] itemSlotIconFrames = Instruments4MusicPlugin.instance.hudManager.itemSlotIconFrames;
Instruments4MusicPlugin.AddLog("Draw MusicHUD");
frameRectangles.Clear();
textRectangles.Clear();
buttonTips.Clear();
menuRectangles.Clear();
menuTips.Clear();
Button[] array = componentsInChildren;
Rect rect;
foreach (Button val in array)
{
RectTransform component = ((Component)val).GetComponent<RectTransform>();
int num = Random.Range(0, itemSlotIconFrames.Length);
Image val2 = itemSlotIconFrames[num];
GameObject val3 = new GameObject("FrameRectangle");
val3.transform.SetParent(((Component)val).transform, false);
Image val4 = val3.AddComponent<Image>();
((Graphic)val4).color = Color32.op_Implicit(new Color32((byte)254, (byte)73, (byte)0, byte.MaxValue));
val4.sprite = val2.sprite;
RectTransform component2 = val3.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 0f);
component2.anchorMax = new Vector2(1f, 1f);
component2.sizeDelta = new Vector2(0f, 0f);
component2.anchoredPosition = new Vector2(0f, 0f);
frameRectangles.Add(val4);
GameObject val5 = new GameObject("TextRectangle");
val5.transform.SetParent(((Component)val).transform, false);
Image val6 = val5.AddComponent<Image>();
((Graphic)val6).color = Color32.op_Implicit(new Color32((byte)254, (byte)73, (byte)0, (byte)128));
RectTransform component3 = val5.GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0.3f, 0.3f);
component3.anchorMax = new Vector2(0.7f, 0.7f);
component3.offsetMin = new Vector2(0f, 0f);
component3.offsetMax = new Vector2(0f, 0f);
rect = component.rect;
component3.anchoredPosition = new Vector2(0f, -0.5f * ((Rect)(ref rect)).height);
textRectangles.Add(val6);
GameObject val7 = new GameObject("ButtonTip");
val7.transform.SetParent(val5.transform, false);
Text val8 = val7.AddComponent<Text>();
rect = component3.rect;
val8.fontSize = (int)(0.8f * ((Rect)(ref rect)).height);
val8.text = "A";
((Graphic)val8).color = Color.white;
val8.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
val8.alignment = (TextAnchor)4;
val8.fontStyle = (FontStyle)1;
RectTransform component4 = val7.GetComponent<RectTransform>();
component4.anchorMin = new Vector2(0f, 0f);
component4.anchorMax = new Vector2(1f, 1f);
component4.sizeDelta = new Vector2(0f, 0f);
component4.anchoredPosition = new Vector2(0f, 0f);
buttonTips.Add(val8);
}
RectTransform component5 = hudInstance.GetComponent<RectTransform>();
for (int j = 0; j < 5; j++)
{
GameObject val9 = new GameObject("MenuRectangle");
val9.transform.SetParent(hudInstance.transform, false);
Image val10 = val9.AddComponent<Image>();
((Graphic)val10).color = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0));
RectTransform component6 = val9.GetComponent<RectTransform>();
component6.anchorMin = new Vector2(0.41f, 0.46f);
component6.anchorMax = new Vector2(0.59f, 0.54f);
component6.offsetMin = new Vector2(0f, 0f);
component6.offsetMax = new Vector2(0f, 0f);
float num2 = (float)(j - 2) * 0.2f;
rect = component5.rect;
float num3 = num2 * ((Rect)(ref rect)).width;
rect = component5.rect;
component6.anchoredPosition = new Vector2(num3, -0.4f * ((Rect)(ref rect)).height);
menuRectangles.Add(val10);
GameObject val11 = new GameObject("MenuTip");
val11.transform.SetParent(val9.transform, false);
Text val12 = val11.AddComponent<Text>();
rect = component5.rect;
val12.fontSize = (int)(0.04f * ((Rect)(ref rect)).height);
val12.text = "Text";
((Graphic)val12).color = new Color(1f, 1f, 1f, 0.5f);
val12.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
val12.alignment = (TextAnchor)4;
RectTransform component7 = val11.GetComponent<RectTransform>();
component7.anchorMin = new Vector2(0f, 0f);
component7.anchorMax = new Vector2(1f, 1f);
component7.sizeDelta = new Vector2(0f, 0f);
component7.anchoredPosition = new Vector2(0f, 0f);
menuTips.Add(val12);
}
GameObject val13 = new GameObject("InputField");
val13.transform.SetParent(hudInstance.transform, false);
Image val14 = val13.AddComponent<Image>();
((Graphic)val14).color = Color32.op_Implicit(new Color32((byte)254, (byte)73, (byte)0, (byte)80));
RectTransform component8 = val13.GetComponent<RectTransform>();
component8.anchorMin = new Vector2(0.2f, 0.46f);
component8.anchorMax = new Vector2(0.8f, 0.54f);
component8.offsetMin = new Vector2(0f, 0f);
component8.offsetMax = new Vector2(0f, 0f);
rect = component5.rect;
component8.anchoredPosition = new Vector2(0f, 0.4f * ((Rect)(ref rect)).height);
inputField = val13.AddComponent<InputField>();
GameObject val15 = new GameObject("InputText");
val15.transform.SetParent(val13.transform, false);
Text val16 = val15.AddComponent<Text>();
inputField.text = "Press Enter to input music note...";
((Graphic)val16).color = Color.white;
val16.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
RectTransform component9 = val15.GetComponent<RectTransform>();
component9.anchorMin = new Vector2(0f, 0f);
component9.anchorMax = new Vector2(1f, 1f);
component9.offsetMin = new Vector2(10f, 10f);
component9.offsetMax = new Vector2(-10f, -10f);
inputField.textComponent = val16;
Instruments4MusicPlugin.AddLog("Draw MusicHUD success");
}
public static void ShowUserInterface()
{
UpdateButtonTips();
menuTips[0].text = "Quit: " + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.CurtainCall);
menuTips[1].text = "Soft: " + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.Soft);
menuTips[2].text = "Semi: " + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.Semitone);
menuTips[3].text = "Sustain: " + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.Sustain);
menuTips[4].text = "Switch: " + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.ChangeMode);
Instruments4MusicPlugin.instance.hudManager.PingHUDElement(Instruments4MusicPlugin.instance.hudElement, 0f, 0f, 1f);
}
public static void UpdateButtonTips()
{
Instruments4MusicPlugin.AddLog("Load key binds");
string[] array = (TuneAudioScript.secondaryKeyBind ? new string[21]
{
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowCKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowDKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowEKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowFKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowGKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowAKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowBKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidCKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidDKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidEKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidFKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidGKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidAKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidBKey2),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighCKey2),
"",
"",
"",
"",
"",
""
} : new string[21]
{
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowCKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowDKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowEKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowFKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowGKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowAKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.LowBKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidCKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidDKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidEKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidFKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidGKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidAKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.MidBKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighCKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighDKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighEKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighFKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighGKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighAKey),
InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.HighBKey)
});
for (int i = 0; i < array.Length; i++)
{
buttonTips[i].text = array[i];
}
Instruments4MusicPlugin.AddLog("Load key binds success");
}
public static void HideUserInterface()
{
Instruments4MusicPlugin.instance.hudManager.PingHUDElement(Instruments4MusicPlugin.instance.hudElement, 0f, 1f, 0f);
}
private IEnumerator RotateOverTime(int noteNumber, RectTransform rectTransform)
{
Image textImage = textRectangles[noteNumber];
Color textImageColor = ((Graphic)textImage).color;
textImageColor.a = 1f;
((Graphic)textImage).color = textImageColor;
float endRotation = 180f;
float originRotation = 0f;
float speed = 360f;
Quaternion rotation;
while (true)
{
rotation = ((Transform)rectTransform).rotation;
if (!(((Quaternion)(ref rotation)).eulerAngles.y < endRotation))
{
break;
}
float step = speed * Time.deltaTime;
rotation = ((Transform)rectTransform).rotation;
float newAngle = Mathf.Min(((Quaternion)(ref rotation)).eulerAngles.y + step, endRotation);
((Transform)rectTransform).rotation = Quaternion.Euler(((Transform)rectTransform).eulerAngles.x, newAngle, ((Transform)rectTransform).eulerAngles.z);
yield return null;
}
textImageColor.a = 0.5f;
((Graphic)textImage).color = textImageColor;
rotateFinished[noteNumber] = true;
while (true)
{
rotation = ((Transform)rectTransform).rotation;
if (((Quaternion)(ref rotation)).eulerAngles.y > originRotation)
{
float step2 = speed * Time.deltaTime;
rotation = ((Transform)rectTransform).rotation;
float newAngle2 = Mathf.Max(((Quaternion)(ref rotation)).eulerAngles.y - step2, originRotation);
((Transform)rectTransform).rotation = Quaternion.Euler(((Transform)rectTransform).eulerAngles.x, newAngle2, ((Transform)rectTransform).eulerAngles.z);
yield return null;
continue;
}
break;
}
}
public void OnButtonClicked(int num)
{
int num2 = NoteNumberConvert(num);
if (!rotateFinished.ContainsKey(num2) || rotateFinished[num2])
{
if (currentCoroutines.TryGetValue(num2, out IEnumerator value))
{
((MonoBehaviour)this).StopCoroutine(value);
}
rotateFinished[num2] = false;
currentCoroutines[num2] = RotateOverTime(num2, ((Graphic)frameRectangles[num2]).rectTransform);
((MonoBehaviour)this).StartCoroutine(currentCoroutines[num2]);
}
}
public void OnMenuClicked(int num, bool isHolding)
{
//IL_001c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
float num2 = (isHolding ? 1f : 0f);
Color32 val = Color32.op_Implicit(((Graphic)menuRectangles[num]).color);
val.a = (byte)(num2 * 255f);
((Graphic)menuRectangles[num]).color = Color32.op_Implicit(val);
}
private int NoteNumberConvert(int num)
{
int[] array = new int[12]
{
0, 0, 1, 1, 2, 3, 3, 4, 4, 5,
5, 6
};
return num / 12 * 7 + array[num % 12];
}
public void TriggerInputNote()
{
if (isInputing)
{
inputField.DeactivateInputField();
isInputing = false;
Instruments4MusicPlugin.AddLog("Input stop, get note: " + inputField.text + ".");
}
else
{
Instruments4MusicPlugin.AddLog("Input start.");
inputField.ActivateInputField();
isInputing = true;
}
}
}
namespace Instruments4Music
{
public class Config
{
public static ConfigEntry<bool>? configActiveHorn;
public static ConfigEntry<float>? configHUDScale;
public static void Load()
{
ConfigFile? config = Instruments4MusicPlugin.config;
configActiveHorn = ((config != null) ? config.Bind<bool>("InstrumentsActive", "ActiveHorn", true, "Active \"Horn\" as an instrument.") : null);
ConfigFile? config2 = Instruments4MusicPlugin.config;
configHUDScale = ((config2 != null) ? config2.Bind<float>("InstrumentsHUD", "HUDScale", 1f, "Scale the music HUD.") : null);
}
}
public class InputActions : LcInputActions
{
[InputAction("<Keyboard>/backspace", Name = "Showtime!", ActionId = "Showtime", KbmInteractions = "hold(duration = 2)")]
public InputAction? Showtime { get; set; }
[InputAction("<Keyboard>/escape", Name = "Curtain Call", ActionId = "CurtainCall")]
public InputAction? CurtainCall { get; set; }
[InputAction("<Keyboard>/leftShift", Name = "Semitone", ActionId = "Semitone")]
public InputAction? Semitone { get; set; }
[InputAction("<Keyboard>/space", Name = "Sustain", ActionId = "Sustain")]
public InputAction? Sustain { get; set; }
[InputAction("<Keyboard>/leftCtrl", Name = "Soft", ActionId = "Soft")]
public InputAction? Soft { get; set; }
[InputAction("<Keyboard>/tab", Name = "Change Mode", ActionId = "ChangeMode")]
public InputAction? ChangeMode { get; set; }
[InputAction("<Keyboard>/enter", Name = "Input Note", ActionId = "InputNote")]
public InputAction? InputNote { get; set; }
[InputAction("<Keyboard>/q", Name = "High C", ActionId = "HighC")]
public InputAction? HighCKey { get; set; }
[InputAction("<Keyboard>/w", Name = "High D", ActionId = "HighD")]
public InputAction? HighDKey { get; set; }
[InputAction("<Keyboard>/e", Name = "High E", ActionId = "HighE")]
public InputAction? HighEKey { get; set; }
[InputAction("<Keyboard>/r", Name = "High F", ActionId = "HighF")]
public InputAction? HighFKey { get; set; }
[InputAction("<Keyboard>/t", Name = "High G", ActionId = "HighG")]
public InputAction? HighGKey { get; set; }
[InputAction("<Keyboard>/y", Name = "High A", ActionId = "HighA")]
public InputAction? HighAKey { get; set; }
[InputAction("<Keyboard>/u", Name = "High B", ActionId = "HighB")]
public InputAction? HighBKey { get; set; }
[InputAction("<Keyboard>/a", Name = "Mid C", ActionId = "MidC")]
public InputAction? MidCKey { get; set; }
[InputAction("<Keyboard>/s", Name = "Mid D", ActionId = "MidD")]
public InputAction? MidDKey { get; set; }
[InputAction("<Keyboard>/d", Name = "Mid E", ActionId = "MidE")]
public InputAction? MidEKey { get; set; }
[InputAction("<Keyboard>/f", Name = "Mid F", ActionId = "MidF")]
public InputAction? MidFKey { get; set; }
[InputAction("<Keyboard>/g", Name = "Mid G", ActionId = "MidG")]
public InputAction? MidGKey { get; set; }
[InputAction("<Keyboard>/h", Name = "Mid A", ActionId = "MidA")]
public InputAction? MidAKey { get; set; }
[InputAction("<Keyboard>/j", Name = "Mid B", ActionId = "MidB")]
public InputAction? MidBKey { get; set; }
[InputAction("<Keyboard>/z", Name = "Low C", ActionId = "LowC")]
public InputAction? LowCKey { get; set; }
[InputAction("<Keyboard>/x", Name = "Low D", ActionId = "LowD")]
public InputAction? LowDKey { get; set; }
[InputAction("<Keyboard>/c", Name = "Low E", ActionId = "LowE")]
public InputAction? LowEKey { get; set; }
[InputAction("<Keyboard>/v", Name = "Low F", ActionId = "LowF")]
public InputAction? LowFKey { get; set; }
[InputAction("<Keyboard>/b", Name = "Low G", ActionId = "LowG")]
public InputAction? LowGKey { get; set; }
[InputAction("<Keyboard>/n", Name = "Low A", ActionId = "LowA")]
public InputAction? LowAKey { get; set; }
[InputAction("<Keyboard>/m", Name = "Low B", ActionId = "LowB")]
public InputAction? LowBKey { get; set; }
[InputAction("<Keyboard>/y", Name = "Low C2", ActionId = "LowC2")]
public InputAction? LowCKey2 { get; set; }
[InputAction("<Keyboard>/u", Name = "Low D2", ActionId = "LowD2")]
public InputAction? LowDKey2 { get; set; }
[InputAction("<Keyboard>/i", Name = "Low E2", ActionId = "LowE2")]
public InputAction? LowEKey2 { get; set; }
[InputAction("<Keyboard>/o", Name = "Low F2", ActionId = "LowF2")]
public InputAction? LowFKey2 { get; set; }
[InputAction("<Keyboard>/p", Name = "Low G2", ActionId = "LowG2")]
public InputAction? LowGKey2 { get; set; }
[InputAction("<Keyboard>/h", Name = "Low A2", ActionId = "LowA2")]
public InputAction? LowAKey2 { get; set; }
[InputAction("<Keyboard>/j", Name = "Low B2", ActionId = "LowB2")]
public InputAction? LowBKey2 { get; set; }
[InputAction("<Keyboard>/k", Name = "Mid C2", ActionId = "MidC2")]
public InputAction? MidCKey2 { get; set; }
[InputAction("<Keyboard>/l", Name = "Mid D2", ActionId = "MidD2")]
public InputAction? MidDKey2 { get; set; }
[InputAction("<Keyboard>/semicolon", Name = "Mid E2", ActionId = "MidE2")]
public InputAction? MidEKey2 { get; set; }
[InputAction("<Keyboard>/n", Name = "Mid F2", ActionId = "MidF2")]
public InputAction? MidFKey2 { get; set; }
[InputAction("<Keyboard>/m", Name = "Mid G2", ActionId = "MidG2")]
public InputAction? MidGKey2 { get; set; }
[InputAction("<Keyboard>/comma", Name = "Mid A2", ActionId = "MidA2")]
public InputAction? MidAKey2 { get; set; }
[InputAction("<Keyboard>/period", Name = "Mid B2", ActionId = "MidB2")]
public InputAction? MidBKey2 { get; set; }
[InputAction("<Keyboard>/slash", Name = "High C2", ActionId = "HighC2")]
public InputAction? HighCKey2 { get; set; }
public static string GetButtonDescription(InputAction action)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_0074: Unknown result type (might be due to invalid IL or missing references)
bool localPlayerUsingController = StartOfRound.Instance.localPlayerUsingController;
InputBinding? val = null;
Enumerator<InputBinding> enumerator = action.bindings.GetEnumerator();
try
{
if (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (localPlayerUsingController || (!((InputBinding)(ref current)).effectivePath.StartsWith("<Keyboard>") && !((InputBinding)(ref current)).effectivePath.StartsWith("<Mouse>")))
{
return "";
}
val = current;
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
object obj;
if (!val.HasValue)
{
obj = "";
}
else
{
InputBinding value = val.Value;
obj = ((InputBinding)(ref value)).effectivePath;
}
string text = (string)obj;
string[] array = text.Split("/");
string text2 = ((array.Length > 1) ? text : "");
if (1 == 0)
{
}
string result;
switch (text2)
{
case "<Mouse>/leftButton":
result = "LΜB";
break;
case "<Mouse>/rightButton":
result = "RΜB";
break;
case "<Keyboard>/escape":
result = "ESC";
break;
case "<Keyboard>/semicolon":
result = ";";
break;
case "<Keyboard>/comma":
result = ",";
break;
case "<Keyboard>/period":
result = ".";
break;
case "<Keyboard>/slash":
result = "/";
break;
default:
{
object obj2;
if (array.Length <= 1)
{
obj2 = "?";
}
else
{
string text3 = array[1].Substring(0, 1).ToUpper();
string text4 = array[1];
obj2 = text3 + text4.Substring(1, text4.Length - 1);
}
result = (string)obj2;
break;
}
}
if (1 == 0)
{
}
return result;
}
}
[BepInPlugin("com.bean.Instruments4Music", "Instruments4Music", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("Lethal Company.exe")]
public class Instruments4MusicPlugin : BaseUnityPlugin
{
public static Instruments4MusicPlugin instance;
internal static ManualLogSource? logger;
public static ConfigFile? config;
internal static InputActions inputActionsInstance = new InputActions();
public AssetBundle assets;
private readonly Harmony harmony = new Harmony("com.bean.Instruments4Music");
public GameObject hudPrefab;
public GameObject hudInstance;
public HUDManager hudManager;
public HUDElement hudElement;
public float hudScale = 0.45f;
public static void AddLog(string str)
{
ManualLogSource? obj = logger;
if (obj != null)
{
obj.LogInfo((object)str);
}
}
private void Awake()
{
if ((Object)(object)instance != (Object)null)
{
throw new Exception("More than 1 plugin instance.");
}
instance = this;
logger = ((BaseUnityPlugin)this).Logger;
AddLog("Plugin com.bean.Instruments4Music is loaded!");
assets = AssetUtils.LoadAssetBundleFromResources("musichud", typeof(HUDPatches).Assembly);
hudPrefab = assets.LoadAsset<GameObject>("MusicPanel");
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ref StartOfRound __instance)
{
ManualCameraRenderer mapScreen = __instance.mapScreen;
object obj;
if (mapScreen == null)
{
obj = null;
}
else
{
MeshRenderer mesh = mapScreen.mesh;
obj = ((mesh != null) ? ((Component)mesh).gameObject : null);
}
GameObject val = (GameObject)obj;
if (!((Object)(object)val == (Object)null))
{
if ((Object)(object)val.GetComponent<StationaryScript>() == (Object)null)
{
val.AddComponent<StationaryScript>();
Instruments4MusicPlugin.AddLog("StationaryScript Added");
}
if ((Object)(object)val.GetComponent<PortableScript>() == (Object)null)
{
val.AddComponent<PortableScript>();
Instruments4MusicPlugin.AddLog("PortableScript Added");
}
if ((Object)(object)val.GetComponent<TuneAudioScript>() == (Object)null)
{
val.AddComponent<TuneAudioScript>();
Instruments4MusicPlugin.AddLog("TuneAudioScript Added");
}
if ((Object)(object)val.GetComponent<MusicHUD>() == (Object)null)
{
val.AddComponent<MusicHUD>();
Instruments4MusicPlugin.AddLog("MusicHUD Added");
}
}
}
}
[HarmonyPatch(typeof(HUDManager))]
public class HUDPatches
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake_Postfix(HUDManager __instance)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
Instruments4MusicPlugin.instance.hudManager = __instance;
HUDElement[] privateField = __instance.GetPrivateField<HUDElement[]>("HUDElements");
GameObject val = Object.Instantiate<GameObject>(Instruments4MusicPlugin.instance.hudPrefab, ((Component)privateField[0].canvasGroup).transform.parent);
Instruments4MusicPlugin.instance.hudInstance = val;
val.transform.localScale = new Vector3(1f, 1f, 1f) * Instruments4MusicPlugin.instance.hudScale;
Instruments4MusicPlugin.AddLog("MusicHUD Instantiated");
HUDElement val2 = new HUDElement();
Instruments4MusicPlugin.instance.hudElement = val2;
CanvasGroup canvasGroup = val.GetComponent<CanvasGroup>() ?? val.AddComponent<CanvasGroup>();
val2.canvasGroup = canvasGroup;
__instance.PingHUDElement(val2, 0f, 0f, 0f);
HUDElement[] array = privateField;
List<HUDElement> list = new List<HUDElement>(1 + array.Length);
HUDElement[] array2 = array;
foreach (HUDElement item in array2)
{
list.Add(item);
}
list.Add(val2);
List<HUDElement> list2 = list;
List<HUDElement> list3 = list2;
int num = 0;
HUDElement[] array3 = (HUDElement[])(object)new HUDElement[list3.Count];
foreach (HUDElement item2 in list3)
{
array3[num] = item2;
num++;
}
privateField = array3;
((object)__instance).GetType().GetField("HUDElements", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, privateField);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.bean.Instruments4Music";
public const string PLUGIN_NAME = "Instruments4Music";
public const string PLUGIN_VERSION = "1.0.0";
}
public class PortableScript : MonoBehaviour
{
private const int InteractableObjectsMask = 512;
private static PlayerControllerB? Player => GameNetworkManager.Instance?.localPlayerController;
public static bool IsHoldingInstrument(out GameObject? instrumentObj)
{
if ((Object)(object)Player != (Object)null)
{
PlayerControllerB player = Player;
if (((player != null && ((NetworkBehaviour)player).IsOwner && player.isPlayerControlled && (!((NetworkBehaviour)Player).IsServer || Player.isHostPlayerObject)) || Player.isTestingPlayer) && Player.isHoldingObject && !((Object)(object)Player.currentlyHeldObjectServer == (Object)null) && !Player.quickMenuManager.isMenuOpen && !Player.isPlayerDead)
{
if (!Player.currentlyHeldObjectServer.itemProperties.usableInSpecialAnimations)
{
player = Player;
if (player == null || player.isGrabbingObjectAnimation || player.inTerminalMenu || player.isTypingChat || (Player.inSpecialInteractAnimation && !Player.inShockingMinigame))
{
goto IL_00f1;
}
}
GrabbableObject currentlyHeldObjectServer = Player.currentlyHeldObjectServer;
instrumentObj = ((currentlyHeldObjectServer != null) ? ((Component)currentlyHeldObjectServer).gameObject : null);
return (Object)(object)instrumentObj != (Object)null;
}
}
goto IL_00f1;
IL_00f1:
instrumentObj = null;
return false;
}
public static void LetShowBegins(GameObject instrumentObj)
{
WhoopieCushionItem component = instrumentObj.GetComponent<WhoopieCushionItem>();
if ((Object)(object)component != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component).name);
TuneAudioScript.RegisterInstrClip(instrumentObj, 17, component.fartAudios[Random.Range(0, component.fartAudios.Length)], isLoop: false);
return;
}
NoisemakerProp component2 = instrumentObj.GetComponent<NoisemakerProp>();
if ((Object)(object)component2 != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component2).name);
AudioClip val = null;
if ((Object)(object)component2.noiseAudio.clip != (Object)null)
{
val = component2.noiseAudio.clip;
}
else if (component2.noiseSFX.Length != 0)
{
val = component2.noiseSFX[0];
}
if ((Object)(object)val != (Object)null)
{
TuneAudioScript.RegisterInstrClip(instrumentObj, 17, val, isLoop: false);
return;
}
}
GrabbableObject component3 = instrumentObj.GetComponent<GrabbableObject>();
if ((Object)(object)component3 != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component3).name);
AudioClip val2 = null;
if ((Object)(object)component3.itemProperties.dropSFX != (Object)null)
{
val2 = component3.itemProperties.dropSFX;
}
else if ((Object)(object)component3.itemProperties.grabSFX != (Object)null)
{
val2 = component3.itemProperties.grabSFX;
}
else if ((Object)(object)component3.itemProperties.pocketSFX != (Object)null)
{
val2 = component3.itemProperties.pocketSFX;
}
else if ((Object)(object)component3.itemProperties.throwSFX != (Object)null)
{
val2 = component3.itemProperties.throwSFX;
}
if ((Object)(object)val2 != (Object)null)
{
TuneAudioScript.RegisterInstrClip(instrumentObj, 17, val2, isLoop: false);
}
}
}
public void Update()
{
if (!((Object)(object)Player == (Object)null) && !TuneAudioScript.theShowIsOn && IsHoldingInstrument(out GameObject instrumentObj))
{
GrabbableObject val = ((instrumentObj != null) ? instrumentObj.GetComponent<GrabbableObject>() : null);
if (!((Object)(object)val == (Object)null))
{
string text = "Showtime!: [" + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.Showtime) + "] (Hold)";
HUDManager.Instance.ChangeControlTipMultiple(CollectionExtensions.AddToArray<string>(val.itemProperties.toolTips, text), true, val.itemProperties);
}
}
}
}
internal static class ReflectionUtils
{
public static T GetPrivateField<T>(this object obj, string field)
{
return (T)obj.GetType().GetField(field, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
}
}
public class StationaryScript : MonoBehaviour
{
private const int InteractableObjectsMask = 512;
private static PlayerControllerB? Player => GameNetworkManager.Instance?.localPlayerController;
public static bool IsLookingAtInstrument(out GameObject? instrumentObj)
{
//IL_002f: 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)
//IL_0069: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player == (Object)null)
{
instrumentObj = null;
return false;
}
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)Player.gameplayCamera).transform.position, ((Component)Player.gameplayCamera).transform.forward);
if (Player.isTypingChat)
{
instrumentObj = null;
return false;
}
RaycastHit val2 = default(RaycastHit);
if (!Physics.Raycast(val, ref val2, Player.grabDistance, 512, (QueryTriggerInteraction)1) && !Physics.Raycast(((Component)Player.gameplayCamera).transform.position + Vector3.up * 5f, Vector3.down, ref val2, 5f, 512, (QueryTriggerInteraction)1))
{
instrumentObj = null;
return false;
}
instrumentObj = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
if ((Object)(object)instrumentObj == (Object)null)
{
instrumentObj = null;
return false;
}
ShipAlarmCord component = instrumentObj.GetComponent<ShipAlarmCord>();
if ((Object)(object)component != (Object)null)
{
return true;
}
ItemCharger component2 = instrumentObj.GetComponent<ItemCharger>();
if ((Object)(object)component2 != (Object)null)
{
return true;
}
AnimatedObjectTrigger component3 = instrumentObj.GetComponent<AnimatedObjectTrigger>();
if ((Object)(object)component3 != (Object)null)
{
return true;
}
return false;
}
public static void LetShowBegins(GameObject instrumentObj)
{
ShipAlarmCord component = instrumentObj.GetComponent<ShipAlarmCord>();
if ((Object)(object)component != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component).name);
TuneAudioScript.RegisterInstrClip(instrumentObj, 8, component.hornClose.clip, isLoop: true);
return;
}
ItemCharger component2 = instrumentObj.GetComponent<ItemCharger>();
if ((Object)(object)component2 != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component2).name);
TuneAudioScript.RegisterInstrClip(instrumentObj, 8, component2.zapAudio.clip, isLoop: false);
return;
}
AnimatedObjectTrigger component3 = instrumentObj.GetComponent<AnimatedObjectTrigger>();
if ((Object)(object)component3 != (Object)null)
{
Instruments4MusicPlugin.AddLog("Playing " + ((Object)component3).name);
AudioClip val = null;
if ((Object)(object)component3.thisAudioSource.clip != (Object)null)
{
val = component3.thisAudioSource.clip;
}
else if ((Object)(object)component3.playWhileTrue != (Object)null)
{
val = component3.playWhileTrue;
}
else if (component3.boolTrueAudios.Length != 0)
{
val = component3.boolTrueAudios[0];
}
else if (component3.boolFalseAudios.Length != 0)
{
val = component3.boolFalseAudios[0];
}
else if (component3.secondaryAudios.Length != 0)
{
val = component3.secondaryAudios[0];
}
if ((Object)(object)val != (Object)null)
{
TuneAudioScript.RegisterInstrClip(instrumentObj, 17, val, isLoop: false);
}
}
}
public void Update()
{
if (TuneAudioScript.theShowIsOn || !IsLookingAtInstrument(out GameObject instrumentObj) || (Object)(object)Player == (Object)null)
{
return;
}
string text = "Showtime!: [" + InputActions.GetButtonDescription(Instruments4MusicPlugin.inputActionsInstance.Showtime) + "] (Hold)";
InteractTrigger val = ((instrumentObj != null) ? instrumentObj.GetComponent<InteractTrigger>() : null);
if (!((Object)(object)val == (Object)null) && !val.hoverTip.EndsWith(text))
{
val.hoverTip = val.hoverTip + "\n" + text;
Regex regex = new Regex("Showtime!: \\[.*?] \\(Hold\\)$");
if (regex.IsMatch(val.hoverTip))
{
val.hoverTip = regex.Replace(val.hoverTip, text);
}
else
{
val.hoverTip = val.hoverTip + "\n" + text;
}
}
}
}
public class TuneAudioScript : MonoBehaviour
{
private const double TuneCoeff = 1.0594630241394043;
private static float lastTimer = 3f;
private static float attenuationCoeff = 2f;
private static float softModifier = 0.5f;
private static float sustainModifier = 4f;
private static Dictionary<string, (AudioClip, int, bool)> InstrDictionary = new Dictionary<string, (AudioClip, int, bool)>();
private static Dictionary<(string, int), AudioSource> TunedDictionary = new Dictionary<(string, int), AudioSource>();
private static ConcurrentDictionary<(string, int), float> TimerDictionary = new ConcurrentDictionary<(string, int), float>();
public static bool theShowIsOn = false;
public static bool secondaryKeyBind = false;
public static bool keyBindInit = false;
public static string activeClipName = "";
public static GameObject? activeInstrObject;
private static PlayerControllerB? Player => GameNetworkManager.Instance?.localPlayerController;
public static void RegisterInstrClip(GameObject gameObject, int sourceNoteNumber, AudioClip clip, bool isLoop)
{
foreach (KeyValuePair<(string, int), AudioSource> item in TunedDictionary)
{
AudioSource value = item.Value;
if (value != null)
{
value.Stop();
}
}
TunedDictionary.Clear();
Instruments4MusicPlugin.AddLog("TunedDictionary clear.");
InstrDictionary[((Object)clip).name] = (clip, sourceNoteNumber, isLoop);
activeClipName = ((Object)clip).name;
activeInstrObject = gameObject;
theShowIsOn = true;
OnDisable();
if ((Object)(object)Player != (Object)null)
{
Player.inTerminalMenu = true;
}
MusicHUD.ShowUserInterface();
Instruments4MusicPlugin.AddLog("Playing " + activeClipName + ".");
}
public static void DeActiveInstrument()
{
theShowIsOn = false;
OnEnable();
if ((Object)(object)Player != (Object)null)
{
Player.inTerminalMenu = false;
}
MusicHUD.HideUserInterface();
Instruments4MusicPlugin.AddLog("DeActive " + activeClipName + ".");
}
public static void PlayTunedAudio(int targetNoteNumber, bool isSoft, bool newPulse)
{
Instruments4MusicPlugin.AddLog($"Playing note {targetNoteNumber}, softer: {isSoft}.");
MusicHUD.instance.OnButtonClicked(targetNoteNumber);
TimerDictionary[(activeClipName, targetNoteNumber)] = lastTimer;
float num = 1f;
if (isSoft)
{
num -= softModifier;
}
(AudioClip, int, bool) value2;
if (TunedDictionary.TryGetValue((activeClipName, targetNoteNumber), out AudioSource value))
{
value.volume = num;
if (newPulse)
{
value.Play();
}
}
else if (InstrDictionary.TryGetValue(activeClipName, out value2))
{
AudioClip item = value2.Item1;
int item2 = value2.Item2;
bool item3 = value2.Item3;
int num2 = targetNoteNumber - item2;
GameObject? obj = activeInstrObject;
value = ((obj != null) ? obj.AddComponent<AudioSource>() : null);
if (!((Object)(object)value == (Object)null))
{
value.clip = item;
value.pitch = (float)Math.Pow(1.0594630241394043, num2);
value.volume = num;
value.loop = item3;
TunedDictionary.Add((activeClipName, targetNoteNumber), value);
value.Play();
}
}
}
public static void AudioCountDown(bool isSustain)
{
foreach (var key in TimerDictionary.Keys)
{
float num = TimerDictionary[key];
if (TunedDictionary.TryGetValue(key, out AudioSource value) && num >= 0f && value.volume > 0.01f)
{
if (isSustain)
{
TimerDictionary[key] = num - Time.deltaTime / sustainModifier;
value.volume = (float)((double)value.volume * Math.Exp((0f - attenuationCoeff) * Time.deltaTime / sustainModifier));
}
else
{
TimerDictionary[key] = num - Time.deltaTime;
value.volume = (float)((double)value.volume * Math.Exp((0f - attenuationCoeff) * Time.deltaTime));
}
}
else
{
if (value != null)
{
value.Stop();
}
TimerDictionary.Remove(key, out var _);
}
}
}
private static void OnEnable()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
MovementActions movement = Player.playerActions.Movement;
((MovementActions)(ref movement)).Enable();
}
catch (Exception arg)
{
Debug.LogError((object)$"Error while subscribing to input in PlayerController!: {arg}");
}
}
private static void OnDisable()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
try
{
MovementActions movement = Player.playerActions.Movement;
((MovementActions)(ref movement)).Enable();
}
catch (Exception arg)
{
Debug.LogError((object)$"Error while unsubscribing from input in PlayerController!: {arg}");
}
}
public void Awake()
{
InstrDictionary = new Dictionary<string, (AudioClip, int, bool)>();
TunedDictionary = new Dictionary<(string, int), AudioSource>();
TimerDictionary = new ConcurrentDictionary<(string, int), float>();
theShowIsOn = false;
secondaryKeyBind = false;
activeClipName = "";
if (!keyBindInit)
{
SetupKeyBindCallbacks();
keyBindInit = !keyBindInit;
}
}
public void SetupKeyBindCallbacks()
{
Instruments4MusicPlugin.inputActionsInstance.Showtime.performed += OnShowtimePressed;
Instruments4MusicPlugin.inputActionsInstance.CurtainCall.performed += OnCurtainCallPressed;
Instruments4MusicPlugin.inputActionsInstance.ChangeMode.performed += OnChangeModePressed;
Instruments4MusicPlugin.inputActionsInstance.InputNote.performed += OnInputNotePressed;
}
public void OnShowtimePressed(CallbackContext showtimeContext)
{
if (theShowIsOn || !((CallbackContext)(ref showtimeContext)).performed)
{
return;
}
if (StationaryScript.IsLookingAtInstrument(out GameObject instrumentObj))
{
if (!((Object)(object)instrumentObj == (Object)null))
{
Instruments4MusicPlugin.AddLog("It's show time!");
StationaryScript.LetShowBegins(instrumentObj);
}
}
else if (PortableScript.IsHoldingInstrument(out instrumentObj) && !((Object)(object)instrumentObj == (Object)null))
{
Instruments4MusicPlugin.AddLog("It's show time!");
PortableScript.LetShowBegins(instrumentObj);
}
}
public void OnCurtainCallPressed(CallbackContext curtainCallContext)
{
if (theShowIsOn && ((CallbackContext)(ref curtainCallContext)).performed)
{
Instruments4MusicPlugin.AddLog("Maybe next time.");
DeActiveInstrument();
}
}
public void OnChangeModePressed(CallbackContext changeModeContext)
{
if (theShowIsOn && ((CallbackContext)(ref changeModeContext)).performed)
{
Instruments4MusicPlugin.AddLog("Change key bind mode.");
secondaryKeyBind = !secondaryKeyBind;
MusicHUD.UpdateButtonTips();
}
}
public void OnInputNotePressed(CallbackContext inputNoteContext)
{
if (theShowIsOn && ((CallbackContext)(ref inputNoteContext)).performed)
{
Instruments4MusicPlugin.AddLog("Input music note.");
MusicHUD.instance.TriggerInputNote();
}
}
public void Update()
{
bool flag = Instruments4MusicPlugin.inputActionsInstance.Sustain.ReadValue<float>() > 0.5f;
AudioCountDown(flag);
if (!theShowIsOn)
{
return;
}
int num = 0;
bool flag2 = Instruments4MusicPlugin.inputActionsInstance.Soft.ReadValue<float>() > 0.5f;
if (Instruments4MusicPlugin.inputActionsInstance.Semitone.ReadValue<float>() > 0.5f && !secondaryKeyBind)
{
num = 1;
}
InputAction val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowCKey : Instruments4MusicPlugin.inputActionsInstance.LowCKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowDKey : Instruments4MusicPlugin.inputActionsInstance.LowDKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(2 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowEKey : Instruments4MusicPlugin.inputActionsInstance.LowEKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(4, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowFKey : Instruments4MusicPlugin.inputActionsInstance.LowFKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(5 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowGKey : Instruments4MusicPlugin.inputActionsInstance.LowGKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(7 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowAKey : Instruments4MusicPlugin.inputActionsInstance.LowAKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(9 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.LowBKey : Instruments4MusicPlugin.inputActionsInstance.LowBKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(11, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidCKey : Instruments4MusicPlugin.inputActionsInstance.MidCKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(12 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidDKey : Instruments4MusicPlugin.inputActionsInstance.MidDKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(14 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidEKey : Instruments4MusicPlugin.inputActionsInstance.MidEKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(16, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidFKey : Instruments4MusicPlugin.inputActionsInstance.MidFKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(17 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidGKey : Instruments4MusicPlugin.inputActionsInstance.MidGKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(19 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidAKey : Instruments4MusicPlugin.inputActionsInstance.MidAKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(21 + num, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.MidBKey : Instruments4MusicPlugin.inputActionsInstance.MidBKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(23, flag2, val.triggered);
}
val = ((!secondaryKeyBind) ? Instruments4MusicPlugin.inputActionsInstance.HighCKey : Instruments4MusicPlugin.inputActionsInstance.HighCKey2);
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(24 + num, flag2, val.triggered);
}
if (!secondaryKeyBind)
{
val = Instruments4MusicPlugin.inputActionsInstance.HighDKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(26 + num, flag2, val.triggered);
}
val = Instruments4MusicPlugin.inputActionsInstance.HighEKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(28, flag2, val.triggered);
}
val = Instruments4MusicPlugin.inputActionsInstance.HighFKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(29 + num, flag2, val.triggered);
}
val = Instruments4MusicPlugin.inputActionsInstance.HighGKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(31 + num, flag2, val.triggered);
}
val = Instruments4MusicPlugin.inputActionsInstance.HighAKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(33 + num, flag2, val.triggered);
}
val = Instruments4MusicPlugin.inputActionsInstance.HighBKey;
if (val != null && (val.ReadValue<float>() > 0.5f || val.triggered))
{
PlayTunedAudio(35, flag2, val.triggered);
}
}
MusicHUD.instance.OnMenuClicked(1, flag2);
MusicHUD.instance.OnMenuClicked(2, num == 1);
MusicHUD.instance.OnMenuClicked(3, flag);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Instruments4Music";
public const string PLUGIN_NAME = "Instruments4Music";
public const string PLUGIN_VERSION = "0.5.0";
}
}
namespace Jotunn.Utils
{
public static class AssetUtils
{
public const char AssetBundlePathSeparator = '$';
public static Texture2D LoadTexture(string texturePath, bool relativePath = true)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
string text = texturePath;
if (relativePath)
{
text = Path.Combine(Paths.PluginPath, texturePath);
}
if (!File.Exists(text))
{
return null;
}
if (!text.EndsWith(".png") && !text.EndsWith(".jpg"))
{
throw new Exception("LoadTexture can only load png or jpg textures");
}
byte[] array = File.ReadAllBytes(text);
Texture2D val = new Texture2D(2, 2);
val.LoadRawTextureData(array);
return val;
}
public static Sprite LoadSpriteFromFile(string spritePath)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = LoadTexture(spritePath);
if ((Object)(object)val != (Object)null)
{
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f);
}
return null;
}
public static AssetBundle LoadAssetBundle(string bundlePath)
{
string text = Path.Combine(Paths.PluginPath, bundlePath);
if (!File.Exists(text))
{
return null;
}
return AssetBundle.LoadFromFile(text);
}
public static AssetBundle LoadAssetBundleFromResources(string bundleName, Assembly resourceAssembly)
{
string bundleName2 = bundleName;
if (resourceAssembly == null)
{
throw new ArgumentNullException("Parameter resourceAssembly can not be null.");
}
string text = null;
try
{
text = resourceAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(bundleName2));
}
catch (Exception)
{
}
if (text == null)
{
Debug.LogError((object)("AssetBundle " + bundleName2 + " not found in assembly manifest"));
return null;
}
AssetBundle result;
using (Stream stream = resourceAssembly.GetManifestResourceStream(text))
{
result = AssetBundle.LoadFromStream(stream);
}
return result;
}
public static string LoadText(string path)
{
string text = Path.Combine(Paths.PluginPath, path);
if (!File.Exists(text))
{
Debug.LogError((object)("Error, failed to load contents from non-existant path: $" + text));
return null;
}
return File.ReadAllText(text);
}
public static Sprite LoadSprite(string assetPath)
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(Paths.PluginPath, assetPath);
if (!File.Exists(text))
{
return null;
}
if (text.Contains('$'.ToString()))
{
string[] array = text.Split('$');
string text2 = array[0];
string text3 = array[1];
AssetBundle val = AssetBundle.LoadFromFile(text2);
Sprite result = val.LoadAsset<Sprite>(text3);
val.Unload(false);
return result;
}
Texture2D val2 = LoadTexture(text, relativePath: false);
if (!Object.op_Implicit((Object)(object)val2))
{
return null;
}
return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), Vector2.zero);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}