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 CustomizeMusicLC v1.0.8
BepInEx/plugins/HJM-CustomizeMusicLC/HJM.CustomizeMusicLC.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HJM.CustomizeMusicLC")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HJM.CustomizeMusicLC")] [assembly: AssemblyTitle("HJM.CustomizeMusicLC")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 sealed class CarriedVisibility : MonoBehaviour { private BoomboxItem box; private MeshRenderer[] meshes; private bool[] saved; private Camera hiddenFor; private void Awake() { box = ((Component)this).GetComponent<BoomboxItem>(); meshes = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); saved = new bool[meshes.Length]; } private void OnEnable() { RenderPipelineManager.beginCameraRendering += Begin; RenderPipelineManager.endCameraRendering += End; } private void OnDisable() { RenderPipelineManager.beginCameraRendering -= Begin; RenderPipelineManager.endCameraRendering -= End; Restore(); } internal bool FirstPerson(Camera camera) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) PlayerControllerB playerHeldBy = ((GrabbableObject)box).playerHeldBy; if (!Object.op_Implicit((Object)(object)playerHeldBy) || !Object.op_Implicit((Object)(object)GameNetworkManager.Instance) || (Object)(object)playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController || playerHeldBy.isPlayerDead || !((GrabbableObject)box).isPocketed || (Object)(object)camera != (Object)(object)playerHeldBy.gameplayCamera) { return false; } Transform upperSpine = playerHeldBy.upperSpine; if (Object.op_Implicit((Object)(object)upperSpine)) { Vector3 val = Vector3.ProjectOnPlane(((Component)camera).transform.position - upperSpine.position, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.3025f) { return Mathf.Abs(((Component)camera).transform.position.y - upperSpine.position.y) < 1f; } return false; } return true; } private void Begin(ScriptableRenderContext context, Camera camera) { Restore(); if (FirstPerson(camera)) { hiddenFor = camera; for (int i = 0; i < meshes.Length; i++) { saved[i] = ((Renderer)meshes[i]).forceRenderingOff; ((Renderer)meshes[i]).forceRenderingOff = true; } } } private void End(ScriptableRenderContext context, Camera camera) { if ((Object)(object)camera == (Object)(object)hiddenFor) { Restore(); } } private void Restore() { if (!Object.op_Implicit((Object)(object)hiddenFor)) { return; } for (int i = 0; i < meshes.Length; i++) { if (Object.op_Implicit((Object)(object)meshes[i])) { ((Renderer)meshes[i]).forceRenderingOff = saved[i]; } } hiddenFor = null; } } public sealed class CassetteHud : MonoBehaviour { private static CassetteHud active; private TextMeshProUGUI title; private TextMeshProUGUI baseLine; private TextMeshProUGUI sweep; private RectTransform mask; private TextMeshProUGUI[] slots; private int drawn = -1; private float left; private float width; private Vector2 lastSize; private static TextMeshProUGUI Make(Transform parent, TextMeshProUGUI sample, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = ((TMP_Text)sample).font; ((TMP_Text)obj).fontSharedMaterial = ((TMP_Text)sample).fontSharedMaterial; ((TMP_Text)obj).fontSize = ((TMP_Text)sample).fontSize; ((TMP_Text)obj).fontStyle = ((TMP_Text)sample).fontStyle; ((TMP_Text)obj).alignment = (TextAlignmentOptions)4097; ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).richText = false; ((Graphic)obj).raycastTarget = false; return obj; } private static void TightenSpaces(TextMeshProUGUI text) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) float x = ((TMP_Text)text).GetPreferredValues("AA").x; float num = ((TMP_Text)text).GetPreferredValues("A A").x - x; ((TMP_Text)text).wordSpacing = -10f; float num2 = num - (((TMP_Text)text).GetPreferredValues("A A").x - x); ((TMP_Text)text).wordSpacing = ((num2 > 0.0001f) ? (-6.5f * num / num2) : (-20f)); } private static void Place(TextMeshProUGUI text, float rowHeight, int row, float inset) { //IL_0011: 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_0031: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = new Vector2(0.035f, 0.065f); rectTransform.anchorMax = new Vector2(0.97f, 0.065f); rectTransform.pivot = Vector2.zero; rectTransform.sizeDelta = new Vector2(0f, rowHeight); rectTransform.anchoredPosition = new Vector2(inset, rowHeight * (float)row); } internal static void Draw(string caption, Color color, string words, float progress, Color tint) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI[] controlTipLines = HUDManager.Instance.controlTipLines; if (controlTipLines.Length < 3) { return; } if (!Object.op_Implicit((Object)(object)active) || active.slots != controlTipLines) { if (Object.op_Implicit((Object)(object)active)) { Object.Destroy((Object)(object)((Component)active).gameObject); } Transform transform = ((Component)((Graphic)controlTipLines[1]).canvas.rootCanvas).transform; GameObject val = new GameObject("Cassette display", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(transform, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; Vector2 offsetMin = (val2.offsetMax = Vector2.zero); val2.offsetMin = offsetMin; val.layer = ((Component)controlTipLines[1]).gameObject.layer; active = val.AddComponent<CassetteHud>(); active.slots = controlTipLines; active.title = Make((Transform)(object)val2, controlTipLines[1], "Cassette title"); active.baseLine = Make((Transform)(object)val2, controlTipLines[2], "Cassette lyric"); float num = ((TMP_Text)controlTipLines[1]).transform.lossyScale.y / transform.lossyScale.y; TextMeshProUGUI obj = active.title; ((TMP_Text)obj).fontSize = ((TMP_Text)obj).fontSize * num; TextMeshProUGUI obj2 = active.baseLine; ((TMP_Text)obj2).fontSize = ((TMP_Text)obj2).fontSize * num; float rowHeight = Mathf.Max(((TMP_Text)active.title).fontSize, ((TMP_Text)active.baseLine).fontSize) * 1.45f; float x = ((TMP_Text)active.title).GetPreferredValues("nn").x; Place(active.title, rowHeight, 1, x); Place(active.baseLine, rowHeight, 0, x); TightenSpaces(active.title); TightenSpaces(active.baseLine); GameObject val3 = new GameObject("Karaoke reveal", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val3.transform.SetParent(((TMP_Text)active.baseLine).transform, false); active.mask = (RectTransform)val3.transform; active.sweep = Make((Transform)(object)active.mask, controlTipLines[2], "Cassette highlighted lyric"); ((TMP_Text)active.sweep).fontSize = ((TMP_Text)active.baseLine).fontSize; ((TMP_Text)active.sweep).wordSpacing = ((TMP_Text)active.baseLine).wordSpacing; Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = val.layer; } } active.UpdateLines(caption, color, words, progress, tint); } private void UpdateLines(string caption, Color color, string words, float progress, Color tint) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) drawn = Time.frameCount; ((Behaviour)title).enabled = true; ((Graphic)title).color = color; if (((TMP_Text)title).text != caption) { ((TMP_Text)title).text = caption; ((TMP_Text)title).ForceMeshUpdate(false, false); } ((Behaviour)baseLine).enabled = words.Length > 0; ((Behaviour)sweep).enabled = ((Behaviour)baseLine).enabled; if (!((Behaviour)baseLine).enabled) { ((TMP_Text)baseLine).text = ""; return; } RectTransform rectTransform = ((TMP_Text)baseLine).rectTransform; Rect rect; if (!(((TMP_Text)baseLine).text != words)) { Vector2 val = lastSize; rect = rectTransform.rect; if (!(val != ((Rect)(ref rect)).size)) { goto IL_0214; } } ((Graphic)baseLine).color = new Color(0.95f, 0.96f, 1f, 0.72f); ((TMP_Text)baseLine).text = words; ((TMP_Text)baseLine).ForceMeshUpdate(false, false); Bounds textBounds = ((TMP_Text)baseLine).textBounds; left = ((Bounds)(ref textBounds)).min.x - 1f; width = ((Bounds)(ref textBounds)).size.x + 2f; RectTransform obj = mask; Vector2 anchorMin = (mask.anchorMax = rectTransform.pivot); obj.anchorMin = anchorMin; mask.pivot = Vector2.zero; RectTransform obj2 = mask; float num = left; rect = rectTransform.rect; obj2.anchoredPosition = new Vector2(num, ((Rect)(ref rect)).yMin); RectTransform rectTransform2 = ((TMP_Text)sweep).rectTransform; anchorMin = (rectTransform2.anchorMax = Vector2.zero); rectTransform2.anchorMin = anchorMin; rectTransform2.pivot = rectTransform.pivot; rect = rectTransform.rect; rectTransform2.sizeDelta = ((Rect)(ref rect)).size; rectTransform2.anchoredPosition = -mask.anchoredPosition; ((TMP_Text)sweep).text = words; rect = rectTransform.rect; lastSize = ((Rect)(ref rect)).size; goto IL_0214; IL_0214: ((Graphic)sweep).color = tint; RectTransform obj3 = mask; float num2 = width * progress; rect = rectTransform.rect; obj3.sizeDelta = new Vector2(num2, ((Rect)(ref rect)).height); } private void Update() { if (drawn < Time.frameCount - 1) { ((Behaviour)title).enabled = false; ((Behaviour)baseLine).enabled = false; ((Behaviour)sweep).enabled = false; } } } internal static class Models { private sealed class CassetteMeshPart { public string Name; public int MatSlot; public Mesh Mesh; } private static List<CassetteMeshPart> cachedCassetteParts; private static byte[] ReadEmbeddedBytes(string name) { return File.ReadAllBytes(Path.Combine(Port.Folder, "Models", name)); } private static List<CassetteMeshPart> LoadCassetteParts() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown if (cachedCassetteParts != null) { return cachedCassetteParts; } byte[] array = ReadEmbeddedBytes("cassette_model.bin"); if (array == null || array.Length == 0) { return null; } List<CassetteMeshPart> list = new List<CassetteMeshPart>(); using (MemoryStream input = new MemoryStream(array)) { using BinaryReader binaryReader = new BinaryReader(input); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string text = binaryReader.ReadString(); int matSlot = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector2[] array4 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int num3 = binaryReader.ReadInt32(); int[] array5 = new int[num3]; for (int k = 0; k < num3; k++) { array5[k] = binaryReader.ReadInt32(); } Mesh val = new Mesh { name = "Cassette_" + text }; val.vertices = array2; val.normals = array3; val.uv = array4; val.triangles = array5; val.RecalculateBounds(); Object.DontDestroyOnLoad((Object)(object)val); list.Add(new CassetteMeshPart { Name = text, MatSlot = matSlot, Mesh = val }); } } cachedCassetteParts = list; return cachedCassetteParts; } internal static Texture2D LoadEmbeddedTexture(string fileName, bool smoothFilter = false, bool isNormal = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown byte[] array = ReadEmbeddedBytes(fileName); if (array == null || array.Length == 0) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, isNormal); ((Texture)val).filterMode = (FilterMode)(smoothFilter ? 1 : 0); ((Texture)val).wrapMode = (TextureWrapMode)1; if (ImageConversion.LoadImage(val, array)) { Object.DontDestroyOnLoad((Object)(object)val); return val; } return null; } internal static void Apply(BoomboxItem box, string skin) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: 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_03db: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_026f: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)box).gameObject; ((Object)gameObject).hideFlags = (HideFlags)0; gameObject.transform.localScale = Vector3.one; MeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<MeshRenderer>(true); Material sharedMaterial = ((Renderer)componentsInChildren[0]).sharedMaterial; MeshRenderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)array[i]); } Collider[] componentsInChildren2 = gameObject.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } List<Material> list = new List<Material>(); string[] array2 = new string[4] { "case", "face", "cyl1", "cyl2" }; foreach (string text in array2) { Material val = new Material(sharedMaterial); Texture2D val2 = LoadEmbeddedTexture(skin + "_" + text + ".png", smoothFilter: true); string[] array3 = new string[3] { "_BaseColorMap", "_BaseMap", "_MainTex" }; foreach (string text2 in array3) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)(object)val2); } } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } if (text == "case" && val.HasProperty("_EmissiveColorMap")) { val.SetTexture("_EmissiveColorMap", (Texture)(object)LoadEmbeddedTexture(skin + "_glow.png", smoothFilter: true)); val.SetColor("_EmissiveColor", Color.white * 0.4f); val.EnableKeyword("_EMISSIVE_COLOR_MAP"); } list.Add(val); } Bounds? val3 = null; foreach (CassetteMeshPart item in LoadCassetteParts()) { GameObject val4 = new GameObject(item.Name); val4.transform.SetParent(gameObject.transform, false); val4.transform.localScale = Vector3.one * 0.4368f; float num = ((item.Name == "plane_1") ? 0.005f : ((item.Name.StartsWith("cylinder") || item.Name == "plane") ? 0.006f : 0f)); val4.transform.localPosition = Vector3.up * (0.4368f * num); val4.AddComponent<MeshFilter>().sharedMesh = item.Mesh; MeshRenderer val5 = val4.AddComponent<MeshRenderer>(); ((Renderer)val5).sharedMaterial = list[item.MatSlot]; if (item.Name == "cube") { ((GrabbableObject)box).mainObjectRenderer = val5; } Vector3[] vertices = item.Mesh.vertices; for (int i = 0; i < vertices.Length; i++) { Vector3 val6 = vertices[i] * 0.4368f + val4.transform.localPosition; Bounds value = (Bounds)(((??)val3) ?? new Bounds(val6, Vector3.zero)); ((Bounds)(ref value)).Encapsulate(val6); val3 = value; } } BoxCollider val7 = gameObject.AddComponent<BoxCollider>(); Bounds value2 = val3.Value; val7.center = ((Bounds)(ref value2)).center; value2 = val3.Value; val7.size = ((Bounds)(ref value2)).size; ((GrabbableObject)box).propColliders = (Collider[])(object)new Collider[1] { (Collider)val7 }; Item itemProperties = ((GrabbableObject)box).itemProperties; value2 = val3.Value; itemProperties.verticalOffset = 0f - ((Bounds)(ref value2)).min.y; ((GrabbableObject)box).itemProperties.restingRotation = Vector3.zero; Texture2D val8 = LoadEmbeddedTexture(skin + "_icon.png", smoothFilter: true); ((GrabbableObject)box).itemProperties.itemIcon = Sprite.Create(val8, new Rect(0f, 0f, (float)((Texture)val8).width, (float)((Texture)val8).height), Vector2.one * 0.5f); } } [BepInPlugin("hjm.customizemusic.lc", "CustomizeMusic LC", "1.0.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Port : BaseUnityPlugin { internal static string Folder; private static bool ready; private static Port plugin; private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown plugin = this; Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); val.Patch((MethodBase)AccessTools.Method(typeof(GameNetworkManager), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Port), "Register", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "RemovePunctuation", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Port), "Keywords", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(BoomboxItem), "ItemActivate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Port), "Activate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(BoomboxItem), "StartMusic", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Port), "Play", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPrefix] private static void Register() { if (!ready) { Item vanilla = Resources.FindObjectsOfTypeAll<Item>().First((Item i) => i.itemName == "Boombox" && (Object)(object)i.spawnPrefab != (Object)null && (Object)(object)i.spawnPrefab.GetComponent<BoomboxItem>() != (Object)null); Add(vanilla, "kun_music", "sleepy", "困の音箱"); Add(vanilla, "Ice_music", "infinity", "infinity音箱"); Add(vanilla, "hajimi_music", "hachimi", "基米之声"); ready = true; } } private static void Add(Item vanilla, string name, string skin, string library) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) Item val = Object.Instantiate<Item>(vanilla); ((Object)val).name = (val.itemName = name); val.requiresBattery = false; val.syncUseFunction = false; val.automaticallySetUsingPower = true; val.positionOffset = Vector3.zero; val.rotationOffset = new Vector3(0f, 90f, 80f); val.toolTips = Array.Empty<string>(); val.spawnPrefab = NetworkPrefabs.CloneNetworkPrefab(vanilla.spawnPrefab, "HJM_" + ((skin == "hachimi") ? "ha_music" : name)); BoomboxItem component = val.spawnPrefab.GetComponent<BoomboxItem>(); ((GrabbableObject)component).itemProperties = val; Models.Apply(component, skin); val.spawnPrefab.AddComponent<Record>().library = library; val.spawnPrefab.AddComponent<CarriedVisibility>(); int value = ((BaseUnityPlugin)plugin).Config.Bind<int>("Store", name, vanilla.creditsWorth, "Terminal price in credits").Value; Items.RegisterShopItem(val, value); ((BaseUnityPlugin)plugin).Logger.LogInfo((object)$"Registered {name}: {value} credits, {((GrabbableObject)component).propColliders.Length} collider, {((BoxCollider)((GrabbableObject)component).propColliders[0]).size}"); } [HarmonyPatch(typeof(Terminal), "RemovePunctuation")] [HarmonyPostfix] private static void Keywords(ref string __result) { string[] array = __result.Split(' '); for (int i = 0; i < array.Length; i++) { switch (array[i]) { case "kunmusic": array[i] = "kun_music"; break; case "icemusic": array[i] = "ice_music"; break; case "hajimimusic": array[i] = "hajimi_music"; break; } } __result = string.Join(" ", array); } private static bool Activate(BoomboxItem __instance, bool used) { Record component = ((Component)__instance).GetComponent<Record>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } if (((NetworkBehaviour)__instance).IsOwner) { component.Command(used ? Cmd.Play : Cmd.Pause); } return false; } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] [HarmonyPrefix] private static bool Play(BoomboxItem __instance, bool startMusic) { Record component = ((Component)__instance).GetComponent<Record>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } if (!((GrabbableObject)__instance).isPocketed && ((NetworkBehaviour)__instance).IsOwner) { component.Command(startMusic ? Cmd.Play : Cmd.Pause); } return false; } } internal enum Cmd { Snapshot, Play, Pause, Previous, Next, Random, Quieter, Louder } [DefaultExecutionOrder(250)] public sealed class Record : MonoBehaviour { public string library; private static readonly Dictionary<string, string[]> catalogs = new Dictionary<string, string[]>(); private string[] files; private int[] order; private int cursor; private int index; private int volume = 7; private int roundSeed; private double position; private double stamp; private double retry; private bool playing; private bool known; private bool bound; private bool pocketVisible; private string channel; private NetworkManager network; private BoomboxItem box; private Track current; private Track upcoming; private Random random; private Vector3 handContact; private bool startedClip; internal static readonly Color SongColor = new Color(1f, 0.92f, 0.45f); private double Now { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) NetworkTime serverTime = network.ServerTime; return ((NetworkTime)(ref serverTime)).Time; } } private AudioSource Source => box.boomboxAudio; private double TimeInSong => position + (playing ? Math.Max(0.0, Now - stamp) : 0.0); internal Color Accent { get { //IL_005d: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (!(library == "困の音箱")) { if (!(library == "infinity音箱")) { return new Color(1f, 0.62f, 0.26f); } return new Color(0.12f, 0.94f, 0.76f); } return new Color(1f, 0.47f, 0.66f); } } internal Color Highlight { get { //IL_004f: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (!(library == "困の音箱")) { if (!(library == "infinity音箱")) { return Accent; } return new Color(1f / 3f, 1f, 1f); } return new Color(0.82f, 0.68f, 1f); } } private void Start() { //IL_0015: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) box = ((Component)this).GetComponent<BoomboxItem>(); BoxCollider component = ((Component)this).GetComponent<BoxCollider>(); handContact = component.center + Vector3.Scale(component.size, new Vector3(-0.45f, -0.52f, -0.35f)); if (!catalogs.TryGetValue(library, out files)) { files = Directory.GetFiles(Path.Combine(Port.Folder, "CustomBoomboxMusic", library), "*.ogg").OrderBy<string, string>((string x) => x, StringComparer.Ordinal).ToArray(); catalogs[library] = files; } } private void Bind() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown network = NetworkManager.Singleton; if (Object.op_Implicit((Object)(object)network) && network.IsListening && ((NetworkBehaviour)box).IsSpawned && files.Length != 0) { channel = "hjm.cassette.4." + ((NetworkBehaviour)box).NetworkObjectId; network.CustomMessagingManager.RegisterNamedMessageHandler(channel, new HandleNamedMessageDelegate(Receive)); bound = true; if (network.IsServer) { Shuffle(); index = order[0]; known = true; Apply(); } } } private void Shuffle() { roundSeed = StartOfRound.Instance.randomMapSeed; random = new Random(roundSeed + (int)((NetworkBehaviour)box).NetworkObjectId * 7919 + Guid.NewGuid().GetHashCode()); order = Enumerable.Range(0, files.Length).ToArray(); for (int num = order.Length - 1; num > 0; num--) { int num2 = random.Next(num + 1); int num3 = order[num]; order[num] = order[num2]; order[num2] = num3; } cursor = 0; } private void OnDestroy() { if (bound && Object.op_Implicit((Object)(object)network) && network.CustomMessagingManager != null) { network.CustomMessagingManager.UnregisterNamedMessageHandler(channel); } current?.Dispose(); upcoming?.Dispose(); } internal unsafe void Command(Cmd cmd) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!bound) { return; } if (network.IsServer) { if (cmd != Cmd.Snapshot) { Execute(cmd); } return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { int num = (int)cmd; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessage(channel, 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void Receive(ulong sender, FastBufferReader reader) { //IL_0029: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) if (network.IsServer) { if (((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position != 4) { return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); switch (num) { case 0: SendState(sender); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: { if (network.ConnectedClients.TryGetValue(sender, out var value) && Object.op_Implicit((Object)(object)value.PlayerObject)) { PlayerControllerB component = ((Component)value.PlayerObject).GetComponent<PlayerControllerB>(); if (Object.op_Implicit((Object)(object)component) && (!((Object)(object)((GrabbableObject)box).playerHeldBy != (Object)(object)component) || (!((GrabbableObject)box).isHeld && !(Vector3.Distance(((Component)component).transform.position, ((Component)this).transform.position) > 5f)))) { Execute((Cmd)num); } } break; } } } else { if (sender != 0L || ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position < 25) { return; } int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); double num4 = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref num4, default(ForPrimitives)); double num5 = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref num5, default(ForPrimitives)); if (num2 >= 0 && num2 < files.Length) { bool num6 = !known || index != num2 || playing != flag || stamp != num5 || position != num4; index = num2; volume = num3; playing = flag; position = num4; stamp = num5; known = true; if (num6) { Apply(); } else { Source.volume = (float)volume * 0.1f; } } } } private unsafe void SendState(ulong client) { //IL_0015: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref index, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref volume, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref playing, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref position, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref stamp, default(ForPrimitives)); network.CustomMessagingManager.SendNamedMessage(channel, client, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void Execute(Cmd cmd) { if (cmd == Cmd.Quieter || cmd == Cmd.Louder) { volume = Mathf.Clamp(volume + ((cmd == Cmd.Louder) ? 1 : (-1)), 0, 10); Source.volume = (float)volume * 0.1f; } else { if ((cmd == Cmd.Play && playing) || (cmd == Cmd.Pause && !playing)) { return; } if (cmd == Cmd.Pause) { position = TimeInSong; playing = false; } else { if (cmd != Cmd.Play) { int num = ((cmd == Cmd.Random && order.Length > 1) ? random.Next(1, order.Length) : ((cmd != Cmd.Previous) ? 1 : (-1))); cursor = (cursor + num + order.Length) % order.Length; index = order[cursor]; position = 0.0; } stamp = Now; playing = true; } Apply(); } foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendState(connectedClientsId); } } } private void Apply() { Source.Stop(); if (current?.Path != files[index]) { Source.clip = null; current?.Dispose(); if (upcoming?.Path == files[index]) { current = upcoming; upcoming = null; } else { current = new Track(files[index]); } } Source.loop = false; Source.pitch = 1f; Source.volume = (float)volume * 0.1f; ((GrabbableObject)box).isBeingUsed = (box.isPlayingMusic = playing); startedClip = false; } private void Update() { if (!bound) { Bind(); if (!bound) { return; } } if (!known) { if (Now >= retry) { Command(Cmd.Snapshot); retry = Now + 1.0; } return; } if (network.IsServer && roundSeed != StartOfRound.Instance.randomMapSeed) { Shuffle(); cursor = Array.IndexOf(order, index); } current.Poll(); upcoming?.Poll(); if (playing && Object.op_Implicit((Object)(object)current.Clip)) { if (TimeInSong >= (double)current.Clip.length) { if (network.IsServer) { Execute(Cmd.Next); } } else if (!startedClip) { Source.clip = current.Clip; Source.time = (float)TimeInSong; Source.Play(); startedClip = true; } } if (playing && current.Failed && network.IsServer) { Execute(Cmd.Pause); } if (network.IsServer && playing && startedClip && order.Length > 1) { string text = files[order[(cursor + 1) % order.Length]]; if (upcoming?.Path != text) { upcoming?.Dispose(); upcoming = new Track(text); } } HandleKeys(); } private void HandleKeys() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Keyboard val = Keyboard.current; if (val == null) { return; } Cmd cmd; if (((ButtonControl)val.rKey).wasPressedThisFrame) { cmd = Cmd.Random; } else if (((ButtonControl)val.pageUpKey).wasPressedThisFrame) { cmd = Cmd.Previous; } else if (((ButtonControl)val.pageDownKey).wasPressedThisFrame) { cmd = Cmd.Next; } else if (((ButtonControl)val.equalsKey).wasPressedThisFrame || ((ButtonControl)val.numpadPlusKey).wasPressedThisFrame) { cmd = Cmd.Louder; } else { if (!((ButtonControl)val.minusKey).wasPressedThisFrame && !((ButtonControl)val.numpadMinusKey).wasPressedThisFrame) { return; } cmd = Cmd.Quieter; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!Object.op_Implicit((Object)(object)localPlayerController) || localPlayerController.isPlayerDead || localPlayerController.inTerminalMenu || localPlayerController.isTypingChat || localPlayerController.quickMenuManager.isMenuOpen) { return; } GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer; BoomboxItem val2 = (BoomboxItem)(object)((currentlyHeldObjectServer is BoomboxItem) ? currentlyHeldObjectServer : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)((Component)val2).GetComponent<Record>())) { val2 = null; Transform transform = ((Component)localPlayerController.gameplayCamera).transform; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(transform.position, transform.forward, ref val3, localPlayerController.grabDistance, 1073742656)) { val2 = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<BoomboxItem>(); } if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)((Component)val2).GetComponent<Record>())) { val2 = localPlayerController.ItemSlots.OfType<BoomboxItem>().FirstOrDefault((Func<BoomboxItem, bool>)((BoomboxItem b) => Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)((Component)b).GetComponent<Record>()))); } } if ((Object)(object)val2 == (Object)(object)box) { Command(cmd); } } private void LateUpdate() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)box)) { return; } PlayerControllerB playerHeldBy = ((GrabbableObject)box).playerHeldBy; bool flag = ((GrabbableObject)box).isPocketed && Object.op_Implicit((Object)(object)playerHeldBy) && !playerHeldBy.isPlayerDead; if (Object.op_Implicit((Object)(object)playerHeldBy) && (flag || ((GrabbableObject)box).isHeld)) { Vector3 val = Vector3.ProjectOnPlane(((Component)playerHeldBy).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; ((Component)this).transform.rotation = (flag ? Quaternion.LookRotation(((Component)playerHeldBy).transform.right, normalized) : Quaternion.LookRotation(-((Component)playerHeldBy).transform.right, -normalized)); if (flag && Object.op_Implicit((Object)(object)playerHeldBy.upperSpine)) { if (!pocketVisible) { ((GrabbableObject)box).EnableItemMeshes(true); } ((Component)this).transform.position = playerHeldBy.upperSpine.position + normalized * 0.16f - Vector3.up * 0.1f; } else if (Object.op_Implicit((Object)(object)((GrabbableObject)box).parentObject)) { ((Component)this).transform.position = ((GrabbableObject)box).parentObject.position - ((Component)this).transform.TransformVector(handContact); } } pocketVisible = flag; if (Object.op_Implicit((Object)(object)playerHeldBy) && !((Object)(object)playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && known && Object.op_Implicit((Object)(object)HUDManager.Instance)) { GrabbableObject currentlyHeldObjectServer = playerHeldBy.currentlyHeldObjectServer; bool flag2 = (Object)(object)currentlyHeldObjectServer == (Object)(object)box; if ((flag2 || (flag && playing && (!Object.op_Implicit((Object)(object)currentlyHeldObjectServer) || !Object.op_Implicit((Object)(object)((Component)currentlyHeldObjectServer).GetComponent<Record>())))) && (flag2 || !((Object)(object)playerHeldBy.ItemSlots.OfType<BoomboxItem>().FirstOrDefault((Func<BoomboxItem, bool>)((BoomboxItem x) => Object.op_Implicit((Object)(object)x) && x.isPlayingMusic && Object.op_Implicit((Object)(object)((Component)x).GetComponent<Record>()))) != (Object)(object)box))) { float progress = 0f; string words = ((playing && startedClip && Object.op_Implicit((Object)(object)Source.clip)) ? current.Line(Source.time, out progress) : ""); CassetteHud.Draw(playing ? ("正在播放: " + current.Title) : ("音响: " + library), playing ? SongColor : Accent, words, progress, Highlight); } } } } internal sealed class Track : IDisposable { internal readonly string Path; internal readonly string Title; internal AudioClip Clip; internal bool Failed; private UnityWebRequest request; private readonly Task<KeyValuePair<double, string>[]> lyrics; private static readonly Regex stamp = new Regex("\\[(\\d+):(\\d+(?:[.:]\\d+)?)\\]", RegexOptions.Compiled); internal Track(string path) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) Path = path; Title = System.IO.Path.GetFileNameWithoutExtension(path); lyrics = Task.Run(() => ReadLyrics(System.IO.Path.ChangeExtension(path, ".lrc"))); request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, (AudioType)14); ((DownloadHandlerAudioClip)request.downloadHandler).streamAudio = true; request.SendWebRequest(); } private static KeyValuePair<double, string>[] ReadLyrics(string path) { List<KeyValuePair<double, string>> list = new List<KeyValuePair<double, string>>(); if (File.Exists(path)) { foreach (string item in File.ReadLines(path)) { MatchCollection matchCollection = stamp.Matches(item); if (matchCollection.Count == 0) { continue; } Match match = matchCollection[matchCollection.Count - 1]; string value = item.Substring(match.Index + match.Length).Trim(); foreach (Match item2 in matchCollection) { if (double.TryParse(item2.Groups[2].Value.Replace(':', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { list.Add(new KeyValuePair<double, string>((double)(60 * int.Parse(item2.Groups[1].Value)) + result, value)); } } } } return list.OrderBy((KeyValuePair<double, string> x) => x.Key).ToArray(); } internal string Line(double time, out float progress) { progress = 0f; if (lyrics.Status != TaskStatus.RanToCompletion) { return ""; } KeyValuePair<double, string>[] result = lyrics.Result; int num = 0; int num2 = result.Length; while (num < num2) { int num3 = (num + num2) / 2; if (result[num3].Key <= time + 0.05) { num = num3 + 1; } else { num2 = num3; } } if (num == 0) { return ""; } KeyValuePair<double, string> keyValuePair = result[num - 1]; double val = ((num < result.Length) ? Math.Max(0.4, result[num].Key - keyValuePair.Key) : 5.0); progress = Mathf.Clamp01((float)((time - keyValuePair.Key) / Math.Min(9.0, val))); return keyValuePair.Value; } internal void Poll() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (request != null && request.isDone) { if ((int)request.result == 1) { Clip = DownloadHandlerAudioClip.GetContent(request); } Failed = !Object.op_Implicit((Object)(object)Clip); if (Failed) { Debug.LogWarning((object)("[CustomizeMusic] Cannot load " + Title + ": " + request.error)); } request.Dispose(); request = null; } } public void Dispose() { if (request != null) { request.Abort(); request.Dispose(); } if (Object.op_Implicit((Object)(object)Clip)) { Object.Destroy((Object)(object)Clip); } } }