Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TVSirzone v1.0.4
BepInEx/plugins/LethalTVManager.dll
Decompiled 2 years agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; 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("LethalTVManager")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalTVManager")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f688ce86-9a58-4272-bc2a-83d61a41fe2e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace LethalTVManager { public class PluginInfo { public const string modGUID = "Bushwacc.TV"; public const string modName = "LethalTelevisions"; public const string modVersion = "1.0.0"; } [BepInPlugin("Bushwacc.TV", "LethalTelevisions", "1.0.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; public static string[] filePaths; private string[] files; public static Plugin instance; internal ManualLogSource mls; private string pluginpath; private void Awake() { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown instance = this; if (Paths.PluginPath.ToString().Contains("Thunderstore Mod Manager")) { string[] obj = new string[5] { Paths.PluginPath, null, null, null, null }; char directorySeparatorChar = Path.DirectorySeparatorChar; obj[1] = directorySeparatorChar.ToString(); obj[2] = "Bushwacc-LethalTVManager"; directorySeparatorChar = Path.DirectorySeparatorChar; obj[3] = directorySeparatorChar.ToString(); obj[4] = "media"; pluginpath = string.Concat(obj); files = Directory.GetFiles(pluginpath); } else { string pluginPath = Paths.PluginPath; char directorySeparatorChar = Path.DirectorySeparatorChar; pluginpath = pluginPath + directorySeparatorChar + "media"; files = Directory.GetFiles(pluginpath); } int num = 0; int num2 = 0; string[] array = files; foreach (string text in array) { num++; if (text != null && text.Contains(".mp4")) { num2++; } } filePaths = new string[num2]; int num3 = 0; for (int j = 0; j < num; j++) { if (files[j] != null && files[j].Contains(".mp4")) { filePaths[num3] = files[j]; Log("Loaded file: " + filePaths[num3]); num3++; } } _harmony = new Harmony("LethalTelevisions"); _harmony.PatchAll(); Debug.Log((object)"LethalTelevisions mod loaded"); } public static void Log(string message) { Debug.Log((object)message); } } } namespace LethalTVManager.Patches { [HarmonyPatch] internal class LethalTVController { public static int TVIndex; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] public static void SetTVIndex() { TVIndex = 0; } [HarmonyPatch(typeof(TVScript), "TVFinishedClip")] [HarmonyPrefix] public static bool TVFinishedClip() { return false; } [HarmonyPatch(typeof(TVScript), "Update")] [HarmonyPrefix] public static bool Update() { return false; } [HarmonyPatch(typeof(TVScript), "TurnTVOnOff")] [HarmonyPrefix] public static bool TurnTVOnOff(bool on, TVScript __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 __instance.tvOn = on; if ((int)__instance.video.source != 1 || __instance.video.url == "") { __instance.video.clip = null; __instance.tvSFX.clip = null; Plugin.Log("file://" + Plugin.filePaths[TVIndex]); __instance.video.url = "file://" + Plugin.filePaths[TVIndex]; __instance.video.source = (VideoSource)1; __instance.video.controlledAudioTrackCount = 1; __instance.video.audioOutputMode = (VideoAudioOutputMode)1; __instance.video.SetTargetAudioSource((ushort)0, __instance.tvSFX); __instance.video.Prepare(); __instance.video.Stop(); __instance.tvSFX.Stop(); } if (on) { Plugin.Log("Turning on TV"); SetTVScreenMaterial(__instance, b: true); __instance.video.Play(); __instance.tvSFX.Play(); __instance.tvSFX.PlayOneShot(__instance.switchTVOn); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOn, 1f); } else { Plugin.Log("Turning off TV"); SetTVScreenMaterial(__instance, b: false); __instance.tvSFX.Stop(); __instance.tvSFX.PlayOneShot(__instance.switchTVOff); __instance.video.Stop(); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOff, 1f); } return false; } public static void SetTVScreenMaterial(TVScript instance, bool b) { MethodInfo method = ((object)instance).GetType().GetMethod("SetTVScreenMaterial", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(instance, new object[1] { b }); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void GetTVInput(PlayerControllerB __instance) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || __instance.inTerminalMenu || __instance.isTypingChat || __instance.isPlayerDead) { return; } InteractTrigger hoveringOverTrigger = __instance.hoveringOverTrigger; object obj; if ((Object)(object)hoveringOverTrigger == (Object)null) { obj = null; } else { Transform parent = ((Component)hoveringOverTrigger).transform.parent; obj = (((Object)(object)parent != (Object)null) ? ((Component)parent).gameObject : null); } bool flag = false; GameObject val = (GameObject)obj; if ((Object)(object)val != (Object)null && ((Object)val).name.Contains("Television")) { flag = true; } if (!flag) { return; } VideoPlayer componentInChildren = val.GetComponentInChildren<VideoPlayer>(); double num = componentInChildren.time; int num2 = TVIndex; float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y; if (!((Object)(object)componentInChildren != (Object)null)) { return; } if (((ButtonControl)Keyboard.current.leftBracketKey).wasPressedThisFrame) { num -= 15.0; if (num < 0.0) { componentInChildren.time = 0.0; Plugin.Log("AdjustTime: " + 0f); } else { componentInChildren.time = num; Plugin.Log("AdjustTime: " + num); } } if (((ButtonControl)Keyboard.current.rightBracketKey).wasPressedThisFrame) { Plugin.Log("AdjustTime: " + (componentInChildren.time = num + 15.0)); } if (((ButtonControl)Keyboard.current.commaKey).wasPressedThisFrame) { num2 = ((num2 <= 0) ? (Plugin.filePaths.Length - 1) : (num2 - 1)); } if (((ButtonControl)Keyboard.current.periodKey).wasPressedThisFrame) { num2 = ((num2 < Plugin.filePaths.Length - 1) ? (num2 + 1) : 0); } Transform parent2 = ((Component)componentInChildren).transform.parent; InteractTrigger val2 = (((Object)(object)parent2 != (Object)null) ? ((Component)parent2).GetComponentInChildren<InteractTrigger>() : null); if ((Object)(object)val2 == (Object)null) { Plugin.Log("Television trigger missing!"); } val2.hoverTip = "[ ] to jump forward or backwards, comma or period to switch channels, Scroll for volume. Channel: " + (num2 + 1); if (num2 != TVIndex) { TVIndex = num2; componentInChildren.time = 0.0; componentInChildren.url = "file://" + Plugin.filePaths[TVIndex]; Plugin.Log("AdjustMediaFile: " + Plugin.filePaths[TVIndex]); } if (y != 0f) { AudioSource component = ((Component)val.transform.Find("TVAudio")).GetComponent<AudioSource>(); y /= 6000f; float volume = component.volume; volume = Mathf.Clamp(volume + y, 0f, 1f); component.volume = volume; Plugin.Log("Changed volume: " + component.volume); } } [HarmonyPatch(typeof(TVScript), "__initializeVariables")] [HarmonyPostfix] public static void SetTelevisionHoverTip(TVScript __instance) { Transform parent = ((Component)__instance).transform.parent; InteractTrigger val = (((Object)(object)parent != (Object)null) ? ((Component)parent).GetComponentInChildren<InteractTrigger>() : null); if ((Object)(object)val == (Object)null) { Plugin.Log("Television trigger missing!"); } else { val.hoverTip = "[ ] to jump forward or backwards, comma or period to switch channels, Scroll for volume"; } } } }