using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using TurronishMod.Logger; using UnityEngine; 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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace ControlDoblaje; [BepInPlugin("com.turronish.contenido", "Turronish Contenido", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TurronishContenidoPlugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.turronish.contenido").PatchAll(); TurronishDiagLogger.Info("[Contenido]", "TurronishContenido cargado OK."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Contenido] TurronishContenido cargado."); } } public static class ImagePatchGuard { public static readonly HashSet EnProceso = new HashSet(); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class ImageSpritePatch { private static void Prefix(Image __instance, ref Sprite value) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (!ControlDoblajePlugin.ImagenesActivas || (Object)(object)value == (Object)null || (Object)(object)__instance == (Object)null || ControlDoblajePlugin.EnTransicion) { return; } string name = ((Object)value).name; if (name.StartsWith("_replaced_") || name.StartsWith("ex_turronish_", StringComparison.OrdinalIgnoreCase) || name.StartsWith("ex_Turronish_", StringComparison.Ordinal)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (ImagePatchGuard.EnProceso.Contains(instanceID)) { return; } ImageTracker.Registrar(name); string text = ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name); if (text == null) { return; } Texture2D val = TexturaCache.Obtener(text); if ((Object)(object)val == (Object)null) { return; } ControlDoblajePlugin.Log.LogInfo((object)("[IMAGE] Reemplazando sprite: " + name)); Vector2 pivot = value.pivot; float x = pivot.x; Rect rect = value.rect; float num = x / Mathf.Max(((Rect)(ref rect)).width, 1f); float y = pivot.y; rect = value.rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num, y / Mathf.Max(((Rect)(ref rect)).height, 1f)); ImagePatchGuard.EnProceso.Add(instanceID); try { Sprite val3 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), val2, value.pixelsPerUnit); ((Object)val3).name = "_replaced_" + name; value = val3; } finally { ImagePatchGuard.EnProceso.Remove(instanceID); } } } [HarmonyPatch(typeof(Image), "OnEnable")] public class ImageOnEnablePatch { private static void Postfix(Image __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.sprite == (Object)null || !ControlDoblajePlugin.ImagenesActivas || ControlDoblajePlugin.EnTransicion) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (ImagePatchGuard.EnProceso.Contains(instanceID)) { return; } string name = ((Object)__instance.sprite).name; if (!name.StartsWith("ex_turronish_", StringComparison.OrdinalIgnoreCase) && !name.StartsWith("ex_Turronish_", StringComparison.Ordinal)) { string text = ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name); if (text != null) { Sprite sprite = __instance.sprite; __instance.sprite = sprite; } } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class SpriteRendererSpritePatch { private static void Prefix(ref Sprite value) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (!ControlDoblajePlugin.ImagenesActivas || (Object)(object)value == (Object)null || ControlDoblajePlugin.EnTransicion) { return; } string name = ((Object)value).name; if (name.StartsWith("_replaced_")) { return; } ImageTracker.Registrar(name); string text = ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name); if (text != null) { Texture2D val = TexturaCache.Obtener(text); if (!((Object)(object)val == (Object)null)) { ControlDoblajePlugin.Log.LogInfo((object)("[IMAGE] SpriteRenderer reemplazando: " + name)); float x = value.pivot.x; Rect rect = value.rect; float num = x / Mathf.Max(((Rect)(ref rect)).width, 1f); float y = value.pivot.y; rect = value.rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num, y / Mathf.Max(((Rect)(ref rect)).height, 1f)); Sprite val3 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), val2, value.pixelsPerUnit); ((Object)val3).name = "_replaced_" + name; value = val3; } } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class VideoPlayerClipSetterPatch { private static readonly Dictionary _rutasPendientes = new Dictionary(); private static void Prefix(VideoPlayer __instance, ref VideoClip value) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)value == (Object)null) && ControlDoblajePlugin.VideoClipsActivo) { string name = ((Object)value).name; VideoClipTracker.Registrar(name); string text = VideoExtensions.BuscarArchivo(ControlDoblajePlugin.VideoClipsPath, name); if (text != null) { _rutasPendientes[((Object)__instance).GetInstanceID()] = text; ControlDoblajePlugin.Log.LogInfo((object)("[VIDEOCLIP] Redirigiendo clip: " + name)); } } } private static void Postfix(VideoPlayer __instance) { if (!((Object)(object)__instance == (Object)null)) { int instanceID = ((Object)__instance).GetInstanceID(); if (_rutasPendientes.TryGetValue(instanceID, out var value)) { _rutasPendientes.Remove(instanceID); __instance.source = (VideoSource)1; __instance.url = "file:///" + value.Replace("\\", "/"); } } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class VideoPlayerUrlSetterPatch { private static void Prefix(VideoPlayer __instance, ref string value) { if ((Object)(object)__instance == (Object)null || string.IsNullOrEmpty(value) || !ControlDoblajePlugin.VideoClipsActivo || (value.StartsWith("file:///") && value.Contains(ControlDoblajePlugin.VideoClipsPath.Replace("\\", "/")))) { return; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(value); if (!string.IsNullOrEmpty(fileNameWithoutExtension)) { VideoClipTracker.Registrar(fileNameWithoutExtension); string text = VideoExtensions.BuscarArchivo(ControlDoblajePlugin.VideoClipsPath, fileNameWithoutExtension); if (text != null) { ControlDoblajePlugin.Log.LogInfo((object)("[VIDEOCLIP] Redirigiendo URL: " + fileNameWithoutExtension)); value = "file:///" + text.Replace("\\", "/"); } } } }