using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("MonoGame Team")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("BoomboxController")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BoomboxController")] [assembly: AssemblyTitle("BoomboxController")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoGame/MonoGame")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BoomboxController { [BepInPlugin("KoderTech.BoomboxController", "BoomboxController", "1.1.0")] public class Plugin : BaseUnityPlugin { public static Plugin instance; private static Harmony HarmonyLib; public static Configs config; private void Awake() { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown instance = this; if (File.Exists("BoomboxController\\lang\\boombox_ru.cfg")) { File.Delete("BoomboxController\\lang\\boombox_ru.cfg"); } if (File.Exists("BoomboxController\\lang\\boombox_en.cfg")) { File.Delete("BoomboxController\\lang\\boombox_en.cfg"); } config = new Configs(); config.GetConfig(); string text = config.languages.Value.ToLower(); string text2 = text; if (!(text2 == "ru")) { if (text2 == "en") { config.GetLang().GetConfigEN(); } } else { config.GetLang().GetConfigRU(); } WriteLogo(); if (!Directory.Exists("BoomboxController\\lang")) { Directory.CreateDirectory("BoomboxController\\lang"); } if (!Directory.Exists("BoomboxController\\other")) { Directory.CreateDirectory("BoomboxController\\other"); } if (!Directory.Exists("BoomboxController\\other\\playlist")) { Directory.CreateDirectory("BoomboxController\\other\\playlist"); } if (!File.Exists("BoomboxController\\other\\ffmpeg.exe")) { if (File.Exists("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip")) { Unpacking(); } else { Thread thread = new Thread((ThreadStart)delegate { DownloadFilesToUnpacking(new Uri("https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"), "BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip"); }); thread.Start(); } } HarmonyLib = new Harmony("com.kodertech.BoomboxController"); HarmonyLib.PatchAll(typeof(BoomboxController)); } public void WriteLogo() { ((BaseUnityPlugin)this).Logger.LogInfo((object)" /$$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$__ $$ | $$__ $$ /$$__ $$ | $$ | $$| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$ \\ $$ /$$$$$$ /$$$$$$ /$$$$$$/$$$$ | $$ \\ $$ /$$$$$$ /$$ /$$ | $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$| $$ /$$$$$$ /$$$$$$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$$$$$$ /$$__ $$ /$$__ $$| $$_ $$_ $$| $$$$$$$ /$$__ $$| $$ /$$/ | $$ /$$__ $$| $$__ $$|_ $$_/ /$$__ $$ /$$__ $$| $$| $$ /$$__ $$ /$$__ $$"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$__ $$| $$ \\ $$| $$ \\ $$| $$ \\ $$ \\ $$| $$__ $$| $$ \\ $$ \\ $$$$/ | $$ | $$ \\ $$| $$ \\ $$ | $$ | $$ \\__/| $$ \\ $$| $$| $$| $$$$$$$$| $$ \\__/"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$ \\ $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$ \\ $$| $$ | $$ >$$ $$ | $$ $$| $$ | $$| $$ | $$ | $$ /$$| $$ | $$ | $$| $$| $$| $$_____/| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"| $$$$$$$/| $$$$$$/| $$$$$$/| $$ | $$ | $$| $$$$$$$/| $$$$$$/ /$$/\\ $$ | $$$$$$/| $$$$$$/| $$ | $$ | $$$$/| $$ | $$$$$$/| $$| $$| $$$$$$$| $$ "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"|_______/ \\______/ \\______/ |__/ |__/ |__/|_______/ \\______/ |__/ \\__/ \\______/ \\______/ |__/ |__/ \\___/ |__/ \\______/ |__/|__/ \\_______/|__/ "); } public static void DownloadFilesToUnpacking(Uri uri, string filename) { WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += Web_DownloadFileCompletedToUnpacking; webClient.DownloadFileAsync(uri, filename); } public static void DownloadFiles(Uri uri, string filename) { WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += Web_DownloadFileCompleted; webClient.DownloadFileAsync(uri, filename); } private static void Web_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { Thread.CurrentThread.Abort(); } private static void Web_DownloadFileCompletedToUnpacking(object sender, AsyncCompletedEventArgs e) { Unpacking(); if (!File.Exists("BoomboxController\\other\\yt-dlp.exe")) { Thread thread = new Thread((ThreadStart)delegate { DownloadFiles(new Uri("https://github.com/yt-dlp/yt-dlp/releases/download/2023.11.16/yt-dlp.exe"), "BoomboxController\\other\\yt-dlp.exe"); }); thread.Start(); } Thread.CurrentThread.Abort(); } public static void Unpacking() { using (ZipArchive zipArchive = ZipFile.OpenRead("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip")) { foreach (ZipArchiveEntry entry in zipArchive.Entries) { if (entry.Name.Equals("ffmpeg.exe")) { entry.ExtractToFile(Path.Combine("BoomboxController\\other", entry.Name)); } } } File.Delete("BoomboxController\\other\\ffmpeg-master-latest-win64-gpl.zip"); } public void Log(object message) { ((BaseUnityPlugin)this).Logger.LogInfo(message); } } public class QuitManager : MonoBehaviour { private void OnApplicationQuit() { DeleteFile(); } public void DeleteFile() { FileInfo[] files = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles(); foreach (FileInfo fileInfo in files) { fileInfo.Delete(); } FileInfo[] files2 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (files2.Length == 1) { File.Delete("BoomboxController\\other\\" + files2[0].Name); } } } public class Configs { public class Lang { public ConfigEntry main_1; public ConfigEntry main_2; public ConfigEntry main_3; public ConfigEntry main_4; public ConfigEntry main_5; public ConfigEntry main_6; public ConfigEntry main_7; public ConfigEntry main_8; public ConfigEntry main_9; public ConfigEntry main_10; public ConfigEntry main_11; public ConfigEntry main_12; public ConfigEntry main_13; public ConfigEntry main_14; public void GetConfigRU() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\lang\\boombox_ru.cfg", true); main_1 = val.Bind("General", "Main_1", "Пожалуйста, подождите, загружаются дополнительные библиотеки, чтобы модификация заработала.", (ConfigDescription)null); main_2 = val.Bind("General", "Main_2", "Взять BoomBox[1.0.0] : [E]\n@2 - @3\n@1 громкость\nСейчас играет: @4\nДоступных треков: @5\nУвеличить громкость [PU]\nУменьшить громкость [PG]", (ConfigDescription)null); main_3 = val.Bind("General", "Main_3", "Все дополнительные библиотеки загружены, теперь вы можете использовать команды для бумбокса.", (ConfigDescription)null); main_4 = val.Bind("General", "Main_4", "Подождите, трек еще загружается!", (ConfigDescription)null); main_5 = val.Bind("General", "Main_5", "Команды:\n/bplay - Проиграть музыку\n/btime - Изменить позицию песни\n/bvolume - Изменить громкость трека", (ConfigDescription)null); main_6 = val.Bind("General", "Main_6", "Введите правильный URL-адрес!", (ConfigDescription)null); main_7 = val.Bind("General", "Main_7", "Пожалуйста подождите...", (ConfigDescription)null); main_8 = val.Bind("General", "Main_8", "Трек был загружен в бумбокс", (ConfigDescription)null); main_9 = val.Bind("General", "Main_9", "@1 изменил громкость трека @2", (ConfigDescription)null); main_10 = val.Bind("General", "Main_10", "Введите правильную громкость трека (пример: 0, 10, 20, 30...)!", (ConfigDescription)null); main_11 = val.Bind("General", "Main_11", "Ссылка недействительная!", (ConfigDescription)null); main_12 = val.Bind("General", "Main_12", "Позиция трека изменена на @1!", (ConfigDescription)null); main_13 = val.Bind("General", "Main_13", "Загрузка трека отменена!", (ConfigDescription)null); main_14 = val.Bind("General", "Main_14", "Текущий трек был переключен на: @1!", (ConfigDescription)null); } public void GetConfigEN() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\lang\\boombox_en.cfg", true); main_1 = val.Bind("General", "Main_1", "Please wait, additional libraries are being loaded for the modification to work.", (ConfigDescription)null); main_2 = val.Bind("General", "Main_2", "Pickup BoomBox[1.0.0] : [E]\n@2 - @3\n@1 volume\nNow playing: @4\nAvailable tracks: @5\nIncrease volume [PU]\nDecrease volume [PG]", (ConfigDescription)null); main_3 = val.Bind("General", "Main_3", "All libraries have loaded, now you can use the boombox commands.", (ConfigDescription)null); main_4 = val.Bind("General", "Main_4", "Another track is being uploaded to the boombox!", (ConfigDescription)null); main_5 = val.Bind("General", "Main_5", "Commands:\n/bplay - Play music\n/btime - Change the position of the song\n/bvolume - Change Boombox volume", (ConfigDescription)null); main_6 = val.Bind("General", "Main_6", "Enter the correct URL!", (ConfigDescription)null); main_7 = val.Bind("General", "Main_7", "Please wait...", (ConfigDescription)null); main_8 = val.Bind("General", "Main_8", "The track was uploaded to the boombox", (ConfigDescription)null); main_9 = val.Bind("General", "Main_9", "@1 changed the volume @2 of the boombox.", (ConfigDescription)null); main_10 = val.Bind("General", "Main_10", "Enter the correct Volume (example: 0, 10, 20, 30...)!", (ConfigDescription)null); main_11 = val.Bind("General", "Main_11", "Link is invalid!", (ConfigDescription)null); main_12 = val.Bind("General", "Main_12", "Track position changed to @1!", (ConfigDescription)null); main_13 = val.Bind("General", "Main_13", "Track download canceled!", (ConfigDescription)null); main_14 = val.Bind("General", "Main_14", "The current track has been switched to: @1!", (ConfigDescription)null); } } public ConfigEntry requstbattery; public ConfigEntry languages; public static Lang lang = new Lang(); public void GetConfig() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ConfigFile val = new ConfigFile("BoomboxController\\boombox_controller.cfg", true); requstbattery = val.Bind("General.Toggles", "RequestBattery", false, "Enable/disable boombox battery (that is true = Enable; false = Disable)"); languages = val.Bind("General", "Languages", "en", "EN/RU"); } public Lang GetLang() { return lang; } } public class BoomboxController : MonoBehaviour { public static bool startMusics = true; public static AudioBoomBox bom; public static int timesPlayedWithoutTurningOff = 0; public static BoomboxItem boomboxItem = new BoomboxItem(); public static int isSendingItemRPC = 0; public static string LastMessage; public static bool LoadingMusicBoombox = false; public static bool LoadingLibrary = false; public static string LastnameOfUserWhoTyped; public static double curretTime = 0.0; public static double totalTime = 0.0; public static Thread thread; public static bool isplayList = false; public static int Id = 0; public static int totalTack = 0; public static int currectTrack = 0; public static string NameTrack; public static AudioClip[] musicList; public static QuitManager quit; public static QuitManager quits; [HarmonyPatch(typeof(MenuManager), "OnEnable")] [HarmonyPrefix] public static void OnEnable() { //IL_0020: 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_003e: Expected O, but got Unknown LastMessage = string.Empty; if ((Object)(object)quit == (Object)null) { quit = new GameObject("QuitManager").AddComponent(); Object.DontDestroyOnLoad((Object)quit); } } [HarmonyPatch(typeof(StartOfRound), "OnEnable")] [HarmonyPrefix] public static void OnEnables() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if ((Object)(object)quits == (Object)null) { quits = new GameObject("QuitManager").AddComponent(); Object.DontDestroyOnLoad((Object)quits); } } [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPrefix] public static bool SetHoverTipAndCurrentInteractTrigger(PlayerControllerB __instance, ref RaycastHit ___hit, ref Ray ___interactRay, ref int ___playerMask, ref int ___interactableObjectsMask) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) //IL_0038: 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_0b00: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isGrabbingObjectAnimation) { ___interactRay = new Ray(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward); if (Physics.Raycast(___interactRay, ref ___hit, __instance.grabDistance, ___interactableObjectsMask) && ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.layer != 8) { string tag = ((Component)((RaycastHit)(ref ___hit)).collider).tag; if (!(tag == "PhysicsProp")) { if (tag == "InteractTrigger") { InteractTrigger component = ((Component)((RaycastHit)(ref ___hit)).transform).gameObject.GetComponent(); if ((Object)(object)component != (Object)(object)__instance.previousHoveringOverTrigger && (Object)(object)__instance.previousHoveringOverTrigger != (Object)null) { __instance.previousHoveringOverTrigger.isBeingHeldByPlayer = false; } if (!((Object)(object)component == (Object)null)) { __instance.hoveringOverTrigger = component; if (!component.interactable) { __instance.cursorIcon.sprite = component.disabledHoverIcon; ((Behaviour)__instance.cursorIcon).enabled = (Object)(object)component.disabledHoverIcon != (Object)null; ((TMP_Text)__instance.cursorTip).text = component.disabledHoverTip; } else if (component.isPlayingSpecialAnimation) { ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = ""; } else if (__instance.isHoldingInteract) { if (__instance.twoHanded) { ((TMP_Text)__instance.cursorTip).text = "[Hands full]"; } else if (!string.IsNullOrEmpty(component.holdTip)) { ((TMP_Text)__instance.cursorTip).text = component.holdTip; } } else { ((Behaviour)__instance.cursorIcon).enabled = true; __instance.cursorIcon.sprite = component.hoverIcon; ((TMP_Text)__instance.cursorTip).text = component.hoverTip; } } } } else { if (FirstEmptyItemSlot(__instance) == -1) { ((TMP_Text)__instance.cursorTip).text = "Inventory full!"; } else { GrabbableObject component2 = ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.GetComponent(); if (!GameNetworkManager.Instance.gameHasStarted && !component2.itemProperties.canBeGrabbedBeforeGameStart && (Object)(object)StartOfRound.Instance.testRoom == (Object)null) { ((TMP_Text)__instance.cursorTip).text = "(Cannot pickup until ship is landed)"; } if ((Object)(object)((Component)((RaycastHit)(ref ___hit)).transform).gameObject.GetComponent() != (Object)null) { float volume = boomboxItem.boomboxAudio.volume; if ((Object)(object)component2 != (Object)null && !string.IsNullOrEmpty(component2.customGrabTooltip)) { ((TMP_Text)__instance.cursorTip).text = component2.customGrabTooltip; } if (GameNetworkManager.Instance.gameHasStarted && ((Object)((RaycastHit)(ref ___hit)).transform).name.ToString() == "Boombox(Clone)") { if (!File.Exists("BoomboxController\\other\\ffmpeg.exe") || !File.Exists("BoomboxController\\other\\yt-dlp.exe")) { ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_1.Value; } else { if (!boomboxItem.isPlayingMusic) { curretTime = 0.0; totalTime = 0.0; } int num = (int)curretTime % 3600; string text = Mathf.Floor((float)((int)curretTime / 3600)).ToString("00"); string text2 = Mathf.Floor((float)(num / 60)).ToString("00"); string text3 = Mathf.Floor((float)(num % 60)).ToString("00"); int num2 = (int)totalTime % 3600; string text4 = Mathf.Floor((float)((int)totalTime / 3600)).ToString("00"); string text5 = Mathf.Floor((float)(num2 / 60)).ToString("00"); string text6 = Mathf.Floor((float)(num2 % 60)).ToString("00"); if (Plugin.config.languages.Value == "en" && (musicList == null || musicList.Length != 0)) { string text7 = (boomboxItem.isPlayingMusic ? "[Home]" : "Nothing"); ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", text7 ?? "") .Replace("@5", $"{totalTack}"); } if (Plugin.config.languages.Value == "ru" && (musicList == null || musicList.Length != 0)) { string text8 = (boomboxItem.isPlayingMusic ? "[Home]" : "Нечего"); ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", text8 ?? "") .Replace("@5", $"{totalTack}"); } if (((ButtonControl)Keyboard.current.pageDownKey).wasPressedThisFrame && volume > 0f) { float volume2 = volume - 0.1f; boomboxItem.boomboxAudio.volume = volume2; } if (((ButtonControl)Keyboard.current.pageUpKey).wasPressedThisFrame && volume < 1f) { float volume3 = volume + 0.1f; boomboxItem.boomboxAudio.volume = volume3; } if (InputControlExtensions.IsPressed((InputControl)(object)Keyboard.current.homeKey, 0f)) { if (musicList.Length == 1) { ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", NameTrack.Substring(0, NameTrack.Length - 4) ?? "") .Replace("@5", $"{totalTack}"); } if (musicList.Length > 1) { ((TMP_Text)__instance.cursorTip).text = Plugin.config.GetLang().main_2.Value.Replace("@1", $"{Math.Round(volume * 100f)}%").Replace("@2", text + ":" + text2 + ":" + text3).Replace("@3", text4 + ":" + text5 + ":" + text6) .Replace("@4", NameTrack.Replace(" ", "") ?? "") .Replace("@5", $"{totalTack}"); } } } } } } ((Behaviour)__instance.cursorIcon).enabled = true; __instance.cursorIcon.sprite = __instance.grabItemIcon; } } else { ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = ""; if ((Object)(object)__instance.hoveringOverTrigger != (Object)null) { __instance.previousHoveringOverTrigger = __instance.hoveringOverTrigger; } __instance.hoveringOverTrigger = null; } } if (StartOfRound.Instance.localPlayerUsingController) { StringBuilder stringBuilder = new StringBuilder(((TMP_Text)__instance.cursorTip).text); stringBuilder.Replace("[E]", "[X]"); stringBuilder.Replace("[LMB]", "[X]"); stringBuilder.Replace("[RMB]", "[R-Trigger]"); stringBuilder.Replace("[F]", "[R-Shoulder]"); stringBuilder.Replace("[Z]", "[L-Shoulder]"); ((TMP_Text)__instance.cursorTip).text = stringBuilder.ToString(); } else { ((TMP_Text)__instance.cursorTip).text = ((TMP_Text)__instance.cursorTip).text.Replace("[LMB]", "[E]"); } if (!__instance.isFreeCamera && Physics.Raycast(___interactRay, ref ___hit, 5f, ___playerMask)) { PlayerControllerB component3 = ((Component)((RaycastHit)(ref ___hit)).collider).gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.ShowNameBillboard(); } } return false; } [HarmonyPatch(typeof(BoomboxItem), "Start")] [HarmonyPrefix] private static void Start(BoomboxItem __instance) { bom = new AudioBoomBox(); __instance.boomboxAudio.volume = 0.5f; __instance.musicAudios = null; ((GrabbableObject)__instance).itemProperties.requiresBattery = Plugin.config.requstbattery.Value; boomboxItem = __instance; } [HarmonyPatch(typeof(BoomboxItem), "StartMusic")] [HarmonyPrefix] private static bool Prefix(BoomboxItem __instance, bool startMusic, bool pitchDown, ref int ___timesPlayedWithoutTurningOff) { if (!LoadingMusicBoombox) { Plugin.instance.Log(startMusic + " startmusic"); if (startMusic) { boomboxItem.boomboxAudio.clip = musicList[currectTrack]; boomboxItem.boomboxAudio.pitch = 1f; boomboxItem.boomboxAudio.Play(); boomboxItem.isPlayingMusic = startMusic; ((GrabbableObject)boomboxItem).isBeingUsed = startMusic; startMusics = false; } else if (boomboxItem.isPlayingMusic) { boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = startMusic; ((GrabbableObject)boomboxItem).isBeingUsed = startMusic; startMusics = true; } } return false; } [HarmonyPatch(typeof(BoomboxItem), "Update")] [HarmonyPrefix] private static void Postfix(BoomboxItem __instance, ref int ___timesPlayedWithoutTurningOff) { if (timesPlayedWithoutTurningOff <= 0) { ___timesPlayedWithoutTurningOff = 0; } timesPlayedWithoutTurningOff = ___timesPlayedWithoutTurningOff; if (boomboxItem.isPlayingMusic) { curretTime = boomboxItem.boomboxAudio.time; totalTime = boomboxItem.boomboxAudio.clip.length; } else { boomboxItem.boomboxAudio.time = 0f; } if (musicList != null) { totalTack = musicList.Length; } } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPrefix] private static void Updat(HUDManager __instance) { if (File.Exists("BoomboxController\\other\\ffmpeg.exe") && File.Exists("BoomboxController\\other\\yt-dlp.exe") && LoadingLibrary) { DrawString(__instance, Plugin.config.GetLang().main_3.Value, "Boombox", "Boombox"); LoadingLibrary = false; } } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPrefix] private static void StartPostfix(HUDManager __instance) { __instance.chatTextField.characterLimit = 200; } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] [HarmonyPrefix] private static bool AddChatMessage(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped) { if (!(__instance.lastChatMessage == chatMessage)) { __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("" + nameOfUserWhoTyped + ": '" + chatMessage + "'") : ("" + chatMessage + "")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[i]; } } AddChatMessageMain(__instance, chatMessage, nameOfUserWhoTyped); return false; } public static async void AddChatMessageMain(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped) { if (!File.Exists("BoomboxController\\other\\ffmpeg.exe") || !File.Exists("BoomboxController\\other\\yt-dlp.exe")) { DrawString(__instance, Plugin.config.GetLang().main_1.Value, "Boombox", nameOfUserWhoTyped); LoadingLibrary = true; return; } string[] vs = chatMessage.Split(new char[1] { ' ' }); switch (vs[0].Replace("/", "")) { case "bhelp": if (Plugin.config.languages.Value.ToLower().Equals("en")) { DrawString(__instance, Plugin.config.GetLang().main_5.Value + "\nThe creator of the mod is KoderTech.\nWith love from Russia", "Boombox", nameOfUserWhoTyped); } if (Plugin.config.languages.Value.ToLower().Equals("ru")) { DrawString(__instance, Plugin.config.GetLang().main_5.Value + "\nСоздатель мода KoderTech.\nСпасибо что вы скачали именно этот мод)))", "Boombox", nameOfUserWhoTyped); } break; case "bplay": { Regex regex = new Regex("^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"); if (regex.IsMatch(vs[1])) { string url = vs[1].Remove(0, 8); string text2 = url.Substring(0, url.IndexOf('/')); string text3 = text2; string text4 = text3; if (!(text4 == "www.youtube.com")) { if (text4 == "soundcloud.com") { if (vs[1].Contains("sets")) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox SoundCloud", nameOfUserWhoTyped); break; } boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; FileInfo[] file2 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (file2.Length == 1) { File.Delete("BoomboxController\\other\\" + file2[0].Name); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox SoundCloud", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag4 = false; Process process3 = new Process(); process3.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process3.StartInfo.UseShellExecute = false; process3.StartInfo.Arguments = vs[1] ?? ""; process3.StartInfo.WorkingDirectory = "BoomboxController\\other"; process3.StartInfo.CreateNoWindow = true; process3.Start(); Id = process3.Id; while (!flag4) { FileInfo[] files4 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); foreach (FileInfo fileInfo3 in files4) { if (fileInfo3.Exists) { NameTrack = fileInfo3.Name; } } if (Process.GetProcessById(process3.Id).HasExited) { if (File.Exists("BoomboxController\\other\\" + NameTrack)) { flag4 = true; } else { DrawString(__instance, Plugin.config.GetLang().main_11.Value, "Boombox SoundCloud", nameOfUserWhoTyped); } break; } Thread.Sleep(1000); } }); if (!File.Exists("BoomboxController\\other\\" + NameTrack)) { LoadingMusicBoombox = false; isplayList = false; } else { currectTrack = 0; bom.Start(bom.GetAudioClip("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\" + NameTrack, boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox SoundCloud", nameOfUserWhoTyped); } } else { int type = GetAudioType(vs[1].Remove(0, vs[1].Length - 3)); if (type == -1) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox", nameOfUserWhoTyped); break; } LoadingMusicBoombox = true; DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox", nameOfUserWhoTyped); bom.Start(bom.GetAudioClip(vs[1], boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox", nameOfUserWhoTyped); } break; } if (vs[1].Contains("search_query")) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } if (vs[1].Contains("playlist")) { boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; if (File.Exists("BoomboxController\\other\\output.txt")) { File.Delete("BoomboxController\\other\\output.txt"); } FileInfo[] files = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles(); foreach (FileInfo track in files) { track.Delete(); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox YouTube", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag3 = false; Process process2 = new Process(); process2.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process2.StartInfo.UseShellExecute = false; process2.StartInfo.Arguments = "-f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 " + vs[1]; process2.StartInfo.WorkingDirectory = "BoomboxController\\other\\playlist"; process2.StartInfo.CreateNoWindow = true; process2.StartInfo.RedirectStandardOutput = true; process2.Start(); string value = process2.StandardOutput.ReadToEnd(); Id = process2.Id; while (!flag3) { if (Process.GetProcessById(process2.Id).HasExited && new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles("*.webm").Length == 0) { flag3 = true; break; } Thread.Sleep(1000); } using StreamWriter streamWriter = File.CreateText("BoomboxController\\other\\output.txt"); streamWriter.WriteLine(value); }); if (new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles("*.mp3").Length == 0) { LoadingMusicBoombox = false; isplayList = false; DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } using (StreamReader sr = new StreamReader("BoomboxController\\other\\output.txt")) { while (sr.Peek() >= 0) { string text = sr.ReadLine(); if (text.Contains("[download] Downloading playlist:")) { string[] vs2 = text.Split(new char[1] { ':' }); NameTrack = vs2[1]; } } } currectTrack = 0; thread = new Thread((ThreadStart)delegate { LoadPlaylist(__instance, nameOfUserWhoTyped); }); thread.Start(); break; } if (vs[1].Contains("list")) { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } boomboxItem.boomboxAudio.Stop(); boomboxItem.boomboxAudio.PlayOneShot(boomboxItem.stopAudios[Random.Range(0, boomboxItem.stopAudios.Length)]); timesPlayedWithoutTurningOff = 0; boomboxItem.isPlayingMusic = false; ((GrabbableObject)boomboxItem).isBeingUsed = false; LoadingMusicBoombox = true; FileInfo[] file = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); if (file.Length == 1) { File.Delete("BoomboxController\\other\\" + file[0].Name); } DrawString(__instance, Plugin.config.GetLang().main_7.Value, "Boombox YouTube", nameOfUserWhoTyped); if (isplayList) { break; } isplayList = true; await Task.Run(delegate { bool flag = false; bool flag2 = false; Process process = new Process(); process.StartInfo.FileName = "BoomboxController\\other\\yt-dlp.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.Arguments = "-f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 " + vs[1]; process.StartInfo.WorkingDirectory = "BoomboxController\\other"; process.StartInfo.CreateNoWindow = true; process.Start(); Id = process.Id; while (!flag) { if (flag2) { if (File.Exists("BoomboxController\\other\\" + NameTrack)) { flag = true; break; } } else { FileInfo[] files2 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.mp3"); foreach (FileInfo fileInfo in files2) { if (fileInfo.Exists) { NameTrack = fileInfo.Name; } } FileInfo[] files3 = new DirectoryInfo("BoomboxController\\other").GetFiles("*.webm"); foreach (FileInfo fileInfo2 in files3) { if (fileInfo2.Exists) { NameTrack = fileInfo2.Name; } } if (Process.GetProcessById(process.Id).HasExited) { if (!File.Exists("BoomboxController\\other\\" + NameTrack) && !File.Exists("BoomboxController\\other\\" + NameTrack)) { DrawString(__instance, Plugin.config.GetLang().main_11.Value, "Boombox YouTube", nameOfUserWhoTyped); break; } flag2 = true; } } Thread.Sleep(1000); } }); if (!File.Exists("BoomboxController\\other\\" + NameTrack)) { LoadingMusicBoombox = false; isplayList = false; } else { currectTrack = 0; bom.Start(bom.GetAudioClip("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\" + NameTrack, boomboxItem, (AudioType)13)); DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox YouTube", nameOfUserWhoTyped); } } else { DrawString(__instance, Plugin.config.GetLang().main_6.Value, "Boombox", nameOfUserWhoTyped); } break; } case "btime": { string[] arg = vs[1].Split(new char[1] { ':' }); switch (arg.Length) { case 2: { if (!boomboxItem.isPlayingMusic) { break; } int arg2 = Convert.ToInt32(arg[0]); int arg4 = Convert.ToInt32(arg[1]); switch (arg2) { case 0: switch (arg4) { case 0: boomboxItem.boomboxAudio.time = 0f; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:00"), "Boombox", nameOfUserWhoTyped); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: boomboxItem.boomboxAudio.time = arg4; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:" + arg4.ToString("00")), "Boombox", nameOfUserWhoTyped); break; } break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: { int correct = arg2 * 60; if (arg4 > 0 && arg4 < 60) { int correct_sec = correct + arg4; boomboxItem.boomboxAudio.time = correct_sec; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg2.ToString("00") + ":" + arg4.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg2.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } break; } } break; } case 3: { if (!boomboxItem.isPlayingMusic) { break; } int arg3 = Convert.ToInt32(arg[0]); int arg5 = Convert.ToInt32(arg[1]); int arg6 = Convert.ToInt32(arg[2]); switch (arg3) { case 0: if (arg5 == 0 && arg6 == 0) { boomboxItem.boomboxAudio.time = 0f; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:00:00"), "Boombox", nameOfUserWhoTyped); } else if (arg5 > 0 && arg5 < 60) { int correct2 = arg5 * 60; if (arg6 > 0 && arg6 < 60) { int correct_sec2 = correct2 + arg6; boomboxItem.boomboxAudio.time = correct_sec2; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg5.ToString("00") + ":" + arg6.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct2; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", "00:" + arg5.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } } break; case 1: case 2: { int correct3 = arg3 * 3600; if (arg5 > 0 && arg5 < 60) { int correct_minutes = correct3 + arg5 * 60; if (arg6 > 0 && arg6 < 60) { int correct_sec3 = correct_minutes + arg6; boomboxItem.boomboxAudio.time = correct_sec3; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":" + arg5.ToString("00") + ":" + arg6.ToString("00")), "Boombox", nameOfUserWhoTyped); } else { boomboxItem.boomboxAudio.time = correct_minutes; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":" + arg5.ToString("00") + ":00"), "Boombox", nameOfUserWhoTyped); } } else { boomboxItem.boomboxAudio.time = correct3; DrawString(__instance, Plugin.config.GetLang().main_12.Value.Replace("@1", arg3.ToString("00") + ":00:00"), "Boombox", nameOfUserWhoTyped); } break; } } break; } } break; } case "bvolume": { float volume = boomboxItem.boomboxAudio.volume; float correct_volume = (float)(Convert.ToInt32(vs[1]) / 10) * 0.1f; if (volume != correct_volume && (volume < correct_volume || volume > correct_volume)) { boomboxItem.boomboxAudio.volume = correct_volume; DrawString(__instance, Plugin.config.GetLang().main_9.Value.Replace("@1", nameOfUserWhoTyped ?? "").Replace("@2", vs[1] + "%"), "Boombox", nameOfUserWhoTyped); } break; } case "btrack": if (Convert.ToInt32(vs[1]) > 0 && Convert.ToInt32(vs[1]) <= totalTack) { int track2 = Convert.ToInt32(vs[1]) - 1; currectTrack = track2; boomboxItem.boomboxAudio.Stop(); timesPlayedWithoutTurningOff = 0; boomboxItem.boomboxAudio.clip = musicList[currectTrack]; boomboxItem.boomboxAudio.pitch = 1f; boomboxItem.boomboxAudio.Play(); DrawString(__instance, Plugin.config.GetLang().main_14.Value.Replace("@1", vs[1] ?? ""), "Boombox", nameOfUserWhoTyped); } break; } } public static void LoadPlaylist(HUDManager __instance, string nameOfUserWhoTyped) { bool flag = false; int num = 0; int num2 = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles().Length; FileInfo[] files = new DirectoryInfo("BoomboxController\\other\\playlist").GetFiles(); while (!flag && num != num2) { if (files[num].Exists) { bom.Start(bom.GetPlayList("file:///" + Paths.GameRootPath + "\\BoomboxController\\other\\playlist\\" + files[num].Name, boomboxItem, (AudioType)13)); num++; } Thread.Sleep(2000); } musicList = bom.audioclipsplay.ToArray(); bom.audioclipsplay.Clear(); LoadingMusicBoombox = false; DrawString(__instance, Plugin.config.GetLang().main_8.Value, "Boombox YouTube", nameOfUserWhoTyped); isplayList = false; thread.Abort(); } public static int GetAudioType(string ext) { if (ext == "mp3") { return 13; } return -1; } public static void DrawString(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped, string? name) { if (!(LastMessage == chatMessage)) { LastMessage = chatMessage; LastnameOfUserWhoTyped = name; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("" + nameOfUserWhoTyped + ": '" + chatMessage + "'") : ("" + chatMessage + "")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[i]; } } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")] [HarmonyPostfix] [ServerRpc(RequireOwnership = false)] private static void AddPlayerChatMessageServerRpc(HUDManager __instance, string chatMessage, int playerId) { if (chatMessage.Length > 50) { MethodInfo method = ((object)__instance).GetType().GetMethod("AddPlayerChatMessageClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(__instance, new object[2] { chatMessage, playerId }); } } [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] private static bool SubmitChat_performed(HUDManager __instance, ref CallbackContext context) { //IL_0106: 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) if (!LoadingMusicBoombox) { __instance.localPlayer = GameNetworkManager.Instance.localPlayerController; if (((CallbackContext)(ref context)).performed && !((Object)(object)__instance.localPlayer == (Object)null) && __instance.localPlayer.isTypingChat && ((((NetworkBehaviour)__instance.localPlayer).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.localPlayer.isHostPlayerObject)) || __instance.localPlayer.isTestingPlayer) && !__instance.localPlayer.isPlayerDead) { if (!string.IsNullOrEmpty(__instance.chatTextField.text) && __instance.chatTextField.text.Length < 200) { __instance.AddTextToChatOnServer(__instance.chatTextField.text, (int)__instance.localPlayer.playerClientId); } for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) > 24.4f && (!GameNetworkManager.Instance.localPlayerController.holdingWalkieTalkie || !StartOfRound.Instance.allPlayerScripts[i].holdingWalkieTalkie)) { __instance.playerCouldRecieveTextChatAnimator.SetTrigger("ping"); break; } } __instance.localPlayer.isTypingChat = false; __instance.chatTextField.text = ""; EventSystem.current.SetSelectedGameObject((GameObject)null); __instance.PingHUDElement(__instance.Chat, 2f, 1f, 0.2f); ((Behaviour)__instance.typingIndicator).enabled = false; return false; } } return false; } public static int FirstEmptyItemSlot(PlayerControllerB __instance) { int result = -1; if ((Object)(object)__instance.ItemSlots[__instance.currentItemSlot] == (Object)null) { result = __instance.currentItemSlot; } else { for (int i = 0; i < __instance.ItemSlots.Length; i++) { if ((Object)(object)__instance.ItemSlots[i] == (Object)null) { result = i; break; } } } return result; } } public class AudioBoomBox : MonoBehaviour { private static AudioBoomBox _instance; public List audioclips = new List(); public List audioclipsplay = new List(); public Coroutine Start(IEnumerator routine) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { _instance = new GameObject("AudioBoomBox").AddComponent(); Object.DontDestroyOnLoad((Object)_instance); } return ((MonoBehaviour)_instance).StartCoroutine(routine); } public IEnumerator GetAudioClip(string url, BoomboxItem boombox, AudioType type) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) audioclips.Clear(); UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, type); try { yield return www.SendWebRequest(); if ((int)www.result == 2) { BoomboxController.LoadingMusicBoombox = false; Plugin.instance.Log(www.error); BoomboxController.isplayList = false; } else { BoomboxController.LoadingMusicBoombox = false; AudioClip myClip = DownloadHandlerAudioClip.GetContent(www); audioclips.Add(myClip); BoomboxController.musicList = audioclips.ToArray(); BoomboxController.isplayList = false; } } finally { ((IDisposable)www)?.Dispose(); } } public IEnumerator GetPlayList(string url, BoomboxItem boombox, AudioType type) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, type); try { yield return www.SendWebRequest(); if ((int)www.result == 2) { Plugin.instance.Log(www.error); yield break; } AudioClip myClip = DownloadHandlerAudioClip.GetContent(www); audioclipsplay.Add(myClip); } finally { ((IDisposable)www)?.Dispose(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "BoomboxController"; public const string PLUGIN_NAME = "BoomboxController"; public const string PLUGIN_VERSION = "1.0.0"; } }