using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Web; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks.CompilerServices; using GameNetcodeStuff; using HarmonyLib; using LethalModUtils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Unity.Netcode; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public class ConstValues { public const string RequestSongApiURL = "https://music.163.com/song/media/outer/url?id="; public const string SongInfoApi = "https://music.163.com/api/song/detail?ids="; } [HarmonyPatch(typeof(HUDManager), "EnableChat_performed")] public class HUDManager_OpenChatPatch { [HarmonyPrefix] public static void Prefix(HUDManager __instance) { __instance.chatTextField.characterLimit = int.MaxValue; } } public class NormalInfoData { public string name; public long id; } public class SingleSongInfoData : NormalInfoData { public List artists; public string getAllArtists() { string[] array = new string[artists.Count]; int num = 0; foreach (NormalInfoData artist in artists) { if (num <= artists.Count - 1) { array[num] = artist.name; num++; } } return string.Join(",", array); } } public class RequestSongInfoData { public List songs; } internal static class StringUtils { internal static string[] ToCommandLineArgs(this string str) { string[] array = str.Split(" "); bool flag = false; string text = ""; List list = new List(); for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (!flag) { if (text2.StartsWith("\"") && !text2.EndsWith("\"")) { flag = true; text = ""; text += text2; continue; } if (text2.StartsWith("\"") && text2.EndsWith("\"")) { text2 = text2.RemoveStartWith("\""); text2 = text2.RemoveEndWith("\""); } list.Add(text2); } else if (text2.EndsWith("\"") && !text2.StartsWith("\"")) { flag = false; text = text + " " + text2; text = text.RemoveEndWith("\""); text = text.RemoveStartWith("\""); list.Add(text); } else { text = text + " " + text2; } } return list.ToArray(); } internal static string RemoveEndWith(this string str, string endStr) { if (str.EndsWith(endStr)) { return str.Substring(0, str.Length - endStr.Length); } return str; } internal static string RemoveStartWith(this string str, string startStr) { if (str.StartsWith(startStr)) { return str.Substring(startStr.Length, str.Length - startStr.Length); } return str; } } public class URLData { public bool isHttp { get; private set; } public string Domain { get; private set; } public string Path { get; private set; } public List queryData { get; private set; } public URLData(bool isHttp, string domain, string path, List queryData) { this.isHttp = isHttp; Domain = domain; Path = path; this.queryData = queryData; } } public class QueryData { public string key { get; private set; } public string value { get; private set; } public QueryData(string key, string value) { this.key = key; this.value = value; } } public class URLProcess { public static URLData ProcessURL(string url) { Debug.Log((object)("Processing URL: " + url)); Uri uri = new Uri(url); bool isHttp = uri.Scheme == Uri.UriSchemeHttp; string host = uri.Host; string absolutePath = uri.AbsolutePath; NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(uri.Query); List list = new List(); for (int i = 0; i < nameValueCollection.Count; i++) { string key = nameValueCollection.AllKeys[i]; string value = nameValueCollection[i]; list.Add(new QueryData(key, value)); } return new URLData(isHttp, host, absolutePath, list); } } [CompilerGenerated] [EditorBrowsable(EditorBrowsableState.Never)] [GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)] internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 { private struct MonoScriptData { public byte[] FilePathsData; public byte[] TypesData; public int TotalTypes; public int TotalFiles; public bool IsEditorOnly; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static MonoScriptData Get() { MonoScriptData result = default(MonoScriptData); result.FilePathsData = new byte[733] { 0, 0, 0, 1, 0, 0, 0, 48, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 65, 117, 100, 105, 111, 70, 105, 108, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 51, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 65, 117, 100, 105, 111, 77, 97, 110, 97, 103, 101, 114, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 61, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 67, 104, 97, 116, 67, 111, 109, 109, 97, 110, 100, 73, 110, 116, 101, 103, 114, 97, 116, 105, 111, 110, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 50, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 67, 111, 110, 115, 116, 86, 97, 108, 117, 101, 115, 46, 99, 115, 0, 0, 0, 4, 0, 0, 0, 57, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 63, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 72, 85, 68, 77, 97, 110, 97, 103, 101, 114, 95, 79, 112, 101, 110, 67, 104, 97, 116, 80, 97, 116, 99, 104, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 58, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 77, 111, 100, 78, 101, 116, 119, 111, 114, 107, 66, 101, 104, 97, 118, 105, 111, 117, 114, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 51, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 77, 121, 80, 108, 117, 103, 105, 110, 73, 110, 102, 111, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 53, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 78, 111, 114, 109, 97, 108, 73, 110, 102, 111, 68, 97, 116, 97, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 50, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 83, 116, 114, 105, 110, 103, 85, 116, 105, 108, 115, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 46, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 85, 82, 76, 68, 97, 116, 97, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 49, 92, 65, 115, 115, 101, 116, 115, 92, 76, 101, 116, 104, 97, 108, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 66, 111, 120, 92, 83, 99, 114, 105, 112, 116, 115, 92, 85, 82, 76, 80, 114, 111, 99, 101, 115, 115, 46, 99, 115 }; result.TypesData = new byte[569] { 0, 0, 0, 0, 28, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 65, 117, 100, 105, 111, 70, 105, 108, 101, 0, 0, 0, 0, 31, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 65, 117, 100, 105, 111, 77, 97, 110, 97, 103, 101, 114, 0, 0, 0, 0, 33, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 66, 111, 111, 109, 98, 111, 120, 67, 111, 109, 109, 97, 110, 100, 0, 0, 0, 0, 12, 124, 67, 111, 110, 115, 116, 86, 97, 108, 117, 101, 115, 0, 0, 0, 0, 37, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 0, 0, 0, 0, 48, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 46, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 83, 116, 97, 114, 116, 80, 97, 116, 99, 104, 0, 0, 0, 0, 47, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 46, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 73, 110, 105, 116, 80, 97, 116, 99, 104, 0, 0, 0, 0, 54, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 46, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 66, 111, 111, 109, 98, 111, 120, 80, 108, 97, 121, 80, 97, 116, 99, 104, 0, 0, 0, 0, 25, 124, 72, 85, 68, 77, 97, 110, 97, 103, 101, 114, 95, 79, 112, 101, 110, 67, 104, 97, 116, 80, 97, 116, 99, 104, 0, 0, 0, 0, 38, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 77, 111, 100, 78, 101, 116, 119, 111, 114, 107, 66, 101, 104, 97, 118, 105, 111, 117, 114, 0, 0, 0, 0, 31, 67, 117, 115, 116, 111, 109, 66, 111, 111, 109, 98, 111, 120, 77, 117, 115, 105, 99, 124, 77, 121, 80, 108, 117, 103, 105, 110, 73, 110, 102, 111, 0, 0, 0, 0, 15, 124, 78, 111, 114, 109, 97, 108, 73, 110, 102, 111, 68, 97, 116, 97, 0, 0, 0, 0, 19, 124, 83, 105, 110, 103, 108, 101, 83, 111, 110, 103, 73, 110, 102, 111, 68, 97, 116, 97, 0, 0, 0, 0, 20, 124, 82, 101, 113, 117, 101, 115, 116, 83, 111, 110, 103, 73, 110, 102, 111, 68, 97, 116, 97, 0, 0, 0, 0, 12, 124, 83, 116, 114, 105, 110, 103, 85, 116, 105, 108, 115, 0, 0, 0, 0, 8, 124, 85, 82, 76, 68, 97, 116, 97, 0, 0, 0, 0, 10, 124, 81, 117, 101, 114, 121, 68, 97, 116, 97, 0, 0, 0, 0, 11, 124, 85, 82, 76, 80, 114, 111, 99, 101, 115, 115 }; result.TotalFiles = 12; result.TotalTypes = 18; result.IsEditorOnly = false; return result; } } namespace CustomBoomboxMusic { public sealed class AudioFile { public int? VanillaId { get; } public uint? Crc { get; } public AudioClip AudioClip { get; } public string FilePath { get; } public string Name => Path.GetFileNameWithoutExtension(FilePath); public AudioFile(uint crc, AudioClip audioClip, string filePath) { Crc = crc; AudioClip = audioClip; FilePath = filePath; } public AudioFile(int vanillaId, AudioClip audioClip) { VanillaId = vanillaId; AudioClip = audioClip; FilePath = $"Boombox {vanillaId + 1} (Lethal Company)"; } public override string ToString() { return "{ VanillaId: " + a(VanillaId) + ", Crc: " + a(Crc) + ", AudioClip: " + b(AudioClip) + ", FilePath: " + c(FilePath) + ", Name: " + c(Name) + " }"; static string a(object? e) { if (e != null) { return e.ToString(); } return "null"; } static string b(AudioClip e) { if (!((Object)(object)e == (Object)null) && Object.op_Implicit((Object)(object)e)) { return ((object)e).ToString(); } return "null"; } static string c(string? e) { if (e != null) { return "\"" + e.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\n", "\\n") + "\""; } return "null"; } } } public static class AudioManager { private static List audioClips = new List(); internal const string VANILLA_AUDIO_CLIP_NAME = "Boombox {0} (Lethal Company)"; public static IReadOnlyList AudioClips => audioClips; public static IReadOnlyList VanillaAudioClips(BoomboxItem boombox) { return boombox.musicAudios.Select((AudioClip clip, int i) => new AudioFile(i, clip)).ToList(); } internal static void Reload() { CollectionExtensions.Do((IEnumerable)audioClips, (Action)delegate(AudioFile f) { f.AudioClip.UnloadAudioData(); }); audioClips.Clear(); FS.IterateDirectories(new DirectoryInfo(Paths.BepInExRootPath), (Action)ProcessFile, (Func)((DirectoryInfo i) => i.Name.Equals("CustomBoomboxMusic", StringComparison.CurrentCultureIgnoreCase) ? ((ProcessFilter)0) : ((ProcessFilter)2))); audioClips = audioClips.OrderBy((AudioFile f) => f.Crc).ToList(); CustomBoomboxMusic.BoomboxPlayPatch.rng = new ConditionalWeakTable>(); } internal static void ProcessFile(FileInfo file) { CustomBoomboxMusic.Logger.LogDebug((object)$">> ProcessFile(file: {file})"); try { UnityWebRequest val = default(UnityWebRequest); AudioClip audioClip = Audio.Load(new Uri(file.FullName), ref val, (TimeSpan?)CustomBoomboxMusic.Instance.LoadTimeOut); audioClips.Add(new AudioFile(Crc32.Calculate(val.downloadHandler.data), audioClip, file.FullName)); } catch (Exception arg) { CustomBoomboxMusic.Logger.LogWarning((object)$"Couldn't load file {file.FullName}: {arg}"); } } internal static void ProcessFile(FileInfo file, out AudioFile audioFile) { CustomBoomboxMusic.Logger.LogDebug((object)$">> ProcessFile(file: {file})"); audioFile = null; try { UnityWebRequest val = default(UnityWebRequest); AudioClip audioClip = Audio.Load(new Uri(file.FullName), ref val, (TimeSpan?)CustomBoomboxMusic.Instance.LoadTimeOut); audioFile = new AudioFile(Crc32.Calculate(val.downloadHandler.data), audioClip, file.FullName); audioClips.Add(audioFile); } catch (Exception arg) { CustomBoomboxMusic.Logger.LogWarning((object)$"Couldn't load file {file.FullName}: {arg}"); } } public static bool TryGetCrc(uint crc, out AudioFile audioClip) { return (audioClip = AudioClips.FirstOrDefault((AudioFile i) => i.Crc.HasValue && i.Crc.Value == crc)) != null; } public static bool TryGetVanillaId(BoomboxItem boombox, int vanillaId, out AudioFile audioClip) { return (audioClip = VanillaAudioClips(boombox).FirstOrDefault((AudioFile i) => i.VanillaId.HasValue && i.VanillaId.Value == vanillaId)) != null; } } [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyWrapSafe] public class BoomboxCommand { public static MethodInfo GrabbaleObject_ActivateItemRpc = typeof(GrabbableObject).GetMethod("ActivateItemRpc", BindingFlags.Instance | BindingFlags.NonPublic); public static string error; [HarmonyPrefix] public static bool Prefix(HUDManager __instance) { //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) __instance.chatTextField.characterLimit = int.MaxValue; bool flag = (__instance.chatTextField.text.StartsWith("!") && __instance.chatTextField.text.StartsWith("!boombox") && __instance.chatTextField.text.Length > "!boombox ".Length) || (__instance.chatTextField.text.StartsWith("!") && __instance.chatTextField.text.StartsWith("!boo") && __instance.chatTextField.text.Length > "!boo ".Length); if (!flag) { return true; } string[] array = __instance.chatTextField.text.RemoveStartWith("!boombox ").RemoveStartWith("!boo ").ToCommandLineArgs(); error = ""; string text = ((array.Length != 0) ? array[0] : null); GrabbableObject val = GameNetworkManager.Instance?.localPlayerController?.currentlyHeldObjectServer; BoomboxItem val2 = null; bool flag2 = (Object)(object)val != (Object)null && ((Component)val).gameObject.TryGetComponent(ref val2); switch (text) { default: switch (text) { case "list": case "l": { List list = AudioManager.AudioClips.OrderBy((AudioFile i) => i.Name).ToList(); int count2 = list.Count; HUDManager.Instance.DisplayTip("Info", (count2 == 0) ? (a(count2) + " loaded") : (a(count2) + " loaded:\n> " + GeneralExtensions.Join((IEnumerable)list, (Func)((AudioFile i) => i.Name), "\n> ")), false, false, "LC_Tip1"); CustomBoomboxMusic.Logger.LogInfo((object)$"Listing loaded tracks ({count2}):"); foreach (AudioFile item in list) { CustomBoomboxMusic.Logger.LogInfo((object)$"> {item.Name} - {item.FilePath} (CRC32: {item.Crc})"); } break; } case "play": case "p": error = "Invalid arguments"; if (array.Length < 2) { __instance.localPlayer.isTypingChat = false; break; } error = "You need to be holding a boombox"; if (!flag2) { __instance.localPlayer.isTypingChat = false; break; } error = "Track could not be found"; return Play(GeneralExtensions.Join((IEnumerable)array[1..], (Func)null, " "), val2); case "nlink": case "nurl": { string text2 = ((array.Length > 1) ? array[1] : null); try { if (text2 == null) { error = "Invalid arguments"; break; } if (!flag2) { error = "You need to be holding a boombox"; __instance.localPlayer.isTypingChat = false; break; } string value = URLProcess.ProcessURL(text2).queryData.FirstOrDefault((QueryData i) => i.key == "id").value; ModNetworkBehaviour.Instance?.DownloadSong_Rpc(value, NetworkObjectReference.op_Implicit(((NetworkBehaviour)val2).NetworkObject)); } catch (Exception ex) { Debug.LogException(ex); } break; } case "dlink": case "durl": case "dl": { string text3 = ((array.Length > 1) ? array[1] : null); try { if (text3 == null) { error = "Invalid arguments"; } else if (!flag2) { error = "You need to be holding a boombox"; __instance.localPlayer.isTypingChat = false; } else { __instance.AddTextToChatOnServer("Your song has been started downloading.", -1); ModNetworkBehaviour.Instance?.DownloadDirectLinkSong_Rpc(text3, NetworkObjectReference.op_Implicit(((NetworkBehaviour)val2).NetworkObject)); } } catch (Exception ex2) { Debug.LogException(ex2); } break; } case "bypassReverb": case "br": if (array.Length < 2) { error = "Invalid arguments"; } else if (!flag2) { error = "You need to be holding a boombox"; __instance.localPlayer.isTypingChat = false; } else { bool bypass = bool.Parse(array[1]); ModNetworkBehaviour.Instance?.BoomBoxBypassReverb_Rpc(bypass, NetworkObjectReference.op_Implicit(((NetworkBehaviour)val2).NetworkObject)); __instance.AddTextToChatOnServer("Changed bypass reverb.", -1); } break; default: HUDManager.Instance.DisplayTip("Warn", "Invalid subcommand, use /help for usage information", true, false, "LC_Tip1"); break; } break; case "reload": case "r": HUDManager.Instance.DisplayTip("Info", "Reloading...", false, false, "LC_Tip1"); AudioManager.Reload(); HUDManager.Instance.DisplayTip("Info", "Done reloading, found " + a(AudioManager.AudioClips.Count), false, false, "LC_Tip1"); break; case "version": case "v": case null: HUDManager.Instance.DisplayTip("Info", "CustomBoomboxMusic v1.0.1\n" + a(AudioManager.AudioClips.Count) + " loaded", false, false, "LC_Tip1"); break; } if (flag) { __instance.chatTextField.text = ""; return true; } return true; static string a(int count) { if (count != 0) { return $"{count} track{b(count)}"; } return "No tracks"; } static string b(int count) { if (count != 1) { return "s"; } return string.Empty; } } private static bool Play(string identifier, BoomboxItem boombox) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList readOnlyList = AudioManager.AudioClips; if (CustomBoomboxMusic.Instance.IncludeVanilla || readOnlyList.Count == 0) { readOnlyList = readOnlyList.Concat(AudioManager.VanillaAudioClips(boombox)).ToList(); } List list = new List(); if (uint.TryParse(identifier, out var result) && AudioManager.TryGetCrc(result, out var audioClip)) { list.Add(audioClip); } if (list.Count == 0) { list.AddRange(readOnlyList.Where((AudioFile i) => string.Equals(i.Name, identifier, StringComparison.CurrentCultureIgnoreCase))); } if (list.Count == 0) { list.AddRange(readOnlyList.Where((AudioFile i) => i.Name.StartsWith(identifier, StringComparison.CurrentCultureIgnoreCase))); } if (list.Count == 0) { return false; } foreach (AudioFile item in list) { if (item == null) { continue; } if ((Object)(object)ModNetworkBehaviour.Instance != (Object)null) { if (item.VanillaId.HasValue) { ModNetworkBehaviour.Instance.StartPlayingVanillaMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boombox).NetworkObject), item.VanillaId.Value); } else { if (!item.Crc.HasValue) { CustomBoomboxMusic.Logger.LogWarning((object)$"AudioFile doesn't have CRC nor VanillaID: {item}"); continue; } ModNetworkBehaviour.Instance.StartPlayingMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boombox).NetworkObject), item.Crc.Value, item.Name); } return true; } if (!((GrabbableObject)boombox).isBeingUsed) { GrabbaleObject_ActivateItemRpc.Invoke(boombox, new object[2] { true, true }); } boombox.boomboxAudio.clip = item.AudioClip; boombox.boomboxAudio.pitch = 1f; boombox.boomboxAudio.Play(); ((GrabbableObject)boombox).isBeingUsed = (boombox.isPlayingMusic = true); CustomBoomboxMusic.AnnouncePlaying(item); return true; } return false; } } [BepInPlugin("LTGVE.CustomBoomboxMusic", "CustomBoomboxMusic", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CustomBoomboxMusic : BaseUnityPlugin { [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class StartPatch { private static void Postfix() { Logger.LogDebug((object)$">> StartPatch() ClientSide:{Instance.ClientSide} networkPrefab:{a(networkPrefab)}"); if (!Instance.ClientSide && !((Object)(object)networkPrefab != (Object)null)) { networkPrefab = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, "modnetworkmanager")).LoadAsset("ModNetworkManager"); ((Object)networkPrefab).name = "LTGVE.CustomBoomboxMusic-ModNetworkManager"; networkPrefab.AddComponent(); NetworkManager.Singleton.AddNetworkPrefab(networkPrefab); Logger.LogDebug((object)(" Registered network prefab " + a(networkPrefab))); } } } [HarmonyPatch(typeof(StartOfRound), "Awake")] internal static class InitPatch { private static void Postfix() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug((object)$">> InitPatch() ClientSide:{Instance.ClientSide} IsHost:{NetworkManager.Singleton.IsHost} IsServer:{NetworkManager.Singleton.IsServer} networkPrefab:{a(networkPrefab)}"); if (Instance.ClientSide || (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer) || (Object)(object)networkPrefab == (Object)null) { Logger.LogDebug((object)"<< InitPatch false"); return; } Object.Instantiate(networkPrefab, Vector3.zero, Quaternion.identity).GetComponent().Spawn(true); Logger.LogDebug((object)"<< InitPatch true"); } } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] internal static class BoomboxPlayPatch { internal static ConditionalWeakTable> rng = new ConditionalWeakTable>(); private static IReadOnlyList GetClips(BoomboxItem __instance) { IReadOnlyList readOnlyList = AudioManager.AudioClips; if (Instance.IncludeVanilla || readOnlyList.Count == 0) { readOnlyList = readOnlyList.Concat(AudioManager.VanillaAudioClips(__instance)).ToList(); } return readOnlyList; } private static IEnumerator RNG(BoomboxItem __instance) { IReadOnlyList clips = GetClips(__instance); Logger.LogDebug((object)$">> RNG({__instance}) clips.Count: {clips.Count}"); List clipIds = Enumerable.Range(0, clips.Count).ToList(); while (clipIds.Count > 0) { int index = __instance.musicRandomizer.Next(clipIds.Count); int num = clipIds[index]; clipIds.RemoveAt(index); Logger.LogDebug((object)$"Requested new RNG Value for {__instance}: {num} ({clipIds.Count} remaining)"); yield return clips[num]; } } private static AudioFile OldRNG(BoomboxItem __instance) { IReadOnlyList clips = GetClips(__instance); Logger.LogDebug((object)$">> OldRNG({__instance}) clips.Count: {clips.Count}"); return clips[__instance.musicRandomizer.Next(clips.Count)]; } private static AudioFile GetNextClip(BoomboxItem __instance) { Logger.LogDebug((object)$">> GetNextClip({__instance})"); if (!Instance.NewRNG) { return OldRNG(__instance); } if (!rng.TryGetValue(__instance, out var enumerator)) { Logger.LogDebug((object)" Failed to obtain enumerator, creating new..."); create(); } AudioFile current = enumerator.Current; Logger.LogDebug((object)$" Got clip: {current}"); if (!enumerator.MoveNext()) { Logger.LogDebug((object)" Failed to advance RNG, creating new..."); create(); } return current; void create() { rng.AddOrUpdate(__instance, enumerator = RNG(__instance)); enumerator.MoveNext(); } } private static bool Prefix(ref BoomboxItem __instance, ref bool startMusic, ref bool pitchDown) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!startMusic) { return true; } if (!Instance.ClientSide && !((NetworkBehaviour)__instance).IsOwner) { return false; } AudioFile nextClip = GetNextClip(__instance); if ((Object)(object)ModNetworkBehaviour.Instance != (Object)null) { if (nextClip.VanillaId.HasValue) { ModNetworkBehaviour.Instance.StartPlayingVanillaMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), nextClip.VanillaId.Value); } else if (nextClip.Crc.HasValue) { ModNetworkBehaviour.Instance.StartPlayingMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), nextClip.Crc.Value, nextClip.Name); } else { Logger.LogWarning((object)$"AudioFile doesn't have CRC nor VanillaID: {nextClip}"); } } else { __instance.boomboxAudio.clip = nextClip.AudioClip; __instance.boomboxAudio.pitch = 1f; __instance.boomboxAudio.Play(); BoomboxItem obj = __instance; BoomboxItem obj2 = __instance; bool num = startMusic; bool isBeingUsed = num; obj2.isPlayingMusic = num; ((GrabbableObject)obj).isBeingUsed = isBeingUsed; a(nextClip, __instance); } return false; } private static void a(AudioFile audioFile, BoomboxItem boombox) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug((object)$">> BoomboxPlayPatch({audioFile}, {boombox}) IsOwner:{((NetworkBehaviour)boombox).IsOwner}"); if (!((Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null) && (!GameNetworkManager.Instance.localPlayerController.isPlayerDead || GameNetworkManager.Instance.localPlayerController.hasBegunSpectating) && (Vector3.Distance(((Component)boombox.boomboxAudio).transform.position, GameNetworkManager.Instance.localPlayerController.isPlayerDead ? ((Component)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript).transform.position : ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) <= boombox.boomboxAudio.maxDistance || ((NetworkBehaviour)boombox).IsOwner || ((NetworkBehaviour)boombox).OwnerClientId == GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript.actualClientId)) { AnnouncePlaying(audioFile); } } } public const string DIRECTORY_NAME = "CustomBoomboxMusic"; private ConfigEntry loadTimeOut; private ConfigEntry displayNowPlaying; private ConfigEntry includeVanilla; private ConfigEntry newRNG; private ConfigEntry clientSide; private static GameObject networkPrefab; public static CustomBoomboxMusic Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } public static string PluginPath => Path.GetDirectoryName(typeof(CustomBoomboxMusic).Assembly.Location); public TimeSpan LoadTimeOut => TimeSpan.FromSeconds(loadTimeOut.Value); public bool DisplayNowPlaying => displayNowPlaying.Value; public bool IncludeVanilla => includeVanilla.Value; public bool NewRNG => newRNG.Value; public bool ClientSide { get; private set; } private void Awake() { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; loadTimeOut = ((BaseUnityPlugin)this).Config.Bind("General", "LoadTimeOut", 10f, "Maximum amount of time to wait for an audio file to load. Increase this value if you have giant files or are using a slow drive"); displayNowPlaying = ((BaseUnityPlugin)this).Config.Bind("General", "DisplayNowPlaying", true, "Whether to display a popup about which song is currently playing"); includeVanilla = ((BaseUnityPlugin)this).Config.Bind("General", "IncludeVanilla", true, "Includes vanilla music (forced true if no custom music is present)"); includeVanilla.SettingChanged += delegate { BoomboxPlayPatch.rng = new ConditionalWeakTable>(); }; newRNG = ((BaseUnityPlugin)this).Config.Bind("General", "NewRNG", true, "Enables an improved RNG which prevents repeats"); clientSide = ((BaseUnityPlugin)this).Config.Bind("General", "ClientSide", false, "Enables or disables custom networking to more accurately sync which song is currently playing"); ClientSide = clientSide.Value; clientSide.SettingChanged += delegate { Logger.LogWarning((object)"ClientSide requires a restart of the game to apply"); }; Logger.LogInfo((object)("Client-side mode " + (ClientSide ? "enabled" : "disabled"))); AudioManager.Reload(); if (Harmony == null) { Harmony = new Harmony("LTGVE.CustomBoomboxMusic"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); Logger.LogInfo((object)"LTGVE.CustomBoomboxMusic v1.0.1 has loaded!"); } private static string a(GameObject? e) { if (!((Object)(object)e == (Object)null)) { return ((object)e).ToString(); } return "null"; } internal static void AnnouncePlaying(AudioFile audioFile) { string name = audioFile.Name; Logger.LogInfo((object)("Now playing: " + name)); if (Instance.DisplayNowPlaying) { HUDManager.Instance.DisplayTip("Now playing:", name ?? "", false, false, "LC_Tip1"); } } internal static void AnnounceMissing(string missingName) { Logger.LogWarning((object)("Missing audio for " + missingName)); HUDManager.Instance.DisplayTip("Missing audio:", missingName + " could not be played", true, false, "LC_Tip1"); } } public class ModNetworkBehaviour : NetworkBehaviour { [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__16 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public string url; public ModNetworkBehaviour <>4__this; public BoomboxItem boomboxItem; private UnityWebRequest 5__2; private UnityWebRequestAsyncOperationAwaiter <>u__1; private void MoveNext() { //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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003d: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_00d9: Invalid comparison between Unknown and I4 //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ModNetworkBehaviour modNetworkBehaviour = <>4__this; try { UnityWebRequestAsyncOperationAwaiter awaiter; if (num != 0) { 5__2 = new UnityWebRequest(url); 5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); awaiter = UnityAsyncExtensions.GetAwaiter(5__2.SendWebRequest()); if (!((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__16>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(UnityWebRequestAsyncOperationAwaiter); num = (<>1__state = -1); } UnityWebRequest result = ((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).GetResult(); string text = Path.Combine(CustomBoomboxMusic.PluginPath, "CustomBoomboxMusic"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string fileName = GetFileName(5__2.GetResponseHeader("Content-Disposition")); if (result != null && (int)result.result == 1) { byte[] data = result.downloadHandler.data; string text2 = text + "/" + fileName.Replace("%", "_").Replace(":", "_").Replace("?", "_") .Replace("=", "_") .Replace("&", "_") .Replace("#", "_") .Replace("~", "_") .Replace("*", "_") .Replace("<", "_") .Replace(">", "_") .Replace("|", "_") + ((fileName.EndsWith(".mp3") || fileName.EndsWith(".wav")) ? "" : ".mp3"); File.WriteAllBytes(text2, data); FileInfo fileInfo = new FileInfo(text2); CustomBoomboxMusic.Logger.LogDebug((object)$"Downloaded Song! : {fileName} Size : {fileInfo.Length / 1024}KB"); AudioManager.ProcessFile(fileInfo, out var audioFile); if (audioFile != null) { if (((NetworkBehaviour)modNetworkBehaviour).NetworkManager.IsHost) { modNetworkBehaviour.StartPlayingMusicClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boomboxItem).NetworkObject), audioFile.Crc.Value); } else { modNetworkBehaviour.StartPlayingMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boomboxItem).NetworkObject), audioFile.Crc.Value); } } HUDManager.Instance.AddTextToChatOnServer("Song has been downloaded and added to the boombox! name : " + fileName, -1); } else { CustomBoomboxMusic.Logger.LogError((object)("Failed to download song! : " + fileName)); } } catch (Exception exception) { <>1__state = -2; 5__2 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; 5__2 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct d__14 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public string songID; public ModNetworkBehaviour <>4__this; public BoomboxItem boomboxItem; private string 5__2; private string 5__3; private UnityWebRequestAsyncOperationAwaiter <>u__1; private void MoveNext() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_0052: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Invalid comparison between Unknown and I4 //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ModNetworkBehaviour modNetworkBehaviour = <>4__this; try { UnityWebRequestAsyncOperationAwaiter awaiter; if (num != 0) { if (num == 1) { awaiter = <>u__1; <>u__1 = default(UnityWebRequestAsyncOperationAwaiter); num = (<>1__state = -1); goto IL_019d; } 5__2 = "https://music.163.com/song/media/outer/url?id=" + songID + ".mp3"; awaiter = UnityAsyncExtensions.GetAwaiter(UnityWebRequest.Get("https://music.163.com/api/song/detail?ids=[" + songID + "]").SendWebRequest()); if (!((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__14>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(UnityWebRequestAsyncOperationAwaiter); num = (<>1__state = -1); } UnityWebRequest result = ((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).GetResult(); 5__3 = ""; if (result != null && (int)result.result == 1) { string text = result.downloadHandler.text; Debug.Log((object)"Get Song Info Success!"); RequestSongInfoData requestSongInfoData = JsonConvert.DeserializeObject(text); string name = requestSongInfoData.songs[0].name; string allArtists = requestSongInfoData.songs[0].getAllArtists(); 5__3 = allArtists + " - " + name; Debug.Log((object)("Found Song! : " + 5__3)); awaiter = UnityAsyncExtensions.GetAwaiter(new UnityWebRequest(5__2) { downloadHandler = (DownloadHandler)new DownloadHandlerBuffer() }.SendWebRequest()); if (!((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 1); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__14>(ref awaiter, ref this); return; } goto IL_019d; } goto end_IL_000e; IL_019d: UnityWebRequest result2 = ((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).GetResult(); string text2 = Path.Combine(CustomBoomboxMusic.PluginPath, "CustomBoomboxMusic"); if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); } if (result2 != null && (int)result2.result == 1) { byte[] data = result2.downloadHandler.data; string text3 = text2 + "/" + 5__3.Replace("%", "_").Replace(":", "_").Replace("?", "_") .Replace("=", "_") .Replace("&", "_") .Replace("#", "_") .Replace("~", "_") .Replace("*", "_") .Replace("<", "_") .Replace(">", "_") .Replace("|", "_") + ".mp3"; File.WriteAllBytes(text3, data); FileInfo fileInfo = new FileInfo(text3); CustomBoomboxMusic.Logger.LogDebug((object)$"Downloaded Song! : {5__3} Size : {fileInfo.Length / 1024}KB"); AudioManager.ProcessFile(fileInfo, out var audioFile); if (audioFile != null) { if (((NetworkBehaviour)modNetworkBehaviour).NetworkManager.IsHost) { modNetworkBehaviour.StartPlayingMusicClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boomboxItem).NetworkObject), audioFile.Crc.Value); } else { modNetworkBehaviour.StartPlayingMusicServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)boomboxItem).NetworkObject), audioFile.Crc.Value); } } HUDManager.Instance.AddTextToChatOnServer("Song has been downloaded and added to the boombox! name : " + 5__3, -1); } else { CustomBoomboxMusic.Logger.LogError((object)("Failed to download song! : " + 5__3)); } end_IL_000e:; } catch (Exception exception) { <>1__state = -2; 5__2 = null; 5__3 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; 5__2 = null; 5__3 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } public static ModNetworkBehaviour? Instance { get; private set; } public override void OnNetworkSpawn() { CustomBoomboxMusic.Logger.LogDebug((object)(">> OnNetworkSpawn() Instance:" + (((object)Instance)?.ToString() ?? "null"))); if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { ModNetworkBehaviour? instance = Instance; if (instance != null) { NetworkObject component = ((Component)instance).gameObject.GetComponent(); if (component != null) { component.Despawn(true); } } } Instance = this; ((NetworkBehaviour)this).OnNetworkSpawn(); } public static bool IsInBoomboxRange(BoomboxItem? boombox) { //IL_00a0: 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_00b3: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = StartOfRound.Instance?.localPlayerController; CustomBoomboxMusic.Logger.LogDebug((object)$">> IsInBoomboxRange(boombox: {boombox}) localPlayer:{val} isPLayerDead:{val?.isPlayerDead} spectatedPlayerScript:{val?.spectatedPlayerScript}"); bool flag = boombox != null && boombox.boomboxAudio != null; if (flag) { bool flag2 = ((val != null && (!val.isPlayerDead || val.spectatedPlayerScript != null)) ? true : false); flag = flag2; } if (flag) { if (!(Vector3.Distance(((Component)boombox.boomboxAudio).transform.position, val.isPlayerDead ? ((Component)val.spectatedPlayerScript).transform.position : ((Component)val).transform.position) <= boombox.boomboxAudio.maxDistance) && !((NetworkBehaviour)boombox).IsOwner) { return ((NetworkBehaviour)boombox).OwnerClientId == val.spectatedPlayerScript.actualClientId; } return true; } return false; } public override void OnNetworkDespawn() { CustomBoomboxMusic.Logger.LogDebug((object)string.Format(">> OnNetworkDespawn() Instance:{0} ==this:{1}", ((object)Instance)?.ToString() ?? "null", (Object)(object)Instance == (Object)(object)this)); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } ((NetworkBehaviour)this).OnNetworkDespawn(); } private static void Play(BoomboxItem boombox, AudioFile clip) { CustomBoomboxMusic.Logger.LogDebug((object)$">> Play({boombox}, {clip}) IsOwner:{((NetworkBehaviour)boombox).IsOwner}"); boombox.boomboxAudio.clip = clip.AudioClip; boombox.boomboxAudio.pitch = 1f; boombox.boomboxAudio.Play(); ((GrabbableObject)boombox).isBeingUsed = (boombox.isPlayingMusic = true); if (!((Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null) && (!GameNetworkManager.Instance.localPlayerController.isPlayerDead || GameNetworkManager.Instance.localPlayerController.hasBegunSpectating) && IsInBoomboxRange(boombox)) { CustomBoomboxMusic.AnnouncePlaying(clip); } } private static void PlayFallback(BoomboxItem boombox, string missingName) { CustomBoomboxMusic.Logger.LogDebug((object)$">> PlayFallback({boombox}, {missingName}) IsOwner:{((NetworkBehaviour)boombox).IsOwner}"); boombox.boomboxAudio.clip = boombox.musicAudios[boombox.musicRandomizer.Next(boombox.musicAudios.Length)]; boombox.boomboxAudio.pitch = 1f; boombox.boomboxAudio.Play(); ((GrabbableObject)boombox).isBeingUsed = (boombox.isPlayingMusic = true); if (!((Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null) && (!GameNetworkManager.Instance.localPlayerController.isPlayerDead || GameNetworkManager.Instance.localPlayerController.hasBegunSpectating) && IsInBoomboxRange(boombox)) { CustomBoomboxMusic.AnnounceMissing(missingName); } } [ServerRpc(RequireOwnership = false)] public void StartPlayingMusicServerRpc(NetworkObjectReference boomboxObjectReference, uint crc, string? clipName = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(216803380u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, crc); bool flag = clipName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(clipName, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 216803380u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; CustomBoomboxMusic.Logger.LogDebug((object)$">> StartPlayingMusicServerRpc({boomboxObjectReference}, {crc})"); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val3, (NetworkManager)null)) { StartPlayingMusicClientRpc(boomboxObjectReference, crc, clipName); } else { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingMusicServerRpc] Boombox object could not be found, dropping request"); } } } [ClientRpc] public void StartPlayingMusicClientRpc(NetworkObjectReference boomboxObjectReference, uint crc, string? clipName = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3131806306u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, crc); bool flag = clipName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(clipName, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3131806306u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; CustomBoomboxMusic.Logger.LogDebug((object)$">> StartPlayingMusicClientRpc({boomboxObjectReference}, {crc}, {clipName})"); NetworkObject val3 = default(NetworkObject); if (!((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val3, (NetworkManager)null)) { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingMusicClientRpc] Boombox object could not be found, dropping request"); return; } CustomBoomboxMusic.Logger.LogDebug((object)$" {val3}"); BoomboxItem val4 = default(BoomboxItem); if (!((Component)val3).TryGetComponent(ref val4)) { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingMusicClientRpc] Boombox component could not be found, dropping request"); return; } CustomBoomboxMusic.Logger.LogDebug((object)$" {val4}"); if (!AudioManager.TryGetCrc(crc, out var audioClip)) { CustomBoomboxMusic.Logger.LogWarning((object)$"Couldn't find AudioClip with crc32 {crc}, playing fallback"); PlayFallback(val4, $"{clipName} (CRC32: {crc})"); } else { CustomBoomboxMusic.Logger.LogDebug((object)$" {audioClip}"); Play(val4, audioClip); } } [ServerRpc(RequireOwnership = false)] public void StartPlayingVanillaMusicServerRpc(NetworkObjectReference boomboxObjectReference, int vanillaId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3312431966u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, vanillaId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3312431966u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; CustomBoomboxMusic.Logger.LogDebug((object)$">> StartPlayingVanillaMusicServerRpc({boomboxObjectReference}, {vanillaId})"); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val3, (NetworkManager)null)) { StartPlayingVanillaMusicClientRpc(boomboxObjectReference, vanillaId); } else { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingVanillaMusicServerRpc] Boombox object could not be found, dropping request"); } } } [ClientRpc] public void StartPlayingVanillaMusicClientRpc(NetworkObjectReference boomboxObjectReference, int vanillaId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(623513330u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, vanillaId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 623513330u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; CustomBoomboxMusic.Logger.LogDebug((object)$">> StartPlayingVanillaMusicClientRpc({boomboxObjectReference}, {vanillaId})"); NetworkObject val3 = default(NetworkObject); if (!((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val3, (NetworkManager)null)) { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingVanillaMusicClientRpc] Boombox object could not be found, dropping request"); return; } CustomBoomboxMusic.Logger.LogDebug((object)$" {val3}"); BoomboxItem val4 = default(BoomboxItem); if (!((Component)val3).TryGetComponent(ref val4)) { CustomBoomboxMusic.Logger.LogWarning((object)"[StartPlayingMusicClientRpc] Boombox component could not be found, dropping request"); return; } CustomBoomboxMusic.Logger.LogDebug((object)$" {val4}"); if (!AudioManager.TryGetVanillaId(val4, vanillaId, out var audioClip)) { CustomBoomboxMusic.Logger.LogWarning((object)$"Couldn't find AudioClip with vanillaId {vanillaId}, playing fallback"); PlayFallback(val4, $"Boombox {vanillaId + 1} (Lethal Company)"); } else { CustomBoomboxMusic.Logger.LogDebug((object)$" {audioClip}"); Play(val4, audioClip); } } [Rpc(/*Could not decode attribute arguments.*/)] internal void DownloadSong_Rpc(string songID, NetworkObjectReference boomboxObjectReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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: 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_00b2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2829645196u, val2, val, (SendTo)6, (RpcDelivery)0); bool flag = songID != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val3)).WriteValueSafe(songID, false); } ((FastBufferWriter)(ref val3)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 2829645196u, val2, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); BoomboxItem boomboxItem = default(BoomboxItem); if (((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent(ref boomboxItem)) { UniTaskExtensions.Forget(DownloadSongAsync(songID, boomboxItem)); } } } [AsyncStateMachine(typeof(d__14))] private UniTask DownloadSongAsync(string songID, BoomboxItem boomboxItem) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__14 d__ = default(d__14); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>4__this = this; d__.songID = songID; d__.boomboxItem = boomboxItem; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__14>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } [Rpc(/*Could not decode attribute arguments.*/)] internal void DownloadDirectLinkSong_Rpc(string url, NetworkObjectReference boomboxObjectReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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: 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_00b2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(3475648198u, val2, val, (SendTo)6, (RpcDelivery)0); bool flag = url != null; ((FastBufferWriter)(ref val3)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val3)).WriteValueSafe(url, false); } ((FastBufferWriter)(ref val3)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 3475648198u, val2, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); BoomboxItem boomboxItem = default(BoomboxItem); if (((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent(ref boomboxItem)) { UniTaskExtensions.Forget(DownloadDirectLinkSongAsync(url, boomboxItem)); } } } [AsyncStateMachine(typeof(d__16))] private UniTask DownloadDirectLinkSongAsync(string url, BoomboxItem boomboxItem) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) d__16 d__ = default(d__16); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>4__this = this; d__.url = url; d__.boomboxItem = boomboxItem; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__16>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } [Rpc(/*Could not decode attribute arguments.*/)] internal void BoomBoxBypassReverb_Rpc(bool bypass, NetworkObjectReference boomboxObjectReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a9: 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) //IL_00db: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(4232062437u, val2, val, (SendTo)6, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref bypass, default(ForPrimitives)); ((FastBufferWriter)(ref val3)).WriteValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 4232062437u, val2, val, (SendTo)6, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); BoomboxItem val5 = default(BoomboxItem); if (((NetworkObjectReference)(ref boomboxObjectReference)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent(ref val5)) { Debug.Log((object)("BoomBoxBypassReverb_Rpc called! value : " + bypass)); val5.boomboxAudio.bypassReverbZones = bypass; val5.boomboxAudio.bypassEffects = bypass; val5.boomboxAudio.bypassListenerEffects = bypass; ((Behaviour)((Component)val4).GetComponent()).enabled = !bypass; } } } private static string GetFileName(string contentDisposition) { if (string.IsNullOrEmpty(contentDisposition)) { return DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".mp3"; } Match match = Regex.Match(contentDisposition, "filename\\*=UTF-8''([^;]+)"); if (match.Success) { return Uri.UnescapeDataString(match.Groups[1].Value); } match = Regex.Match(contentDisposition, "filename=\"?([^\";]+)\"?"); if (match.Success) { return match.Groups[1].Value; } return DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".mp3"; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(216803380u, new RpcReceiveHandler(__rpc_handler_216803380), "StartPlayingMusicServerRpc"); ((NetworkBehaviour)this).__registerRpc(3131806306u, new RpcReceiveHandler(__rpc_handler_3131806306), "StartPlayingMusicClientRpc"); ((NetworkBehaviour)this).__registerRpc(3312431966u, new RpcReceiveHandler(__rpc_handler_3312431966), "StartPlayingVanillaMusicServerRpc"); ((NetworkBehaviour)this).__registerRpc(623513330u, new RpcReceiveHandler(__rpc_handler_623513330), "StartPlayingVanillaMusicClientRpc"); ((NetworkBehaviour)this).__registerRpc(2829645196u, new RpcReceiveHandler(__rpc_handler_2829645196), "DownloadSong_Rpc"); ((NetworkBehaviour)this).__registerRpc(3475648198u, new RpcReceiveHandler(__rpc_handler_3475648198), "DownloadDirectLinkSong_Rpc"); ((NetworkBehaviour)this).__registerRpc(4232062437u, new RpcReceiveHandler(__rpc_handler_4232062437), "BoomBoxBypassReverb_Rpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_216803380(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); uint crc = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref crc); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string clipName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref clipName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).StartPlayingMusicServerRpc(boomboxObjectReference, crc, clipName); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3131806306(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); uint crc = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref crc); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string clipName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref clipName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).StartPlayingMusicClientRpc(boomboxObjectReference, crc, clipName); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3312431966(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: 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) //IL_005c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); int vanillaId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref vanillaId); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).StartPlayingVanillaMusicServerRpc(boomboxObjectReference, vanillaId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_623513330(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_003e: 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) //IL_005c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); int vanillaId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref vanillaId); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).StartPlayingVanillaMusicClientRpc(boomboxObjectReference, vanillaId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2829645196(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_007c: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string songID = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref songID, false); } NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).DownloadSong_Rpc(songID, boomboxObjectReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3475648198(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_007c: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string url = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref url, false); } NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).DownloadDirectLinkSong_Rpc(url, boomboxObjectReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4232062437(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool bypass = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref bypass, default(ForPrimitives)); NetworkObjectReference boomboxObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref boomboxObjectReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModNetworkBehaviour)(object)target).BoomBoxBypassReverb_Rpc(bypass, boomboxObjectReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ModNetworkBehaviour"; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LTGVE.CustomBoomboxMusic"; public const string PLUGIN_NAME = "CustomBoomboxMusic"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } }