using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Newtonsoft.Json.Linq; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("REPO_TV")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("SOSRY7C6PMFEVJP")] [assembly: AssemblyProduct("REPO_TV")] [assembly: AssemblyCopyright("Copyright © SOSRY7C6PMFEVJP 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a03cea98-efc0-455e-a11b-780d04619db8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public static class BiliBili { private static readonly int[] mixinKeyEncTab; private static readonly HttpClient client; private static string wbiImgKey; private static string wbiSubKey; private static DateTime wbiCacheTime; static BiliBili() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown mixinKeyEncTab = new int[64] { 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52 }; HttpClientHandler val = new HttpClientHandler(); val.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; val.AllowAutoRedirect = false; client = new HttpClient((HttpMessageHandler)(object)val); client.Timeout = TimeSpan.FromSeconds(10.0); wbiImgKey = null; wbiSubKey = null; wbiCacheTime = DateTime.MinValue; } private static string GetMixinKey(string orig) { StringBuilder stringBuilder = new StringBuilder(64); int[] array = mixinKeyEncTab; foreach (int index in array) { stringBuilder.Append(orig[index]); } return stringBuilder.ToString(0, Math.Min(32, stringBuilder.Length)); } private static Dictionary EncWbi(Dictionary parameters, string imgKey, string subKey) { string mixinKey = GetMixinKey(imgKey + subKey); string value = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); SortedDictionary sortedDictionary = new SortedDictionary(parameters); sortedDictionary["wts"] = value; Dictionary dictionary = sortedDictionary.ToDictionary((KeyValuePair p) => p.Key, (KeyValuePair p) => new string(p.Value.Where((char ch) => !Enumerable.Contains("!'()*", ch)).ToArray())); string text = string.Join("&", dictionary.Select((KeyValuePair p) => Uri.EscapeDataString(p.Key) + "=" + Uri.EscapeDataString(p.Value))); byte[] array; using (MD5 mD = MD5.Create()) { array = mD.ComputeHash(Encoding.UTF8.GetBytes(text + mixinKey)); } string value2 = BitConverter.ToString(array).Replace("-", "").ToLowerInvariant(); dictionary["w_rid"] = value2; return dictionary; } private static async Task HttpGetAsync(string url, Dictionary parameters, string sessdata) { string qs = ((parameters == null || parameters.Count == 0) ? "" : string.Join("&", parameters.Select((KeyValuePair p) => Uri.EscapeDataString(p.Key) + "=" + Uri.EscapeDataString(p.Value)))); string full = (string.IsNullOrEmpty(qs) ? url : (url.Contains("?") ? (url + "&" + qs) : (url + "?" + qs))); HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, full); ((HttpHeaders)req.Headers).TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0 Safari/537.36"); ((HttpHeaders)req.Headers).TryAddWithoutValidation("Referer", "https://www.bilibili.com/"); if (!string.IsNullOrEmpty(sessdata)) { ((HttpHeaders)req.Headers).TryAddWithoutValidation("Cookie", "SESSDATA=" + sessdata); } HttpResponseMessage resp = await client.SendAsync(req); resp.EnsureSuccessStatusCode(); return await resp.Content.ReadAsStringAsync(); } private static async Task<(string imgKey, string subKey)> GetWbiKeysAsync(string sessdata) { if (!string.IsNullOrEmpty(wbiImgKey) && !string.IsNullOrEmpty(wbiSubKey) && DateTime.UtcNow - wbiCacheTime < TimeSpan.FromMinutes(10.0)) { return (wbiImgKey, wbiSubKey); } JObject root = JObject.Parse(await HttpGetAsync("https://api.bilibili.com/x/web-interface/nav", null, sessdata)); JToken data = root["data"]; string imgUrl = (string)data[(object)"wbi_img"][(object)"img_url"]; string subUrl = (string)data[(object)"wbi_img"][(object)"sub_url"]; string imgKey = imgUrl.Split(new char[1] { '/' }).Last().Split(new char[1] { '.' })[0]; string subKey = subUrl.Split(new char[1] { '/' }).Last().Split(new char[1] { '.' })[0]; wbiCacheTime = DateTime.UtcNow; wbiImgKey = imgKey; wbiSubKey = subKey; return (imgKey, subKey); } private static async Task GetCidAsync(string bvid, string sessdata, string imgKey, string subKey) { Dictionary signed = EncWbi(new Dictionary { { "bvid", bvid } }, imgKey, subKey); JObject root = JObject.Parse(await HttpGetAsync("https://api.bilibili.com/x/web-interface/wbi/view", signed, sessdata)); if ((int)root["code"] != 0) { throw new Exception("view接口错误: " + (string)root["message"]); } JToken data = root["data"]; JToken obj = data[(object)"pages"]; JArray pages = (JArray)(object)((obj is JArray) ? obj : null); if (pages != null && ((JContainer)pages).Count > 0) { return (long)pages[0][(object)"cid"]; } return (long)data[(object)"cid"]; } private static async Task GetPlayurlAsync(string bvid, long cid, string sessdata, string imgKey, string subKey, int fnval, int? qn, bool html5 = true) { Dictionary baseParams = new Dictionary { { "bvid", bvid }, { "cid", cid.ToString() }, { "fnval", fnval.ToString() }, { "fnver", "0" }, { "fourk", "1" }, { "platform", html5 ? "html5" : "web" } }; if (qn.HasValue) { baseParams["qn"] = qn.Value.ToString(); } Dictionary signed = EncWbi(baseParams, imgKey, subKey); return JObject.Parse(await HttpGetAsync("https://api.bilibili.com/x/player/wbi/playurl", signed, sessdata)); } private static string TakeUrlFromDurlNewtonsoft(JToken data) { JToken obj = data[(object)"durl"]; JArray val = (JArray)(object)((obj is JArray) ? obj : null); if (val != null && ((JContainer)val).Count > 0) { foreach (JToken item in val) { string text = (string)item[(object)"url"]; if (!string.IsNullOrEmpty(text)) { return text; } JToken obj2 = item[(object)"backup_url"]; JArray val2 = (JArray)(object)((obj2 is JArray) ? obj2 : null); if (val2 == null || ((JContainer)val2).Count <= 0) { continue; } foreach (JToken item2 in val2) { string text2 = (string)item2; if (!string.IsNullOrEmpty(text2)) { return text2; } } } } return string.Empty; } public static string GetBiliBiliUrl(string bvid, int qn, string SSESDATA = "") { try { string sessdata = SSESDATA ?? ""; (string, string) result = GetWbiKeysAsync(sessdata).GetAwaiter().GetResult(); long result2 = GetCidAsync(bvid, sessdata, result.Item1, result.Item2).GetAwaiter().GetResult(); JObject result3 = GetPlayurlAsync(bvid, result2, sessdata, result.Item1, result.Item2, 1, qn).GetAwaiter().GetResult(); JToken val = result3["data"]; if (val != null) { string text = (((string)val[(object)"format"]) ?? "").ToLowerInvariant(); if (text.Contains("mp4")) { string text2 = TakeUrlFromDurlNewtonsoft(val); if (!string.IsNullOrEmpty(text2)) { return text2; } } } JObject result4 = GetPlayurlAsync(bvid, result2, sessdata, result.Item1, result.Item2, 1, null).GetAwaiter().GetResult(); JToken val2 = result4["data"]; if (val2 != null) { string text3 = (((string)val2[(object)"format"]) ?? "").ToLowerInvariant(); if (text3.Contains("mp4")) { string text4 = TakeUrlFromDurlNewtonsoft(val2); if (!string.IsNullOrEmpty(text4)) { return text4; } } } JObject result5 = GetPlayurlAsync(bvid, result2, sessdata, result.Item1, result.Item2, 0, qn, html5: false).GetAwaiter().GetResult(); JToken val3 = result5["data"]; if (val3 != null) { string text5 = (((string)val3[(object)"format"]) ?? "").ToLowerInvariant(); if (text5.Contains("flv")) { string text6 = TakeUrlFromDurlNewtonsoft(val3); if (!string.IsNullOrEmpty(text6)) { return text6; } } } JObject result6 = GetPlayurlAsync(bvid, result2, sessdata, result.Item1, result.Item2, 0, null, html5: false).GetAwaiter().GetResult(); JToken val4 = result6["data"]; if (val4 != null) { string text7 = (((string)val4[(object)"format"]) ?? "").ToLowerInvariant(); if (text7.Contains("flv")) { string text8 = TakeUrlFromDurlNewtonsoft(val4); if (!string.IsNullOrEmpty(text8)) { return text8; } } } return string.Empty; } catch { return string.Empty; } } public static async Task GetBiliBiliUrlAsync(string bvid, int qn, string SSESDATA = "") { try { string sess = SSESDATA ?? ""; (string imgKey, string subKey) keys = await GetWbiKeysAsync(sess); long cid = await GetCidAsync(bvid, sess, keys.imgKey, keys.subKey); JToken data3 = (await GetPlayurlAsync(bvid, cid, sess, keys.imgKey, keys.subKey, 1, qn))["data"]; if (data3 != null) { string format4 = (((string)data3[(object)"format"]) ?? "").ToLowerInvariant(); if (format4.Contains("mp4")) { string url4 = TakeUrlFromDurlNewtonsoft(data3); if (!string.IsNullOrEmpty(url4)) { return url4; } } } JToken data4 = (await GetPlayurlAsync(bvid, cid, sess, keys.imgKey, keys.subKey, 1, null))["data"]; if (data4 != null) { string format3 = (((string)data4[(object)"format"]) ?? "").ToLowerInvariant(); if (format3.Contains("mp4")) { string url3 = TakeUrlFromDurlNewtonsoft(data4); if (!string.IsNullOrEmpty(url3)) { return url3; } } } JToken data2 = (await GetPlayurlAsync(bvid, cid, sess, keys.imgKey, keys.subKey, 0, qn, html5: false))["data"]; if (data2 != null) { string format2 = (((string)data2[(object)"format"]) ?? "").ToLowerInvariant(); if (format2.Contains("flv")) { string url2 = TakeUrlFromDurlNewtonsoft(data2); if (!string.IsNullOrEmpty(url2)) { return url2; } } } JToken data = (await GetPlayurlAsync(bvid, cid, sess, keys.imgKey, keys.subKey, 0, null, html5: false))["data"]; if (data != null) { string format = (((string)data[(object)"format"]) ?? "").ToLowerInvariant(); if (format.Contains("flv")) { string url = TakeUrlFromDurlNewtonsoft(data); if (!string.IsNullOrEmpty(url)) { return url; } } } return string.Empty; } catch { return string.Empty; } } public static string GetBiliBiliUrl(string bvid) { return GetBiliBiliUrl(bvid, 64); } public static Task GetBiliBiliUrlAsync(string bvid) { return GetBiliBiliUrlAsync(bvid, 64); } public static string GetVedioName(string BVID, string SSESDATA = "") { try { string sessdata = SSESDATA ?? ""; (string, string) result = GetWbiKeysAsync(sessdata).GetAwaiter().GetResult(); Dictionary parameters = EncWbi(new Dictionary { { "bvid", BVID } }, result.Item1, result.Item2); string result2 = HttpGetAsync("https://api.bilibili.com/x/web-interface/wbi/view", parameters, sessdata).GetAwaiter().GetResult(); JObject val = JObject.Parse(result2); if ((int)val["code"] != 0) { return string.Empty; } JToken val2 = val["data"]; JToken val3 = ((val2 != null) ? val2[(object)"title"] : null); return (val3 != null) ? ((string)val3) : string.Empty; } catch { return string.Empty; } } } namespace REPO_TV; [BepInPlugin("com.xiaohai.REPO_TV", "REPO_TV", "1.0.4")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.xiaohai.REPO_TV"; public const string PLUGIN_NAME = "REPO_TV"; public const string PLUGIN_VERSION = "1.0.4"; public static Plugin instance; public static ManualLogSource logger; public AudioClip pressing; public GameObject TvPrefab; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) instance = this; logger = ((BaseUnityPlugin)this).Logger; logger.LogInfo((object)"Plugin REPO_TV is loaded!"); LoadAB(); new Harmony("com.xiaohai.REPO_TV").PatchAll(); } private void LoadAB() { string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); string text = Path.Combine(directoryName, "xiaohaitv"); AssetBundle val = AssetBundle.LoadFromFile(text); pressing = val.LoadAsset("pressing.wav"); TvPrefab = val.LoadAsset("TV.prefab"); if ((Object)(object)TvPrefab != (Object)null) { TvPrefab.AddComponent(); TvPrefab.AddComponent(); logger.LogInfo((object)"TV Prefab 加载成功."); NetworkPrefabs.RegisterNetworkPrefab(TvPrefab); Utilities.FixAudioMixerGroups(TvPrefab); } else { logger.LogError((object)"电视机预制体加载失败."); } } } [HarmonyPatch] public static class Patch { [HarmonyPatch(typeof(LevelGenerator))] public class LevelGeneratorPatch { [HarmonyPatch("GenerateDone")] [HarmonyPostfix] private static void AfterLevelGenerated(LevelGenerator __instance) { //IL_008a: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!ShouldRunCustomLogic() || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } Plugin.logger.LogInfo((object)"在关卡生成后放置电视机."); GameObject val = GameObject.Find("cctv"); if ((Object)(object)val != (Object)null) { Plugin.logger.LogInfo((object)"cctv不为空!."); if (SemiFunc.IsMultiplayer()) { GameObject val2 = PhotonNetwork.InstantiateRoomObject(((Object)Plugin.instance.TvPrefab).name, Vector3.zero, Quaternion.identity, (byte)0, (object[])null); } else { GameObject val2 = Object.Instantiate(Plugin.instance.TvPrefab, Vector3.zero, Quaternion.identity); } } } private static bool ShouldRunCustomLogic() { RunManager instance = RunManager.instance; return (Object)(object)instance != (Object)null && instance.levels.Contains(instance.levelCurrent) && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelTutorial && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelShop && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelLobbyMenu; } } } public class TVButtonManager : MonoBehaviour { private enum BtnType { None, Switch, Play, Next, VolumeUp, VolumeDown } private class Btn { public StaticGrabObject sgo; public BtnType type; public float timer; public bool pressedLast; public bool fired; public Image ring; public bool soundStarted; public AudioSource audio; public float threshold; } [SerializeField] private Transform root; [SerializeField] private float holdTime = 2f; [SerializeField] private bool debugLog = true; private TVScript tv; private Sound pressingSound; private AudioClip pressingClip; private readonly List buttons = new List(); private void Awake() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown tv = ((Component)this).GetComponent(); if ((Object)(object)tv == (Object)null) { tv = ((Component)this).GetComponentInParent(); } PhysGrabObjectImpactDetector component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { UnityEvent onAllBreaks = component.onAllBreaks; if (onAllBreaks != null) { onAllBreaks.AddListener((UnityAction)delegate { if (Object.op_Implicit((Object)(object)tv)) { tv.Switch(); } }); } } root = (Object.op_Implicit((Object)(object)root) ? root : ((Component)this).transform); pressingClip = Plugin.instance?.pressing; if (debugLog) { Debug.Log((object)"[TVButtonManager(Mod)] Awake"); } StaticGrabObject[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (StaticGrabObject val in componentsInChildren) { BtnType btnType = Classify(((Object)val).name); if (btnType != 0) { Image ring = null; Transform val2 = ((Component)val).transform.Find("Ring"); if (Object.op_Implicit((Object)(object)val2)) { ring = ((Component)val2).GetComponent(); } float threshold = ((btnType == BtnType.VolumeUp || btnType == BtnType.VolumeDown) ? 1f : holdTime); buttons.Add(new Btn { sgo = val, type = btnType, timer = 0f, pressedLast = false, fired = false, ring = ring, soundStarted = false, threshold = threshold }); if (debugLog) { Debug.Log((object)("[TVButtonManager(Mod)] Button: " + ((Object)val).name + " -> " + btnType)); } } } } private void Update() { //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) Btn btn = null; foreach (Btn button in buttons) { if (Object.op_Implicit((Object)(object)button.sgo) && button.sgo.grabbed && (!SemiFunc.IsMasterClientOrSingleplayer() || button.sgo.playerGrabbing.Count > 0)) { btn = button; break; } } foreach (Btn button2 in buttons) { if (btn != null && button2 != btn && Object.op_Implicit((Object)(object)button2.sgo)) { if (((Behaviour)button2.sgo).enabled) { ((Behaviour)button2.sgo).enabled = false; } } else if (Object.op_Implicit((Object)(object)button2.sgo) && !((Behaviour)button2.sgo).enabled) { ((Behaviour)button2.sgo).enabled = true; } } foreach (Btn button3 in buttons) { bool flag = Object.op_Implicit((Object)(object)button3.sgo) && button3.sgo.grabbed && (!SemiFunc.IsMasterClientOrSingleplayer() || button3.sgo.playerGrabbing.Count > 0); if (flag) { if (!button3.pressedLast) { button3.timer = 0f; button3.fired = false; button3.soundStarted = false; if (Object.op_Implicit((Object)(object)button3.ring)) { button3.ring.fillAmount = 0f; } } if (!button3.fired) { button3.timer += Time.deltaTime; } if (!button3.soundStarted && Object.op_Implicit((Object)(object)pressingClip)) { if (pressingSound == null) { pressingSound = new Sound(); pressingSound.Type = (AudioType)6; pressingSound.SpatialBlend = 1f; pressingSound.Volume = 1f; pressingSound.Pitch = 1f; } pressingSound.Sounds = (AudioClip[])(object)new AudioClip[1] { pressingClip }; pressingSound.Source = null; button3.audio = pressingSound.Play(((Component)button3.sgo).transform.position, 1f, 1f, 1f, 1f); button3.soundStarted = true; } if (!button3.fired && button3.timer >= button3.threshold) { Fire(button3.type); button3.fired = true; button3.timer = 0f; } if (Object.op_Implicit((Object)(object)button3.ring)) { button3.ring.fillAmount = (button3.fired ? 0f : Mathf.Clamp01(button3.timer / button3.threshold)); } } else { button3.timer = 0f; button3.fired = false; button3.soundStarted = false; if (Object.op_Implicit((Object)(object)button3.ring)) { button3.ring.fillAmount = 0f; } if (Object.op_Implicit((Object)(object)button3.audio)) { if (button3.audio.isPlaying) { button3.audio.Stop(); } if (Object.op_Implicit((Object)(object)button3.audio)) { Object.Destroy((Object)(object)((Component)button3.audio).gameObject); } button3.audio = null; } } button3.pressedLast = flag; } } private void Fire(BtnType type) { if (Object.op_Implicit((Object)(object)tv)) { switch (type) { case BtnType.Switch: tv.Switch(); break; case BtnType.Play: tv.Play(); break; case BtnType.Next: tv.Next(); break; case BtnType.VolumeUp: tv.VolumeUp(); break; case BtnType.VolumeDown: tv.VolumeDown(); break; } } } private BtnType Classify(string name) { string text = name.ToLowerInvariant(); if (text.Contains("switch") || text.Contains("开关") || text.Contains("电源")) { return BtnType.Switch; } if (text.Contains("play") || text.Contains("播放") || text.Contains("暂停")) { return BtnType.Play; } if (text.Contains("next") || text.Contains("下一")) { return BtnType.Next; } if (text.Contains("volumeup") || text.Contains("音量+") || (text.Contains("volume") && (text.Contains("up") || text.Contains("+") || text.Contains("increase") || text.Contains("加")))) { return BtnType.VolumeUp; } if (text.Contains("volumedown") || text.Contains("音量-") || (text.Contains("volume") && (text.Contains("down") || text.Contains("-") || text.Contains("decrease") || text.Contains("减")))) { return BtnType.VolumeDown; } return BtnType.None; } } public class TVScript : MonoBehaviourPun { private class PlaylistItem { public string url; public bool isLocal; public string name; } [CompilerGenerated] private sealed class <>c__DisplayClass34_0 { public string bv; internal string b__0() { return BiliBili.GetVedioName(bv); } } [CompilerGenerated] private sealed class d__34 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string bv; public TVScript <>4__this; private <>c__DisplayClass34_0 <>8__1; private Task 5__2; private string 5__3; private Task 5__4; private string 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass34_0(); <>8__1.bv = bv; <>4__this.bilibiliReturnInfo = ""; 5__2 = BiliBili.GetBiliBiliUrlAsync(<>8__1.bv); goto IL_0089; case 1: <>1__state = -1; goto IL_0089; case 2: { <>1__state = -1; break; } IL_0089: if (!5__2.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } 5__3 = 5__2.Result; 5__4 = Task.Run(() => BiliBili.GetVedioName(<>8__1.bv)); break; } if (!5__4.IsCompleted) { <>2__current = null; <>1__state = 2; return true; } 5__5 = (string.IsNullOrEmpty(5__4.Result) ? <>8__1.bv : 5__4.Result); if (!string.IsNullOrEmpty(5__3)) { if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)<>4__this).photonView.RPC("RPC_AddPlaylistItem", (RpcTarget)3, new object[3] { 5__3, 5__5, true }); } else { <>4__this.RPC_AddPlaylistItem(5__3, 5__5, playImmediately: true); } <>4__this.bilibiliReturnInfo = "视频播放成功!"; } else { <>4__this.bilibiliReturnInfo = "获取视频链接失败!"; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly List videoFilePaths = new List(); private bool videosLoaded = false; private readonly List playlist = new List(); private MeshRenderer meshRenderer; private AudioSource audioSource; private VideoPlayer videoPlayer; private Light tvLight; private GameObject volumeRoot; private Image volumeFill; private float volumeUITimer; private RenderTexture renderTexture; private Texture originalTexture; private Color originalColor; private Vector2 originalOffset; private Vector2 originalScale; private int materialIndex = 2; private Texture originalEmissionMap; private Color originalEmissionColor; private bool originalEmissionEnabled; private int currentIndex; private int lastIndex; private bool powered; private bool playing; private bool showBilibiliWindow; private string bvInput; private string bilibiliReturnInfo; private Rect bilibiliWindowRect = new Rect(100f, 100f, 420f, 420f); private Vector2 playlistScroll; private void Awake() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown GameObject gameObject = ((Component)this).gameObject; GameObject val = GameObject.Find("cctv"); if ((Object)(object)gameObject != (Object)null && (Object)(object)val != (Object)null) { Plugin.logger.LogInfo((object)"tv不为空!."); gameObject.transform.SetParent(val.transform, false); gameObject.transform.localPosition = new Vector3(2.22f, -1.18f, -0.84f); gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one; } Transform val2 = ((Component)this).transform.Find("TVMesh"); if (Object.op_Implicit((Object)(object)val2)) { meshRenderer = ((Component)val2).GetComponentInChildren(); } if (!Object.op_Implicit((Object)(object)meshRenderer)) { meshRenderer = ((Component)this).GetComponentInChildren(); } Transform val3 = ((Component)this).transform.Find("Audio"); if (Object.op_Implicit((Object)(object)val3)) { audioSource = ((Component)val3).GetComponentInChildren(); } if (!Object.op_Implicit((Object)(object)audioSource)) { audioSource = ((Component)this).GetComponentInChildren(); } Transform val4 = ((Component)this).transform.Find("Video"); if (Object.op_Implicit((Object)(object)val4)) { videoPlayer = ((Component)val4).GetComponentInChildren(); } if (!Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer = ((Component)this).GetComponentInChildren(); } Transform val5 = ((Component)this).transform.Find("Light"); if (Object.op_Implicit((Object)(object)val5)) { tvLight = ((Component)val5).GetComponent(); } if (!Object.op_Implicit((Object)(object)tvLight)) { tvLight = ((Component)this).GetComponentInChildren(); } Transform val6 = ((Component)this).transform.Find("Canvas/Controller"); if (Object.op_Implicit((Object)(object)val6)) { val6.localPosition = new Vector3(-1.889f, -0.612f, -0.006f); } Transform val7 = ((Component)this).transform.Find("Canvas/Volume"); if (Object.op_Implicit((Object)(object)val7)) { volumeRoot = ((Component)val7).gameObject; Transform val8 = val7.Find("BG/Fill"); if (Object.op_Implicit((Object)(object)val8)) { volumeFill = ((Component)val8).GetComponent(); } if (Object.op_Implicit((Object)(object)volumeFill)) { volumeFill.type = (Type)3; volumeFill.fillMethod = (FillMethod)1; volumeFill.fillOrigin = 0; volumeFill.fillAmount = (Object.op_Implicit((Object)(object)audioSource) ? Mathf.Clamp01(audioSource.volume) : 0f); } volumeRoot.SetActive(false); } if (Object.op_Implicit((Object)(object)meshRenderer) && materialIndex >= 0 && materialIndex < ((Renderer)meshRenderer).materials.Length) { Material val9 = ((Renderer)meshRenderer).materials[materialIndex]; originalTexture = val9.mainTexture; originalColor = val9.color; originalOffset = val9.mainTextureOffset; originalScale = val9.mainTextureScale; if (val9.HasProperty("_EmissionColor")) { originalEmissionColor = val9.GetColor("_EmissionColor"); } if (val9.HasProperty("_EmissionMap")) { originalEmissionMap = val9.GetTexture("_EmissionMap"); } originalEmissionEnabled = val9.IsKeywordEnabled("_EMISSION"); } if (Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer.renderMode = (VideoRenderMode)2; if (!Object.op_Implicit((Object)(object)renderTexture)) { renderTexture = new RenderTexture(1920, 1080, 0); } videoPlayer.targetTexture = renderTexture; videoPlayer.audioOutputMode = (VideoAudioOutputMode)1; if (Object.op_Implicit((Object)(object)audioSource)) { videoPlayer.EnableAudioTrack((ushort)0, true); videoPlayer.SetTargetAudioSource((ushort)0, audioSource); } videoPlayer.playOnAwake = false; videoPlayer.source = (VideoSource)1; } ReloadLocalPlaylist(); } private void Update() { if ((Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) && Input.GetKeyDown((KeyCode)98) && SemiFunc.IsMasterClientOrSingleplayer()) { showBilibiliWindow = !showBilibiliWindow; Cursor.visible = showBilibiliWindow; } if (Object.op_Implicit((Object)(object)volumeRoot) && volumeRoot.activeSelf && volumeUITimer > 0f) { volumeUITimer -= Time.deltaTime; if (volumeUITimer <= 0f) { volumeRoot.SetActive(false); } } } private void OnGUI() { //IL_0068: 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_0083: Expected O, but got Unknown //IL_007e: 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) if (SemiFunc.IsMasterClientOrSingleplayer() && showBilibiliWindow) { if ((Object)(object)GUI.skin != (Object)null) { GUI.skin.label.fontSize = 12; GUI.skin.button.fontSize = 12; GUI.skin.textField.fontSize = 12; } bilibiliWindowRect = GUI.Window(0, bilibiliWindowRect, new WindowFunction(DrawBilibiliWindow), "小海REPO电视机v1.0.4"); } } private void DrawBilibiliWindow(int windowID) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("BV号/链接:", Array.Empty()); bvInput = GUILayout.TextField(bvInput ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (GUILayout.Button("播放", Array.Empty())) { string text = ExtractBVFromInput(bvInput); bvInput = ""; if (string.IsNullOrEmpty(text)) { bilibiliReturnInfo = "bv号获取失败,请检查输入!"; } else { ((MonoBehaviour)this).StartCoroutine(PlayBilibiliCoroutine(text)); } } if (GUILayout.Button("加载本地视频", Array.Empty())) { ReloadLocalPlaylist(); } GUILayout.EndHorizontal(); GUILayout.Label("返回信息: " + bilibiliReturnInfo, Array.Empty()); playlistScroll = GUILayout.BeginScrollView(playlistScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(300f) }); for (int i = 0; i < playlist.Count; i++) { PlaylistItem playlistItem = playlist[i]; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(i.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); GUILayout.Label(playlistItem.name ?? "", Array.Empty()); if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }) && SemiFunc.IsMasterClientOrSingleplayer()) { if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_RemovePlaylistItem", (RpcTarget)3, new object[1] { i }); } else { RPC_RemovePlaylistItem(i); } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); if (GUILayout.Button("关闭", Array.Empty())) { showBilibiliWindow = false; } GUILayout.EndVertical(); GUI.DragWindow(); } private string ExtractBVFromInput(string input) { if (string.IsNullOrEmpty(input)) { return null; } Match match = Regex.Match(input, "BV[0-9A-Za-z]{10}"); return match.Success ? match.Value : null; } [IteratorStateMachine(typeof(d__34))] private IEnumerator PlayBilibiliCoroutine(string bv) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(0) { <>4__this = this, bv = bv }; } private void VolumeUIShow() { if (powered) { if (Object.op_Implicit((Object)(object)volumeRoot)) { volumeRoot.SetActive(true); volumeUITimer = 2f; } if (Object.op_Implicit((Object)(object)volumeFill) && Object.op_Implicit((Object)(object)audioSource)) { volumeFill.fillAmount = Mathf.Clamp01(audioSource.volume); } } } private void LoadVideoFiles() { string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty; string text = Path.Combine(path, "Vedio"); string text2 = Path.Combine(path, "Video"); string path2 = (Directory.Exists(text) ? text : (Directory.Exists(text2) ? text2 : text)); if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); return; } string[] supportedExtensions = new string[5] { ".mp4", ".mov", ".webm", ".avi", ".wmv" }; List list = (from file in Directory.GetFiles(path2) where supportedExtensions.Contains(Path.GetExtension(file).ToLower()) orderby file select file).ToList(); if (list.Count != 0) { videoFilePaths.Clear(); videoFilePaths.AddRange(list); videosLoaded = true; } } public void Switch() { if (SemiFunc.IsMasterClientOrSingleplayer()) { bool flag = !powered; if (!flag) { lastIndex = currentIndex; } int num = (flag ? lastIndex : currentIndex); bool flag2 = flag; if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { flag, flag2, num }); } else { RPC_ApplyState(flag, flag2, num); } } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_Switch", (RpcTarget)2, Array.Empty()); } } public void Play() { if (!powered || (Object)(object)videoPlayer == (Object)null || (Object)(object)meshRenderer == (Object)null || !videosLoaded) { return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { bool flag = !playing; if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { powered, flag, currentIndex }); } else { RPC_ApplyState(powered, flag, currentIndex); } } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_PlayToggle", (RpcTarget)2, Array.Empty()); } } public void Next() { if (!powered || !videosLoaded) { return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { int num = ((playlist.Count != 0) ? ((currentIndex + 1) % playlist.Count) : 0); if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { true, true, num }); } else { RPC_ApplyState(newPowered: true, newPlaying: true, num); } } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_Next", (RpcTarget)2, Array.Empty()); } } public void VolumeUp() { if (!Object.op_Implicit((Object)(object)audioSource) || !powered) { return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { float num = Mathf.Clamp01(audioSource.volume + 0.1f); if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_SetVolume", (RpcTarget)3, new object[1] { num }); } else { RPC_SetVolume(num); } VolumeUIShow(); } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_VolumeUp", (RpcTarget)2, Array.Empty()); } } public void VolumeDown() { if (!Object.op_Implicit((Object)(object)audioSource) || !powered) { return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { float num = Mathf.Clamp01(audioSource.volume - 0.1f); if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_SetVolume", (RpcTarget)3, new object[1] { num }); } else { RPC_SetVolume(num); } VolumeUIShow(); } else { ((MonoBehaviourPun)this).photonView.RPC("RPC_VolumeDown", (RpcTarget)2, Array.Empty()); } } public void PowerOn() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) powered = true; if (Object.op_Implicit((Object)(object)tvLight)) { tvLight.color = Color.blue; } if ((Object)(object)videoPlayer != (Object)null && (Object)(object)meshRenderer != (Object)null && videosLoaded) { currentIndex = lastIndex; StartPlayFromIndex(currentIndex); } } public void PowerOff() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) Stop(); powered = false; if (Object.op_Implicit((Object)(object)tvLight)) { tvLight.color = Color.red; } } public void Stop() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_0115: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer.Stop(); } if (Object.op_Implicit((Object)(object)audioSource)) { audioSource.Stop(); } if (Object.op_Implicit((Object)(object)meshRenderer) && materialIndex >= 0 && materialIndex < ((Renderer)meshRenderer).materials.Length) { Material val = ((Renderer)meshRenderer).materials[materialIndex]; val.mainTexture = originalTexture; val.color = originalColor; val.mainTextureOffset = originalOffset; val.mainTextureScale = originalScale; if (originalEmissionEnabled) { val.EnableKeyword("_EMISSION"); } else { val.DisableKeyword("_EMISSION"); } if (val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", originalEmissionMap); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", originalEmissionColor); } } playing = false; } private void StartPlayInternal(string videoUrl) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer.source = (VideoSource)1; videoPlayer.url = videoUrl; } if (Object.op_Implicit((Object)(object)meshRenderer)) { Material[] materials = ((Renderer)meshRenderer).materials; if (materialIndex >= 0 && materialIndex < materials.Length) { Material val = materials[materialIndex]; val.mainTexture = (Texture)(object)renderTexture; val.color = Color.white; val.mainTextureScale = new Vector2(1.77f, 3.18f); val.mainTextureOffset = Vector2.zero; val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)4; val.EnableKeyword("_EMISSION"); if (val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", (Texture)(object)renderTexture); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", new Color(0.2f, 0.2f, 0.2f)); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0f); } } } if (Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer.Play(); } playing = true; } private void StartPlayFromIndex(int idx) { if (videosLoaded && playlist.Count != 0) { currentIndex = Mathf.Clamp(idx, 0, playlist.Count - 1); PlaylistItem playlistItem = playlist[currentIndex]; StartPlayInternal(playlistItem.url); } } private void PauseInternal() { if (Object.op_Implicit((Object)(object)videoPlayer)) { videoPlayer.Pause(); } if (Object.op_Implicit((Object)(object)audioSource)) { audioSource.Pause(); } playing = false; } [PunRPC] private void RPC_ApplyState(bool newPowered, bool newPlaying, int newIndex) { //IL_0059: 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) newIndex = Mathf.Clamp(newIndex, 0, (playlist.Count != 0) ? (playlist.Count - 1) : 0); powered = newPowered; currentIndex = newIndex; if (Object.op_Implicit((Object)(object)tvLight)) { tvLight.color = (powered ? Color.blue : Color.red); } if (!powered) { lastIndex = currentIndex; Stop(); playing = false; } else if (newPlaying) { StartPlayFromIndex(currentIndex); } else { PauseInternal(); } } [PunRPC] private void RPC_Switch() { if (SemiFunc.IsMasterClient()) { bool flag = !powered; if (!flag) { lastIndex = currentIndex; } int num = (flag ? lastIndex : currentIndex); bool flag2 = flag; ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { flag, flag2, num }); } } [PunRPC] private void RPC_PlayToggle() { if (SemiFunc.IsMasterClient() && powered && !((Object)(object)videoPlayer == (Object)null) && !((Object)(object)meshRenderer == (Object)null) && videosLoaded) { bool flag = !playing; ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { powered, flag, currentIndex }); } } [PunRPC] private void RPC_Next() { if (SemiFunc.IsMasterClient() && powered && videosLoaded) { int num = ((playlist.Count != 0) ? ((currentIndex + 1) % playlist.Count) : 0); ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyState", (RpcTarget)3, new object[3] { true, true, num }); } } [PunRPC] private void RPC_SetVolume(float v) { if (Object.op_Implicit((Object)(object)audioSource)) { audioSource.volume = Mathf.Clamp01(v); VolumeUIShow(); } } [PunRPC] private void RPC_SetBilibiliVideoUrl(string videoUrl) { } [PunRPC] private void RPC_VolumeUp() { if (SemiFunc.IsMasterClient() && Object.op_Implicit((Object)(object)audioSource)) { float num = Mathf.Clamp01(audioSource.volume + 0.1f); ((MonoBehaviourPun)this).photonView.RPC("RPC_SetVolume", (RpcTarget)3, new object[1] { num }); } } [PunRPC] private void RPC_VolumeDown() { if (SemiFunc.IsMasterClient() && Object.op_Implicit((Object)(object)audioSource)) { float num = Mathf.Clamp01(audioSource.volume - 0.1f); ((MonoBehaviourPun)this).photonView.RPC("RPC_SetVolume", (RpcTarget)3, new object[1] { num }); } } [PunRPC] private void RPC_AddPlaylistItem(string url, string name, bool playImmediately) { if (!string.IsNullOrEmpty(url)) { playlist.Add(new PlaylistItem { url = url, isLocal = false, name = name }); videosLoaded = playlist.Count > 0; if (playImmediately) { currentIndex = playlist.Count - 1; StartPlayFromIndex(currentIndex); } } } [PunRPC] private void RPC_RemovePlaylistItem(int index) { if (index >= 0 && index < playlist.Count) { playlist.RemoveAt(index); if (currentIndex >= playlist.Count) { currentIndex = Mathf.Max(0, playlist.Count - 1); } videosLoaded = playlist.Count > 0; } } [PunRPC] private void RPC_SetPlaylistLocal(string[] urls, string[] names) { playlist.Clear(); if (urls != null) { for (int i = 0; i < urls.Length; i++) { string name = ((names != null && i < names.Length) ? names[i] : ""); playlist.Add(new PlaylistItem { url = urls[i], isLocal = true, name = name }); } } videosLoaded = playlist.Count > 0; currentIndex = Mathf.Clamp(currentIndex, 0, (playlist.Count != 0) ? (playlist.Count - 1) : 0); } private void ReloadLocalPlaylist() { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } LoadVideoFiles(); playlist.Clear(); List list = new List(); List list2 = new List(); foreach (string videoFilePath in videoFilePaths) { string item = "file:///" + videoFilePath.Replace("\\", "/"); string fileName = Path.GetFileName(videoFilePath); list.Add(item); list2.Add(fileName); } if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("RPC_SetPlaylistLocal", (RpcTarget)3, new object[2] { list.ToArray(), list2.ToArray() }); } else { RPC_SetPlaylistLocal(list.ToArray(), list2.ToArray()); } } }