Decompiled source of Turronish v1.0.2
BepInEx/plugins/ControlDoblaje.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TMPro; using TurronishMod.Logger; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.SceneManagement; 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("ControlDoblaje")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ControlDoblaje")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fa4defe9-2a53-4511-a7a4-e9af13103075")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ControlDoblaje; public class DoblejeUIMarker : MonoBehaviour { } public class CoroutineHolder : MonoBehaviour { private static CoroutineHolder _inst; private static void Ensure() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (!((Object)(object)_inst != (Object)null) || !((Object)(object)((Component)_inst).gameObject != (Object)null)) { GameObject val = new GameObject("_CoroutineHolder"); Object.DontDestroyOnLoad((Object)(object)val); _inst = val.AddComponent<CoroutineHolder>(); } } public static void Inicia(IEnumerator r) { Ensure(); ((MonoBehaviour)_inst).StartCoroutine(r); } } public static class Layout { public static float FontCabecera = 22f; public static float FontEtiqueta = 20f; public static float FontDropdown = 20f; public static float FontDropItem = 18f; public static float FontDescTitulo = 22f; public static float FontDescTexto = 18f; public static float FontBoton = 18f; public static float FontInput = 18f; public static float FontChevron = 16f; public static float AltoCabecera = 48f; public static float AltoFila = 48f; public static float AltoFilaGrid = 48f; public static float AltoDropdown = 36f; public static float AltoBoton = 36f; public static float AltoInput = 36f; public static float AltoItemPopup = 36f; public static float AnchoEtiqueta = 200f; public static float AnchoEtiquetaGrid = 160f; public static float AnchoDropdownNormal = 400f; public static float AnchoDropdownGrid = 380f; public static float AnchoDropdownPreset = 320f; public static float AnchoBoton = 280f; public static float AnchoBotonBorrar = 220f; public static float AnchoInput = 300f; public static float GridSepWidth = 2f; public static void CalibrateFrom(Transform tabRoot) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tabRoot == (Object)null) { return; } ScrollRect componentInChildren = ((Component)tabRoot).GetComponentInChildren<ScrollRect>(true); Transform val = (Transform)(object)((componentInChildren != null) ? componentInChildren.content : null); if ((Object)(object)val == (Object)null) { ControlDoblajePlugin.Log.LogWarning((object)"[Layout] CalibrateFrom: no ScrollRect content"); return; } foreach (Transform item in val) { Transform val2 = item; if (((Object)val2).name.StartsWith("*")) { continue; } RectTransform component = ((Component)val2).GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { continue; } float y = component.sizeDelta.y; if (y < 20f || y > 200f) { continue; } TMP_Text componentInChildren2 = ((Component)val2).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren2 != (Object)null) { float fontSize = componentInChildren2.fontSize; FontEtiqueta = Mathf.Round(fontSize * 0.9f); FontDropdown = FontEtiqueta; FontDropItem = Mathf.Round(fontSize * 0.82f); FontCabecera = Mathf.Round(fontSize * 0.9f); FontBoton = Mathf.Round(fontSize * 0.78f); FontInput = Mathf.Round(fontSize * 0.78f); FontDescTitulo = Mathf.Round(fontSize * 1.8f); FontDescTexto = Mathf.Round(fontSize * 1.56f); FontChevron = Mathf.Round(fontSize * 0.6f); AltoFila = Mathf.Clamp(y, 44f, 72f); AltoFilaGrid = AltoFila; AltoCabecera = AltoFila; AltoDropdown = Mathf.Clamp(Mathf.Round(AltoFila * 0.6f), 30f, 44f); AltoBoton = AltoDropdown; AltoInput = AltoDropdown; AltoItemPopup = Mathf.Clamp(Mathf.Round(AltoFila * 0.64f), 32f, 48f); ControlDoblajePlugin.Log.LogInfo((object)$"[Layout] Calibrado desde '{((Object)val2).name}': srcH={y} srcFont={fontSize} -> AltoFila={AltoFila} FontLabel={FontEtiqueta}"); } return; } ControlDoblajePlugin.Log.LogWarning((object)"[Layout] CalibrateFrom: no se encontro fila valida, usando defaults."); } } [BepInPlugin("com.enadoblaje.control", "ENA Control de Doblaje", "1.1.0")] public class ControlDoblajePlugin : BaseUnityPlugin { public static Action InstalarAudioScanners; public static Action<Harmony> PatchAudioExtra; public static Action SceneLoadedAudio; public static Func<IEnumerator> AplicarModelosCallback; public static Action<bool> WandererRadioMute; public static Action ModelosAplicar; public static Action ModelosRestaurar; public static Action SoundPlayRandom; public static Action UIResetarEstado; public static Action UIExtrasTurronishReset; public static Func<IEnumerator> UIExtrasTurronishInyectar; public static Action<GameObject, GameObject, GameObject> UIAttachLogoMonitor; public static Action<Harmony> UITryInstalarPatch; public static Action<string, string, string, string> UIMostrarAvisoActualizacion; public static Action VideoExtrasInicio; public static Action VideoExtrasFin; private static int _frameNum = 0; private static readonly HashSet<string> _carpetasOcultas = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Ambiente" }; public static Func<HashSet<string>> AudioObtenerPersonajesDeBank; public static Action AudioForzarCargaBanks; public static ControlDoblajePlugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static string VoicesPath { get; private set; } public static string VideoClipsPath { get; private set; } public static string ImagesPath { get; private set; } public static string MeshPath { get; private set; } public static string BanksPath { get; private set; } public static string AssetsRoot { get; private set; } public static Dictionary<string, bool> PersonajeActivo { get; private set; } = new Dictionary<string, bool>(); public static List<string> PersonajesDisponibles { get; private set; } = new List<string>(); public static bool VideoClipsActivo { get; set; } = true; public static bool ImagenesActivas { get; set; } = true; public static bool ModelosActivos { get; set; } = true; public static int VarianteENA { get; set; } = 0; public static bool VarianteENAMeanie => VarianteENA == 1; public static int VarianteTaxi { get; set; } = 0; public static int VarianteYowadama { get; set; } = 0; public static bool LogVerboso { get; set; } = false; public static bool LogoBtnActivo { get; set; } = true; public static bool BuscarActualizaciones { get; set; } = true; public static string URLVersion { get; set; } = ""; public static bool EnTransicion { get; set; } = false; public static float VideoClipStartTime { get; set; } = -1f; public static Dictionary<string, string> NombresUI { get; private set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); public static Dictionary<string, string> DescripcionesUI { get; private set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); public static Dictionary<string, string> DescripcionesUI_EN { get; private set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); public static Dictionary<string, string> KeyOverride { get; private set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); public static HashSet<string> VirtualPersonajes { get; private set; } = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static string PersonajesConfigPath => Path.Combine(Path.GetDirectoryName(typeof(ControlDoblajePlugin).Assembly.Location), "personajes_config.json"); private static string ConfigPath => Path.Combine(Paths.ConfigPath, "ENADoblaje_config.json"); public static string NombreUIDePersonaje(string carpeta) { string value; return NombresUI.TryGetValue(carpeta, out value) ? value : carpeta; } public static string DescripcionUIDePersonaje(string carpeta) { Dictionary<string, string> dictionary = (Traducciones.TextoEspanolActivo ? DescripcionesUI : DescripcionesUI_EN); if (!dictionary.TryGetValue(carpeta, out var value) || string.IsNullOrEmpty(value)) { DescripcionesUI.TryGetValue(carpeta, out value); } if (string.IsNullOrEmpty(value)) { return null; } return value.Replace("\n\\ ", "\n").Replace("\n\\", "\n"); } public static string KeyDePersonaje(string carpeta) { string value; return KeyOverride.TryGetValue(carpeta, out value) ? value : carpeta; } private void Update() { _frameNum++; float unscaledDeltaTime = Time.unscaledDeltaTime; if (unscaledDeltaTime > 0.1f && _frameNum > 2) { Log.LogWarning((object)$"[PERF] frame lento #{_frameNum}: {(int)(unscaledDeltaTime * 1000f)}ms (~{(int)(1f / unscaledDeltaTime)}fps)"); } } private static string ResolverCarpetaAssets() { string directoryName = Path.GetDirectoryName(typeof(ControlDoblajePlugin).Assembly.Location); string text = Path.Combine(Paths.BepInExRootPath, "Assets"); string[] array = new string[4] { directoryName, Path.Combine(directoryName, "Assets"), text, Path.Combine(Path.GetDirectoryName(Application.dataPath), "BepInEx", "Assets") }; string[] array2 = array; foreach (string text2 in array2) { try { if (File.Exists(Path.Combine(text2, "assets.dat")) || File.Exists(Path.Combine(text2, "audio.dat")) || File.Exists(Path.Combine(text2, "turronish_img.dat"))) { return text2; } } catch { } } return text; } private void Awake() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; string text = Path.Combine(Paths.BepInExRootPath, "Logs", "Turronish"); TurronishDiagLogger.Initialize(Log, text, (TLogMode)0); TurronishDiagLogger.Verbose = LogVerboso; try { string text2 = (AssetsRoot = ResolverCarpetaAssets()); Log.LogInfo((object)("[Paths] dataPath='" + Application.dataPath + "' dllDir='" + Path.GetDirectoryName(typeof(ControlDoblajePlugin).Assembly.Location) + "' → bepAssets='" + text2 + "'")); AssetPack.Init(text2); VoicesPath = Path.Combine(text2, "Voices"); VideoClipsPath = Path.Combine(text2, "VideoClips"); ImagesPath = Path.Combine(text2, "Images"); MeshPath = Path.Combine(text2, "Mesh"); BanksPath = Path.Combine(text2, "Banks"); EscanearPersonajes(); CargarConfig(); CargarPersonajesConfig(); Traducciones.CargarDesdeJSON(); Harmony val = new Harmony("com.enadoblaje.control"); val.PatchAll(); UITryInstalarPatch?.Invoke(val); PatchAudioExtra?.Invoke(val); InstalarAudioScanners?.Invoke(); SceneManager.sceneLoaded += SceneLoaded_Handler; TurronishDiagLogger.Info("[Core]", "Awake completado. sceneLoaded registrado."); } catch (Exception ex) { TurronishDiagLogger.Error("[Core]", "EXCEPCION EN AWAKE: " + ex.GetType().Name + " — " + ex.Message + "\n" + ex.StackTrace); Log.LogError((object)("[Turronish] EXCEPCION EN AWAKE: " + ex.Message + "\n" + ex.StackTrace)); } } private void SceneLoaded_Handler(Scene scene, LoadSceneMode mode) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) try { SceneLoaded_Impl(scene, mode); } catch (Exception ex) { Log.LogError((object)("[Turronish] SceneLoaded exception: " + ex.Message + "\n" + ex.StackTrace)); } } private void SceneLoaded_Impl(Scene scene, LoadSceneMode mode) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)("[Turronish] sceneLoaded: '" + ((Scene)(ref scene)).name + "'")); TurronishDiagLogger.Info("[Core]", $"sceneLoaded: '{((Scene)(ref scene)).name}' mode={mode}"); EnTransicion = true; UIResetarEstado?.Invoke(); UIExtrasTurronishReset?.Invoke(); SceneLoadedAudio?.Invoke(); if (((Scene)(ref scene)).name == "Boot" && PersonajesDisponibles.Count == 0) { AudioForzarCargaBanks?.Invoke(); if (AudioObtenerPersonajesDeBank != null) { EscanearPersonajes(); CargarPersonajesConfig(); } } if (((Scene)(ref scene)).name.IndexOf("Credit", StringComparison.OrdinalIgnoreCase) >= 0 || ((Scene)(ref scene)).name.IndexOf("Ending", StringComparison.OrdinalIgnoreCase) >= 0 || ((Scene)(ref scene)).name.IndexOf("Grey", StringComparison.OrdinalIgnoreCase) >= 0) { Log.LogInfo((object)("[Credits] Escena detectada: " + ((Scene)(ref scene)).name)); CreditScanner.Escanear(); } try { CoroutineHolder.Inicia(InyectarLogoDespues()); } catch (Exception ex) { Log.LogWarning((object)("[Turronish] CoroutineHolder InyectarLogoDespues: " + ex.Message)); } try { CoroutineHolder.Inicia(DiagnosticarEscena(((Scene)(ref scene)).name)); } catch (Exception ex2) { Log.LogWarning((object)("[Turronish] CoroutineHolder DiagnosticarEscena: " + ex2.Message)); } try { CoroutineHolder.Inicia(EscanearImagenesDespues()); } catch (Exception ex3) { Log.LogWarning((object)("[Turronish] CoroutineHolder EscanearImagenesDespues: " + ex3.Message)); } if (AplicarModelosCallback != null) { try { CoroutineHolder.Inicia(AplicarModelosCallback()); } catch (Exception ex4) { Log.LogWarning((object)("[Turronish] CoroutineHolder AplicarModelos3DDespues: " + ex4.Message)); } } if (((Scene)(ref scene)).name.Equals("Menu", StringComparison.OrdinalIgnoreCase) && UIExtrasTurronishInyectar != null) { try { CoroutineHolder.Inicia(UIExtrasTurronishInyectar()); } catch (Exception ex5) { Log.LogWarning((object)("[Turronish] ExtrasTurronishGestor: " + ex5.Message)); } } } private IEnumerator EscanearImagenesDespues() { for (int i = 0; i < 8; i++) { yield return null; } EnTransicion = false; Log.LogInfo((object)"[IMAGE] Transicion completada — escaneo post-transicion iniciado"); if (!ImagenesActivas) { yield break; } Image[] array = Resources.FindObjectsOfTypeAll<Image>(); Scene scene; foreach (Image img in array) { if ((Object)(object)img == (Object)null || (Object)(object)img.sprite == (Object)null) { continue; } scene = ((Component)img).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { Sprite reemplazado = SpriteReemplazador.Reemplazar(img.sprite); if ((Object)(object)reemplazado != (Object)(object)img.sprite) { img.sprite = reemplazado; } } } SpriteRenderer[] array2 = Resources.FindObjectsOfTypeAll<SpriteRenderer>(); foreach (SpriteRenderer sr in array2) { if ((Object)(object)sr == (Object)null || (Object)(object)sr.sprite == (Object)null) { continue; } scene = ((Component)sr).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { Sprite reemplazado2 = SpriteReemplazador.Reemplazar(sr.sprite); if ((Object)(object)reemplazado2 != (Object)(object)sr.sprite) { sr.sprite = reemplazado2; } } } Log.LogInfo((object)"[IMAGE] Escaneo post-transicion completado"); } private IEnumerator DiagnosticarEscena(string nombreEscena) { if (LogVerboso) { for (int i = 0; i < 5; i++) { yield return null; } VolcarDiagnostico(nombreEscena, "5f"); for (int j = 0; j < 85; j++) { yield return null; } VolcarDiagnostico(nombreEscena, "90f"); } } private void VolcarDiagnostico(string nombreEscena, string etiqueta) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) try { Log.LogInfo((object)$"[DIAG] ═══ {etiqueta} post-carga '{nombreEscena}' tScale={Time.timeScale:F2} ═══"); int num = 0; Canvas[] array = Resources.FindObjectsOfTypeAll<Canvas>(); foreach (Canvas val in array) { if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy) { continue; } Scene scene = ((Component)val).gameObject.scene; object obj; if (!((Scene)(ref scene)).IsValid()) { obj = "DDOL"; } else { scene = ((Component)val).gameObject.scene; obj = ((Scene)(ref scene)).name; } string text = (string)obj; Log.LogInfo((object)("[DIAG] Canvas '" + ((Object)((Component)val).gameObject).name + "' [" + text + "] " + $"mode={val.renderMode} sort={val.sortingOrder} root={val.isRootCanvas}")); Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(false); foreach (Image val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy && !(((Graphic)val2).color.a < 0.5f)) { RectTransform component = ((Component)val2).GetComponent<RectTransform>(); float num2; Rect rect; if (!((Object)(object)component != (Object)null)) { num2 = 0f; } else { rect = component.rect; num2 = ((Rect)(ref rect)).width; } float num3 = num2; float num4; if (!((Object)(object)component != (Object)null)) { num4 = 0f; } else { rect = component.rect; num4 = ((Rect)(ref rect)).height; } float num5 = num4; Log.LogInfo((object)$"[DIAG] Image '{((Object)((Component)val2).gameObject).name}' color={((Graphic)val2).color} {num3:F0}x{num5:F0}"); } } CanvasGroup[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<CanvasGroup>(true); foreach (CanvasGroup val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null) && !(val3.alpha >= 0.99f)) { Log.LogInfo((object)$"[DIAG] CanvasGroup '{((Object)((Component)val3).gameObject).name}' alpha={val3.alpha:F2}"); } } num++; } if (num == 0) { Log.LogInfo((object)"[DIAG] (ningún Canvas activo encontrado)"); } VideoPlayer[] array2 = Resources.FindObjectsOfTypeAll<VideoPlayer>(); foreach (VideoPlayer val4 in array2) { if (!((Object)(object)val4 == (Object)null)) { Log.LogInfo((object)($"[DIAG] VP '{((Object)((Component)val4).gameObject).name}' playing={val4.isPlaying} " + $"paused={val4.isPaused} mode={val4.renderMode} active={((Component)val4).gameObject.activeInHierarchy}")); } } Camera[] allCameras = Camera.allCameras; foreach (Camera val5 in allCameras) { if (!((Object)(object)val5 == (Object)null)) { Log.LogInfo((object)($"[DIAG] Cam '{((Object)((Component)val5).gameObject).name}' depth={val5.depth} " + $"clear={val5.clearFlags} enabled={((Behaviour)val5).enabled} mask={val5.cullingMask}")); } } Log.LogInfo((object)"[DIAG] ══════════════════════════════════════════════════"); } catch (Exception ex) { Log.LogWarning((object)("[DIAG] Error en volcado: " + ex.Message)); } } private IEnumerator InyectarLogoDespues() { yield return null; yield return null; if (!LogoBtnActivo || (Object)(object)GameObject.Find("_TurronishLogoBtn") != (Object)null) { yield break; } GameObject mainMenuGO = GameObject.Find("Main Menu"); if ((Object)(object)mainMenuGO == (Object)null) { Log.LogWarning((object)"[Turronish] Logo: 'Main Menu' no encontrado"); yield break; } Transform bordersPath = mainMenuGO.transform.Find("Borders (Masked)") ?? mainMenuGO.transform.Find("Content (Masked)/Borders (Masked)") ?? mainMenuGO.transform.Find("Content (Masked)/Borders") ?? mainMenuGO.transform; Transform mainPanelT = mainMenuGO.transform.Find("Content (Masked)/Main") ?? mainMenuGO.transform.Find("Main"); if ((Object)(object)bordersPath == (Object)null) { Log.LogWarning((object)"[Turronish] Logo: transform raíz nula, abortando"); yield break; } Log.LogInfo((object)$"[Turronish] Logo: borders='{((Object)bordersPath).name}' main={(Object)(object)mainPanelT != (Object)null}"); GameObject plantilla = null; Button[] componentsInChildren = mainMenuGO.GetComponentsInChildren<Button>(true); foreach (Button btn in componentsInChildren) { if (!((Object)((Component)btn).gameObject).name.ToLower().Contains("logo") && (Object)(object)((Component)btn).GetComponent<Image>() != (Object)null) { plantilla = ((Component)btn).gameObject; break; } } GameObject btnGO; if ((Object)(object)plantilla != (Object)null) { btnGO = Object.Instantiate<GameObject>(plantilla, bordersPath); ((Object)btnGO).name = "_TurronishLogoBtn"; string[] array = new string[3] { "JoelG.ENA4.UI.MainMenuLogo", "JoelG.ENA4.UI.MenuClickScaleVisualFeedback", "JoelG.ENA4.UI.MainMenuBordersAnimator" }; foreach (string cn in array) { Component c = btnGO.GetComponent(cn); if ((Object)(object)c != (Object)null) { Object.DestroyImmediate((Object)(object)c); } } EventTrigger[] componentsInChildren2 = btnGO.GetComponentsInChildren<EventTrigger>(true); foreach (EventTrigger ev in componentsInChildren2) { Object.DestroyImmediate((Object)(object)ev); } TMP_Text[] componentsInChildren3 = btnGO.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text txt in componentsInChildren3) { txt.SetText("T"); } Image rootImg = btnGO.GetComponent<Image>(); if ((Object)(object)rootImg != (Object)null) { ((Graphic)rootImg).raycastTarget = true; } RectTransform rt = btnGO.GetComponent<RectTransform>(); if ((Object)(object)rt != (Object)null) { rt.sizeDelta = new Vector2(380f, 220f); rt.anchoredPosition = new Vector2(1695f, 745f); } Log.LogInfo((object)("[Turronish] Clon emoji OK plantilla='" + ((Object)plantilla).name + "'")); } else { Log.LogWarning((object)"[Turronish] Logo: no se encontró botón emoji — usando fallback naranja"); btnGO = new GameObject("_TurronishLogoBtn"); btnGO.transform.SetParent(bordersPath, false); Transform emoji1Fb = bordersPath.Find("Emoji 1"); if (!((Object)(object)emoji1Fb != (Object)null)) { new Vector2(500f, -80f); } else { _ = ((Component)emoji1Fb).GetComponent<RectTransform>().anchoredPosition; } RectTransform rt2 = btnGO.AddComponent<RectTransform>(); Vector2 anchorMin = (rt2.anchorMax = Vector2.zero); rt2.anchorMin = anchorMin; rt2.pivot = new Vector2(0.5f, 0.5f); rt2.sizeDelta = new Vector2(380f, 220f); rt2.anchoredPosition = new Vector2(1695f, 745f); ((Graphic)btnGO.AddComponent<Image>()).color = new Color(0.8f, 0.55f, 0.1f, 0.88f); GameObject tGO = new GameObject("T"); tGO.transform.SetParent(btnGO.transform, false); RectTransform tRT = tGO.AddComponent<RectTransform>(); tRT.anchorMin = Vector2.zero; tRT.anchorMax = Vector2.one; anchorMin = (tRT.offsetMax = Vector2.zero); tRT.offsetMin = anchorMin; TextMeshProUGUI txt2 = tGO.AddComponent<TextMeshProUGUI>(); ((TMP_Text)txt2).SetText("T"); ((TMP_Text)txt2).fontSize = 40f; ((Graphic)txt2).color = Color.white; ((TMP_Text)txt2).alignment = (TextAlignmentOptions)514; ((TMP_Text)txt2).fontStyle = (FontStyles)1; } btnGO.layer = LayerMask.NameToLayer("UI"); string videoPath = VideoExtensions.BuscarArchivo(VideoClipsPath, "vid_Menu_Logo_Turronish"); if (videoPath != null) { RenderTexture renderTex = new RenderTexture(512, 296, 0); renderTex.Create(); GameObject vidGO = new GameObject("_VideoDisplay"); vidGO.transform.SetParent(btnGO.transform, false); RectTransform vidRT = vidGO.AddComponent<RectTransform>(); vidRT.anchorMin = Vector2.zero; vidRT.anchorMax = Vector2.one; Vector2 anchorMin = (vidRT.offsetMax = Vector2.zero); vidRT.offsetMin = anchorMin; RawImage rawImg = vidGO.AddComponent<RawImage>(); rawImg.texture = (Texture)(object)renderTex; ((Graphic)rawImg).raycastTarget = false; VideoPlayer vp = vidGO.AddComponent<VideoPlayer>(); vp.url = videoPath; vp.renderMode = (VideoRenderMode)2; vp.targetTexture = renderTex; vp.isLooping = true; vp.playOnAwake = true; vp.Play(); Image rootImgVP = btnGO.GetComponent<Image>(); if ((Object)(object)rootImgVP != (Object)null) { ((Graphic)rootImgVP).color = Color.clear; } CanvasGroup cgLogo = btnGO.GetComponent<CanvasGroup>() ?? btnGO.AddComponent<CanvasGroup>(); cgLogo.alpha = 0f; TMP_Text[] txtsLogo = btnGO.GetComponentsInChildren<TMP_Text>(true); vp.prepareCompleted += (EventHandler)delegate { TMP_Text[] array2 = txtsLogo; foreach (TMP_Text val in array2) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } cgLogo.alpha = 1f; Log.LogInfo((object)"[Turronish] Logo video preparado — botón visible"); }; LogoRevealFailsafe fsLogo = btnGO.AddComponent<LogoRevealFailsafe>(); fsLogo.cg = cgLogo; Log.LogInfo((object)"[Turronish] VideoPlayer logo añadido OK (oculto hasta prepare)"); } else { Log.LogWarning((object)("[Turronish] Video del logo no encontrado en " + VideoClipsPath)); } btnGO.transform.SetSiblingIndex(0); if ((Object)(object)mainPanelT != (Object)null) { GameObject proxy = new GameObject("_LogoVisProxy"); proxy.transform.SetParent(mainPanelT, false); proxy.AddComponent<TurronishLogoProxy>().Init(btnGO); Log.LogInfo((object)"[Turronish] Logo: proxy de visibilidad instalado en Main"); } btnGO.AddComponent<TurronishClickBlocker>().Init(btnGO); Log.LogInfo((object)("[Turronish] Logo instalado en " + ((Object)bordersPath).name + ".")); } private void EscanearPersonajes() { PersonajesDisponibles.Clear(); Log.LogInfo((object)$"[Scan] VoicesPath='{VoicesPath}' existe={Directory.Exists(VoicesPath)}"); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (string item in AssetPack.ListarSubcarpetas(VoicesPath)) { string fileName = Path.GetFileName(item); if (AssetPack.Listar(item, new string[2] { ".wav", ".ogg" }, recurse: true).Count != 0) { hashSet.Add(fileName); } } if (AudioObtenerPersonajesDeBank != null) { HashSet<string> hashSet2 = AudioObtenerPersonajesDeBank(); if (hashSet2 != null) { foreach (string item2 in hashSet2) { hashSet.Add(item2); } if (hashSet2.Count > 0) { Log.LogInfo((object)$"[Scan] {hashSet2.Count} personajes detectados desde banks"); } } } foreach (string item3 in hashSet) { if (_carpetasOcultas.Contains(item3)) { if (!PersonajeActivo.ContainsKey(item3)) { PersonajeActivo[item3] = true; } continue; } PersonajesDisponibles.Add(item3); if (!PersonajeActivo.ContainsKey(item3)) { PersonajeActivo[item3] = true; } } Log.LogInfo((object)$"[Scan] {PersonajesDisponibles.Count} personajes disponibles"); } private void CargarPersonajesConfig() { NombresUI.Clear(); DescripcionesUI.Clear(); DescripcionesUI_EN.Clear(); KeyOverride.Clear(); VirtualPersonajes.Clear(); string personajesConfigPath = PersonajesConfigPath; if (!File.Exists(personajesConfigPath)) { File.WriteAllText(personajesConfigPath, "{\n \"NombresUI\": {\n \"Salespersone\": \"ENA Sales\",\n \"Meanie\": \"ENA Meanie\"\n },\n \"KeyOverride\": {\n \"Witches_Maria\": \"Witches\"\n },\n \"Virtual\": [\n \"ExtraEffects\"\n ]\n}\n", Encoding.UTF8); Log.LogInfo((object)("[PersonajesConfig] Plantilla creada en: " + personajesConfigPath)); NombresUI["Salespersone"] = "ENA Sales"; NombresUI["Meanie"] = "ENA Meanie"; return; } try { string json = File.ReadAllText(personajesConfigPath, Encoding.UTF8); ParsearSeccionDict(json, "NombresUI", NombresUI); ParsearSeccionDict(json, "DescripcionesUI", DescripcionesUI); ParsearSeccionDict(json, "DescripcionesUI_EN", DescripcionesUI_EN); ParsearSeccionDict(json, "KeyOverride", KeyOverride); ParsearSeccionArray(json, "Virtual", VirtualPersonajes); foreach (string virtualPersonaje in VirtualPersonajes) { string path = Path.Combine(VoicesPath, virtualPersonaje); if (Directory.Exists(path) && Directory.GetFiles(path, "*.wav").Length != 0) { if (!PersonajesDisponibles.Contains(virtualPersonaje)) { PersonajesDisponibles.Add(virtualPersonaje); } if (!PersonajeActivo.ContainsKey(virtualPersonaje)) { PersonajeActivo[virtualPersonaje] = true; } } } foreach (string key in KeyOverride.Keys) { string path2 = Path.Combine(VoicesPath, key); if (Directory.Exists(path2) && Directory.GetFiles(path2, "*.wav").Length != 0) { if (!PersonajesDisponibles.Contains(key)) { PersonajesDisponibles.Add(key); } if (!PersonajeActivo.ContainsKey(key)) { PersonajeActivo[key] = true; } } } Log.LogInfo((object)$"[PersonajesConfig] UI={NombresUI.Count} KeyOverride={KeyOverride.Count} Virtual={VirtualPersonajes.Count}"); } catch (Exception ex) { Log.LogError((object)("[PersonajesConfig] Error: " + ex.Message)); } Traducciones.AgregarNombresUIAIgnorar(); } private static void ParsearSeccionDict(string json, string seccion, Dictionary<string, string> dest) { int num = json.IndexOf("\"" + seccion + "\"", StringComparison.Ordinal); if (num < 0) { return; } int num2 = json.IndexOf('{', num); if (num2 < 0) { return; } int i = num2 + 1; int num3 = 1; while (i < json.Length && num3 > 0) { for (; i < json.Length && json[i] != '"' && json[i] != '{' && json[i] != '}'; i++) { } if (i >= json.Length) { break; } if (json[i] == '{') { num3++; i++; continue; } if (json[i] == '}') { num3--; i++; continue; } string text = LeerStrJSON(json, ref i); for (; i < json.Length && json[i] != ':'; i++) { } for (i++; i < json.Length && json[i] != '"'; i++) { } string text2 = LeerStrJSON(json, ref i); if (text != null && text2 != null) { dest[text] = text2; } for (; i < json.Length && json[i] != ',' && json[i] != '}'; i++) { } if (i < json.Length && json[i] == ',') { i++; } } } private static void ParsearSeccionArray(string json, string seccion, HashSet<string> dest) { int num = json.IndexOf("\"" + seccion + "\"", StringComparison.Ordinal); if (num < 0) { return; } int num2 = json.IndexOf('[', num); if (num2 < 0) { return; } int i = num2 + 1; while (i < json.Length && json[i] != ']') { for (; i < json.Length && json[i] != '"' && json[i] != ']'; i++) { } if (i >= json.Length || json[i] == ']') { break; } string text = LeerStrJSON(json, ref i); if (text != null) { dest.Add(text); } for (; i < json.Length && json[i] != ',' && json[i] != ']'; i++) { } if (i < json.Length && json[i] == ',') { i++; } } } private static string LeerStrJSON(string txt, ref int i) { if (i >= txt.Length || txt[i] != '"') { return null; } i++; StringBuilder stringBuilder = new StringBuilder(); while (i < txt.Length) { char c = txt[i++]; if (c == '"') { break; } if (c == '\\' && i < txt.Length) { char c2 = txt[i++]; if (c2 == 'n') { stringBuilder.Append('\n'); } else { stringBuilder.Append(c2); } } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private void CargarConfig() { if (!File.Exists(ConfigPath)) { return; } try { string[] array = File.ReadAllLines(ConfigPath); foreach (string text in array) { int num = text.IndexOf('='); if (num <= 0) { continue; } string text2 = text.Substring(0, num).Trim(); string text3 = text.Substring(num + 1).Trim(); switch (text2) { case "_textoEspanol": Traducciones.TextoEspanolActivo = text3 == "true"; break; case "_buscarActualizaciones": BuscarActualizaciones = text3 == "true"; break; case "_urlVersion": URLVersion = text3; break; case "_videoClips": VideoClipsActivo = text3 == "true"; break; case "_imagenes": ImagenesActivas = text3 == "true"; break; case "_modelos": ModelosActivos = text3 == "true"; break; case "_varianteENA": { if (int.TryParse(text3, out var result3)) { VarianteENA = result3; } break; } case "_varianteENAMeanie": VarianteENA = ((text3 == "true") ? 1 : 0); break; case "_varianteTaxi": { if (int.TryParse(text3, out var result2)) { VarianteTaxi = result2; } break; } case "_varianteYowadama": { if (int.TryParse(text3, out var result)) { VarianteYowadama = result; } break; } case "_logoBtnActivo": LogoBtnActivo = text3 == "true"; break; default: PersonajeActivo[text2] = text3 == "true"; break; } } } catch (Exception ex) { Log.LogError((object)("Error cargando config: " + ex.Message)); } } public static void GuardarConfig() { try { List<string> list = new List<string> { "_textoEspanol=" + Traducciones.TextoEspanolActivo.ToString().ToLower(), "_videoClips=" + VideoClipsActivo.ToString().ToLower(), "_imagenes=" + ImagenesActivas.ToString().ToLower(), "_modelos=" + ModelosActivos.ToString().ToLower(), $"_varianteENA={VarianteENA}", $"_varianteTaxi={VarianteTaxi}", $"_varianteYowadama={VarianteYowadama}", "_logoBtnActivo=" + LogoBtnActivo.ToString().ToLower(), "_buscarActualizaciones=" + BuscarActualizaciones.ToString().ToLower(), "_urlVersion=" + URLVersion }; list.AddRange(PersonajeActivo.Select((KeyValuePair<string, bool> p) => p.Key + "=" + p.Value.ToString().ToLower())); File.WriteAllLines(ConfigPath, list); } catch (Exception ex) { Log.LogError((object)("Error guardando config: " + ex.Message)); } } } public static class PresetManager { public class Preset { public string Nombre; public bool TextoEspanol; public bool VideoClips; public bool Imagenes; public bool Modelos3D; public Dictionary<string, bool> AudioPersonajes; public Preset(string n, bool te, bool vc, bool im, bool m3d, Dictionary<string, bool> a) { Nombre = n; TextoEspanol = te; VideoClips = vc; Imagenes = im; Modelos3D = m3d; AudioPersonajes = new Dictionary<string, bool>(a); } } private static string PresetsPath => Path.Combine(Paths.ConfigPath, "ENADoblaje_presets.json"); public static List<Preset> Presets { get; private set; } = new List<Preset>(); public static void Cargar() { Presets.Clear(); if (!File.Exists(PresetsPath)) { return; } try { string text = File.ReadAllText(PresetsPath, Encoding.UTF8); int i; for (i = 0; i < text.Length && text[i] != '['; i++) { } if (i >= text.Length) { return; } i++; while (i < text.Length) { for (; i < text.Length && text[i] != '{' && text[i] != ']'; i++) { } if (i >= text.Length || text[i] == ']') { break; } string text2 = null; bool te = true; bool vc = true; bool im = true; bool m3d = true; Dictionary<string, bool> dictionary = new Dictionary<string, bool>(); int num = 1; i++; bool flag = false; while (i < text.Length && num > 0) { for (; i < text.Length && text[i] != '"' && text[i] != '{' && text[i] != '}'; i++) { } if (i >= text.Length) { break; } if (text[i] == '{') { num++; flag = true; i++; continue; } if (text[i] == '}') { num--; flag = false; i++; continue; } string text3 = LeerStr(text, ref i); for (; i < text.Length && text[i] != ':'; i++) { } for (i++; i < text.Length && (text[i] == ' ' || text[i] == '\t' || text[i] == '\n' || text[i] == '\r'); i++) { } if (i >= text.Length) { break; } if (text[i] == '{') { num++; flag = true; i++; continue; } if (text[i] == '"') { string text4 = LeerStr(text, ref i); if (text3 == "nombre") { text2 = text4; } } else { int j; for (j = i; j < text.Length && text[j] != ',' && text[j] != '}' && text[j] != '\n'; j++) { } string text5 = text.Substring(i, j - i).Trim(); i = j; switch (text3) { case "textoEspanol": te = text5 == "true"; break; case "videoClips": vc = text5 == "true"; break; case "imagenes": im = text5 == "true"; break; case "modelos3D": m3d = text5 == "true"; break; default: if (flag) { dictionary[text3] = text5 == "true"; } break; } } for (; i < text.Length && text[i] != '"' && text[i] != '{' && text[i] != '}'; i++) { } } if (text2 != null) { Presets.Add(new Preset(text2, te, vc, im, m3d, dictionary)); } } } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[Presets] Error: " + ex.Message)); } } public static void Guardar() { try { StringBuilder stringBuilder = new StringBuilder("["); for (int i = 0; i < Presets.Count; i++) { Preset preset = Presets[i]; stringBuilder.Append("\n {\"nombre\":\"" + Esc(preset.Nombre) + "\",\"textoEspanol\":" + (preset.TextoEspanol ? "true" : "false") + ",\"videoClips\":" + (preset.VideoClips ? "true" : "false") + ",\"imagenes\":" + (preset.Imagenes ? "true" : "false") + ",\"modelos3D\":" + (preset.Modelos3D ? "true" : "false") + ",\"audio\":{"); List<string> list = preset.AudioPersonajes.Keys.ToList(); for (int j = 0; j < list.Count; j++) { stringBuilder.Append("\"" + Esc(list[j]) + "\":" + (preset.AudioPersonajes[list[j]] ? "true" : "false") + ((j < list.Count - 1) ? "," : "")); } stringBuilder.Append("}}" + ((i < Presets.Count - 1) ? "," : "")); } stringBuilder.Append("\n]"); File.WriteAllText(PresetsPath, stringBuilder.ToString(), Encoding.UTF8); } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[Presets] Error guardando: " + ex.Message)); } } public static void AgregarPresetActual(string nombre) { Presets.RemoveAll((Preset p) => p.Nombre.Equals(nombre, StringComparison.OrdinalIgnoreCase)); Presets.Add(new Preset(nombre, Traducciones.TextoEspanolActivo, ControlDoblajePlugin.VideoClipsActivo, ControlDoblajePlugin.ImagenesActivas, ControlDoblajePlugin.ModelosActivos, new Dictionary<string, bool>(ControlDoblajePlugin.PersonajeActivo))); Guardar(); } public static void AplicarPreset(Preset p) { Traducciones.TextoEspanolActivo = p.TextoEspanol; ControlDoblajePlugin.VideoClipsActivo = p.VideoClips; ControlDoblajePlugin.ImagenesActivas = p.Imagenes; ControlDoblajePlugin.ModelosActivos = p.Modelos3D; foreach (KeyValuePair<string, bool> audioPersonaje in p.AudioPersonajes) { ControlDoblajePlugin.PersonajeActivo[audioPersonaje.Key] = audioPersonaje.Value; } ControlDoblajePlugin.GuardarConfig(); } public static void EliminarPreset(string nombre) { Presets.RemoveAll((Preset p) => p.Nombre.Equals(nombre, StringComparison.OrdinalIgnoreCase)); Guardar(); } private static string LeerStr(string txt, ref int i) { if (i >= txt.Length || txt[i] != '"') { return ""; } i++; StringBuilder stringBuilder = new StringBuilder(); while (i < txt.Length) { char c = txt[i++]; if (c == '"') { break; } if (c == '\\' && i < txt.Length) { char c2 = txt[i++]; switch (c2) { case 'n': stringBuilder.Append('\n'); break; case '"': stringBuilder.Append('"'); break; default: stringBuilder.Append(c2); break; } } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private static string Esc(string s) { return s.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\n", "\\n"); } } public class SpriteRendererScanner : MonoBehaviour { private float _timer = 0f; private const float INTERVAL = 2f; private static SpriteRendererScanner _instancia; private void Awake() { _instancia = this; } private void Update() { if (!ControlDoblajePlugin.ImagenesActivas) { return; } _timer -= Time.unscaledDeltaTime; if (_timer > 0f) { return; } _timer = 2f; try { EscanearAhora(); } catch { } } public static void EscanearConReintentos() { if ((Object)(object)_instancia != (Object)null) { ((MonoBehaviour)_instancia).StartCoroutine(_instancia.ReintentarScan()); } } private IEnumerator ReintentarScan() { for (int i = 0; i < 20; i++) { yield return (object)new WaitForSecondsRealtime(0.2f); try { EscanearAhora(); } catch { } } } public static void EscanearAhora() { if (ControlDoblajePlugin.ImagenesActivas) { EscanearSpriteRenderers(); EscanearImageComponents(); } } private static void EscanearSpriteRenderers() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>(); Vector2 val3 = default(Vector2); foreach (SpriteRenderer val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null || ((Object)val.sprite).name.StartsWith("_replaced_")) { continue; } string name = ((Object)val.sprite).name; string text = ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name); if (text != null) { Texture2D val2 = TexturaCache.Obtener(text); if (!((Object)(object)val2 == (Object)null)) { float x = val.sprite.pivot.x; Rect rect = val.sprite.rect; float num = x / Mathf.Max(((Rect)(ref rect)).width, 1f); float y = val.sprite.pivot.y; rect = val.sprite.rect; ((Vector2)(ref val3))..ctor(num, y / Mathf.Max(((Rect)(ref rect)).height, 1f)); Sprite val4 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val3, val.sprite.pixelsPerUnit); ((Object)val4).name = "_replaced_" + name; val.sprite = val4; ImageTracker.Registrar(name); ControlDoblajePlugin.Log.LogInfo((object)("[IMAGE] SpriteRenderer reemplazado: " + name)); } } } } private static void EscanearImageComponents() { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) Image[] array = Object.FindObjectsOfType<Image>(); Vector2 val3 = default(Vector2); foreach (Image val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null) { continue; } string name = ((Object)val.sprite).name; if (name.StartsWith("_replaced_")) { continue; } string text = ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name); if (text == null) { if (name.IndexOf("Item", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Acquired", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("sp_UI", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Ina", StringComparison.OrdinalIgnoreCase) >= 0) { ManualLogSource log = ControlDoblajePlugin.Log; string[] obj = new string[6] { "[IMAGE_SCAN] Image sin reemplazo: ", name, " go=", ((Object)((Component)val).gameObject).name, " parent=", null }; Transform parent = ((Component)val).transform.parent; obj[5] = ((parent != null) ? ((Object)((Component)parent).gameObject).name : null) ?? "null"; log.LogInfo((object)string.Concat(obj)); } continue; } Texture2D val2 = TexturaCache.Obtener(text); if (!((Object)(object)val2 == (Object)null)) { float x = val.sprite.pivot.x; Rect rect = val.sprite.rect; float num = x / Mathf.Max(((Rect)(ref rect)).width, 1f); float y = val.sprite.pivot.y; rect = val.sprite.rect; ((Vector2)(ref val3))..ctor(num, y / Mathf.Max(((Rect)(ref rect)).height, 1f)); Sprite val4 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val3, val.sprite.pixelsPerUnit); ((Object)val4).name = "_replaced_" + name; val.sprite = val4; ImageTracker.Registrar(name); ControlDoblajePlugin.Log.LogInfo((object)("[IMAGE] Image reemplazado: " + name)); } } } } public static class VideoClipTracker { private static readonly HashSet<string> Logueados = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static void Registrar(string nombre) { if (!string.IsNullOrEmpty(nombre)) { ControlDoblajePlugin.VideoClipStartTime = Time.realtimeSinceStartup; if (Logueados.Add(nombre)) { ControlDoblajePlugin.Log.LogInfo((object)("[VIDEOCLIP] " + nombre)); } } } } public static class ImageTracker { private static readonly HashSet<string> Logueados = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static void Registrar(string nombre) { if (!string.IsNullOrEmpty(nombre) && Logueados.Add(nombre)) { ControlDoblajePlugin.Log.LogInfo((object)("[IMAGE] " + nombre)); } } } public static class CreditScanner { public static void Escanear() { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (assembly2.GetName().Name == "JoelG.ENA4") { assembly = assembly2; break; } } if (assembly == null) { return; } ControlDoblajePlugin.Log.LogInfo((object)"[Credits] === TIPOS CON 'CREDIT' ==="); Type[] types = assembly.GetTypes(); foreach (Type type in types) { string text = type.FullName ?? ""; if (text.IndexOf("Credit", StringComparison.OrdinalIgnoreCase).Equals(-1) && text.IndexOf("Roll", StringComparison.OrdinalIgnoreCase).Equals(-1)) { continue; } ControlDoblajePlugin.Log.LogInfo((object)("[Credits] TIPO: " + text)); MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { ControlDoblajePlugin.Log.LogInfo((object)("[Credits] -> " + methodInfo.Name + "(" + string.Join(", ", Array.ConvertAll(methodInfo.GetParameters(), (ParameterInfo p) => p.ParameterType.Name + " " + p.Name)) + ")")); } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { ControlDoblajePlugin.Log.LogInfo((object)("[Credits] field: " + fieldInfo.FieldType.Name + " " + fieldInfo.Name)); } } } } public static class VideoExtensions { public static readonly string[] Lista = new string[4] { ".mp4", ".webm", ".ogv", ".mov" }; public static string BuscarArchivo(string carpeta, string nombreSinExt) { string[] lista = Lista; foreach (string text in lista) { string text2 = Path.Combine(carpeta, nombreSinExt + text); if (File.Exists(text2)) { return text2; } } string assetsRoot = ControlDoblajePlugin.AssetsRoot; if (AssetPack.Flattened && !string.IsNullOrEmpty(assetsRoot) && !string.Equals(carpeta, assetsRoot, StringComparison.OrdinalIgnoreCase)) { string[] lista2 = Lista; foreach (string text3 in lista2) { string text4 = Path.Combine(assetsRoot, nombreSinExt + text3); if (File.Exists(text4)) { return text4; } } } return null; } } public class TurronishFixedPosition : MonoBehaviour { private Vector3 _worldPos; private Quaternion _worldRot; private Vector3 _worldScale; public void Init(Vector3 pos, Quaternion rot, Vector3 scale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) _worldPos = pos; _worldRot = rot; _worldScale = scale; } public void Init(Vector3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Init(pos, ((Component)this).transform.rotation, ((Component)this).transform.lossyScale); } private void LateUpdate() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = _worldPos; ((Component)this).transform.rotation = _worldRot; Transform parent = ((Component)this).transform.parent; if ((Object)(object)parent != (Object)null) { Vector3 lossyScale = parent.lossyScale; ((Component)this).transform.localScale = new Vector3((lossyScale.x != 0f) ? (_worldScale.x / lossyScale.x) : 1f, (lossyScale.y != 0f) ? (_worldScale.y / lossyScale.y) : 1f, (lossyScale.z != 0f) ? (_worldScale.z / lossyScale.z) : 1f); } } } public class TurronishLogoProxy : MonoBehaviour { private GameObject _btn; private float _readyAt; private Transform _mainPanel; public void Init(GameObject btn) { _btn = btn; _btn.SetActive(false); _readyAt = Time.realtimeSinceStartup + 1.5f; _mainPanel = ((Component)this).transform.parent; } private void OnDisable() { if ((Object)(object)_btn != (Object)null) { _btn.SetActive(false); } } private void Update() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown if ((Object)(object)_btn == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { if (Time.realtimeSinceStartup < _readyAt) { return; } bool flag = (Object)(object)_mainPanel != (Object)null && ((Component)_mainPanel).gameObject.activeInHierarchy; bool flag2 = false; if (flag && (Object)(object)_mainPanel.parent != (Object)null) { foreach (Transform item in _mainPanel.parent) { Transform val = item; if (!((Object)(object)val == (Object)(object)_mainPanel) && ((Component)val).gameObject.activeInHierarchy) { string name = ((Object)((Component)val).gameObject).name; if (name.IndexOf("Settings", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Options", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Extras", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Credits", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Supporter", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Turronish", StringComparison.OrdinalIgnoreCase) >= 0) { flag2 = true; break; } } } } bool flag3 = ControlDoblajePlugin.LogoBtnActivo && flag && !flag2; if (flag3 != _btn.activeSelf) { _btn.SetActive(flag3); } } } } public class TurronishClickBlocker : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerClickHandler, IPointerExitHandler { private GameObject _clon; public void Init(GameObject clon) { _clon = clon; } public void OnPointerDown(PointerEventData e) { ((AbstractEventData)e).Use(); TurronishScaleTween.ScaleTo(_clon, 1.15f, 0.07f); } public void OnPointerClick(PointerEventData e) { ((AbstractEventData)e).Use(); TurronishScaleTween.ScaleTo(_clon, 1f, 0.12f); ControlDoblajePlugin.SoundPlayRandom?.Invoke(); ControlDoblajePlugin.Log.LogInfo((object)"[Turronish] ¡Click!"); } public void OnPointerExit(PointerEventData e) { TurronishScaleTween.ScaleTo(_clon, 1f, 0.08f); } } public class TurronishScaleTween : MonoBehaviour { private float _target = 1f; private float _speed = 0.08f; private bool _running = false; public static void ScaleTo(GameObject go, float target, float duration) { if (!((Object)(object)go == (Object)null)) { TurronishScaleTween component = go.GetComponent<TurronishScaleTween>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } TurronishScaleTween turronishScaleTween = go.AddComponent<TurronishScaleTween>(); turronishScaleTween._target = target; turronishScaleTween._speed = Mathf.Max(duration, 0.001f); turronishScaleTween._running = true; } } private void Update() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_009a: Unknown result type (might be due to invalid IL or missing references) if (_running) { float num = 1f - Mathf.Pow(0.001f, Time.unscaledDeltaTime / _speed); ((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, Vector3.one * _target, num); if (Vector3.Distance(((Component)this).transform.localScale, Vector3.one * _target) < 0.001f) { ((Component)this).transform.localScale = Vector3.one * _target; _running = false; Object.Destroy((Object)(object)this); } } } } public static class Localizacion { private class DatosIdioma { public string Nombre; public Dictionary<string, string> Nativo; public Dictionary<string, string> NativoCI; public Dictionary<string, string> Inverso; public HashSet<string> Valores; } public static string IdiomaTextos = "es"; private static readonly Dictionary<string, DatosIdioma> _idiomas = new Dictionary<string, DatosIdioma>(StringComparer.Ordinal); public static IEnumerable<string> IdiomasDisponibles => _idiomas.Keys; public static bool EsPassthroughActual => EsPassthrough(IdiomaTextos); private static DatosIdioma Actual { get { DatosIdioma value; return _idiomas.TryGetValue(IdiomaTextos, out value) ? value : null; } } public static Dictionary<string, string> MapaActual => Actual?.Nativo; public static Dictionary<string, string> MapaActualCI => Actual?.NativoCI; public static Dictionary<string, string> MapaInversoActual => Actual?.Inverso; public static HashSet<string> ValoresActual => Actual?.Valores; public static event Action OnIdiomaChanged; public static void NotificarCambio() { Localizacion.OnIdiomaChanged?.Invoke(); } public static string NombreDe(string idioma) { DatosIdioma value; return _idiomas.TryGetValue(idioma, out value) ? value.Nombre : idioma; } public static bool EsPassthrough(string idioma) { DatosIdioma value; return idioma == "en" || !_idiomas.TryGetValue(idioma, out value) || value.Nativo == null; } public static void RegistrarIdioma(string id, string nombre, Dictionary<string, string> nativo) { DatosIdioma datosIdioma = new DatosIdioma { Nombre = nombre }; if (nativo != null) { datosIdioma.Nativo = nativo; datosIdioma.NativoCI = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); datosIdioma.Inverso = new Dictionary<string, string>(StringComparer.Ordinal); datosIdioma.Valores = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, string> item in nativo) { if (!datosIdioma.NativoCI.ContainsKey(item.Key)) { datosIdioma.NativoCI[item.Key] = item.Value; } if (!datosIdioma.Inverso.ContainsKey(item.Value)) { datosIdioma.Inverso[item.Value] = item.Key; } datosIdioma.Valores.Add(item.Value); } } _idiomas[id] = datosIdioma; } public static string AIngles(string texto) { if (string.IsNullOrEmpty(texto)) { return texto; } foreach (KeyValuePair<string, DatosIdioma> idioma in _idiomas) { Dictionary<string, string> inverso = idioma.Value.Inverso; if (inverso != null && inverso.TryGetValue(texto, out var value)) { return value; } } return texto; } public static string ArchivoIdioma(string carpetaAbs, string baseName, string ext) { string text = Path.Combine(carpetaAbs, baseName + "." + IdiomaTextos + ext); if (AssetPack.Existe(text)) { return text; } return Path.Combine(carpetaAbs, baseName + ext); } } public static class ReporteLogs { private class ReporteLogsRunner : MonoBehaviour { } public const string WEBHOOK_URL = "https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u"; private const long MAX_LOG_BYTES = 900000L; private static ReporteLogsRunner _runner; public static bool Enviando { get; private set; } public static bool Configurado => !string.IsNullOrEmpty("https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u") && !"https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u".StartsWith("REEMPLAZAR"); private static string BepInExDir => Paths.BepInExRootPath; private static string ArchivoDiagMasReciente() { try { string path = Path.Combine(BepInExDir, "Logs", "Turronish"); if (!Directory.Exists(path)) { return null; } string result = null; DateTime dateTime = DateTime.MinValue; string[] files = Directory.GetFiles(path, "turronish_*.txt"); foreach (string text in files) { DateTime lastWriteTime = File.GetLastWriteTime(text); if (lastWriteTime > dateTime) { dateTime = lastWriteTime; result = text; } } return result; } catch { return null; } } private static string LeerCola(string path, long maxBytes) { try { if (string.IsNullOrEmpty(path) || !File.Exists(path)) { return "(no encontrado)"; } using FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); long num = Math.Max(0L, fileStream.Length - maxBytes); fileStream.Seek(num, SeekOrigin.Begin); using StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8); string text = streamReader.ReadToEnd(); if (num > 0) { text = $"...(recortado; últimos {maxBytes / 1024} KB)...\n" + text; } return text; } catch (Exception ex) { return "(error leyendo: " + ex.Message + ")"; } } private static byte[] ConstruirReporte(string nota, string discord, bool incluirLogOutput, out string nombre) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== Reporte Turronish ==="); stringBuilder.AppendLine("Fecha: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); stringBuilder.AppendLine("OS: " + SystemInfo.operatingSystem); stringBuilder.AppendLine("Idioma textos: " + Localizacion.IdiomaTextos); stringBuilder.AppendLine("Discord: " + (string.IsNullOrWhiteSpace(discord) ? "(no indicado)" : discord.Trim())); stringBuilder.AppendLine("Nota: " + (string.IsNullOrWhiteSpace(nota) ? "(sin nota)" : nota.Trim())); stringBuilder.AppendLine(); string text = ArchivoDiagMasReciente(); stringBuilder.AppendLine("--- " + ((text != null) ? Path.GetFileName(text) : "turronish log (no encontrado)") + " ---"); stringBuilder.AppendLine(LeerCola(text, 900000L)); if (incluirLogOutput) { stringBuilder.AppendLine(); stringBuilder.AppendLine("--- LogOutput.log ---"); stringBuilder.AppendLine(LeerCola(Path.Combine(BepInExDir, "LogOutput.log"), 900000L)); } nombre = "turronish_report_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"; return Encoding.UTF8.GetBytes(stringBuilder.ToString()); } private static ReporteLogsRunner Runner() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_runner == (Object)null) { GameObject val = new GameObject("_TurronishReporteRunner"); Object.DontDestroyOnLoad((Object)(object)val); _runner = val.AddComponent<ReporteLogsRunner>(); } return _runner; } public static void Enviar(string nota, string discord, bool incluirLogOutput, Action<bool, string> onResult) { if (Enviando) { onResult?.Invoke(arg1: false, "Ya se está enviando..."); return; } if (!Configurado) { onResult?.Invoke(arg1: false, "Webhook no configurado."); return; } try { ((MonoBehaviour)Runner()).StartCoroutine(EnviarCo(nota, discord, incluirLogOutput, onResult)); } catch (Exception ex) { onResult?.Invoke(arg1: false, "No se pudo iniciar el envío: " + ex.Message); } } private static IEnumerator EnviarCo(string nota, string discord, bool incluirLogOutput, Action<bool, string> onResult) { Enviando = true; byte[] archivo = null; string nombre = "report.txt"; string errArmado = null; try { archivo = ConstruirReporte(nota, discord, incluirLogOutput, out nombre); } catch (Exception ex) { Exception e = ex; errArmado = e.Message; } if (errArmado != null) { Enviando = false; onResult?.Invoke(arg1: false, "Error armando reporte: " + errArmado); yield break; } string contenido = "Nuevo reporte" + (string.IsNullOrWhiteSpace(discord) ? "" : (" de " + discord.Trim())) + (string.IsNullOrWhiteSpace(nota) ? "" : (": " + ((nota.Trim().Length > 180) ? nota.Trim().Substring(0, 180) : nota.Trim()))); List<IMultipartFormSection> form = new List<IMultipartFormSection> { (IMultipartFormSection)new MultipartFormDataSection("payload_json", "{\"content\":" + JsonEscape(contenido) + "}"), (IMultipartFormSection)new MultipartFormFileSection("files[0]", archivo, nombre, "text/plain") }; UnityWebRequest req = UnityWebRequest.Post("https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u", form); try { yield return req.SendWebRequest(); bool ok = (int)req.result == 1; Enviando = false; if (ok) { ControlDoblajePlugin.Log.LogInfo((object)"[ReporteLogs] enviado OK"); onResult?.Invoke(arg1: true, "¡Reporte enviado! Gracias."); } else { ControlDoblajePlugin.Log.LogWarning((object)$"[ReporteLogs] fallo: {req.error} (HTTP {req.responseCode})"); onResult?.Invoke(arg1: false, "Fallo al enviar: " + (req.error ?? ("HTTP " + req.responseCode))); } } finally { ((IDisposable)req)?.Dispose(); } } private static string JsonEscape(string s) { if (s == null) { return "\"\""; } StringBuilder stringBuilder = new StringBuilder("\""); foreach (char c in s) { switch (c) { case '"': stringBuilder.Append("\\\""); continue; case '\\': stringBuilder.Append("\\\\"); continue; case '\n': stringBuilder.Append("\\n"); continue; case '\r': stringBuilder.Append("\\r"); continue; case '\t': stringBuilder.Append("\\t"); continue; } if (c < ' ') { int num = c; stringBuilder.Append("\\u" + num.ToString("x4")); } else { stringBuilder.Append(c); } } stringBuilder.Append("\""); return stringBuilder.ToString(); } } public static class ActualizacionChecker { private static bool _lanzado; public static void LanzarUnaVez() { if (_lanzado) { return; } _lanzado = true; if (!ControlDoblajePlugin.BuscarActualizaciones) { ControlDoblajePlugin.Log.LogInfo((object)"[Actualiz] desactivado por config."); return; } string uRLVersion = ControlDoblajePlugin.URLVersion; if (string.IsNullOrEmpty(uRLVersion) || (!uRLVersion.StartsWith("http") && !uRLVersion.StartsWith("file:"))) { ControlDoblajePlugin.Log.LogInfo((object)"[Actualiz] sin URL configurada — no se consulta."); return; } if (Traducciones.VersionTraduccionLocal == "0") { ControlDoblajePlugin.Log.LogWarning((object)"[Actualiz] traducciones.json sin '__version_traduccion__' — se omite el chequeo."); return; } try { CoroutineHolder.Inicia(ChequeoCo(uRLVersion)); } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] no se pudo lanzar: " + ex.Message)); } } private static IEnumerator ChequeoCo(string url) { UnityWebRequest req = UnityWebRequest.Get(url); try { req.timeout = 10; yield return req.SendWebRequest(); if ((int)req.result != 1) { ControlDoblajePlugin.Log.LogInfo((object)("[Actualiz] sin respuesta (" + req.error + ") — se ignora.")); yield break; } string json = ((req.downloadHandler != null) ? req.downloadHandler.text : null); if (string.IsNullOrEmpty(json)) { yield break; } string remota = ExtraerCampo(json, "version"); string urlDesc = ExtraerCampo(json, "url"); string changelog = ExtraerCampo(json, "changelog"); string local = Traducciones.VersionTraduccionLocal; if (string.IsNullOrEmpty(remota)) { ControlDoblajePlugin.Log.LogInfo((object)"[Actualiz] JSON sin 'version' — se ignora."); yield break; } int cmp = CompararVersiones(remota, local); ControlDoblajePlugin.Log.LogInfo((object)$"[Actualiz] local='{local}' remota='{remota}' cmp={cmp}"); if (cmp <= 0) { yield break; } Action<string, string, string, string> hook = ControlDoblajePlugin.UIMostrarAvisoActualizacion; if (hook != null) { try { hook(local, remota, urlDesc ?? "", changelog ?? ""); } catch (Exception ex) { Exception ex2 = ex; ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] hook de UI falló: " + ex2.Message)); } } else { ControlDoblajePlugin.Log.LogWarning((object)"[Actualiz] hay update pero la UI no registró el hook."); } } finally { ((IDisposable)req)?.Dispose(); } } private static string ExtraerCampo(string json, string campo) { if (string.IsNullOrEmpty(json)) { return null; } int num = json.IndexOf("\"" + campo + "\"", StringComparison.Ordinal); if (num < 0) { return null; } int num2 = json.IndexOf(':', num + campo.Length + 2); if (num2 < 0) { return null; } int i; for (i = num2 + 1; i < json.Length && char.IsWhiteSpace(json[i]); i++) { } if (i >= json.Length || json[i] != '"') { return null; } i++; StringBuilder stringBuilder = new StringBuilder(); while (i < json.Length) { char c = json[i++]; if (c == '\\' && i < json.Length) { char c2 = json[i++]; switch (c2) { case 'n': stringBuilder.Append('\n'); break; case 't': stringBuilder.Append('\t'); break; case '"': stringBuilder.Append('"'); break; case '\\': stringBuilder.Append('\\'); break; case '/': stringBuilder.Append('/'); break; default: stringBuilder.Append(c2); break; case 'r': break; } } else { if (c == '"') { break; } stringBuilder.Append(c); } } return stringBuilder.ToString().Trim(); } public static int CompararVersiones(string a, string b) { int[] array = Parsear(a); int[] array2 = Parsear(b); if (array == null || array2 == null) { return (!string.Equals(a?.Trim(), b?.Trim(), StringComparison.OrdinalIgnoreCase)) ? string.Compare(a?.Trim(), b?.Trim(), StringComparison.OrdinalIgnoreCase) : 0; } int num = Math.Max(array.Length, array2.Length); for (int i = 0; i < num; i++) { int num2 = ((i < array.Length) ? array[i] : 0); int num3 = ((i < array2.Length) ? array2[i] : 0); if (num2 != num3) { return (num2 > num3) ? 1 : (-1); } } return 0; } private static int[] Parsear(string v) { if (string.IsNullOrEmpty(v)) { return null; } v = v.Trim(); if (v.Length > 0 && (v[0] == 'v' || v[0] == 'V')) { v = v.Substring(1); } string[] array = v.Split(new char[1] { '.' }); int[] array2 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { if (!int.TryParse(array[i].Trim(), out array2[i])) { return null; } } return array2; } } public static class Traducciones { private static readonly Dictionary<string, string> Cache = new Dictionary<string, string>(StringComparer.Ordinal); private static readonly HashSet<string> YaLogueados = new HashSet<string>(StringComparer.Ordinal); private static readonly Dictionary<string, string> EstiloAPersonaje = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Dratula", "Dratula" }, { "SuspiciousMan", "SuspiciousMan" } }; public const string VERSION_KEY = "__version_traduccion__"; public static Action OnIdiomaChanged; private static readonly HashSet<string> IgnorarLog = new HashSet<string>(StringComparer.Ordinal) { "Doblaje", "Preajustes", "Borrar", "Guardar", "Idioma general", "Textos", "IDIOMA GENERAL", "TRADUCCION VISUAL", "AUDIO POR PERSONAJE", "Español", "Original", "Inglés", "-- Ninguno --", "-- None --", "Dratula", "SuspiciousMan", "TheBus", "Wanderer", "Todo Español", "Todo Original", "Todo English", "Todo Spanish", "Presets", "Delete", "Save", "General language", "Texts", "GENERAL LANGUAGE", "VISUAL TRANSLATION", "AUDIO PER CHARACTER", "Spanish", "English", "All Spanish", "All English", "VideoClips", "Video Clips", "Imágenes", "Images", "Turronish", "Nombre del preajuste...", "Preset name...", "CoralGlasses", "Froggy", "Meanie", "Mitu", "Phindol", "PurgeKiosk", "Receptionist", "Salespersone", "Taxi", "TimothyRundle", "Witches", "ENA Sales", "ENA Meanie", "Coral Glasses", "Purge Kiosk", "Suspicious Man", "The Bus", "Timothy Rundle" }; private static string _dumpSinTrad; public static bool TextoEspanolActivo { get { return Localizacion.IdiomaTextos == "es"; } set { Localizacion.IdiomaTextos = (value ? "es" : "en"); } } public static Dictionary<string, string> Mapa => Localizacion.MapaActual; private static Dictionary<string, string> MapaInverso => Localizacion.MapaInversoActual; private static HashSet<string> ValoresTraducidos => Localizacion.ValoresActual; public static string JSONPath { get { string text = Path.Combine(Path.GetDirectoryName(typeof(Traducciones).Assembly.Location), "traducciones.json"); if (File.Exists(text)) { return text; } return Path.Combine(Paths.ConfigPath, "traducciones.json"); } } public static string VersionTraduccionLocal { get; private set; } = "0"; public static void CargarDesdeJSON() { if (!File.Exists(JSONPath)) { ControlDoblajePlugin.Log.LogWarning((object)("[Traducciones] No se encontro: " + JSONPath)); return; } try { string text = File.ReadAllText(JSONPath, Encoding.UTF8); int num = text.IndexOf("\"traducciones\""); if (num < 0) { return; } num = text.IndexOf('{', num); if (num < 0) { return; } int i = num + 1; int num2 = 0; Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); while (i < text.Length) { for (; i < text.Length && text[i] != '"' && text[i] != '}'; i++) { } if (i >= text.Length || text[i] == '}') { break; } string text2 = LeerStringJSON(text, ref i); if (text2 == null) { break; } for (; i < text.Length && text[i] != ':'; i++) { } for (i++; i < text.Length && text[i] != '"'; i++) { } string text3 = LeerStringJSON(text, ref i); if (text3 == null) { break; } if (text2 == "__version_traduccion__") { VersionTraduccionLocal = text3.Trim(); } else if (!text2.StartsWith("---") && !text2.StartsWith("//") && text3.Length > 0) { string key = text2.Replace("\r\n", "\n"); string value = text3.Replace("\r\n", "\n"); dictionary[key] = value; num2++; } for (; i < text.Length && text[i] != ',' && text[i] != '}'; i++) { } if (i < text.Length && text[i] == ',') { i++; } } Localizacion.RegistrarIdioma("en", "English", null); Localizacion.RegistrarIdioma("es", "Español", dictionary); Cache.Clear(); YaLogueados.Clear(); ControlDoblajePlugin.Log.LogInfo((object)$"[Traducciones] {num2} entradas cargadas (idioma actual: {Localizacion.IdiomaTextos})."); } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[Traducciones] Error: " + ex.Message)); } } public static void RefrescarTextosActivos() { if (!TextoEspanolActivo) { return; } try { TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val == (Object)null || EsDeNuestraUI((Component)(object)val) || (Object)(object)((Component)val).GetComponentInParent<TMP_InputField>() != (Object)null) { continue; } string text = ((TMP_Text)val).text; if (!string.IsNullOrEmpty(text)) { Cache.Remove(text); string text2 = Aplicar(text); if (text2 != text) { ((TMP_Text)val).SetText(text2); } } } } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[RefrescarTextos] " + ex.Message)); } } private static void RefrescarDropdownsNativos() { try { int num = 0; TMP_Dropdown[] array = Resources.FindObjectsOfTypeAll<TMP_Dropdown>(); foreach (TMP_Dropdown val in array) { if ((Object)(object)val == (Object)null || EsDeNuestraUI((Component)(object)val)) { continue; } try { try { val.RefreshShownValue(); } catch { } TMP_Text captionText = val.captionText; List<OptionData> options = val.options; if ((Object)(object)captionText != (Object)null && options != null && val.value >= 0 && val.value < options.Count) { string text = Aplicar(Localizacion.AIngles(options[val.value].text)); if (captionText.text != text) { captionText.SetText(text); num++; } } } catch { } } if (num > 0) { ControlDoblajePlugin.Log.LogInfo((object)$"[DDNativos] {num} caption(s) forzados a idioma '{Localizacion.IdiomaTextos}'."); } } catch { } } public static void DesactivarYRevertir() { Dictionary<string, string> mapaInverso = MapaInverso; TextoEspanolActivo = false; Cache.Clear(); TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if (!((Object)(object)val == (Object)null) && !EsDeNuestraUI((Component)(object)val) && !((Object)(object)((Component)val).GetComponentInParent<TMP_InputField>() != (Object)null)) { string text = ((TMP_Text)val).text; if (!string.IsNullOrEmpty(text) && mapaInverso != null && mapaInverso.TryGetValue(text, out var value)) { ((TMP_Text)val).SetText(value); } } } RefrescarDropdownsNativos(); OnIdiomaChanged?.Invoke(); Localizacion.NotificarCambio(); } public static void ActivarYAplicar() { TextoEspanolActivo = true; Cache.Clear(); TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val == (Object)null || EsDeNuestraUI((Component)(object)val) || (Object)(object)((Component)val).GetComponentInParent<TMP_InputField>() != (Object)null) { continue; } string text = ((TMP_Text)val).text; if (!string.IsNullOrEmpty(text)) { string text2 = Aplicar(text); if (text2 != text) { ((TMP_Text)val).SetText(text2); } } } RefrescarDropdownsNativos(); OnIdiomaChanged?.Invoke(); Localizacion.NotificarCambio(); } public static bool EsDeNuestraUI(Component c) { if ((Object)(object)c == (Object)null) { return false; } Transform val = c.transform; while ((Object)(object)val != (Object)null) { if ((Object)(object)((Component)val).GetComponent<DoblejeUIMarker>() != (Object)null) { return true; } val = val.parent; } return false; } private static string LeerStringJSON(string texto, ref int i) { if (i >= texto.Length || texto[i] != '"') { return null; } i++; StringBuilder stringBuilder = new StringBuilder(); while (i < texto.Length) { char c = texto[i++]; if (c == '"') { break; } if (c == '\\' && i < texto.Length) { char c2 = texto[i++]; switch (c2) { case '"': stringBuilder.Append('"'); break; case '\\': stringBuilder.Append('\\'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': if (i + 4 <= texto.Length) { stringBuilder.Append((char)Convert.ToInt32(texto.Substring(i, 4), 16)); i += 4; } break; default: stringBuilder.Append(c2); break; } } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); } public static void AgregarNombresUIAIgnorar() { foreach (string value in ControlDoblajePlugin.NombresUI.Values) { IgnorarLog.Add(value); } foreach (string personajesDisponible in ControlDoblajePlugin.PersonajesDisponibles) { IgnorarLog.Add(personajesDisponible); } } public static void InvalidarCache(string texto) { Cache.Remove(texto); } private static bool EsTodoMayusculas(string s) { bool result = false; foreach (char c in s) { if (char.IsLetter(c)) { result = true; if (char.IsLower(c)) { return false; } } } return result; } private static bool BuscarTrad(string s, out string trad) { trad = null; if (string.IsNullOrEmpty(s)) { return false; } Dictionary<string, string> mapa = Mapa; if (mapa == null) { return false; } if (mapa.TryGetValue(s, out trad)) { return true; } string text = s.Replace('’', '\'').Replace('‘', '\'').Replace('“', '"') .Replace('”', '"'); if ((object)text != s && mapa.TryGetValue(text, out trad)) { return true; } Dictionary<string, string> mapaActualCI = Localizacion.MapaActualCI; if (mapaActualCI != null && (mapaActualCI.TryGetValue(s, out trad) || mapaActualCI.TryGetValue(text, out trad))) { if (EsTodoMayusculas(s)) { trad = trad.ToUpperInvariant(); } return true; } trad = null; return false; } public static string Aplicar(string texto) { if (string.IsNullOrEmpty(texto) || Localizacion.EsPassthroughActual) { return texto; } if (Cache.TryGetValue(texto, out var value)) { return value; } string text = texto.Replace("\r\n", "\n"); if (ValoresTraducidos.Contains(text)) { Cache[texto] = texto; return texto; } if (BuscarTrad(text, out var trad)) { Cache[texto] = trad; return trad; } string text2 = text.Replace('’', '\'').Replace('‘', '\'').Replace('“', '"') .Replace('”', '"'); if ((object)text2 != text && Mapa.TryGetValue(text2, out var value2)) { Cache[texto] = value2; return value2; } string text3 = text.Trim(); if (text3.Length != text.Length) { if (BuscarTrad(text3, out var trad2)) { Cache[texto] = trad2; return trad2; } string text4 = text3.Replace('’', '\'').Replace('‘', '\'').Replace('“', '"') .Replace('”', '"'); if ((object)text4 != text3 && Mapa.TryGetValue(text4, out var value3)) { Cache[texto] = value3; return value3; } } string text5 = AplicarPatronLastSaved(text); if (text5 != null) { Cache[texto] = text5; return text5; } string text6 = AplicarPatronTimeAgo(text); if (text6 != null) { Cache[texto] = text6; return text6; } if (Enumerable.Contains(text, '\n')) { string[] array = text.Split(new char[1] { '\n' }); bool flag = false; bool flag2 = true; for (int i = 0; i < array.Length; i++) { if (string.IsNullOrEmpty(array[i])) { continue; } string text7 = array[i]; if (ValoresTraducidos.Contains(text7)) { flag = true; continue; } if (BuscarTrad(text7, out var trad3)) { array[i] = trad3; flag = true; continue; } string text8 = text7.Replace('’', '\'').Replace('‘', '\'').Replace('“', '"') .Replace('”', '"'); if ((object)text8 != text7 && Mapa.TryGetValue(text8, out var value4)) { array[i] = value4; flag = true; continue; } string text9 = text7.Trim(); if (text9.Length != text7.Length) { if (BuscarTrad(text9, out var trad4)) { array[i] = trad4; flag = true; continue; } string text10 = text9.Replace('’', '\'').Replace('‘', '\''); if ((object)text10 != text9 && Mapa.TryGetValue(text10, out var value5)) { array[i] = value5; flag = true; continue; } } string text11 = TraducirTiempoRelativo(text9); if (text11 != null && text11 != text9) { array[i] = text7.Replace(text9, text11); flag = true; continue; } Match match = Regex.Match(text9, "^(?<pre>(?:<[^<>]+>)+)?(?<core>[^<>]+?)(?<post>(?:<[^<>]+>)+)?$"); if (match.Success) { string text12 = match.Groups["core"].Value.Trim(); if (text12.Length > 0 && text12.Length != text9.Length) { if (!BuscarTrad(text12, out var trad5)) { trad5 = TraducirTiempoRelativo(text12); } if (trad5 != null && trad5 != text12) { array[i] = text7.Replace(text12, trad5); flag = true; continue; } } } flag2 = false; } if (flag) { string text13 = string.Join("\n", array); if (flag2) { Cache[texto] = text13; } return text13; } } string text14 = text.Trim(); if (!DebeIgnorar(text14) && !YaLogueados.Contains(text14)) { ControlDoblajePlugin.Log.LogInfo((object)("SIN_TRADUCIR: [" + texto + "]")); YaLogueados.Add(text14); VolcarSinTraducir(texto); } if (!EsTextoAleatorio(text14)) { Cache[texto] = texto; } return texto; } private static void VolcarSinTraducir(string texto) { try { if (_dumpSinTrad == null) { _dumpSinTrad = Path.Combine(Paths.ConfigPath, "sin_traducir_dump.jsonl"); } string text = "\"" + texto.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\r", "\\r") .Replace("\n", "\\n") .Replace("\t", "\\t") + "\""; File.AppendAllText(_dumpSinTrad, text + "\n", Encoding.UTF8); } catch { } } private static string AplicarPatronLastSaved(string norm) { if (!norm.StartsWith("Last Saved: ", StringComparison.Ordinal)) { return null; } string parte = norm.Substring("Last Saved: ".Length).Trim(); string text = TraducirTiempoRelativo(parte); if (text == null) { return null; } return "Último guardado: " + text; } private static string AplicarPatronTimeAgo(string norm) { string text = TraducirTiempoRelativo(norm); return (text != null && text != norm) ? text : null; } private static string TraducirTiempoRelativo(string parte) { if (Mapa.TryGetValue(parte, out var value)) { return value; } string key = parte.Replace('’', '\'').Replace('‘', '\''); if (Mapa.TryGetValue(key, out var value2)) { return value2; } string text = parte.ToLowerInvariant(); if (text == "less than a minute ago") { return "Hace menos de un minuto"; } if (text == "just now" || text == "a moment ago") { return "Ahora mismo"; } switch (text) { case "1 minute ago": return "Hace 1 minuto"; case "1 hour ago": return "Hace 1 hora"; case "1 day ago": return "Hace 1 día"; default: { Match match = Regex.Match(text, "^(\\d+)\\s+(minute|hour|day|week)s?\\s+ago$"); if (match.Success) { string value3 = match.Groups[1].Value; switch (match.Groups[2].Value) { case "minute": return "Hace " + value3 + " minutos"; case "hour": return "Hace " + value3 + " horas"; case "day": return "Hace " + value3 + " días"; case "week": return "Hace " + value3 + " semanas"; } } return null; } } } private static string PersonajeDueno(string texto) { if (!texto.StartsWith("<style=")) { return null; } int num = texto.IndexOf('>', 7); if (num < 0) { return null; } string value; return EstiloAPersonaje.TryGetValue(texto.Substring(7, num - 7), out value) ? value : null; } public static bool EsTextoAleatorio(string s) { if (string.IsNullOrEmpty(s)) { return false; } if (s.Length <= 10 && s[0] == '¢') { return true; } int num = 0; int num2 = 0; foreach (char c in s) { if (!char.IsWhiteSpace(c)) { num++; if (c >= 'ɐ' && c <= 'ʯ') { num2++; } } } return num > 0 && num2 * 2 > num; } private static bool DebeIgnorar(string trim) { if (trim.Length <= 3 || IgnorarLog.Contains(trim)) { return true; } if (EsTextoAleatorio(trim)) { return true; } if (trim.Contains("<alpha=") || trim.StartsWith("USB_LP_") || trim.Contains("<sprite=")) { return true; } if (trim.Length <= 8 && (char.IsDigit(trim[0]) || trim[0] == '-')) { return true; } if (Enumerable.Contains(trim, '%') || (trim.StartsWith("v") && Enumerable.Contains(trim, '.'))) { return true; } if (Enumerable.Contains(trim, 'ó') || Enumerable.Contains(trim, 'á') || Enumerable.Contains(trim, 'é') || Enumerable.Contains(trim, 'í') || Enumerable.Contains(trim, 'ú') || Enumerable.Contains(trim, 'ñ') || Enumerable.Contains(trim, '¿') || Enumerable.Contains(trim, '¡') || Enumerable.Contains(trim, 'Ú') || Enumerable.Contains(trim, 'à')) { return true; } if (trim.StartsWith("ÚLtimo guardado:") || trim.StartsWith("Hace ") || trim.StartsWith("Ahora mismo") || trim.StartsWith("Hace menos de")) { return true; } if (Enumerable.Contains(trim, '\n')) { int num = trim.Split(new char[1] { '\n' }).Length; bool flag = trim.Contains("<style=") || trim.Contains("<color=") || trim.Contains("<u>") || trim.Contains("<size=") || trim.Contains("<align=") || trim.Contains("<i>"); if (num >= 5 && !flag) { return true; } } return false; } } public static class ImageExtensions { public static readonly string[] Lista = new string[3] { ".png", ".jpg", ".jpeg" }; public static string BuscarArchivo(string carpeta, string nombreSinExt) { string[] lista = Lista; foreach (string text in lista) { string text2 = Path.Combine(carpeta, nombreSinExt + text); if (AssetPack.Existe(text2)) { return text2; } } int num = nombreSinExt.LastIndexOf('_'); if (num > 0) { string text3 = nombreSinExt.Substring(num + 1); if (text3.Length > 0 && text3.All(char.IsDigit)) { string text4 = nombreSinExt.Substring(0, num); string[] lista2 = Lista; foreach (string text5 in lista2) { string text6 = Path.Combine(carpeta, text4 + text5); if (AssetPack.Existe(text6)) { return text6; } } } } return null; } } public static class OfuscadorAssets { private static readonly byte[] Magic = new byte[4] { 84, 82, 78, 49 }; private static readonly byte[] Key = Encoding.ASCII.GetBytes("TurronishDoblaje_2026_Blix"); public static byte[] Desofuscar(byte[] datos) { if (datos == null || datos.Length < Magic.Length) { return datos; } for (int i = 0; i < Magic.Length; i++) { if (datos[i] != Magic[i]) { return datos; } } int num = datos.Length - Magic.Length; byte[] array = new byte[num]; for (int j = 0; j < num; j++) { array[j] = (byte)(datos[j + Magic.Length] ^ Key[j % Key.Length]); } return array; } } public class LogoRevealFailsafe : MonoBehaviour { public CanvasGroup cg; private float _t; private void Update() { if ((Object)(object)cg == (Object)null || cg.alpha >= 1f) { ((Behaviour)this).enabled = false; return; } _t += Time.unscaledDeltaTime; if (_t > 6f) { cg.alpha = 1f; ((Behaviour)this).enabled = false; } } } public static class AssetPack { private static readonly byte[] Magic = new byte[4] { 84, 80, 65, 75 }; internal const uint HDR_EXT_A = 1114401144u; internal const uint HDR_EXT_B = 1247901184u; private static readonly byte[] Key = Encoding.ASCII.GetBytes("TurronishDoblaje_2026_Blix"); private static string _root; private static bool _cargado; private static bool _flattened; private static readonly List<string> _packs = new List<string>(); private static readonly List<FileStream> _packStreams = new List<FileStream>(); private static readonly List<object> _packLocks = new List<object>(); private static readonly Dictionary<string, long[]> _index = new Dictionary<string, long[]>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> _dirsPack = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static byte[] _keyExp; public static bool Flattened => _flattened; private static void DesXor(byte[] buf, int len) { if (_keyExp == null) { _keyExp = new byte[Key.Length * 16]; for (int i = 0; i < _keyExp.Length; i++) { _keyExp[i] = Key[i % Key.Length]; } } int num = _keyExp.Length; int num2; for (int j = 0; j < len; j += num2) { num2 = num; if (j + num2 > len) { num2 = len - j; } for (int k = 0; k < num2; k++) { buf[j + k] ^= _keyExp[k]; } } } private static string Norm(string rel) { return rel.Replace('/', '\\').TrimStart(new char[1] { '\\' }); } public static void Init(string assetsRoot) { _root = assetsRoot; _cargado = false; _index.Clear(); _packs.Clear(); _dirsPack.Clear(); foreach (FileStream packStream in _packStreams) { try { packStream.Dispose(); } catch { } } _packStreams.Clear(); _packLocks.Clear(); string[] array = new string[3] { "assets.dat", "audio.dat", "turronish_img.dat" }; foreach (string path in array) { string text = Path.Combine(assetsRoot, path); if (File.Exists(text)) { CargarPack(text); } } _cargado = _index.Count > 0; _flattened = _cargado && !Directory.Exists(Path.Combine(assetsRoot, "VideoClips")); if (_cargado) { ControlDoblajePlugin.Log.LogInfo((object)($"[AssetPack] {_packs.Count} .dat cargado(s): {_index.Count} entradas" + (_flattened ? " · layout APLANADO (sueltos en raíz)" : ""))); } else { ControlDoblajePlugin.Log.LogInfo((object)"[AssetPack] sin .dat — archivos sueltos (disco)"); } } private static void CargarPack(string packPath) { try { int count = _packs.Count; using (FileStream input = File.OpenRead(packPath)) { using BinaryReader binaryReader = new BinaryReader(input); byte[] array = binaryReader.ReadBytes(4); for (int i = 0; i < 4; i++) { if (i >= array.Length || array[i] != Magic[i]) { ControlDoblajePlugin.Log.LogWarning((object)("[AssetPack] " + Path.GetFileName(packPath) + ": magic inválida — ignorado")); return; } } binaryReader.ReadInt32(); int num = binaryReader.ReadInt32(); for (int j = 0; j < num; j++) { int count2 = binaryReader.ReadInt16(); string rel = Encoding.UTF8.GetString(binaryReader.ReadBytes(count2)); long num2 = binaryReader.ReadInt64(); int num3 = binaryReader.ReadInt32(); string text = Norm(rel); _index[text] = new long[3] { count, num2, num3 }; int num4 = text.LastIndexOf('\\'); while (num4 > 0) { string text2 = text.Substring(0, num4); if (!_dirsPack.Add(text2)) { break; } num4 = text2.LastIndexOf('\\'); } } } _packs.Add(packPath); _packStreams.Add(new FileStream(packPath, FileMode.Open, FileAccess.Read, FileShare.Read)); _packLocks.Add(new object()); } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[AssetPack] error cargando " + Path.GetFileName(packPath) + ": " + ex.Message)); } } private static string Rel(string abs) { if (_root == null || abs == null || !abs.StartsWith(_root, StringComparison.OrdinalIgnoreCase)) { return null; } return Norm(abs.Substring(_root.Length)); } public static bool EstaEnPack(string abs) { if (!_cargado) { return false; } string text = Rel(abs); return text != null && _index.ContainsKey(text); } public static bool CarpetaExiste(string absFolder) { if (Directory.Exists(absFolder)) { return true; } if (!_cargado) { return false; } string text = Rel(absFolder); if (text == null) { return false; } return _dirsPack.Contains(text.TrimEnd(new char[1] { '\\' })); } private static string FlatPath(string abs) { if (!_flattened || _root == null || string.IsNullOrEmpty(abs)) { return null; } string text = Path.Combine(_root, Path.GetFileName(abs)); return string.Equals(text, abs, StringComparison.OrdinalIgnoreCase) ? null : text; } public static bool Existe(string abs) { if (EstaEnPack(abs) || File.Exists(abs)) { return true; } string text = FlatPath(abs); return text != null && File.Exists(text); } public static List<string> ListarArchivos(string absFolder, string ext) { List<string> list = new List<string>(); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if (Directory.Exists(absFolder)) { string[] files = Directory.GetFiles(absFolder, "*" + ext, SearchOption.TopDirectoryOnly); foreach (string text in files) { list.Add(text); hashSet.Add(Path.GetFileName(text)); } } if (_cargado) { string text2 = Rel(absFolder); if (text2 != null) { string text3 = text2.TrimEnd(new char[1] { '\\' }) + "\\"; foreach (string key in _index.Keys) { if (key.StartsWith(text3, StringComparison.OrdinalIgnoreCase) && key.EndsWith(ext, StringComparison.OrdinalIgnoreCase)) { string text4 = key.Substring(text3.Length); if (text4.IndexOf('\\') < 0 && !hashSet.Contains(text4)) { list.Add(Path.Combine(_root, key)); } } } } } return list; } public static byte[] LeerBytes(string abs) { if (_cargado) { string text = Rel(abs); if (text != null && _index.TryGetValue(text, out var value)) { try { int index = (int)value[0]; int num = (int)value[2]; byte[] array = new byte[num]; lock (_packLocks[index]) { FileStream fileStream = _packStreams[index]; fileStream.Seek(value[1], SeekOrigin.Begin); int num2; for (int i = 0; i < num; i += num2) { num2 = fileStream.Read(array, i, num - i); if (num2 <= 0) { break; } } } DesXor(array, num); return array; } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[AssetPack] error leyendo " + text + ": " + ex.Message)); } } } string path = abs; if (!File.Exists(path)) { string text2 = FlatPath(abs); if (text2 != null && File.Exists(text2)) { path = text2; } } return OfuscadorAssets.Desofuscar(File.ReadAllBytes(path)); } public static string LeerTexto(string abs) { return Encoding.UTF8.GetString(LeerBytes(abs)); } public static string[] LeerLineas(string abs) { if (!Existe(abs)) { return new string[0]; } string text = LeerTexto(abs); if (text.Length > 0 && text[0] == '\ufeff') { text = text.Substring(1); } return text.Replace("\r\n", "\n").Replace("\r", "\n").Split(new char[1] { '\n' }); } public static List<string> Listar(string absFolder, string[] exts, bool recurse) { HashSet<string> set = new HashSet<string>(StringComparer.OrdinalIgnoreCase); List<string> res = new List<string>(); try { if (Directory.Exists(absFolder)) { string[] files = Directory.GetFiles(absFolder, "*", recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); foreach (string f in files) { if (exts == null || Array.Exists(exts, (string x) => f.EndsWith(x, StringComparison.OrdinalIgnoreCase))) { Add(f); } } } } catch { } if (_cargado) { string text = Rel(absFolder); if (text != null) { text = text.TrimEnd(new char[1] { '\\' }) + "\\"; } if (text != null) { foreach (KeyValuePair<string, long[]> kv in _index) { if (kv.Key.StartsWith(text, StringComparison.OrdinalIgnoreCase) && (recurse || kv.Key.IndexOf('\\', text.Length) < 0) && (exts == null || Array.Exists(exts, (string x) => kv.Key.EndsWith(x, StringComparison.OrdinalIgnoreCase)))) { Add(Path.Combine(_root, kv.Key)); } } } } return res; void Add(string abs) { if (set.Add(abs)) { res.Add(abs); } } } public static List<string> ListarSubcarpetas(string absFolder) { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); List<string> list = new List<string>(); try { if (Directory.Exists(absFolder)) { string[] directories = Directory.GetDirectories(absFolder); foreach (string item in directories) { if (hashSet.Add(item))
BepInEx/plugins/TurronishAudio.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using FMOD; using FMOD.Studio; using FMODUnity; using HarmonyLib; using TurronishMod.Logger; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.SceneManagement; 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; internal static class ListenerCache { private static StudioListener _cache; public static StudioListener Get() { if ((Object)(object)_cache == (Object)null) { Object obj = Object.FindObjectOfType(typeof(StudioListener)); _cache = (StudioListener)(object)((obj is StudioListener) ? obj : null); } return _cache; } } internal static class AudioPack { public unsafe static RESULT CrearSound(System sys, string ruta, MODE modo, ref CREATESOUNDEXINFO ex, out Sound sound) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (AssetPack.EstaEnPack(ruta)) { try { byte[] array = AssetPack.LeerBytes(ruta); if (ex.cbsize == 0) { ex.cbsize = Marshal.SizeOf(typeof(CREATESOUNDEXINFO)); } ex.length = (uint)array.Length; MODE val = (MODE)(modo | 0x800); RESULT val2 = ((System)(ref sys)).createSound(array, val, ref ex, ref sound); if ((int)val2 == 0) { return val2; } ControlDoblajePlugin.Log.LogWarning((object)("[AudioPack] createSound memoria falló (" + ((object)(*(RESULT*)(&val2))/*cast due to .constrained prefix*/).ToString() + ") " + Path.GetFileName(ruta) + " — fallback disco")); } catch (Exception ex2) { ControlDoblajePlugin.Log.LogWarning((object)("[AudioPack] excepción memoria " + ex2.Message + " — fallback disco")); } } return ((System)(ref sys)).createSound(ruta, modo, ref ex, ref sound); } } [BepInPlugin("com.turronish.audio", "Turronish Audio", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TurronishAudioPlugin : BaseUnityPlugin { private void Awake() { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown ControlDoblajePlugin.InstalarAudioScanners = (Action)Delegate.Combine(ControlDoblajePlugin.InstalarAudioScanners, new Action(AudioNuclearScannerInstaller.Instalar)); ControlDoblajePlugin.PatchAudioExtra = (Action<Harmony>)Delegate.Combine(ControlDoblajePlugin.PatchAudioExtra, (Action<Harmony>)delegate(Harmony h) { FMODPatchInstaller.InstalarSiNoEsta(h); PhoneCallPatcher.TryInstalar(h); }); ControlDoblajePlugin.SceneLoadedAudio = (Action)Delegate.Combine(ControlDoblajePlugin.SceneLoadedAudio, (Action)delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if ((Object)(object)Object.FindObjectOfType<VideoTimescaleWatcher>() == (Object)null && (Object)(object)GameObject.Find("_VideoTimescaleWatcher") == (Object)null) { GameObject val2 = new GameObject("_VideoTimescaleWatcher"); Object.DontDestroyOnLoad((Object)(object)val2); val2.AddComponent<VideoTimescaleWatcher>(); } CinematicaMultiPistaPlayer.RefrescarCacheWAV(); CinematicaMultiPistaPlayer.CargarBanksTurronish(); WandererGestor.LimpiarInstancia(); WandererGestor.DesmuteearRadio(); HeadtombsGestor.LimpiarInstancia(); WandererCutscenePlayer.UltimoDisparo = -999f; WandererAttackPlayer.DetenerSiActivo(); ExtrasVideoDuckingManager.RestaurarSiNecesario(); if ((Object)(object)CinematicaMultiPistaPlayer.RunnerActivo != (Object)null) { ControlDoblajePlugin.Log.LogInfo((object)"[SceneLoad] Runner activo tras cambio escena — limpiando"); try { CinematicaMultiPistaPlayer.RunnerActivo.Detener(); } catch { } CinematicaMultiPistaPlayer.RunnerActivo = null; } if ((Object)(object)CinematicaMultiPistaPlayer.AmbienterRunnerActivo != (Object)null) { try { CinematicaMultiPistaPlayer.AmbienterRunnerActivo.Detener(); } catch { } CinematicaMultiPistaPlayer.AmbienterRunnerActivo = null; } CinematicaMultiPistaPlayer.LimpiarInstanciaFMOD(); FMODStopHelper.NPCVideoRegistrado = false; }); ControlDoblajePlugin.AplicarModelosCallback = AplicarModelos3DDespues; ControlDoblajePlugin.WandererRadioMute = (Action<bool>)Delegate.Combine(ControlDoblajePlugin.WandererRadioMute, (Action<bool>)delegate(bool mute) { if (mute) { WandererGestor.MutearRadio(); } else { WandererGestor.DesmuteearRadio(); } }); ControlDoblajePlugin.ModelosAplicar = ModelosGestor.AplicarEnEscena; ControlDoblajePlugin.ModelosRestaurar = ModelosGestor.RestaurarMeshesOriginales; ControlDoblajePlugin.VideoExtrasInicio = ExtrasVideoDuckingManager.Inicio; ControlDoblajePlugin.VideoExtrasFin = ExtrasVideoDuckingManager.Fin; ControlDoblajePlugin.SoundPlayRandom = TurronishSoundPlayer.PlayRandom; ControlDoblajePlugin.AudioObtenerPersonajesDeBank = TurronishBankLoader.ObtenerPersonajesDeBank; ControlDoblajePlugin.AudioForzarCargaBanks = TurronishBankLoader.LoadIfNeeded; Harmony val = new Harmony("com.turronish.audio"); int num = 0; int num2 = 0; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { val.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { ControlDoblajePlugin.Log.LogError((object)("[Audio] Patch FAILED '" + type.Name + "': " + ex.GetType().Name + " — " + ex.Message)); num2++; } } } ControlDoblajePlugin.Log.LogInfo((object)$"[Audio] PatchAllSafe: {num} ok, {num2} fallidos"); TurronishDiagLogger.Info("[Audio]", "TurronishAudio cargado OK."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Audio] TurronishAudio cargado."); } private static IEnumerator AplicarModelos3DDespues() { for (int i = 0; i < 8; i++) { yield return null; } ModelosGestor.AplicarEnEscena(); } } public static class AudioLogTracker { private static readonly HashSet<string> _vistos = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static void Registrar(string clipName, string goName = null) { if (string.IsNullOrEmpty(clipName)) { return; } if (!ControlDoblajePlugin.LogVerboso) { _vistos.Add(clipName); return; } string text = (string.IsNullOrEmpty(goName) ? clipName : (clipName + " [GO:" + goName + "]")); if (_vistos.Add(clipName)) { ControlDoblajePlugin.Log.LogInfo((object)("[AUDIO_NEW] " + text)); } } public static void RegistrarSiempre(string clipName, string goName = null) { if (!string.IsNullOrEmpty(clipName)) { Registrar(clipName, goName); if (ControlDoblajePlugin.LogVerboso) { string text = (string.IsNullOrEmpty(goName) ? clipName : (clipName + " [GO:" + goName + "]")); ControlDoblajePlugin.Log.LogInfo((object)("[AUDIO_PLAY] " + text)); } } } } public class AudioNuclearScanner : MonoBehaviour { private static readonly HashSet<string> _scannedClips = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> _scannedGOs = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private float _timer = 0f; private const float INTERVAL = 0.5f; private void Update() { if (!ControlDoblajePlugin.LogVerboso) { return; } _timer -= Time.unscaledDeltaTime; if (_timer > 0f) { return; } _timer = 0.5f; try { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); AudioSource[] array2 = array; foreach (AudioSource val in array2) { if ((Object)(object)val == (Object)null || !val.isPlaying || (Object)(object)val.clip == (Object)null) { continue; } string name = ((Object)val.clip).name; GameObject gameObject = ((Component)val).gameObject; string text = ((gameObject != null) ? ((Object)gameObject).name : null) ?? "?"; string item = name + "|" + text; if (_scannedGOs.Add(item)) { if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)$"[SCAN_NEW] clip={name} GO={text} loop={val.loop} vol={val.volume:F2} spatial={val.spatialBlend:F1}"); } } else if (ControlDoblajePlugin.LogVerboso && (name.IndexOf("wander", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("USB", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("LP", StringComparison.OrdinalIgnoreCase) >= 0)) { ControlDoblajePlugin.Log.LogInfo((object)("[SCAN_LOOP] clip=" + name + " GO=" + text)); } } } catch { } } public void ResetarGOs() { _scannedGOs.Clear(); } } public static class AudioNuclearScannerInstaller { private static GameObject _go; public static void Instalar() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)_go != (Object)null)) { _go = new GameObject("_AudioNuclearScanner"); Object.DontDestroyOnLoad((Object)(object)_go); _go.AddComponent<AudioNuclearScanner>(); ControlDoblajePlugin.Log.LogInfo((object)"[AUDIO] Scanner nuclear instalado."); } } } public static class FMODLogTracker { private static readonly HashSet<string> _vistos = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static void Log(string path, string via) { if (string.IsNullOrEmpty(path)) { return; } if (_vistos.Add(path)) { ControlDoblajePlugin.Log.LogInfo((object)("[FMOD_NEW] " + path)); if (ControlDoblajePlugin.LogVerboso) { LogBusDeEvento(path); } } if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[FMOD:" + via + "] " + path)); } } private static void LogBusDeEvento(string path) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) try { System studioSystem = RuntimeManager.StudioSystem; EventDescription val = default(EventDescription); EventInstance val2 = default(EventInstance); if ((int)((System)(ref studioSystem)).getEvent(path, ref val) > 0 || (int)((EventDescription)(ref val)).createInstance(ref val2) > 0) { return; } ChannelGroup val3 = default(ChannelGroup); if ((int)((EventInstance)(ref val2)).getChannelGroup(ref val3) == 0 && ((ChannelGroup)(ref val3)).hasHandle()) { string text = "?"; string[] array = new string[10] { "bus:/SFX", "bus:/SFX/Dialogue", "bus:/SFX/NPC", "bus:/Voice", "bus:/Voices", "bus:/NPCs", "bus:/Music", "bus:/Ambience", "bus:/UI", "bus:/" }; string[] array2 = array; Bus val4 = default(Bus); ChannelGroup val5 = default(ChannelGroup); foreach (string text2 in array2) { studioSystem = RuntimeManager.StudioSystem; if ((int)((System)(ref studioSystem)).getBus(text2, ref val4) == 0 && (int)((Bus)(ref val4)).getChannelGroup(ref val5) == 0 && ((ChannelGroup)(ref val5)).hasHandle() && val5.handle == val3.handle) { text = text2; break; } } ControlDoblajePlugin.Log.LogInfo((object)("[FMOD_BUS] " + path + " → " + text)); } ((EventInstance)(ref val2)).release(); } catch { } } public static void Registrar(string path) { Log(path, "?"); } } public class AudioSourcePlayPatch { private static void Prefix(AudioSource __instance) { if (!((Object)(object)((__instance != null) ? __instance.clip : null) == (Object)null)) { string name = ((Object)__instance.clip).name; GameObject gameObject = ((Component)__instance).gameObject; AudioLogTracker.RegistrarSiempre(name, (gameObject != null) ? ((Object)gameObject).name : null); } } } [HarmonyPatch(typeof(AudioSource), "PlayDelayed", new Type[] { typeof(float) })] public class AudioSourcePlayDelayedPatch { private static void Prefix(AudioSource __instance) { if (!((Object)(object)((__instance != null) ? __instance.clip : null) == (Object)null)) { string name = ((Object)__instance.clip).name; GameObject gameObject = ((Component)__instance).gameObject; AudioLogTracker.RegistrarSiempre(name, "delayed|" + ((gameObject != null) ? ((Object)gameObject).name : null)); } } } [HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })] public class AudioSourcePlayOneShotPatch { private static void Prefix(AudioSource __instance, AudioClip clip) { if (!((Object)(object)clip == (Object)null)) { string name = ((Object)clip).name; object goName; if (__instance == null) { goName = null; } else { GameObject gameObject = ((Component)__instance).gameObject; goName = ((gameObject != null) ? ((Object)gameObject).name : null); } AudioLogTracker.RegistrarSiempre(name, (string)goName); } } } [HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip), typeof(float) })] public class AudioSourcePlayOneShotVolPatch { private static void Prefix(AudioSource __instance, AudioClip clip) { if (!((Object)(object)clip == (Object)null)) { string name = ((Object)clip).name; object goName; if (__instance == null) { goName = null; } else { GameObject gameObject = ((Component)__instance).gameObject; goName = ((gameObject != null) ? ((Object)gameObject).name : null); } AudioLogTracker.RegistrarSiempre(name, (string)goName); } } } [HarmonyPatch(typeof(AudioSource), "PlayClipAtPoint", new Type[] { typeof(AudioClip), typeof(Vector3) })] public class AudioSourcePlayClipAtPointPatch { private static void Prefix(AudioClip clip, Vector3 position) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)clip == (Object)null)) { AudioLogTracker.RegistrarSiempre(((Object)clip).name, $"AtPoint:{position:F0}"); } } } [HarmonyPatch(typeof(AudioSource), "PlayClipAtPoint", new Type[] { typeof(AudioClip), typeof(Vector3), typeof(float) })] public class AudioSourcePlayClipAtPointVolPatch { private static void Prefix(AudioClip clip, Vector3 position) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)clip == (Object)null)) { AudioLogTracker.RegistrarSiempre(((Object)clip).name, $"AtPoint:{position:F0}"); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class AudioSourceClipSetterPatch { private static void Prefix(AudioSource __instance, AudioClip value) { if (!((Object)(object)value == (Object)null)) { string name = ((Object)value).name; object obj; if (__instance == null) { obj = null; } else { GameObject gameObject = ((Component)__instance).gameObject; obj = ((gameObject != null) ? ((Object)gameObject).name : null); } AudioLogTracker.Registrar(name, "clipset|" + (string?)obj); } } } public class VideoTimescaleWatcher : MonoBehaviour { private float _lastScale = 1f; private readonly HashSet<int> _pausadosPorNosotros = new HashSet<int>(); private VideoPlayer[] _vpCache = null; private float _cacheTimer = 0f; private const float CACHE_INTERVAL = 2f; private void Update() { float timeScale = Time.timeScale; bool flag = timeScale == 0f; bool flag2 = timeScale != _lastScale; _lastScale = timeScale; if (!flag && !flag2) { return; } _cacheTimer -= Time.unscaledDeltaTime; if (_vpCache == null || _cacheTimer <= 0f) { _vpCache = Object.FindObjectsOfType<VideoPlayer>(); _cacheTimer = 2f; } VideoPlayer[] vpCache = _vpCache; foreach (VideoPlayer val in vpCache) { if ((Object)(object)val == (Object)null) { continue; } if (flag) { if (val.isPlaying) { _pausadosPorNosotros.Add(((Object)val).GetInstanceID()); val.Pause(); } } else if (flag2) { int instanceID = ((Object)val).GetInstanceID(); if (val.isPaused && _pausadosPorNosotros.Contains(instanceID)) { _pausadosPorNosotros.Remove(instanceID); val.Play(); } } } if (!flag && flag2) { _pausadosPorNosotros.Clear(); } } } public static class CinematicaDuckingManager { public class DuckingSegmento { public uint FadeOutInicioMs; public uint SilencioDesdeMs; public uint RestoreDesdeMs; public uint RestoreFinMs; public bool Instantaneo; } public class DuckingConfig { public string WavPattern; public uint InicioMs; public uint FinMs; public float FadeDuckSec; public float FadeRestoreSec; public bool DuckearWanderers; public bool PreservarFX; public List<DuckingSegmento> Segmentos; } internal static readonly byte[] CurvaAtenuacion = new byte[16] { 0, 10, 20, 29, 51, 54, 39, 46, 21, 62, 41, 71, 92, 120, 158, 255 }; public static readonly List<DuckingConfig> Configs = new List<DuckingConfig> { new DuckingConfig { WavPattern = "VL_Mitu_1I_CS_Intro", InicioMs = 35170u, FinMs = 54890u, FadeDuckSec = 0.5f, FadeRestoreSec = 1.5f, DuckearWanderers = true, PreservarFX = false }, new DuckingConfig { WavPattern = "TaskiMaiden_01", InicioMs = 34450u, FinMs = 45000u, FadeDuckSec = 0.5f, FadeRestoreSec = 0.8f, DuckearWanderers = true, PreservarFX = true }, new DuckingConfig { WavPattern = "VL_VendingMachine_1I_CS_Intro", DuckearWanderers = true, PreservarFX = false, Segmentos = new List<DuckingSegmento> { new DuckingSegmento { FadeOutInicioMs = 22470u, SilencioDesdeMs = 23550u, RestoreDesdeMs = 27070u, RestoreFinMs = 27410u, Instantaneo = false }, new DuckingSegmento { FadeOutInicioMs = 28170u, SilencioDesdeMs = 28170u, RestoreDesdeMs = 32000u, RestoreFinMs = 35000u, Instantaneo = true } } } }; public static float WandererDuckFactor = 1f; private static DuckingConfig _cfgActiva = null; private static float _nivelDuck = 1f; private static bool _resetPendiente = false; private static readonly Dictionary<string, float> _volsCapturados = new Dictionary<string, float>(); public static void Tick(string wavFileName, uint posMs) { DuckingConfig duckingConfig = null; foreach (DuckingConfig config in Configs) { if (wavFileName.IndexOf(config.WavPattern, StringComparison.OrdinalIgnoreCase) >= 0) { duckingConfig = config; break; } } if (duckingConfig == null) { return; } if (_cfgActiva == null) { CapturarVolumenes(duckingConfig); } _cfgActiva = duckingConfig; _resetPendiente = true; float num; float num2; if (duckingConfig.Segmentos != null && duckingConfig.Segmentos.Count > 0) { num = 1f; num2 = 5f; foreach (DuckingSegmento segmento in duckingConfig.Segmentos) { if (posMs >= segmento.FadeOutInicioMs) { if (posMs < segmento.SilencioDesdeMs) { num = 0f; float num3 = (float)(segmento.SilencioDesdeMs - segmento.FadeOutInicioMs) / 1000f; num2 = (segmento.Instantaneo ? 100f : ((num3 > 0.01f) ? (1f / num3) : 100f)); break; } if (posMs < segmento.RestoreDesdeMs) { num = 0f; num2 = 100f; break; } if (posMs < segmento.RestoreFinMs) { num = 1f; float num4 = (float)(segmento.RestoreFinMs - segmento.RestoreDesdeMs) / 1000f; num2 = ((num4 > 0.01f) ? (1f / num4) : 100f); break; } } } } else { bool flag = posMs >= duckingConfig.InicioMs && posMs < duckingConfig.FinMs; num = (flag ? 0f : 1f); num2 = (flag ? (1f / duckingConfig.FadeDuckSec) : (1f / duckingConfig.FadeRestoreSec)); } float num5 = Mathf.MoveTowards(_nivelDuck, num, num2 * Time.unscaledDeltaTime); if (!Mathf.Approximately(num5, _nivelDuck)) { _nivelDuck = num5; AplicarBuses(duckingConfig, _nivelDuck); WandererDuckFactor = (duckingConfig.DuckearWanderers ? _nivelDuck : 1f); } } public static void Reset() { if (_resetPendiente || !(_nivelDuck >= 1f)) { _resetPendiente = false; _nivelDuck = 1f; WandererDuckFactor = 1f; if (_cfgActiva != null) { AplicarBuses(_cfgActiva, 1f); _cfgActiva = null; } _volsCapturados.Clear(); } } private static void CapturarVolumenes(DuckingConfig cfg) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) _volsCapturados.Clear(); string[] array = ObtenerBuses(cfg); Bus val = default(Bus); foreach (string text in array) { float value = 1f; try { System studioSystem = RuntimeManager.StudioSystem; if ((int)((System)(ref studioSystem)).getBus(text, ref val) == 0) { ((Bus)(ref val)).getVolume(ref value); } } catch { } _volsCapturados[text] = value; } } private static string[] ObtenerBuses(DuckingConfig cfg) { if (cfg.PreservarFX) { return new string[2] { "bus:/Music", "bus:/SFX/Music" }; } return new string[6] { "bus:/Music", "bus:/Ambience", "bus:/SFX/Ambience", "bus:/SFX/Music", "bus:/SFX", "bus:/FX" }; } private static void AplicarBuses(DuckingConfig cfg, float duckFactor) { string[] array = ObtenerBuses(cfg); foreach (string busPath in array) { SetBusVol(busPath, duckFactor); } } private static void SetBusVol(string busPath, float duckFactor) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!_volsCapturados.TryGetValue(busPath, out var value)) { value = 1f; } try { System studioSystem = RuntimeManager.StudioSystem; Bus val = default(Bus); if ((int)((System)(ref studioSystem)).getBus(busPath, ref val) == 0) { ((Bus)(ref val)).setVolume(value * duckFactor); } } catch { } } } public class WandererGestor : MonoBehaviour { private static WandererGestor _instancia = null; private readonly HashSet<int> _yaReemplazados = new HashSet<int>(); private int _frame = 0; private static readonly Dictionary<int, uint> _posicionGuardada = new Dictionary<int, uint>(); private static readonly Dictionary<int, uint> _posNativoTakeover = new Dictionary<int, uint>(); private static readonly Dictionary<int, float> _tiempoTakeover = new Dictionary<int, float>(); private static readonly List<(Sound s, Channel c)> _todosLosCanales = new List<(Sound, Channel)>(); private static bool _muteado = false; public static readonly HashSet<int> _nativosDetenidos = new HashSet<int>(); public static string BuscarWAV(string pathSinExt) { string text = pathSinExt + "_es.wav"; if (AssetPack.Existe(text)) { return text; } string text2 = pathSinExt + "_es.ogg"; if (AssetPack.Existe(text2)) { return text2; } string text3 = pathSinExt + ".wav"; if (AssetPack.Existe(text3)) { return text3; } string text4 = pathSinExt + ".ogg"; if (AssetPack.Existe(text4)) { return text4; } return null; } internal static bool PosicionNatural(int emitterId, out uint posMs) { posMs = 0u; if (!_posNativoTakeover.TryGetValue(emitterId, out var value) || !_tiempoTakeover.TryGetValue(emitterId, out var value2)) { return false; } posMs = value + (uint)((Time.realtimeSinceStartup - value2) * 1000f); return true; } public static void MutearRadio() { _muteado = true; if ((Object)(object)_instancia != (Object)null) { _instancia.RestaurarEmittersAhora(); } } public static void DesmuteearRadio() { _muteado = false; } public void RestaurarEmittersAhora() { StudioEventEmitter[] array = Object.FindObjectsOfType<StudioEventEmitter>(); foreach (StudioEventEmitter val in array) { if (!((Object)(object)val == (Object)null) && !(((Object)((Component)val).gameObject).name != "FMOD Emitter - Wanderer")) { ReanudarEmitterNativo(val); } } } public unsafe static void ReanudarEmitterNativo(StudioEventEmitter em) { //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Invalid comparison between Unknown and I4 //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Invalid comparison between Unknown and I4 //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_006d: Invalid comparison between Unknown and I4 //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Invalid comparison between Unknown and I4 //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Invalid comparison between Unknown and I4 //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Invalid comparison between Unknown and I4 //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0381: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)em == (Object)null) { return; } try { bool flag = false; FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EventInstance val = (EventInstance)field.GetValue(em); PLAYBACK_STATE val2 = default(PLAYBACK_STATE); if (((EventInstance)(ref val)).isValid() && (int)((EventInstance)(ref val)).getPlaybackState(ref val2) == 0 && (int)val2 != 2 && (int)val2 != 4) { flag = true; ((EventInstance)(ref val)).setPaused(false); ((EventInstance)(ref val)).setVolume(1f); if (_nativosDetenidos.Contains(((Object)em).GetInstanceID())) { try { if (!_posicionGuardada.TryGetValue(((Object)em).GetInstanceID(), out var value) || value == 0) { PosicionNatural(((Object)em).GetInstanceID(), out value); } EventDescription val3 = default(EventDescription); int num = default(int); if (value != 0 && (int)((EventInstance)(ref val)).getDescription(ref val3) == 0 && ((EventDescription)(ref val3)).isValid() && (int)((EventDescription)(ref val3)).getLength(ref num) == 0 && num > 500) { ((EventInstance)(ref val)).setTimelinePosition((int)(value % (uint)num)); } } catch { } _nativosDetenidos.Remove(((Object)em).GetInstanceID()); ControlDoblajePlugin.Log.LogInfo((object)("[WandererGestor] Nativo despertado (unpause): " + ((Object)((Component)em).gameObject).name)); } } } if (flag) { return; } bool flag2 = false; RESULT val4 = (RESULT)30; if (field != null) { try { EventInstance val5 = (EventInstance)field.GetValue(em); if (((EventInstance)(ref val5)).isValid()) { ((EventInstance)(ref val5)).setVolume(1f); val4 = ((EventInstance)(ref val5)).start(); PLAYBACK_STATE val6 = default(PLAYBACK_STATE); if ((int)val4 == 0 && (int)((EventInstance)(ref val5)).getPlaybackState(ref val6) == 0 && (int)val6 != 2 && (int)val6 != 4) { flag2 = true; } } } catch { } } if (!flag2) { try { try { em.Stop(); } catch { } FieldInfo field2 = typeof(StudioEventEmitter).GetField("hasTriggered", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(em, false); } em.Play(); if (field != null) { EventInstance val7 = (EventInstance)field.GetValue(em); PLAYBACK_STATE val8 = default(PLAYBACK_STATE); if (((EventInstance)(ref val7)).isValid() && (int)((EventInstance)(ref val7)).getPlaybackState(ref val8) == 0 && (int)val8 != 2 && (int)val8 != 4) { flag2 = true; } } } catch { } } if (!flag2) { ControlDoblajePlugin.Log.LogWarning((object)("[WandererGestor] Relanzamiento FALLÓ (" + ((Object)((Component)em).gameObject).name + ") start=" + ((object)(*(RESULT*)(&val4))/*cast due to .constrained prefix*/).ToString() + " — reintentará")); } else { if (!flag2) { return; } try { if (_posicionGuardada.TryGetValue(((Object)em).GetInstanceID(), out var value2) && value2 != 0 && field != null) { EventInstance val9 = (EventInstance)field.GetValue(em); if (((EventInstance)(ref val9)).isValid()) { int num2 = 0; bool flag3 = false; try { EventDescription val10 = default(EventDescription); flag3 = (int)((EventInstance)(ref val9)).getDescription(ref val10) == 0 && ((EventDescription)(ref val10)).isValid() && (int)((EventDescription)(ref val10)).getLength(ref num2) == 0 && num2 > 500; } catch { } if (flag3) { ((EventInstance)(ref val9)).setTimelinePosition((int)(value2 % (uint)num2)); PLAYBACK_STATE val11 = default(PLAYBACK_STATE); if ((int)((EventInstance)(ref val9)).getPlaybackState(ref val11) == 0 && ((int)val11 == 2 || (int)val11 == 4)) { ControlDoblajePlugin.Log.LogWarning((object)"[WandererGestor] seek de continuidad mató el evento — reviviendo SIN seek"); ((EventInstance)(ref val9)).start(); } } } } } catch { } _nativosDetenidos.Remove(((Object)em).GetInstanceID()); ControlDoblajePlugin.Log.LogInfo((object)("[WandererGestor] Nativo relanzado: " + ((Object)((Component)em).gameObject).name)); } } catch { } } public static bool NativoDetenido(int id) { return _nativosDetenidos.Contains(id); } public static void InyectarSiNecesario() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instancia != (Object)null)) { GameObject val = new GameObject("_WandererGestor"); Object.DontDestroyOnLoad((Object)(object)val); _instancia = val.AddComponent<WandererGestor>(); ControlDoblajePlugin.Log.LogInfo((object)"[WandererGestor] Inyectado correctamente."); } } private static void SilenciarEmitter(StudioEventEmitter emitter) { //IL_0039: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (_muteado) { return; } try { FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field == null)) { EventInstance val = (EventInstance)field.GetValue(emitter); if (((EventInstance)(ref val)).isValid()) { ((EventInstance)(ref val)).setVolume(0f); ((EventInstance)(ref val)).setPaused(true); _nativosDetenidos.Add(((Object)emitter).GetInstanceID()); } } } catch { } } private void Update() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) if (++_frame % 15 != 0) { return; } WandererAttackSoundRunner runnerActivo = WandererAttackPlayer.RunnerActivo; if ((Object)(object)runnerActivo != (Object)null && runnerActivo.IsListo) { try { StudioListener val = ListenerCache.Get(); Vector3 posListener = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero)); runnerActivo.ActualizarVolumen(posListener); } catch { } } StudioEventEmitter[] array = Object.FindObjectsOfType<StudioEventEmitter>(); int num = default(int); foreach (StudioEventEmitter val2 in array) { if ((Object)(object)val2 == (Object)null || ((Object)((Component)val2).gameObject).name != "FMOD Emitter - Wanderer") { continue; } int instanceID = ((Object)val2).GetInstanceID(); bool flag = val2.IsPlaying(); if (!ControlDoblajePlugin.PersonajeActivo.TryGetValue("Wanderer", out var value) || !value) { if (_muteado) { ReanudarEmitterNativo(val2); continue; } if (!flag && NativoDetenido(instanceID)) { ReanudarEmitterNativo(val2); } _yaReemplazados.Remove(instanceID); continue; } if (_yaReemplazados.Contains(instanceID)) { if (flag) { SilenciarEmitter(val2); } continue; } if (!flag) { if (NativoDetenido(instanceID)) { ReanudarEmitterNativo(val2); } continue; } string path = Path.Combine(ControlDoblajePlugin.VoicesPath, "Wanderer"); string text = BuscarWAV(Path.Combine(path, "USB_LP_Wanderer_RadioDry")); string text2 = BuscarWAV(Path.Combine(path, "USB_LP_Wanderer_RadioWet")); if (text == null && text2 == null) { continue; } _yaReemplazados.Add(instanceID); try { FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EventInstance val3 = (EventInstance)field.GetValue(val2); if (((EventInstance)(ref val3)).isValid() && (int)((EventInstance)(ref val3)).getTimelinePosition(ref num) == 0 && num > 0) { _posicionGuardada[instanceID] = (uint)num; if (!_posNativoTakeover.ContainsKey(instanceID)) { _posNativoTakeover[instanceID] = (uint)num; _tiempoTakeover[instanceID] = Time.realtimeSinceStartup; } } } } catch { } SilenciarEmitter(val2); ManualLogSource log = ControlDoblajePlugin.Log; string name = ((Object)((Component)val2).gameObject).name; Transform parent = ((Component)val2).transform.parent; log.LogInfo((object)("[WandererRadio] Emitter detectado playing: " + name + " parent=" + ((parent != null) ? ((Object)parent).name : null))); ((MonoBehaviour)this).StartCoroutine(RadioLoop(val2, text, text2)); } } private unsafe IEnumerator RadioLoop(StudioEventEmitter emitter, string rutaDryR, string rutaWetR) { bool tieneDry = rutaDryR != null; bool tieneWet = rutaWetR != null; ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] Iniciando loop para " + ((Object)((Component)emitter).gameObject).name)); Sound sDry = default(Sound); Sound sWet = default(Sound); Channel cDry = default(Channel); Channel cWet = default(Channel); MODE modo = (MODE)524434; System coreSystem = RuntimeManager.CoreSystem; ChannelGroup grupo = default(ChannelGroup); ((System)(ref coreSystem)).getMasterChannelGroup(ref grupo); ControlDoblajePlugin.Log.LogInfo((object)"[WandererRadio] Bus=CoreMaster (stable root)"); if (tieneDry) { CREATESOUNDEXINFO ex = default(CREATESOUNDEXINFO); ex.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(ex); RESULT r = AudioPack.CrearSound(RuntimeManager.CoreSystem, rutaDryR, modo, ref ex, out sDry); ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] createSound Dry=" + ((object)(*(RESULT*)(&r))/*cast due to .constrained prefix*/).ToString())); if ((int)r == 0) { coreSystem = RuntimeManager.CoreSystem; ((System)(ref coreSystem)).playSound(sDry, grupo, false, ref cDry); ((Channel)(ref cDry)).setVolume(0f); ((Channel)(ref cDry)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sDry, cDry)); int emId2 = ((Object)emitter).GetInstanceID(); bool posRestaurada = false; if (!_posicionGuardada.TryGetValue(emId2, out var posSaved) || posSaved == 0) { PosicionNatural(emId2, out posSaved); } if (posSaved != 0) { try { uint lenD = 0u; ((Sound)(ref sDry)).getLength(ref lenD, (TIMEUNIT)1); uint posSeed = ((lenD > 500) ? (posSaved % lenD) : posSaved); ((Channel)(ref cDry)).setPosition(posSeed, (TIMEUNIT)1); posRestaurada = true; } catch { } } if (!posRestaurada) { try { FieldInfo fi = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { EventInstance inst = (EventInstance)fi.GetValue(emitter); if (((EventInstance)(ref inst)).isValid()) { int posMs = 0; ((EventInstance)(ref inst)).getTimelinePosition(ref posMs); if (posMs > 0) { ((Channel)(ref cDry)).setPosition((uint)posMs, (TIMEUNIT)1); } } } } catch { } } } else { tieneDry = false; } } if (tieneWet) { CREATESOUNDEXINFO ex2 = default(CREATESOUNDEXINFO); ex2.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(ex2); RESULT r2 = AudioPack.CrearSound(RuntimeManager.CoreSystem, rutaWetR, modo, ref ex2, out sWet); ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] createSound Wet=" + ((object)(*(RESULT*)(&r2))/*cast due to .constrained prefix*/).ToString())); if ((int)r2 == 0) { coreSystem = RuntimeManager.CoreSystem; ((System)(ref coreSystem)).playSound(sWet, grupo, false, ref cWet); ((Channel)(ref cWet)).setVolume(0f); ((Channel)(ref cWet)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sWet, cWet)); try { if (tieneDry) { uint posDry = 0u; ((Channel)(ref cDry)).getPosition(ref posDry, (TIMEUNIT)1); if (posDry != 0) { ((Channel)(ref cWet)).setPosition(posDry, (TIMEUNIT)1); } } } catch { } } else { tieneWet = false; } } if (!tieneDry && !tieneWet) { _yaReemplazados.Remove(((Object)emitter).GetInstanceID()); yield break; } ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] Loop activo dry=" + tieneDry + " wet=" + tieneWet)); try { uint lenD9 = 0u; if (tieneDry) { ((Sound)(ref sDry)).getLength(ref lenD9, (TIMEUNIT)1); } else if (tieneWet) { ((Sound)(ref sWet)).getLength(ref lenD9, (TIMEUNIT)1); } int lenN9 = 0; FieldInfo fi9 = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (fi9 != null) { EventInstance i9 = (EventInstance)fi9.GetValue(emitter); EventDescription d9 = default(EventDescription); if (((EventInstance)(ref i9)).isValid() && (int)((EventInstance)(ref i9)).getDescription(ref d9) == 0 && ((EventDescription)(ref d9)).isValid()) { ((EventDescription)(ref d9)).getLength(ref lenN9); } } ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio-DIAG] lenDub=" + lenD9 + "ms lenEventoNativo=" + lenN9 + "ms")); } catch { } bool estabaPausado = false; bool muteAnterior = _muteado; int tick = 0; float rampElapsed = 0f; int posNms = default(int); uint pd = default(uint); uint pw = default(uint); while ((Object)(object)emitter != (Object)null && ((Component)emitter).gameObject.activeInHierarchy && _yaReemplazados.Contains(((Object)emitter).GetInstanceID())) { SilenciarEmitter(emitter); bool pausar = Time.timeScale == 0f; if (pausar != estabaPausado) { if (tieneDry) { ((Channel)(ref cDry)).setPaused(pausar); } if (tieneWet) { ((Channel)(ref cWet)).setPaused(pausar); } estabaPausado = pausar; } if (muteAnterior && !_muteado) { try { uint posNat = 0u; bool anclado = false; FieldInfo fiN = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (fiN != null) { EventInstance instN = (EventInstance)fiN.GetValue(emitter); if (((EventInstance)(ref instN)).isValid() && (int)((EventInstance)(ref instN)).getTimelinePosition(ref posNms) == 0 && posNms > 0) { posNat = (uint)posNms; anclado = true; } } if (!anclado) { PosicionNatural(((Object)emitter).GetInstanceID(), out posNat); } if (posNat != 0) { uint lenRef = 0u; if (tieneDry) { ((Sound)(ref sDry)).getLength(ref lenRef, (TIMEUNIT)1); } else if (tieneWet) { ((Sound)(ref sWet)).getLength(ref lenRef, (TIMEUNIT)1); } uint dest = ((lenRef > 500) ? (posNat % lenRef) : posNat); if (tieneDry) { ((Channel)(ref cDry)).setPosition(dest, (TIMEUNIT)1); } if (tieneWet) { ((Channel)(ref cWet)).setPosition(dest, (TIMEUNIT)1); } _posicionGuardada[((Object)emitter).GetInstanceID()] = dest; ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] Dub anclado al handoff: " + dest + "ms (fuente=" + (anclado ? "nativo" : "reloj") + ")")); } } catch { } rampElapsed = 0f; } muteAnterior = _muteado; if (!pausar) { rampElapsed += 0.1f; float rampFactor = ((rampElapsed < 1f) ? Mathf.SmoothStep(0f, 1f, rampElapsed / 1f) : 1f); Vector3 posEm = ((Component)emitter).transform.position; VECTOR pos3D = new VECTOR { x = posEm.x, y = posEm.y, z = posEm.z }; VECTOR vel3D = new VECTOR { x = 0f, y = 0f, z = 0f }; if (tieneDry) { ((Channel)(ref cDry)).set3DAttributes(ref pos3D, ref vel3D); } if (tieneWet) { ((Channel)(ref cWet)).set3DAttributes(ref pos3D, ref vel3D); } StudioListener listener2 = ListenerCache.Get(); Vector3 posL = (((Object)(object)listener2 != (Object)null) ? ((Component)listener2).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : posEm)); float dist = Vector3.Distance(posL, posEm); float wetT = Mathf.Clamp01((dist - 5f) / 25f); float falloff = Mathf.Clamp01(5f / Mathf.Max(dist, 0.1f)); if (falloff > 0.05f && dist > 1f) { try { Vector3 rayOrig = posL + Vector3.up * 0.5f; Vector3 val = posEm - rayOrig; Vector3 rayDir = ((Vector3)(ref val)).normalized; float rayDist = Mathf.Max(dist - 0.5f, 0.1f); RaycastHit[] hits = Physics.RaycastAll(rayOrig, rayDir, rayDist); int solidWalls = 0; RaycastHit[] array = hits; for (int j = 0; j < array.Length; j++) { RaycastHit h = array[j]; if (!((Object)(object)((RaycastHit)(ref h)).collider == (Object)null) && !((RaycastHit)(ref h)).collider.isTrigger) { Bounds bounds = ((RaycastHit)(ref h)).collider.bounds; float maxSize = Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z }); if (maxSize > 1f) { solidWalls++; } } } if (solidWalls > 0) { falloff *= Mathf.Pow(0.5f, (float)solidWalls); } } catch { } } float busRadio = MultiPistaRunner.LeerVolBus("bus:/Ambience") * MultiPistaRunner.LeerVolBus("bus:/"); float comp = (_muteado ? 0f : (busRadio * CinematicaDuckingManager.WandererDuckFactor)); if (dist > 45f) { falloff *= Mathf.Clamp01((55f - dist) / 10f); } float volDry = (tieneDry ? (falloff * (1f - wetT) * comp * rampFactor) : 0f); float volWet = (tieneWet ? (falloff * wetT * comp * rampFactor) : 0f); if (tieneDry) { ((Channel)(ref cDry)).setVolume(volDry * 2.4f); } if (tieneWet) { ((Channel)(ref cWet)).setVolume(volWet * 2.4f); } if (tieneDry) { try { if ((int)((Channel)(ref cDry)).getPosition(ref pd, (TIMEUNIT)1) == 0 && pd != 0) { _posicionGuardada[((Object)emitter).GetInstanceID()] = pd; if (tieneWet && tick % 10 == 0 && (int)((Channel)(ref cWet)).getPosition(ref pw, (TIMEUNIT)1) == 0) { long drift = (long)pd - (long)pw; if (drift < 0) { drift = -drift; } if (drift > 60) { ((Channel)(ref cWet)).setPosition(pd, (TIMEUNIT)1); } } } } catch { } } if (tick % 30 == 0) { bool ipD = false; bool ipW = false; float audD = -1f; float audW = -1f; try { if (tieneDry) { ((Channel)(ref cDry)).isPlaying(ref ipD); ((Channel)(ref cDry)).getAudibility(ref audD); } } catch { } try { if (tieneWet) { ((Channel)(ref cWet)).isPlaying(ref ipW); ((Channel)(ref cWet)).getAudibility(ref audW); } } catch { } ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio-DIAG] dist=" + dist.ToString("F1") + " wetT=" + wetT.ToString("F2") + " volDry=" + volDry.ToString("F2") + " volWet=" + volWet.ToString("F2") + " bus=" + busRadio.ToString("F2") + " duck=" + CinematicaDuckingManager.WandererDuckFactor.ToString("F2") + " mute=" + _muteado + " dry[play=" + ipD + " aud=" + audD.ToString("F2") + "] wet[play=" + ipW + " aud=" + audW.ToString("F2") + "]")); if ((tieneDry || tieneWet) && !ipD && !ipW) { ControlDoblajePlugin.Log.LogWarning((object)"[WandererRadio] canales muertos — reiniciando takeover"); _yaReemplazados.Remove(((Object)emitter).GetInstanceID()); break; } } } tick++; yield return (object)new WaitForSecondsRealtime(0.1f); } ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] Loop terminado " + (((Object)(object)emitter != (Object)null) ? ((Object)((Component)emitter).gameObject).name : "null"))); if ((Object)(object)emitter != (Object)null) { int emId3 = ((Object)emitter).GetInstanceID(); try { uint posMs2 = 0u; if (tieneDry) { ((Channel)(ref cDry)).getPosition(ref posMs2, (TIMEUNIT)1); } if (posMs2 != 0) { _posicionGuardada[emId3] = posMs2; } } catch { } } _yaReemplazados.Remove(((Object)(object)emitter != (Object)null) ? ((Object)emitter).GetInstanceID() : (-1)); for (int _ci = _todosLosCanales.Count - 1; _ci >= 0; _ci--) { (Sound s, Channel c) e = _todosLosCanales[_ci]; if ((tieneDry && e.s.handle == sDry.handle) || (tieneWet && e.s.handle == sWet.handle)) { _todosLosCanales.RemoveAt(_ci); } } try { if (tieneDry) { ((Channel)(ref cDry)).stop(); ((Sound)(ref sDry)).release(); } } catch { } try { if (tieneWet) { ((Channel)(ref cWet)).stop(); ((Sound)(ref sWet)).release(); } } catch { } if ((Object)(object)emitter != (Object)null) { ReanudarEmitterNativo(emitter); ControlDoblajePlugin.Log.LogInfo((object)"[WandererRadio] Emitter nativo reanudado (vol 1 / re-Play)"); } } public static void LimpiarInstancia() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instancia == (Object)null) { return; } foreach (var todosLosCanale in _todosLosCanales) { var (val, val2) = todosLosCanale; try { ((Channel)(ref val2)).stop(); } catch { } try { ((Sound)(ref val)).release(); } catch { } } _todosLosCanales.Clear(); ((MonoBehaviour)_instancia).StopAllCoroutines(); _instancia._yaReemplazados.Clear(); } private void OnDestroy() { if ((Object)(object)_instancia == (Object)(object)this) { _instancia = null; } } } public class HeadtombsGestor : MonoBehaviour { private static HeadtombsGestor _instancia = null; private readonly HashSet<int> _yaReemplazados = new HashSet<int>(); private int _frame = 0; private static readonly List<(Sound s, Channel c)> _todosLosCanales = new List<(Sound, Channel)>(); private const string EMITTER_GO_NAME = "GR1_L_HeadtombRamble"; private const string WAV_CARPETA = "HeadTombs"; private const string WAV_NOMBRE = "D1G_Headtombs_Mumble.wav"; private const string PERSONAJE_KEY = "HeadTombs"; private const float MIN_DIST = 12.25f; private const float MAX_DIST = 24.84f; public static void InyectarSiNecesario() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_instancia != (Object)null)) { GameObject val = new GameObject("_HeadtombsGestor"); Object.DontDestroyOnLoad((Object)(object)val); _instancia = val.AddComponent<HeadtombsGestor>(); ControlDoblajePlugin.Log.LogInfo((object)"[HeadtombsGestor] Inyectado."); } } public static void LimpiarInstancia() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instancia == (Object)null) { return; } foreach (var todosLosCanale in _todosLosCanales) { var (val, val2) = todosLosCanale; try { ((Channel)(ref val2)).stop(); } catch { } try { ((Sound)(ref val)).release(); } catch { } } _todosLosCanales.Clear(); ((MonoBehaviour)_instancia).StopAllCoroutines(); _instancia._yaReemplazados.Clear(); } private static void SilenciarEmitter(StudioEventEmitter emitter) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field == null)) { EventInstance val = (EventInstance)field.GetValue(emitter); if (((EventInstance)(ref val)).isValid()) { ((EventInstance)(ref val)).setVolume(0f); ((EventInstance)(ref val)).setPaused(true); WandererGestor._nativosDetenidos.Add(((Object)emitter).GetInstanceID()); } } } catch { } } private void Update() { if (++_frame % 15 != 0) { return; } StudioEventEmitter[] array = Object.FindObjectsOfType<StudioEventEmitter>(); foreach (StudioEventEmitter val in array) { if ((Object)(object)val == (Object)null || !((Object)((Component)val).gameObject).name.EndsWith("GR1_L_HeadtombRamble", StringComparison.OrdinalIgnoreCase)) { continue; } int instanceID = ((Object)val).GetInstanceID(); bool flag = val.IsPlaying(); if (!ControlDoblajePlugin.PersonajeActivo.TryGetValue("HeadTombs", out var value) || !value) { if (!flag && WandererGestor.NativoDetenido(instanceID)) { WandererGestor.ReanudarEmitterNativo(val); } _yaReemplazados.Remove(instanceID); continue; } if (_yaReemplazados.Contains(instanceID)) { if (flag) { SilenciarEmitter(val); } continue; } if (!flag) { if (WandererGestor.NativoDetenido(instanceID)) { WandererGestor.ReanudarEmitterNativo(val); } continue; } string text = WandererGestor.BuscarWAV(Path.Combine(ControlDoblajePlugin.VoicesPath, "HeadTombs", Path.GetFileNameWithoutExtension("D1G_Headtombs_Mumble.wav"))); if (text != null) { _yaReemplazados.Add(instanceID); SilenciarEmitter(val); ManualLogSource log = ControlDoblajePlugin.Log; string name = ((Object)((Component)val).gameObject).name; Transform parent = ((Component)val).transform.parent; log.LogInfo((object)("[HeadtombsGestor] Emitter detectado: " + name + " parent=" + ((parent != null) ? ((Object)parent).name : null))); ((MonoBehaviour)this).StartCoroutine(MumbleLoop(val, text)); } } } private unsafe IEnumerator MumbleLoop(StudioEventEmitter emitter, string wavPath) { ControlDoblajePlugin.Log.LogInfo((object)("[HeadtombsGestor] Iniciando loop: " + wavPath)); System coreSystem = RuntimeManager.CoreSystem; ChannelGroup grupo = default(ChannelGroup); ((System)(ref coreSystem)).getMasterChannelGroup(ref grupo); ControlDoblajePlugin.Log.LogInfo((object)"[HeadtombsGestor] Bus=CoreMaster (stable root)"); MODE modo = (MODE)524562; CREATESOUNDEXINFO ex = default(CREATESOUNDEXINFO); ex.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(ex); Sound sound; RESULT r = AudioPack.CrearSound(RuntimeManager.CoreSystem, wavPath, modo, ref ex, out sound); ControlDoblajePlugin.Log.LogInfo((object)("[HeadtombsGestor] createSound=" + ((object)(*(RESULT*)(&r))/*cast due to .constrained prefix*/).ToString())); if ((int)r > 0) { _yaReemplazados.Remove(((Object)emitter).GetInstanceID()); yield break; } coreSystem = RuntimeManager.CoreSystem; Channel canal = default(Channel); ((System)(ref coreSystem)).playSound(sound, grupo, false, ref canal); ((Channel)(ref canal)).setVolume(0f); ((Channel)(ref canal)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sound, canal)); try { FieldInfo fi = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { EventInstance inst = (EventInstance)fi.GetValue(emitter); if (((EventInstance)(ref inst)).isValid()) { int posMs = 0; ((EventInstance)(ref inst)).getTimelinePosition(ref posMs); if (posMs > 0) { ((Channel)(ref canal)).setPosition((uint)posMs, (TIMEUNIT)1); } } } } catch { } ControlDoblajePlugin.Log.LogInfo((object)"[HeadtombsGestor] Loop activo"); bool estabaPausado = false; int tick = 0; float rampElapsed = 0f; while ((Object)(object)emitter != (Object)null && ((Component)emitter).gameObject.activeInHierarchy && _yaReemplazados.Contains(((Object)emitter).GetInstanceID())) { SilenciarEmitter(emitter); bool pausar = Time.timeScale == 0f; if (pausar != estabaPausado) { ((Channel)(ref canal)).setPaused(pausar); estabaPausado = pausar; } if (!pausar) { rampElapsed += 0.1f; float rampFactor = ((rampElapsed < 0.5f) ? Mathf.SmoothStep(0f, 1f, rampElapsed / 0.5f) : 1f); Vector3 posEm = ((Component)emitter).transform.position; VECTOR pos3D = new VECTOR { x = posEm.x, y = posEm.y, z = posEm.z }; VECTOR vel3D = new VECTOR { x = 0f, y = 0f, z = 0f }; ((Channel)(ref canal)).set3DAttributes(ref pos3D, ref vel3D); StudioListener listener = ListenerCache.Get(); Vector3 posL = (((Object)(object)listener != (Object)null) ? ((Component)listener).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : posEm)); float dist = Vector3.Distance(posL, posEm); float vol = ((dist <= 12.25f) ? 1f : ((!(dist >= 24.84f)) ? (1f - (dist - 12.25f) / 12.59f) : 0f)); float busHT = MultiPistaRunner.LeerVolBus("bus:/Ambience") * MultiPistaRunner.LeerVolBus("bus:/"); ((Channel)(ref canal)).setVolume(vol * rampFactor * 1f * busHT); if (tick % 30 == 0 && ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[HeadtombsGestor] dist=" + dist.ToString("F1") + " vol=" + vol.ToString("F2"))); } } tick++; yield return (object)new WaitForSecondsRealtime(0.1f); } ControlDoblajePlugin.Log.LogInfo((object)"[HeadtombsGestor] Loop terminado"); _yaReemplazados.Remove(((Object)(object)emitter != (Object)null) ? ((Object)emitter).GetInstanceID() : (-1)); for (int ci = _todosLosCanales.Count - 1; ci >= 0; ci--) { if (_todosLosCanales[ci].s.handle == sound.handle) { _todosLosCanales.RemoveAt(ci); } } try { ((Channel)(ref canal)).stop(); ((Sound)(ref sound)).release(); } catch { } if ((Object)(object)emitter != (Object)null) { WandererGestor.ReanudarEmitterNativo(emitter); } } private void OnDestroy() { if ((Object)(object)_instancia == (Object)(object)this) { _instancia = null; } } } public static class ObjCargador { private static float Pf(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } public static Mesh Cargar(string ruta) { //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_074d: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) if (!AssetPack.Existe(ruta)) { return null; } List<Vector3> posG = new List<Vector3>(); List<Vector3> normG = new List<Vector3>(); List<Vector2> uvG = new List<Vector2>(); List<List<(int v, int vt, int vn)[]>> subCaras = new List<List<(int, int, int)[]>>(); List<string> subNombres = new List<string>(); NuevaSub("default"); int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; string[] array = AssetPack.LeerLineas(ruta); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length == 0 || text2[0] == '#') { continue; } string[] array2 = text2.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length == 0) { continue; } switch (array2[0]) { case "v": if (array2.Length >= 4) { posG.Add(new Vector3(Pf(array2[1]), Pf(array2[2]), 0f - Pf(array2[3]))); } break; case "vt": if (array2.Length >= 3) { uvG.Add(new Vector2(Pf(array2[1]), Pf(array2[2]))); } break; case "vn": if (array2.Length >= 4) { normG.Add(new Vector3(Pf(array2[1]), Pf(array2[2]), 0f - Pf(array2[3]))); } break; case "usemtl": NuevaSub((array2.Length >= 2) ? array2[1] : "mat"); break; case "f": { (int, int, int)[] array3 = new(int, int, int)[array2.Length - 1]; for (int j = 1; j < array2.Length; j++) { string[] array4 = array2[j].Split(new char[1] { '/' }); array3[j - 1] = (int.Parse(array4[0]) - 1, (array4.Length > 1 && array4[1].Length > 0) ? (int.Parse(array4[1]) - 1) : (-1), (array4.Length > 2 && array4[2].Length > 0) ? (int.Parse(array4[2]) - 1) : (-1)); } List<(int, int, int)[]> list = subCaras[subCaras.Count - 1]; if (array3.Length == 4) { Vector3 val = ((array3[0].Item1 >= 0 && array3[0].Item1 < posG.Count) ? posG[array3[0].Item1] : Vector3.zero); Vector3 val2 = ((array3[1].Item1 >= 0 && array3[1].Item1 < posG.Count) ? posG[array3[1].Item1] : Vector3.zero); Vector3 val3 = ((array3[2].Item1 >= 0 && array3[2].Item1 < posG.Count) ? posG[array3[2].Item1] : Vector3.zero); Vector3 val4 = ((array3[3].Item1 >= 0 && array3[3].Item1 < posG.Count) ? posG[array3[3].Item1] : Vector3.zero); Vector3 val5 = Vector3.Cross(val2 - val, val3 - val); Vector3 val6 = Vector3.Cross(val3 - val, val4 - val); if (Vector3.Dot(val5, val6) >= 0f) { list.Add(new(int, int, int)[3] { array3[0], array3[2], array3[1] }); list.Add(new(int, int, int)[3] { array3[0], array3[3], array3[2] }); num2++; } else { list.Add(new(int, int, int)[3] { array3[0], array3[3], array3[1] }); list.Add(new(int, int, int)[3] { array3[1], array3[3], array3[2] }); num3++; } } else { for (int k = 1; k < array3.Length - 1; k++) { list.Add(new(int, int, int)[3] { array3[0], array3[k + 1], array3[k] }); } if (array3.Length == 3) { num++; } else { num4++; } } break; } } } List<Vector3> verts = new List<Vector3>(); List<Vector3> norms = new List<Vector3>(); List<Vector2> uvLst = new List<Vector2>(); Dictionary<(int, int, int), int> mapa = new Dictionary<(int, int, int), int>(); List<int[]> list2 = new List<int[]>(); List<string> list3 = new List<string>(); for (int l = 0; l < subCaras.Count; l++) { List<(int, int, int)[]> list4 = subCaras[l]; if (list4.Count == 0) { continue; } List<int> list5 = new List<int>(list4.Count * 3); foreach ((int, int, int)[] item in list4) { (int, int, int)[] array5 = item; foreach ((int, int, int) k2 in array5) { list5.Add(GetIdx(k2)); } } list2.Add(list5.ToArray()); list3.Add(subNombres[l]); } if (verts.Count == 0 || list2.Count == 0) { ControlDoblajePlugin.Log.LogWarning((object)("[OBJ] '" + Path.GetFileName(ruta) + "': sin geometría")); return null; } Mesh val7 = new Mesh(); ((Object)val7).name = Path.GetFileNameWithoutExtension(ruta); if (verts.Count > 65535) { val7.indexFormat = (IndexFormat)1; } val7.SetVertices(verts); val7.SetUVs(0, uvLst); val7.subMeshCount = list2.Count; for (int n = 0; n < list2.Count; n++) { val7.SetTriangles(list2[n], n); } val7.RecalculateNormals(); val7.RecalculateTangents(); val7.RecalculateBounds(); ControlDoblajePlugin.Log.LogInfo((object)($"[OBJ] '{((Object)val7).name}' cargado: {verts.Count} verts, " + $"{list2.Sum((int[] s) => s.Length / 3)} tris, " + $"{list2.Count} sub-malla(s) " + $"[caras: tri={num} quadAC={num2} quadBD={num3} ngon={num4}]")); return val7; int GetIdx((int v, int vt, int vn) key) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (mapa.TryGetValue(key, out var value)) { return value; } value = verts.Count; mapa[key] = value; verts.Add((key.v >= 0 && key.v < posG.Count) ? posG[key.v] : Vector3.zero); norms.Add((key.vn >= 0 && key.vn < normG.Count) ? normG[key.vn] : Vector3.up); uvLst.Add((key.vt >= 0 && key.vt < uvG.Count) ? uvG[key.vt] : Vector2.zero); return value; } void NuevaSub(string nombre) { if (subCaras.Count == 0 || subCaras[subCaras.Count - 1].Count > 0) { subCaras.Add(new List<(int, int, int)[]>()); subNombres.Add(nombre); } else { subNombres[subNombres.Count - 1] = nombre; } } } } public static class ModelosGestor { private struct BoneDataEntry { public Vector3 pos; public int boneIdx; } private struct BoneDataFile { public Matrix4x4[] bindposes; public BoneDataEntry[] vertices; } private static readonly Dictionary<string, Mesh> _cache = new Dictionary<string, Mesh>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<int, Mesh> _originalMeshFilters = new Dictionary<int, Mesh>(); private static readonly Dictionary<int, Mesh> _originalSMRs = new Dictionary<int, Mesh>(); private static readonly Dictionary<string, BoneDataFile?> _bonedataCache = new Dictionary<string, BoneDataFile?>(StringComparer.OrdinalIgnoreCase); public static void LimpiarCache() { _cache.Clear(); } public static void RestaurarMeshesOriginales() { MeshFilter[] array = Resources.FindObjectsOfTypeAll<MeshFilter>(); SkinnedMeshRenderer[] array2 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); int num = 0; MeshFilter[] array3 = array; foreach (MeshFilter val in array3) { if (!((Object)(object)val == (Object)null) && _originalMeshFilters.TryGetValue(((Object)val).GetInstanceID(), out var value) && (Object)(object)value != (Object)null) { val.sharedMesh = value; num++; } } SkinnedMeshRenderer[] array4 = array2; foreach (SkinnedMeshRenderer val2 in array4) { if (!((Object)(object)val2 == (Object)null) && _originalSMRs.TryGetValue(((Object)val2).GetInstanceID(), out var value2) && (Object)(object)value2 != (Object)null) { val2.sharedMesh = value2; num++; } } ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] Meshes originales restaurados: {num}"); } private static BoneDataFile? CargarBoneData(string rutaOBJ) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(rutaOBJ); if (_bonedataCache.TryGetValue(fileNameWithoutExtension, out var value)) { return value; } string text = Path.ChangeExtension(rutaOBJ, ".bonedata"); if (!AssetPack.Existe(text)) { _bonedataCache[fileNameWithoutExtension] = null; return null; } try { string[] array = AssetPack.LeerLineas(text); int num = 0; if (array[num].Trim() != "BONEDATA") { _bonedataCache[fileNameWithoutExtension] = null; return null; } num++; string[] array2 = array[num].Trim().Split(new char[1] { ' ' }); int num2 = int.Parse(array2[1]); num++; Matrix4x4[] array3 = (Matrix4x4[])(object)new Matrix4x4[num2]; for (int i = 0; i < num2; i++) { string[] array4 = array[num++].Trim().Split(new char[1] { ' ' }); array3[i] = new Matrix4x4 { m00 = float.Parse(array4[0], CultureInfo.InvariantCulture), m01 = float.Parse(array4[1], CultureInfo.InvariantCulture), m02 = float.Parse(array4[2], CultureInfo.InvariantCulture), m03 = float.Parse(array4[3], CultureInfo.InvariantCulture), m10 = float.Parse(array4[4], CultureInfo.InvariantCulture), m11 = float.Parse(array4[5], CultureInfo.InvariantCulture), m12 = float.Parse(array4[6], CultureInfo.InvariantCulture), m13 = float.Parse(array4[7], CultureInfo.InvariantCulture), m20 = float.Parse(array4[8], CultureInfo.InvariantCulture), m21 = float.Parse(array4[9], CultureInfo.InvariantCulture), m22 = float.Parse(array4[10], CultureInfo.InvariantCulture), m23 = float.Parse(array4[11], CultureInfo.InvariantCulture), m30 = float.Parse(array4[12], CultureInfo.InvariantCulture), m31 = float.Parse(array4[13], CultureInfo.InvariantCulture), m32 = float.Parse(array4[14], CultureInfo.InvariantCulture), m33 = float.Parse(array4[15], CultureInfo.InvariantCulture) }; } array2 = array[num].Trim().Split(new char[1] { ' ' }); int num3 = int.Parse(array2[1]); num++; BoneDataEntry[] array5 = new BoneDataEntry[num3]; for (int j = 0; j < num3; j++) { string[] array6 = array[num++].Trim().Split(new char[1] { ' ' }); float num4 = float.Parse(array6[0], CultureInfo.InvariantCulture); float num5 = float.Parse(array6[1], CultureInfo.InvariantCulture); float num6 = float.Parse(array6[2], CultureInfo.InvariantCulture); int boneIdx = int.Parse(array6[3]); array5[j] = new BoneDataEntry { pos = new Vector3(num4, num5, num6), boneIdx = boneIdx }; } BoneDataFile value2 = new BoneDataFile { bindposes = array3, vertices = array5 }; _bonedataCache[fileNameWithoutExtension] = value2; ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] .bonedata cargado: {num2} bindposes, {num3} verts originales"); return value2; } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Modelos] Error leyendo .bonedata: " + ex.Message)); _bonedataCache[fileNameWithoutExtension] = null; return null; } } public static void AplicarEnEscena() { //IL_098e: Unknown result type (might be due to invalid IL or missing references) //IL_0993: Unknown result type (might be due to invalid IL or missing references) //IL_0995: Unknown result type (might be due to invalid IL or missing references) //IL_099a: Unknown result type (might be due to invalid IL or missing references) //IL_09c5: Unknown result type (might be due to invalid IL or missing references) //IL_09ca: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09e6: Unknown result type (might be due to invalid IL or missing references) //IL_0a01: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a1: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_08ab: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_0922: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_08eb: Unknown result type (might be due to invalid IL or missing references) //IL_08f0: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: 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) //IL_12ef: Unknown result type (might be due to invalid IL or missing references) //IL_12f9: Unknown result type (might be due to invalid IL or missing references) //IL_12fe: Unknown result type (might be due to invalid IL or missing references) //IL_1303: Unknown result type (might be due to invalid IL or missing references) //IL_130e: Unknown result type (might be due to invalid IL or missing references) //IL_1318: Unknown result type (might be due to invalid IL or missing references) //IL_131d: Unknown result type (might be due to invalid IL or missing references) //IL_1322: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0d8c: Unknown result type (might be due to invalid IL or missing references) //IL_0d91: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d98: Unknown result type (might be due to invalid IL or missing references) //IL_13e1: Unknown result type (might be due to invalid IL or missing references) //IL_13fe: Unknown result type (might be due to invalid IL or missing references) //IL_1400: Unknown result type (might be due to invalid IL or missing references) //IL_1582: Unknown result type (might be due to invalid IL or missing references) //IL_1587: Unknown result type (might be due to invalid IL or missing references) //IL_158e: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_11f8: Unknown result type (might be due to invalid IL or missing references) //IL_11fd: Unknown result type (might be due to invalid IL or missing references) //IL_11ff: Unknown result type (might be due to invalid IL or missing references) //IL_1204: Unknown result type (might be due to invalid IL or missing references) //IL_0db6: Unknown result type (might be due to invalid IL or missing references) //IL_0dbc: Unknown result type (might be due to invalid IL or missing references) //IL_0dc1: Unknown result type (might be due to invalid IL or missing references) //IL_0dc6: Unknown result type (might be due to invalid IL or missing references) //IL_0e1a: Unknown result type (might be due to invalid IL or missing references) //IL_0e1f: Unknown result type (might be due to invalid IL or missing references) //IL_0e24: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0de7: Unknown result type (might be due to invalid IL or missing references) //IL_0dec: Unknown result type (might be due to invalid IL or missing references) //IL_0df1: Unknown result type (might be due to invalid IL or missing references) //IL_0e31: Unknown result type (might be due to invalid IL or missing references) //IL_0e36: Unknown result type (might be due to invalid IL or missing references) //IL_0e3b: Unknown result type (might be due to invalid IL or missing references) //IL_1128: Unknown result type (might be due to invalid IL or missing references) //IL_112d: Unknown result type (might be due to invalid IL or missing references) //IL_1130: Unknown result type (might be due to invalid IL or missing references) //IL_113a: Unknown result type (might be due to invalid IL or missing references) //IL_1147: Unknown result type (might be due to invalid IL or missing references) //IL_1151: Unknown result type (might be due to invalid IL or missing references) //IL_15d8: Unknown result type (might be due to invalid IL or missing references) //IL_15dd: Unknown result type (might be due to invalid IL or missing references) //IL_15df: Unknown result type (might be due to invalid IL or missing references) //IL_15e4: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_1186: Unknown result type (might be due to invalid IL or missing references) //IL_1170: Unknown result type (might be due to invalid IL or missing references) //IL_1250: Unknown result type (might be due to invalid IL or missing references) //IL_1256: Unknown result type (might be due to invalid IL or missing references) //IL_125b: Unknown result type (might be due to invalid IL or missing references) //IL_1260: Unknown result type (might be due to invalid IL or missing references) //IL_122e: Unknown result type (might be due to invalid IL or missing references) //IL_1234: Unknown result type (might be due to invalid IL or missing references) //IL_1239: Unknown result type (might be due to invalid IL or missing references) //IL_123e: Unknown result type (might be due to invalid IL or missing references) //IL_1289: Unknown result type (might be due to invalid IL or missing references) //IL_128e: Unknown result type (might be due to invalid IL or missing references) //IL_1293: Unknown result type (might be due to invalid IL or missing references) //IL_0ed7: Unknown result type (might be due to invalid IL or missing references) //IL_0edc: Unknown result type (might be due to invalid IL or missing references) //IL_0ede: Unknown result type (might be due to invalid IL or missing references) //IL_0ee3: Unknown result type (might be due to invalid IL or missing references) //IL_16a9: Unknown result type (might be due to invalid IL or missing references) //IL_16b2: Unknown result type (might be due to invalid IL or missing references) //IL_16b7: Unknown result type (might be due to invalid IL or missing references) //IL_1682: Unknown result type (might be due to invalid IL or missing references) //IL_12a0: Unknown result type (might be due to invalid IL or missing references) //IL_12a5: Unknown result type (might be due to invalid IL or missing references) //IL_12aa: Unknown result type (might be due to invalid IL or missing references) //IL_0e73: Unknown result type (might be due to invalid IL or missing references) //IL_0e79: Unknown result type (might be due to invalid IL or missing references) //IL_0e7e: Unknown result type (might be due to invalid IL or missing references) //IL_0e83: Unknown result type (might be due to invalid IL or missing references) //IL_0e8e: Unknown result type (might be due to invalid IL or missing references) //IL_0e94: Unknown result type (might be due to invalid IL or missing references) //IL_0e99: Unknown result type (might be due to invalid IL or missing references) //IL_0e9e: Unknown result type (might be due to invalid IL or missing references) //IL_171d: Unknown result type (might be due to invalid IL or missing references) //IL_1731: Unknown result type (might be due to invalid IL or missing references) //IL_0f16: Unknown result type (might be due to invalid IL or missing references) //IL_0f1c: Unknown result type (might be due to invalid IL or missing references) //IL_0f21: Unknown result type (might be due to invalid IL or missing references) //IL_0f26: Unknown result type (might be due to invalid IL or missing references) //IL_0efa: Unknown result type (might be due to invalid IL or missing references) //IL_0f00: Unknown result type (might be due to invalid IL or missing references) //IL_0f05: Unknown result type (might be due to invalid IL or missing references) //IL_0f0a: Unknown result type (might be due to invalid IL or missing references) //IL_0f4f: Unknown result type (might be due to invalid IL or missing references) //IL_0f54: Unknown result type (might be due to invalid IL or missing references) //IL_0f59: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0f8e: Unknown result type (might be due to invalid IL or missing references) //IL_0f9d: Unknown result type (might be due to invalid IL or missing references) //IL_0fb6: Unknown result type (might be due to invalid IL or missing references) //IL_0fc5: Unknown result type (might be due to invalid IL or missing references) //IL_0fdd: Unknown result type (might be due to invalid IL or missing references) //IL_0fe4: Unknown result type (might be due to invalid IL or missing references) //IL_0f66: Unknown result type (might be due to invalid IL or missing references) //IL_0f6b: Unknown result type (might be due to invalid IL or missing references) //IL_0f70: Unknown result type (might be due to invalid IL or missing references) //IL_1008: Unknown result type (might be due to invalid IL or missing references) //IL_100f: Unknown result type (might be due to invalid IL or missing references) //IL_17de: Unknown result type (might be due to invalid IL or missing references) //IL_17e7: Unknown result type (might be due to invalid IL or missing references) //IL_17ec: Unknown result type (might be due to invalid IL or missing references) //IL_17f1: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_1915: Unknown result type (might be due to invalid IL or missing references) //IL_191e: Unknown result type (might be due to invalid IL or missing references) //IL_1927: Unknown result type (might be due to invalid IL or missing references) //IL_192c: Unknown result type (might be due to invalid IL or missing references) //IL_1931: Unknown result type (might be due to invalid IL or missing references) //IL_1936: Unknown result type (might be due to invalid IL or missing references) //IL_1b77: Unknown result type (might be due to invalid IL or missing references) //IL_1b84: Unknown result type (might be due to invalid IL or missing references) //IL_1b89: Unknown result type (might be due to invalid IL or missing references) //IL_1bac: Unknown result type (might be due to invalid IL or missing references) //IL_1bb9: Unknown result type (might be due to invalid IL or missing references) //IL_1bbe: Unknown result type (might be due to invalid IL or missing references) //IL_1b31: Unknown result type (might be due to invalid IL or missing references) //IL_1b50: Unknown result type (might be due to invalid IL or missing references) //IL_1a2e: Unknown result type (might be due to invalid IL or missing references) //IL_1c48: Unknown result type (might be due to invalid IL or missing references) //IL_1c68: Unknown result type (might be due to invalid IL or missing references) //IL_1c87: Unknown result type (might be due to invalid IL or missing references) //IL_1ca7: Unknown result type (might be due to invalid IL or missing references) //IL_1cc6: Unknown result type (might be due to invalid IL or missing references) //IL_1ce6: Unknown result type (might be due to invalid IL or missing references) //IL_1a57: Unknown result type (might be due to invalid IL or missing references) //IL_1a50: Unknown result type (might be due to invalid IL or missing references) //IL_1e04: Unknown result type (might be due to invalid IL or missing references) //IL_1e0f: Unknown result type (might be due to invalid IL or missing references) //IL_1e14: Unknown result type (might be due to invalid IL or missing references) //IL_1e37: Unknown result type (might be due to invalid IL or missing references) //IL_1e42: Unknown result type (might be due to invalid IL or missing references) //IL_1e47: Unknown result type (might be due to invalid IL or missing references) //IL_1dc0: Unknown result type (might be due to invalid IL or missing references) //IL_1ddd: Unknown result type (might be due to invalid IL or missing references) //IL_1ec7: Unknown result type (might be due to invalid IL or missing references) //IL_1ee7: Unknown result type (might be due to invalid IL or missing references) //IL_1f06: Unknown result type (might be due to invalid IL or missing references) //IL_1f26: Unknown result type (might be due to invalid IL or missing references) //IL_1f45: Unknown result type (might be due to invalid IL or missing references) //IL_1f65: Unknown result type (might be due to invalid IL or missing references) if (!ControlDoblajePlugin.ModelosActivos) { ControlDoblajePlugin.Log.LogInfo((object)"[Modelos] Modelos3D inactivo — saltando"); return; } string meshPath = ControlDoblajePlugin.MeshPath; if (!AssetPack.CarpetaExiste(meshPath)) { ControlDoblajePlugin.Log.LogInfo((object)"[Modelos] Carpeta Mesh no encontrada (ni disco ni pack), saltando"); return; } string[] array = AssetPack.ListarArchivos(meshPath, ".obj").ToArray(); if (array.Length == 0) { return; } Stopwatch stopwatch = Stopwatch.StartNew(); ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] Escaneando escena — {array.Length} OBJ disponible(s)"); _originalMeshFilters.Clear(); _originalSMRs.Clear(); MeshFilter[] array2 = Resources.FindObjectsOfTypeAll<MeshFilter>(); SkinnedMeshRenderer[] array3 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); int num = 0; string[] array4 = array; foreach (string text in array4) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (!_cache.TryGetValue(fileNameWithoutExtension, out var value) || (Object)(object)value == (Object)null) { value = ObjCargador.Cargar(text); if ((Object)(object)value == (Object)null) { continue; } _cache[fileNameWithoutExtension] = value; } MeshFilter[] array5 = array2; Scene scene; foreach (MeshFilter val in array5) { if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null) { continue; } scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((Object)val.sharedMesh).name.Equals(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) { int instanceID = ((Object)val).GetInstanceID(); if (!_originalMeshFilters.ContainsKey(instanceID)) { _originalMeshFilters[instanceID] = val.sharedMesh; } AjustarMateriales(((Component)val).GetComponent<Renderer>(), value.subMeshCount); val.sharedMesh = value; num++; ControlDoblajePlugin.Log.LogInfo((object)("[Modelos] MeshFilter '" + ((Object)((Component)val).gameObject).name + "' → " + fileNameWithoutExtension + " " + $"({value.vertexCount} verts)")); } } BoneDataFile? boneDataFile = CargarBoneData(text); SkinnedMeshRenderer[] array6 = array3; foreach (SkinnedMeshRenderer val2 in array6) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { continue; } scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || !((Object)val2.sharedMesh).name.Equals(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) { continue; } if (value.bindposes == null || value.bindposes.Length == 0) { if (boneDataFile.HasValue) { BoneDataFile value2 = boneDataFile.Value; value.bindposes = value2.bindposes; Vector3[] vertices = value.vertices; BoneWeight[] array7 = (BoneWeight[])(object)new BoneWeight[vertices.Length]; int num2 = val2.bones.Length - 1; Dictionary<int, Vector3> dictionary = new Dictionary<int, Vector3>(); Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); BoneDataEntry[] vertices2 = value2.vertices; for (int l = 0; l < vertices2.Length; l++) { BoneDataEntry boneDataEntry = vertices2[l]; int num3 = Mathf.Clamp(boneDataEntry.boneIdx, 0, num2); if (!dictionary.ContainsKey(num3)) { dictionary[num3] = Vector3.zero; dictionary2[num3] = 0; } Dictionary<int, Vector3> dictionary3 = dictionary; int key = num3; dictionary3[key] += boneDataEntry.pos; dictionary2[num3]++; } int num4 = Mathf.Max(2, value2.vertices.Length / 20); List<(int, Vector3)> list = new List<(int, Vector3)>(); foreach (KeyValuePair<int, Vector3> item2 in dictionary) { if (dictionary2[item2.Key] >= num4) { list.Add((item2.Key, item2.Value / (float)dictionary2[item2.Key])); } } if (list.Count == 0) { foreach (KeyValuePair<int, Vector3> item3 in dictionary) { list.Add((item3.Key, item3.Value / (float)dictionary2[item3.Key])); } } foreach (var (num5, val3) in list) { ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] Centroide hueso {num5}: ({val3.x:F3},{val3.y:F3},{val3.z:F3}) n={dictionary2[num5]}"); } List<Vector3> list2 = new List<Vector3>(); List<int> list3 = new List<int>(); int num6 = -1; bool flag = false; try { foreach (string item4 in File.ReadLines(text)) { string text2 = item4.Trim(); if ((text2.StartsWith("o ") || text2.StartsWith("g ")) && text2.Length > 2) { num6 = (flag ? (num6 + 1) : 0); flag = true; } else if (text2.Length > 2 && text2[0] == 'v' && text2[1] == ' ') { string[] array8 = text2.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array8.Length >= 4 && float.TryParse(array8[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array8[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array8[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { list2.Add(new Vector3(result, result2, 0f - result3)); list3.Add(Math.Max(0, num6)); } } } } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Modelos] Error leyendo OBJ: " + ex.Message)); } int num7 = ((list2.Count > 0) ? ((list3.Count <= 0) ? 1 : (list3[list3.Count - 1] + 1)) : 0); ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] OBJ parser: {list2.Count} verts, {num7} grupos ('o' markers)"); int[] array9 = new int[vertices.Length]; Vector3 val4; Vector3 val5; if (num7 >= 2 && list2.Count > 0) { for (int m = 0; m < vertices.Length; m++) { float num8 = float.MaxValue; int num9 = 0; for (int n = 0; n < list2.Count; n++) { val4 = vertices[m] - list2[n]; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num8) { num8 = sqrMagnitude; num9 = list3[n]; } } array9[m] = ((num9 != 0) ? 1 : 0); } int num10 = 0; int num11 = 0; val5 = Vector3.zero; Vector3 val6 = Vector3.zero; for (int num12 = 0; num12 < vertices.Length; num12++) { if (array9[num12] == 0) { val5 += vertices[num12]; num10++; } else { val6 += vertices[num12]; num11++; } } if (num10 > 0) { val5 /= (float)num10; } if (num11 > 0) { val6 /= (float)num11; } ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] OBJ grupos: grp0={num10} cent=({val5.x:F4},{val5.y:F4}) | grp1={num11} cent=({val6.x:F4},{val6.y:F4})"); } else { ControlDoblajePlugin.Log.LogInfo((object)$"[Modelos] Sin grupos OBJ (numGrps={num7}) — intentando BFS"); bool flag2 = false; int num10 = 0; int num11 = 0; val5 = Vector3.zero; Vector3 val6 = Vector3.zero; int[] triangles = value.triangles; int[] array10 = new int[vertices.Length]; Dictionary<long, int> dictionary4 = new Dictionary<long, int>(); for (int num13 = 0; num13 < vertices.Length; num13++) { Vector3 val7 = vertices[num13]; long key2 = ((long)Mathf.RoundToInt(val7.x * 100000f) * 73856093L) ^ ((long)Mathf.RoundToInt(val7.y * 100000f) * 19349663L) ^ ((long)Mathf.RoundToInt(val7.z * 100000f) * 83492791L); if (!dictionary4.TryGetValue(key2, out var value3)) { value3 = num13; dictionary4[key2] = num13; } array10[num13] = value3; } List<int>[] array11 = new List<int>[vertices.Length]; for (int num14 = 0; num14 < vertices.Length; num14++) { array11[num14] = new List<int>(8); } for (int num15 = 0; num15 < triangles.Length; num15 += 3) { int num16 = array10[triangles[num15]]; int num17 = array10[triangles[num15 + 1]]; int num18 = array10[triangles[num15 + 2]]; if (num16 != num17 && !array11[num16].Contains(num17)) { array11[num16].Add(num17); array11[num17].A
BepInEx/plugins/TurronishContenido.dll
Decompiled a day agousing 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<int> EnProceso = new HashSet<int>(); } [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<int, string> _rutasPendientes = new Dictionary<int, string>(); 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("\\", "/"); } } } }
BepInEx/plugins/TurronishLocalizacion.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using TMPro; using TurronishMod.Logger; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: Guid("426c6978-4a61-7600-9d41-426c69784a61")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace ControlDoblaje; [BepInPlugin("com.turronish.localizacion", "Turronish Localizacion", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TurronishLocalizacionPlugin : BaseUnityPlugin { private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown TraduccionParcialScannerInstaller.Instalar(); Harmony val = new Harmony("com.turronish.localizacion"); val.PatchAll(); try { Type type = AccessTools.TypeByName("Febucci.UI.TextAnimatorPlayer"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "ShowText", new Type[1] { typeof(string) }, (Type[])null) : null); if (methodInfo != null) { val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(FebucciShowTextPatch).GetMethod("Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Fade] Febucci ShowText parcheado (traducción en entrada)."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Fade] Febucci TextAnimatorPlayer.ShowText no encontrado — fade-in del español quedará sin re-cálculo."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fade] patch Febucci falló (omitido): " + ex.Message)); } TurronishDiagLogger.Info("[Localizacion]", "TurronishLocalizacion cargado OK."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Localizacion] TurronishLocalizacion cargado."); } } public static class FebucciShowTextPatch { public static void Prefix(ref string text) { if (string.IsNullOrEmpty(text)) { return; } try { text = Traducciones.Aplicar(text); } catch { } } } public class TraduccionParcialScanner : MonoBehaviour { private float _timer = 0f; private const float INTERVAL = 0.8f; private static readonly char[] _accentadas = "áéíóúñ¡¿ÁÉÍÓÚÑ".ToCharArray(); private void Update() { if (!Traducciones.TextoEspanolActivo) { return; } _timer -= Time.unscaledDeltaTime; if (_timer > 0f) { return; } _timer = 0.8f; try { EscanearTextosParcia(); } catch { } } private static void EscanearTextosParcia() { TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val == (Object)null || Traducciones.EsDeNuestraUI((Component)(object)val)) { continue; } string text = ((TMP_Text)val).text; if (string.IsNullOrEmpty(text) || !text.Contains("\n") || (Object)(object)((Component)val).GetComponentInParent<TMP_InputField>() != (Object)null) { continue; } bool flag = false; bool flag2 = false; string[] array2 = text.Split(new char[1] { '\n' }); foreach (string text2 in array2) { if (!string.IsNullOrWhiteSpace(text2)) { if (text2.IndexOfAny(_accentadas) >= 0) { flag = true; } else if (text2.Trim().Length >= 8) { flag2 = true; } if (flag && flag2) { break; } } } if (flag && flag2) { Traducciones.InvalidarCache(text); string text3 = Traducciones.Aplicar(text); if (text3 != text) { ((TMP_Text)val).SetText(text3); } } } } } public static class TraduccionParcialScannerInstaller { private static GameObject _go; public static void Instalar() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)_go != (Object)null)) { _go = new GameObject("_TraduccionParcialScanner"); Object.DontDestroyOnLoad((Object)(object)_go); _go.AddComponent<TraduccionParcialScanner>(); _go.AddComponent<SpriteRendererScanner>(); } } } internal static class PromptFix { private static readonly HashSet<int> _ensanchadas = new HashSet<int>(); public static void AjustarLargo(TMP_Text tmp, string textoFinal) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tmp == (Object)null || textoFinal == null) { return; } string text = Regex.Replace(textoFinal, "<[^>]+>", string.Empty).Trim(); if (text != "Reanudar") { return; } try { bool flag = false; PropertyInfo property = ((object)tmp).GetType().GetProperty("textWrappingMode"); if (property != null) { try { object value = Enum.Parse(property.PropertyType, "NoWrap"); property.SetValue(tmp, value, null); flag = true; } catch { } } if (!flag && tmp.enableWordWrapping) { tmp.enableWordWrapping = false; } tmp.overflowMode = (TextOverflowModes)0; int instanceID = ((Object)tmp).GetInstanceID(); if (!_ensanchadas.Add(instanceID)) { return; } RectTransform rectTransform = tmp.rectTransform; if ((Object)(object)rectTransform != (Object)null) { float num = tmp.GetPreferredValues(textoFinal).x + 8f; float num2 = num - rectTransform.sizeDelta.x; if (num2 > 0f) { rectTransform.sizeDelta = new Vector2(num, rectTransform.sizeDelta.y); rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + num2 * rectTransform.pivot.x, rectTransform.anchoredPosition.y); } } } catch { } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class UITraduccionesSetterPatch { private static readonly HashSet<int> _ajustadas = new HashSet<int>(); private static bool _reparsando = false; private static void Prefix(TMP_Text __instance, ref string value) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponentInParent<TMP_InputField>() != (Object)null) && !Traducciones.EsDeNuestraUI((Component)(object)__instance)) { string text = value; value = Traducciones.Aplicar(value); PromptFix.AjustarLargo(__instance, value); if (value != text && (float)value.Length > (float)text.Length * 1.15f) { _ajustadas.Remove(((Object)__instance).GetInstanceID()); } } } private static void Postfix(TMP_Text __instance) { if (_reparsando || (Object)(object)__instance == (Object)null) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (_ajustadas.Contains(instanceID)) { return; } string text = __instance.text; if (text == null || text.IndexOf("{fade", StringComparison.OrdinalIgnoreCase) < 0) { return; } _ajustadas.Add(instanceID); if (text.Contains("Recuerda,")) { float num = ((__instance.enableAutoSizing && __instance.fontSizeMax > 0f) ? __instance.fontSizeMax : __instance.fontSize); if (num > 0f) { __instance.enableAutoSizing = false; __instance.fontSize = num * 0.75f; ControlDoblajePlugin.Log.LogInfo((object)$"[TMP-Resize] 'Recuerda ENA' → autoSize off, fontSize {num:F1} → {__instance.fontSize:F1}"); } } ReParsearFebucci(__instance, text); } private static void ReParsearFebucci(TMP_Text tmp, string texto) { try { Component[] components = ((Component)tmp).GetComponents<Component>(); Component[] array = components; foreach (Component val in array) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); string name = type.Name; if (name.IndexOf("TextAnimator", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Typewriter", StringComparison.OrdinalIgnoreCase) < 0) { continue; } _reparsando = true; try { if (TryInvocar(val, type, "SetText", new object[2] { texto, false }) || TryInvocar(val, type, "ShowText", new object[1] { texto }) || TryInvocar(val, type, "SetText", new object[1] { texto })) { break; } } finally { _reparsando = false; } } } catch { } } private static bool TryInvocar(object comp, Type tp, string metodo, object[] args) { try { Type[] array = new Type[args.Length]; for (int i = 0; i < args.Length; i++) { array[i] = args[i].GetType(); } MethodInfo method = tp.GetMethod(metodo, BindingFlags.Instance | BindingFlags.Public, null, array, null); if (method == null) { return false; } method.Invoke(comp, args); ControlDoblajePlugin.Log.LogInfo((object)$"[Fade] Febucci re-parse via {tp.Name}.{metodo}({array.Length} args)"); return true; } catch { return false; } } } [HarmonyPatch(typeof(TMP_Text), "SetText", new Type[] { typeof(string) })] public class UITraduccionesSetTextPatch { private static void Prefix(TMP_Text __instance, ref string sourceText) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponentInParent<TMP_InputField>() != (Object)null) && !Traducciones.EsDeNuestraUI((Component)(object)__instance)) { sourceText = Traducciones.Aplicar(sourceText); PromptFix.AjustarLargo(__instance, sourceText); } } } [HarmonyPatch(typeof(TMP_Text), "SetText", new Type[] { typeof(string), typeof(bool) })] public class UITraduccionesSetTextBoolPatch { private static void Prefix(TMP_Text __instance, ref string sourceText) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponentInParent<TMP_InputField>() != (Object)null) && !Traducciones.EsDeNuestraUI((Component)(object)__instance)) { sourceText = Traducciones.Aplicar(sourceText); PromptFix.AjustarLargo(__instance, sourceText); } } } [HarmonyPatch(typeof(TextMeshProUGUI), "OnEnable")] public class UITraduccionesOnEnablePatch { private static void Postfix(TextMeshProUGUI __instance) { if (!((Object)(object)((Component)__instance).GetComponentInParent<TMP_InputField>() != (Object)null) && !Traducciones.EsDeNuestraUI((Component)(object)__instance)) { string text = Traducciones.Aplicar(((TMP_Text)__instance).text); if (text != ((TMP_Text)__instance).text) { ((TMP_Text)__instance).SetText(text); } } } } [HarmonyPatch(typeof(TextMeshProUGUI), "Awake")] public class UITraduccionesAwakePatch { private static void Postfix(TextMeshProUGUI __instance) { if (Traducciones.TextoEspanolActivo && !((Object)(object)((Component)__instance).GetComponentInParent<TMP_InputField>() != (Object)null) && !Traducciones.EsDeNuestraUI((Component)(object)__instance)) { string text = Traducciones.Aplicar(((TMP_Text)__instance).text); if (text != ((TMP_Text)__instance).text) { ((TMP_Text)__instance).SetText(text); } } } }
BepInEx/plugins/TurronishLogger.dll
Decompiled a day agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx.Logging; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("TurronishLogger")] [assembly: AssemblyDescription("DLL 6 — Logger / Diagnostics del Turronish Mod")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TurronishMod")] [assembly: AssemblyCopyright("")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace TurronishMod.Logger; public enum TLogLevel { DEBUG, INFO, WARN, ERROR } public enum TLogMode { DEV, PROD, SILENT } public static class TurronishDiagLogger { internal const string SAL_SESION = "QmxpeA==SmF2"; private static ManualLogSource _bepLog; private static StreamWriter _file; private static readonly object _fileLock = new object(); public static TLogMode Mode { get; set; } = TLogMode.PROD; public static bool Verbose { get; set; } = false; public static string RutaArchivo { get; private set; } public static void Initialize(ManualLogSource bepLog, string logDirectory = null, TLogMode mode = TLogMode.PROD) { _bepLog = bepLog; Mode = mode; if (mode == TLogMode.SILENT || logDirectory == null) { WriteConsole(TLogLevel.INFO, "Logger", $"TurronishLogger iniciado. Modo={mode} | Sin archivo."); return; } try { Directory.CreateDirectory(logDirectory); string text = DateTime.Now.ToString("yyyyMMdd_HHmm"); RutaArchivo = Path.Combine(logDirectory, "turronish_" + text + ".txt"); _file = new StreamWriter(RutaArchivo, append: false, Encoding.UTF8) { AutoFlush = true }; string value = "╔══════════════════════════════════════════╗\n║ TURRONISH MOD — Sesion de Diagnostico ║\n" + $"║ Inicio : {DateTime.Now:yyyy-MM-dd HH:mm:ss} ║\n" + $"║ Modo : {mode,-10} ║\n" + "╚══════════════════════════════════════════╝"; lock (_fileLock) { _file.WriteLine(value); } WriteConsole(TLogLevel.INFO, "Logger", $"TurronishLogger iniciado. Modo={mode} | Archivo: {RutaArchivo}"); } catch (Exception ex) { _file = null; RutaArchivo = null; WriteConsole(TLogLevel.WARN, "Logger", "No se pudo crear archivo de log: " + ex.Message); } } public static void Info(string tag, string msg) { Write(TLogLevel.INFO, tag, msg); } public static void Warn(string tag, string msg) { Write(TLogLevel.WARN, tag, msg); } public static void Error(string tag, string msg) { Write(TLogLevel.ERROR, tag, msg); } public static void Debug(string tag, string msg) { if (Verbose) { Write(TLogLevel.DEBUG, tag, msg); } } public static void Sesion(string tag, string msg) { if (_file != null) { EscribirArchivo(TLogLevel.INFO, tag, "[SESION] " + msg); } } public static void CerrarSesion() { if (_file == null) { return; } EscribirArchivo(TLogLevel.INFO, "Logger", "Sesion cerrada."); lock (_fileLock) { try { _file.Flush(); _file.Close(); } catch { } finally { _file = null; } } } private static void Write(TLogLevel level, string tag, string msg) { bool flag = true; bool flag2 = true; switch (Mode) { case TLogMode.SILENT: flag = false; flag2 = level >= TLogLevel.WARN; break; case TLogMode.PROD: flag = level >= TLogLevel.WARN || (level == TLogLevel.INFO && Verbose); if (level == TLogLevel.DEBUG) { return; } break; } if (flag2) { WriteConsole(level, tag, msg); } if (flag) { EscribirArchivo(level, tag, msg); } } private static void WriteConsole(TLogLevel level, string tag, string msg) { if (_bepLog != null) { string text = "[" + tag + "] " + msg; switch (level) { case TLogLevel.INFO: _bepLog.LogInfo((object)text); break; case TLogLevel.WARN: _bepLog.LogWarning((object)text); break; case TLogLevel.ERROR: _bepLog.LogError((object)text); break; case TLogLevel.DEBUG: _bepLog.LogDebug((object)text); break; } } } private static void EscribirArchivo(TLogLevel level, string tag, string msg) { if (_file == null) { return; } string text = DateTime.Now.ToString("HH:mm:ss.fff"); string text2 = level.ToString().PadRight(5); string value = "[" + text + "][" + text2 + "][" + tag + "] " + msg; lock (_fileLock) { try { _file.WriteLine(value); } catch { } } } }
BepInEx/plugins/TurronishUI.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using JoelG.ENA4.UI; using LMirman.Utilities.UI; using Rewired; using TMPro; using TurronishMod.Logger; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; 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.ui", "Turronish UI", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TurronishUIPlugin : BaseUnityPlugin { private static void PatchAllSafe(Harmony harmony) { int num = 0; int num2 = 0; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { harmony.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[UI] Patch SKIPPED '" + type.Name + "': " + ex.GetType().Name + " — " + ex.Message)); num2++; } } } ControlDoblajePlugin.Log.LogInfo((object)$"[UI] PatchAllSafe: {num} ok, {num2} omitidos"); } private void Awake() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown ControlDoblajePlugin.UIResetarEstado = TurronishExtrasHelper.ResetarEstado; ControlDoblajePlugin.UIExtrasTurronishReset = ExtrasTurronishGestor.Resetar; ControlDoblajePlugin.UIExtrasTurronishInyectar = ExtrasTurronishGestor.InyectarDespues; ControlDoblajePlugin.UIAttachLogoMonitor = TurronishLogoVisibilityMonitor.AttachTo; ControlDoblajePlugin.UITryInstalarPatch = GamePauseManagerPatch.TryInstalar; ControlDoblajePlugin.UIMostrarAvisoActualizacion = AvisoActualizacion.Mostrar; Harmony harmony = new Harmony("com.turronish.ui"); PatchAllSafe(harmony); ControladorNavegacion.Crear(); TurronishDiagLogger.Info("[UI]", "TurronishUI cargado OK."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[UI] TurronishUI cargado."); } } public static class AvisoActualizacion { public static Canvas CanvasHint; public static void Mostrar(string instalada, string disponible, string url, string changelog) { //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = Resources.Load<GameObject>("UI/Confirmation Window"); if ((Object)(object)val == (Object)null) { ControlDoblajePlugin.Log.LogWarning((object)"[Actualiz] prefab 'UI/Confirmation Window' no encontrado."); return; } string discord = (string.IsNullOrEmpty(url) ? "https://discord.gg/nhUEmxqTyv" : url); string text = LabelsUI.Txt("VERSIÓN DESACTUALIZADA", "OUTDATED VERSION"); string text2 = LabelsUI.Txt("¡Una nueva versión del mod está disponible!", "A new version of the mod is available!"); string text3 = LabelsUI.Txt("Versión instalada:", "Installed version:"); string text4 = LabelsUI.Txt("Versión disponible:", "Available version:"); string text5 = LabelsUI.Txt("Actualiza el mod dentro de nuestro servidor de Discord.", "Update the mod inside our Discord server."); string text6 = DividirEnDos(LabelsUI.Txt("Continuar de todas formas", "Continue anyway")); string text7 = LabelsUI.Txt("Ir al Discord", "Go to Discord"); Color32 arriba = default(Color32); ((Color32)(ref arriba))..ctor((byte)191, (byte)219, byte.MaxValue, byte.MaxValue); Color32 abajo = default(Color32); ((Color32)(ref abajo))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); string text8 = "<color=#FFFFFF>" + text2 + "</color>\n\n<color=#FFFFFF>" + text3 + " </color><color=#ED5B5B>V" + instalada + "</color>\n<color=#FFFFFF>" + text4 + " </color>"; string text9 = "\n<color=#F5C518>" + text5 + "</color>"; string text10 = "V" + disponible; string text11 = text8 + "<color=#BFDBFF>" + text10 + "</color>" + text9; string text12 = text8 + "<alpha=#00>" + text10 + "<alpha=#FF>" + text9; Action action = delegate { }; Action action2 = delegate { try { Application.OpenURL(discord); } catch { } }; Canvas val2 = (((Object)(object)CanvasHint != (Object)null) ? CanvasHint : Object.FindObjectOfType<Canvas>()); Request val3 = new Request(action, action2, text, text11, text6, text7); UIFunctions.CreateConfirmationWindow(val3, val, val2); try { ConfirmationWindow mostRecentConfirmation = UIFunctions.MostRecentConfirmation; TMP_Text val4 = null; if ((Object)(object)mostRecentConfirmation != (Object)null) { TMP_Text[] componentsInChildren = ((Component)mostRecentConfirmation).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val5 in componentsInChildren) { if ((Object)(object)val5 != (Object)null && val5.text == text11) { val4 = val5; break; } } } if ((Object)(object)val4 != (Object)null && ConstruirNumeroDividido(val4, text10, arriba, abajo)) { val4.text = text12; } } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] split: " + ex.Message)); } ControlDoblajePlugin.Log.LogInfo((object)("[Actualiz] Aviso nativo mostrado (V" + instalada + " < V" + disponible + ").")); } catch (Exception ex2) { ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] no se pudo mostrar el aviso nativo: " + ex2.Message)); } } private static string DividirEnDos(string s) { if (string.IsNullOrEmpty(s) || s.IndexOf(' ') < 0) { return s; } int num = s.Length / 2; int num2 = -1; int num3 = int.MaxValue; for (int i = 0; i < s.Length; i++) { if (s[i] == ' ') { int num4 = Math.Abs(i - num); if (num4 < num3) { num3 = num4; num2 = i; } } } return (num2 < 0) ? s : (s.Substring(0, num2) + "\n" + s.Substring(num2 + 1)); } private static bool ConstruirNumeroDividido(TMP_Text descTMP, string numero, Color32 arriba, Color32 abajo) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) descTMP.ForceMeshUpdate(false, false); TMP_TextInfo textInfo = descTMP.textInfo; if (textInfo == null || textInfo.characterCount == 0) { return false; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < textInfo.characterCount; i++) { stringBuilder.Append(textInfo.characterInfo[i].character); } int num = stringBuilder.ToString().LastIndexOf(numero, StringComparison.Ordinal); if (num < 0) { return false; } int num2 = num; int num3 = num + numero.Length - 1; if (num3 >= textInfo.characterCount) { return false; } TMP_CharacterInfo val = textInfo.characterInfo[num2]; TMP_CharacterInfo val2 = textInfo.characterInfo[num3]; float x = val.bottomLeft.x; float x2 = val2.topRight.x; float ascender = val.ascender; float descender = val.descender; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor((x + x2) * 0.5f, (ascender + descender) * 0.5f, 0f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(x2 - x, ascender - descender); TMP_FontAsset font = descTMP.font; float fontSize = descTMP.fontSize; GameObject val4 = new GameObject("VerDispSplit"); val4.transform.SetParent(descTMP.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(0.5f, 0.5f); val5.anchorMax = val6; val5.anchorMin = val6; val5.pivot = new Vector2(0.5f, 0.5f); val5.sizeDelta = val3; val4.transform.localPosition = localPosition; MitadNumero(val4.transform, numero, font, fontSize, arriba, val3, esArriba: true); MitadNumero(val4.transform, numero, font, fontSize, abajo, val3, esArriba: false); return true; } private static void MitadNumero(Transform padre, string numero, TMP_FontAsset font, float fs, Color32 col, Vector2 tamCont, bool esArriba) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(esArriba ? "MitadArriba" : "MitadAbajo"); val.transform.SetParent(padre, false); RectTransform val2 = val.AddComponent<RectTransform>(); if (esArriba) { val2.anchorMin = new Vector2(0f, 0.5f); val2.anchorMax = new Vector2(1f, 1f); } else { val2.anchorMin = new Vector2(0f, 0f); val2.anchorMax = new Vector2(1f, 0.5f); } Vector2 val3 = (val2.offsetMin = (val2.offsetMax = Vector2.zero)); val.AddComponent<RectMask2D>(); GameObject val5 = new GameObject("T"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); ((Vector2)(ref val3))..ctor(0.5f, esArriba ? 0f : 1f); val6.anchorMax = val3; val6.anchorMin = val3; val6.pivot = new Vector2(0.5f, 0.5f); val6.sizeDelta = tamCont; val6.anchoredPosition = Vector2.zero; TextMeshProUGUI val7 = val5.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val7).SetText(numero); ((Graphic)val7).color = Color32.op_Implicit(col); ((TMP_Text)val7).fontSize = fs; if ((Object)(object)font != (Object)null) { ((TMP_Text)val7).font = font; } ((TMP_Text)val7).alignment = (TextAlignmentOptions)514; ((TMP_Text)val7).textWrappingMode = (TextWrappingModes)0; ((Graphic)val7).raycastTarget = false; } } public static class DoblajeTabHelper { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<string> <>9__51_0; public static Func<string> <>9__51_2; public static Func<Transform, bool> <>9__79_4; public static UnityAction <>9__79_6; public static UnityAction <>9__79_7; public static Func<string, bool> <>9__81_11; public static Func<string, bool> <>9__81_22; public static Func<string, bool> <>9__81_23; public static Action<int> <>9__81_24; public static Action<int> <>9__81_25; public static Action<int> <>9__81_26; public static Action<int> <>9__81_27; public static Action <>9__81_29; public static Action <>9__81_32; public static Action <>9__81_34; public static Func<string> <>9__81_38; public static Func<string> <>9__81_39; public static Action<int> <>9__81_40; public static Action<int> <>9__81_43; public static Action<int> <>9__81_46; public static Action<int> <>9__81_49; public static UnityAction <>9__81_52; public static Func<string> <>9__81_53; public static Func<string> <>9__81_54; public static Action<int> <>9__84_1; public static Func<Preset, string> <>9__84_5; public static Action<int> <>9__85_2; internal bool <CrearDropdownNativo>b__51_0(string op) { return op.Contains("Personaliz") || op.Contains("Custom"); } internal string <CrearDropdownNativo>b__51_2() { return ""; } internal bool <TryAgregarPestana>b__79_4(Transform t) { return ((Object)t).name == "Setting Details Text" && (Object)(object)((Component)t).GetComponent<DoblejeUIMarker>() == (Object)null; } internal void <TryAgregarPestana>b__79_6() { try { ControlDoblajePlugin.GuardarConfig(); } catch (Exception ex) { ManualLogSource log = ControlDoblajePlugin.Log; if (log != null) { log.LogWarning((object)("[Pref] Save hook: " + ex.Message)); } } } internal void <TryAgregarPestana>b__79_7() { try { typeof(ControlDoblajePlugin).GetMethod("CargarConfig", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(ControlDoblajePlugin.Instance, null); if ((Object)(object)_configParent != (Object)null) { ConfigRebuildHelper.Schedule(_configParent, _configIsPausa); } } catch (Exception ex) { ManualLogSource log = ControlDoblajePlugin.Log; if (log != null) { log.LogWarning((object)("[Pref] Discard hook: " + ex.Message)); } } } internal bool <ConfigurarDoblaje>b__81_11(string p) { bool value; return ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value) && value; } internal bool <ConfigurarDoblaje>b__81_22(string p) { bool value; return ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value) && value; } internal bool <ConfigurarDoblaje>b__81_23(string p) { bool value; return ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value) && !value; } internal void <ConfigurarDoblaje>b__81_24(int idx) { bool textoEspanolActivo = Traducciones.TextoEspanolActivo; if (idx == 0 && !textoEspanolActivo) { Traducciones.ActivarYAplicar(); } else if (idx != 0 && textoEspanolActivo) { Traducciones.DesactivarYRevertir(); } ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__81_25(int idx) { ControlDoblajePlugin.VideoClipsActivo = idx == 0; ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__81_26(int idx) { ControlDoblajePlugin.ImagenesActivas = idx == 0; SpriteReemplazador.ReScanearTodosLosSprites(); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__81_27(int idx) { bool flag = (ControlDoblajePlugin.ModelosActivos = idx == 0); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); if (flag) { ControlDoblajePlugin.ModelosAplicar?.Invoke(); } else { ControlDoblajePlugin.ModelosRestaurar?.Invoke(); } } internal void <ConfigurarDoblaje>b__81_29() { _secSolitariaAbierta = !_secSolitariaAbierta; ChapterAnimHelper.ToggleSol(); } internal void <ConfigurarDoblaje>b__81_32() { _secMultitudAbierta = !_secMultitudAbierta; ChapterAnimHelper.ToggleMul(); } internal void <ConfigurarDoblaje>b__81_34() { _secCaballoAbierta = !_secCaballoAbierta; ChapterAnimHelper.ToggleCab(); } internal string <ConfigurarDoblaje>b__81_38() { return UI("Mixear Voces", "Mix Voices"); } internal string <ConfigurarDoblaje>b__81_39() { return UI("Elige aleatoriamente el idioma de audio de cada personaje. Para una nueva experiencia.", "Randomly picks audio language for each character. For a new experience."); } internal void <ConfigurarDoblaje>b__81_40(int idx) { ControlDoblajePlugin.VarianteENA = idx; ControlDoblajePlugin.GuardarConfig(); VarianteENAPatcher.ReevalAll(); } internal void <ConfigurarDoblaje>b__81_43(int idx) { ControlDoblajePlugin.VarianteTaxi = idx; ControlDoblajePlugin.GuardarConfig(); VarianteTaxiPatcher.ReevalAll(); } internal void <ConfigurarDoblaje>b__81_46(int idx) { ControlDoblajePlugin.VarianteYowadama = idx; ControlDoblajePlugin.GuardarConfig(); } internal void <ConfigurarDoblaje>b__81_49(int idx) { ControlDoblajePlugin.LogoBtnActivo = idx == 0; ControlDoblajePlugin.GuardarConfig(); } internal void <ConfigurarDoblaje>b__81_52() { ControlDoblajePlugin.Log.LogInfo((object)"[Discord] Click!"); Application.OpenURL("https://discord.gg/nhUEmxqTyv"); } internal string <ConfigurarDoblaje>b__81_53() { return UI("Discord", "Discord"); } internal string <ConfigurarDoblaje>b__81_54() { return UI("Abre el servidor de Discord en tu navegador.", "Opens the Discord server in your browser."); } internal void <FilaPreajustesGO>b__84_1(int _) { } internal string <FilaPreajustesGO>b__84_5(Preset p) { return p.Nombre; } internal void <CeldaPersonajeEnGrid>b__85_2(int idx) { } } private static readonly HashSet<int> parcheadas = new HashSet<int>(); private static readonly Color cBlanco = new Color(0.95f, 0.95f, 0.95f, 1f); private static readonly Color cGris = new Color(0.55f, 0.55f, 0.55f, 1f); private static readonly Color cSep = new Color(0.35f, 0.35f, 0.35f, 1f); private static readonly Color cPopupBg = new Color(0.09f, 0.09f, 0.09f, 1f); private static readonly Color cInputBg = new Color(0.12f, 0.12f, 0.12f, 1f); private static readonly Color cBotonBg = new Color(0.14f, 0.14f, 0.14f, 1f); internal const ulong DBG_TINTES = 4786316469352887808uL; internal static readonly Color32 cDbgCaja = new Color32((byte)66, (byte)108, (byte)105, (byte)120); internal static readonly Color32 cDbgBorde = new Color32((byte)74, (byte)97, (byte)118, byte.MaxValue); private static Action _actualizarIdiomaLabel = null; internal static bool _secSolitariaAbierta = true; internal static bool _secMultitudAbierta = false; internal static bool _secCaballoAbierta = false; private static Transform _configParent = null; private static bool _configIsPausa = false; private static readonly Dictionary<string, (string es, string en)> _charLang = new Dictionary<string, (string, string)>(StringComparer.OrdinalIgnoreCase) { { "Froggy", ("Japonés", "Japanese") }, { "Recepcionista", ("Francés", "French") }, { "Receptionist", ("Francés", "French") }, { "Dahlia", ("Francés", "French") }, { "CoralGlasses", ("Coreano", "Korean") }, { "Kane", ("Ruso", "Russian") }, { "HoarderAlex", ("Italiano", "Italian") }, { "Taxista", ("Original", "Original") }, { "TaxiDriver", ("Original", "Original") }, { "TaxiDrivers", ("Original", "Original") }, { "Theodora", ("Griego", "Greek") }, { "TheodoraBroken", ("Griego", "Greek") }, { "Shoryo", ("Japonés", "Japanese") } }; internal static RectTransform _solClipRT; internal static RectTransform _mulClipRT; internal static RectTransform _cabClipRT; internal static float _solGridH; internal static float _mulGridH; internal static float _cabGridH; internal static readonly List<RectTransform> _belowSolRTs = new List<RectTransform>(); internal static readonly List<RectTransform> _belowMulRTs = new List<RectTransform>(); internal static readonly List<RectTransform> _belowCabRTs = new List<RectTransform>(); internal static RectTransform _mainContentRT; internal static Transform _solArrowT; internal static Transform _mulArrowT; internal static Transform _cabArrowT; private static readonly Color cBotonHov = new Color(0.26f, 0.26f, 0.26f, 1f); private static readonly Color cBotonPres = new Color(0.04f, 0.04f, 0.04f, 1f); private static readonly Color cPresetNorm = new Color(0.08f, 0.08f, 0.08f, 1f); private static readonly Color cPresetHov = new Color(0.18f, 0.18f, 0.18f, 1f); private static readonly Color cPresetPres = new Color(0.04f, 0.04f, 0.04f, 1f); private static readonly Color cDropHov = new Color(1f, 1f, 1f, 0.06f); private static readonly Color cDropPres = new Color(0f, 0f, 0f, 0.15f); private static readonly Dictionary<TMP_Text, TMP_Dropdown> _ddNativoPorCaption = new Dictionary<TMP_Text, TMP_Dropdown>(); private static TMP_FontAsset _fuente; private static Sprite _spriteDD; private static GameObject _botonNativoTemplate; private static GameObject _ddNativoTemplate; private static TMP_Text _descTitulo; private static TMP_Text _descCuerpo; private static GameObject _descCanvasGO; private static GameObject _descMask; private static GameObject _panelDescNativo; private static GameObject _panelDescNativo_Pausa; private static TMP_Text _sdtNativo; private static TMP_Text _sdtNativo_Pausa; private static Tab _nuestroTab; private static TabGroup _nuestroTabGroup; private static GameObject _descCanvasGO_Pausa; private static GameObject _descMask_Pausa; private static TMP_Text _descTitulo_Pausa; private static TMP_Text _descCuerpo_Pausa; private static Tab _nuestroTab_Pausa; private static TMP_FontAsset Fuente { get { if ((Object)(object)_fuente != (Object)null) { return _fuente; } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); foreach (TMP_FontAsset val in array) { string name = ((Object)val).name; if (name.IndexOf("RuneScape", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ENA4Font", StringComparison.OrdinalIgnoreCase) >= 0 || name == "ENA" || name.StartsWith("ENA ") || name.StartsWith("ENA-")) { _fuente = val; return _fuente; } } TextMeshProUGUI[] array2 = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val2 in array2) { if (!((Object)(object)((val2 != null) ? ((TMP_Text)val2).font : null) == (Object)null)) { string name2 = ((Object)((TMP_Text)val2).font).name; if (name2.IndexOf("RuneScape", StringComparison.OrdinalIgnoreCase) >= 0 || name2.IndexOf("ENA", StringComparison.OrdinalIgnoreCase) >= 0) { _fuente = ((TMP_Text)val2).font; return _fuente; } } } return null; } } private static Sprite SpriteDD { get { if ((Object)(object)_spriteDD != (Object)null) { return _spriteDD; } Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>(); string[] array2 = new string[4] { "s_Dropdown", "Dropdown", "UISprite", "s_Select" }; Sprite[] array3 = array; foreach (Sprite val in array3) { string[] array4 = array2; foreach (string text in array4) { if (((Object)val).name == text) { _spriteDD = val; return _spriteDD; } } } Sprite[] array5 = array; foreach (Sprite val2 in array5) { string text2 = ((Object)val2).name.ToLower(); if (text2.Contains("dropdown") || text2.Contains("chevron")) { _spriteDD = val2; return _spriteDD; } } return null; } } private static GameObject BotonNativoTemplate { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown Scene scene; if ((Object)(object)_botonNativoTemplate != (Object)null) { scene = _botonNativoTemplate.scene; if (!((Scene)(ref scene)).IsValid()) { _botonNativoTemplate = null; } } if ((Object)(object)_botonNativoTemplate != (Object)null) { return _botonNativoTemplate; } GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } scene = val.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } scene = val.scene; if (!((Scene)(ref scene)).isLoaded || ((Object)val).name.StartsWith("_") || ((Object)val).name == "Resume Button" || (Object)(object)val.GetComponent<DoblejeUIMarker>() != (Object)null || (Object)(object)val.GetComponentInParent<DoblejeUIMarker>() != (Object)null) { continue; } bool flag = false; bool flag2 = false; foreach (Transform item in val.transform) { Transform val2 = item; if (((Object)val2).name == "Border") { flag = true; } if (((Object)val2).name == "Label") { flag2 = true; } } if (flag && flag2 && !((Object)(object)val.GetComponent<Button>() == (Object)null)) { _botonNativoTemplate = val; ControlDoblajePlugin.Log.LogInfo((object)("[UI] Botón nativo encontrado: " + ((Object)val).name)); return _botonNativoTemplate; } } return null; } } private static GameObject DDNativoTemplate { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown Scene scene; if ((Object)(object)_ddNativoTemplate != (Object)null) { scene = _ddNativoTemplate.scene; if (!((Scene)(ref scene)).IsValid()) { _ddNativoTemplate = null; } } if ((Object)(object)_ddNativoTemplate != (Object)null) { return _ddNativoTemplate; } GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } scene = val.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } scene = val.scene; if (!((Scene)(ref scene)).isLoaded || ((Object)val).name.StartsWith("_") || (Object)(object)val.GetComponent<DoblejeUIMarker>() != (Object)null || (Object)(object)val.GetComponentInParent<DoblejeUIMarker>() != (Object)null) { continue; } bool flag = false; bool flag2 = false; bool flag3 = false; foreach (Transform item in val.transform) { Transform val2 = item; if (((Object)val2).name == "Border") { flag = true; } if (((Object)val2).name == "Title Label") { flag2 = true; } if (((Object)val2).name == "Dropdown") { flag3 = true; } } if (flag && flag2 && flag3) { _ddNativoTemplate = val; ControlDoblajePlugin.Log.LogInfo((object)("[UI] Dropdown nativo encontrado: " + ((Object)val).name)); return _ddNativoTemplate; } } return null; } } private static void FijarSeleccionDD(TMP_Text caption, int idx, string[] opciones) { if ((Object)(object)caption == (Object)null) { return; } if (_ddNativoPorCaption.TryGetValue(caption, out var value) && (Object)(object)value != (Object)null) { try { value.SetValueWithoutNotify(idx); value.RefreshShownValue(); return; } catch { } } if (idx >= 0 && idx < opciones.Length) { caption.SetText(opciones[idx]); } } private static GameObject CrearDropdownNativo(Transform parent, string[] opciones, int[] idxRef, string labelES, string labelEN, out TMP_Text valLabel, Action<int> onCambio) { //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown valLabel = null; if (Array.Exists(opciones, (string op) => op.Contains("Personaliz") || op.Contains("Custom"))) { return null; } GameObject dDNativoTemplate = DDNativoTemplate; if ((Object)(object)dDNativoTemplate == (Object)null) { ControlDoblajePlugin.Log.LogWarning((object)"[UI] DDNativo no encontrado, usando fallback"); return null; } GameObject val = Object.Instantiate<GameObject>(dDNativoTemplate); if ((Object)(object)val == (Object)null) { valLabel = null; return null; } ((Object)val).name = "DD_" + labelES; if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, false); } Transform obj = val.transform.Find("Title Label"); TMP_Text val2 = ((obj != null) ? ((Component)obj).GetComponentInChildren<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null) { val2.SetText(UI(labelES, labelEN)); AF(val2); RegUI(val2, labelES, labelEN); } Transform val3 = val.transform.Find("Dropdown"); object obj2; if (val3 == null) { obj2 = null; } else { Transform obj3 = val3.Find("Selection Text"); obj2 = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null); } TMP_Text val4 = (TMP_Text)obj2; if ((Object)(object)val4 == (Object)null && (Object)(object)val3 != (Object)null) { val4 = ((Component)val3).GetComponentInChildren<TMP_Text>(); } if ((Object)(object)val4 != (Object)null) { val4.SetText(opciones[idxRef[0]]); valLabel = val4; } MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val5 in componentsInChildren) { string name = ((object)val5).GetType().Name; if (name == "OptionsSettingData" || name == "DropdownSetting" || name == "FontSizeRectController") { Object.DestroyImmediate((Object)(object)val5); } } Component component = val.GetComponent("JoelG.ENA4.UI.CustomDropdown"); MonoBehaviour val6 = (MonoBehaviour)(object)((component is MonoBehaviour) ? component : null); if ((Object)(object)val6 != (Object)null) { try { Type type = ((object)val6).GetType(); TMP_Dropdown componentInChildren = val.GetComponentInChildren<TMP_Dropdown>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.ClearOptions(); List<OptionData> list = new List<OptionData>(); string[] array = opciones; foreach (string text in array) { list.Add(new OptionData(text)); } componentInChildren.AddOptions(list); componentInChildren.value = idxRef[0]; ((UnityEventBase)componentInChildren.onValueChanged).RemoveAllListeners(); TMP_Text capturedLabel = valLabel; ((UnityEvent<int>)(object)componentInChildren.onValueChanged).AddListener((UnityAction<int>)delegate(int idx) { idxRef[0] = idx; if ((Object)(object)capturedLabel != (Object)null) { capturedLabel.SetText(opciones[idx]); } onCambio(idx); }); ControlDoblajePlugin.Log.LogInfo((object)"[UI] DD nativo conectado via TMP_Dropdown"); TMP_Dropdown ddRef = componentInChildren; string[] opsRef = opciones; LabelsUI.RegRefresco(() => (Object)(object)ddRef != (Object)null, delegate { List<OptionData> options = ddRef.options; if (options == null) { return; } for (int i = 0; i < opsRef.Length && i < options.Count; i++) { options[i].text = opsRef[i]; } try { ddRef.RefreshShownValue(); } catch { } }); if ((Object)(object)val4 != (Object)null) { _ddNativoPorCaption[val4] = componentInChildren; } } } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[UI] DD nativo error: " + ex.Message)); } } HoverDesc(val, () => UI(labelES, labelEN), () => ""); return val; } private static void AF(TMP_Text t) { if ((Object)(object)Fuente != (Object)null) { t.font = Fuente; } } private static string UI(string es, string en) { return LabelsUI.Txt(es, en); } public static TMP_FontAsset GetFuentePublica() { return Fuente; } private static TMP_Text RegUI(TMP_Text t, string es, string en) { return LabelsUI.Reg(t, es, en); } public static void OcultarDescCanvas() { if ((Object)(object)_descCanvasGO_Pausa != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO_Pausa)) { _descCanvasGO_Pausa = null; _descTitulo_Pausa = null; _descCuerpo_Pausa = null; } if ((Object)(object)_descCanvasGO != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO)) { _descCanvasGO = null; _descTitulo = null; _descCuerpo = null; } if ((Object)(object)_descCanvasGO != (Object)null) { _descCanvasGO.SetActive(false); } if ((Object)(object)_descCanvasGO_Pausa != (Object)null) { _descCanvasGO_Pausa.SetActive(false); } if ((Object)(object)_sdtNativo != (Object)null) { _sdtNativo.text = ""; } if ((Object)(object)_sdtNativo_Pausa != (Object)null) { _sdtNativo_Pausa.text = ""; } if ((Object)(object)_panelDescNativo != (Object)null) { _panelDescNativo.SetActive(true); } if ((Object)(object)_panelDescNativo_Pausa != (Object)null) { _panelDescNativo_Pausa.SetActive(true); } } public static void MostrarDescCanvas() { if ((Object)(object)_sdtNativo != (Object)null || (Object)(object)_sdtNativo_Pausa != (Object)null) { if ((Object)(object)_sdtNativo != (Object)null) { _sdtNativo.text = ""; } if ((Object)(object)_sdtNativo_Pausa != (Object)null) { _sdtNativo_Pausa.text = ""; } return; } if ((Object)(object)_descCanvasGO_Pausa != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO_Pausa)) { _descCanvasGO_Pausa = null; _descTitulo_Pausa = null; _descCuerpo_Pausa = null; } if ((Object)(object)_descCanvasGO != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO)) { _descCanvasGO = null; _descTitulo = null; _descCuerpo = null; } if ((Object)(object)_nuestroTab_Pausa != (Object)null && ((Component)_nuestroTab_Pausa).gameObject.activeInHierarchy) { if ((Object)(object)_descCanvasGO != (Object)null) { _descCanvasGO.SetActive(false); } if ((Object)(object)_descCanvasGO_Pausa != (Object)null) { _descCanvasGO_Pausa.SetActive(true); } } else { if ((Object)(object)_descCanvasGO_Pausa != (Object)null) { _descCanvasGO_Pausa.SetActive(false); } if ((Object)(object)_descCanvasGO != (Object)null) { _descCanvasGO.SetActive(true); } } if ((Object)(object)_panelDescNativo != (Object)null) { _panelDescNativo.SetActive(false); } if ((Object)(object)_panelDescNativo_Pausa != (Object)null) { _panelDescNativo_Pausa.SetActive(false); } } public static void SincronizarDescCanvas(MonoBehaviour menuInstance) { bool flag = (Object)(object)_nuestroTab_Pausa != (Object)null && ((Component)_nuestroTab_Pausa).gameObject.activeInHierarchy; bool flag2 = (Object)(object)_nuestroTab != (Object)null && ((Component)_nuestroTab).gameObject.activeInHierarchy; if ((Object)(object)_descCanvasGO_Pausa != (Object)null) { _descCanvasGO_Pausa.SetActive(flag); } if ((Object)(object)_descCanvasGO != (Object)null) { _descCanvasGO.SetActive(flag2 && !flag); } bool flag3 = flag || flag2; if ((Object)(object)_panelDescNativo != (Object)null) { _panelDescNativo.SetActive(!flag3); } if ((Object)(object)_panelDescNativo_Pausa != (Object)null) { _panelDescNativo_Pausa.SetActive(!flag3); } } private static void SetDescActivo(string titulo, string texto) { bool flag = (Object)(object)_nuestroTab_Pausa != (Object)null && ((Component)_nuestroTab_Pausa).gameObject.activeInHierarchy; bool flag2 = !string.IsNullOrEmpty(titulo) || !string.IsNullOrEmpty(texto); TMP_Text val = (flag ? _sdtNativo_Pausa : _sdtNativo); if ((Object)(object)val != (Object)null) { val.text = (flag2 ? ("<size=120%><b>" + titulo + "</b></size>\n" + texto) : ""); return; } if (!string.IsNullOrEmpty(titulo)) { MostrarDescCanvas(); } if (flag) { if ((Object)(object)_descTitulo_Pausa != (Object)null) { _descTitulo_Pausa.SetText(titulo); } if ((Object)(object)_descCuerpo_Pausa != (Object)null) { _descCuerpo_Pausa.SetText(texto); } if ((Object)(object)_descMask_Pausa != (Object)null) { _descMask_Pausa.SetActive(flag2); } } else { if ((Object)(object)_descTitulo != (Object)null) { _descTitulo.SetText(titulo); } if ((Object)(object)_descCuerpo != (Object)null) { _descCuerpo.SetText(texto); } if ((Object)(object)_descMask != (Object)null) { _descMask.SetActive(flag2); } } } private static void LimpiarDescActivo() { if ((Object)(object)_sdtNativo != (Object)null) { _sdtNativo.text = ""; } if ((Object)(object)_sdtNativo_Pausa != (Object)null) { _sdtNativo_Pausa.text = ""; } if ((Object)(object)_descTitulo_Pausa != (Object)null) { _descTitulo_Pausa.SetText(""); } if ((Object)(object)_descCuerpo_Pausa != (Object)null) { _descCuerpo_Pausa.SetText(""); } if ((Object)(object)_descTitulo != (Object)null) { _descTitulo.SetText(""); } if ((Object)(object)_descCuerpo != (Object)null) { _descCuerpo.SetText(""); } if ((Object)(object)_descMask_Pausa != (Object)null) { _descMask_Pausa.SetActive(false); } if ((Object)(object)_descMask != (Object)null) { _descMask.SetActive(false); } } private static void CrearDescZona(Transform tabParent, Transform viewportT, bool isPausa = false) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Expected O, but got Unknown //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Expected O, but got Unknown //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Expected O, but got Unknown //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Expected O, but got Unknown //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) if (isPausa) { if ((Object)(object)_descCanvasGO_Pausa != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO_Pausa)) { _descCanvasGO_Pausa = null; } if ((Object)(object)_descCanvasGO_Pausa != (Object)null) { Object.Destroy((Object)(object)_descCanvasGO_Pausa); _descCanvasGO_Pausa = null; } _descTitulo_Pausa = null; _descCuerpo_Pausa = null; } else { if ((Object)(object)_descCanvasGO != (Object)null && !Object.op_Implicit((Object)(object)_descCanvasGO)) { _descCanvasGO = null; } if ((Object)(object)_descCanvasGO != (Object)null) { Object.Destroy((Object)(object)_descCanvasGO); _descCanvasGO = null; } _descTitulo = null; _descCuerpo = null; } float num = (isPausa ? 175f : 210f); float num2 = (isPausa ? 20f : 32f); RectTransform component = ((Component)viewportT).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { component.offsetMin = new Vector2(component.offsetMin.x, num + num2 + 20f); } GameObject val3; if (isPausa) { Canvas val = null; Transform val2 = tabParent; while ((Object)(object)val2 != (Object)null) { Canvas component2 = ((Component)val2).GetComponent<Canvas>(); if ((Object)(object)component2 != (Object)null && component2.isRootCanvas) { val = component2; break; } val2 = val2.parent; } if ((Object)(object)val != (Object)null) { val3 = new GameObject("_DescCanvas_Pausa"); val3.AddComponent<DoblejeUIMarker>(); val3.transform.SetParent(((Component)val).transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; val4.pivot = Vector2.zero; Canvas val5 = val3.AddComponent<Canvas>(); val5.overrideSorting = true; val5.sortingOrder = val.sortingOrder + 200; val3.AddComponent<GraphicRaycaster>(); ControlDoblajePlugin.Log.LogInfo((object)$"[Desc] Adjuntado a canvas raiz '{((Object)val).name}' sortingOrder={val5.sortingOrder}"); } else { val3 = new GameObject("_DescCanvas_Pausa"); val3.AddComponent<DoblejeUIMarker>(); Canvas val6 = val3.AddComponent<Canvas>(); val6.renderMode = (RenderMode)0; val6.sortingOrder = 999; val3.AddComponent<CanvasScaler>(); ControlDoblajePlugin.Log.LogInfo((object)"[Desc] Fallback: overlay independiente sortingOrder=999"); } } else { Canvas val7 = null; Transform val8 = tabParent; while ((Object)(object)val8 != (Object)null) { Canvas component3 = ((Component)val8).GetComponent<Canvas>(); if ((Object)(object)component3 != (Object)null && component3.isRootCanvas) { val7 = component3; break; } val8 = val8.parent; } if ((Object)(object)val7 != (Object)null) { val3 = new GameObject("_DescCanvas"); val3.AddComponent<DoblejeUIMarker>(); val3.transform.SetParent(((Component)val7).transform, false); RectTransform val9 = val3.AddComponent<RectTransform>(); val9.anchorMin = Vector2.zero; val9.anchorMax = Vector2.one; val9.offsetMin = Vector2.zero; val9.offsetMax = Vector2.zero; val9.pivot = Vector2.zero; Canvas val10 = val3.AddComponent<Canvas>(); val10.overrideSorting = false; val3.AddComponent<GraphicRaycaster>(); int num3 = -1; for (int i = 0; i < ((Component)val7).transform.childCount; i++) { string name = ((Object)((Component)val7).transform.GetChild(i)).name; if (name.Contains("Border") || name.Contains("border")) { num3 = i; break; } } if (num3 >= 0) { val3.transform.SetSiblingIndex(num3); } ControlDoblajePlugin.Log.LogInfo((object)$"[Desc] Adjuntado a canvas raiz main '{((Object)val7).name}' siblingIdx={val3.transform.GetSiblingIndex()} (borders={num3})"); } else { val3 = new GameObject("_DescCanvas"); val3.AddComponent<DoblejeUIMarker>(); Canvas val11 = val3.AddComponent<Canvas>(); val11.renderMode = (RenderMode)0; val11.sortingOrder = 5; val3.AddComponent<CanvasScaler>(); ControlDoblajePlugin.Log.LogInfo((object)"[Desc] Fallback overlay main sortingOrder=5"); } } GameObject val12 = new GameObject("Panel"); val12.transform.SetParent(val3.transform, false); RectTransform val13 = val12.AddComponent<RectTransform>(); val13.anchorMin = new Vector2(0f, 0f); val13.anchorMax = new Vector2(0f, 0f); val13.pivot = new Vector2(0f, 1f); val13.sizeDelta = new Vector2(900f, num); val13.anchoredPosition = new Vector2(200f, 200f); GameObject val14 = new GameObject("MascaraDesc"); val14.transform.SetParent((Transform)(object)val13, false); RectTransform val15 = val14.AddComponent<RectTransform>(); val15.anchorMin = Vector2.zero; val15.anchorMax = Vector2.one; val15.offsetMin = new Vector2(-40f, -55f); val15.offsetMax = new Vector2(40f, 55f); Image val16 = val14.AddComponent<Image>(); ((Graphic)val16).color = new Color(0.04f, 0.04f, 0.04f, 1f); ((Graphic)val16).raycastTarget = false; val14.SetActive(false); Canvas val17 = val12.AddComponent<Canvas>(); val17.overrideSorting = true; val17.sortingOrder = 32000; GameObject val18 = new GameObject("T"); val18.transform.SetParent((Transform)(object)val13, false); RectTransform val19 = val18.AddComponent<RectTransform>(); val19.anchorMin = new Vector2(0f, 0.48f); val19.anchorMax = Vector2.one; Vector2 offsetMin = (val19.offsetMax = Vector2.zero); val19.offsetMin = offsetMin; TextMeshProUGUI val20 = val18.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val20).SetText(""); ((TMP_Text)val20).fontSize = Layout.FontDescTitulo; ((Graphic)val20).color = new Color(0.95f, 0.95f, 0.95f, 1f); ((TMP_Text)val20).fontStyle = (FontStyles)1; ((TMP_Text)val20).alignment = (TextAlignmentOptions)1025; if ((Object)(object)Fuente != (Object)null) { ((TMP_Text)val20).font = Fuente; } GameObject val21 = new GameObject("B"); val21.transform.SetParent((Transform)(object)val13, false); RectTransform val22 = val21.AddComponent<RectTransform>(); val22.anchorMin = Vector2.zero; val22.anchorMax = new Vector2(1f, 0.46f); offsetMin = (val22.offsetMax = Vector2.zero); val22.offsetMin = offsetMin; TextMeshProUGUI val23 = val21.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val23).SetText(""); ((TMP_Text)val23).enableAutoSizing = true; ((TMP_Text)val23).fontSizeMin = 10f; ((TMP_Text)val23).fontSizeMax = Layout.FontDescTexto; ((TMP_Text)val23).fontSize = Layout.FontDescTexto; ((Graphic)val23).color = new Color(0.72f, 0.72f, 0.72f, 1f); ((TMP_Text)val23).alignment = (TextAlignmentOptions)257; ((TMP_Text)val23).overflowMode = (TextOverflowModes)1; if ((Object)(object)Fuente != (Object)null) { ((TMP_Text)val23).font = Fuente; } DescZonaPositioner descZonaPositioner = val3.AddComponent<DescZonaPositioner>(); descZonaPositioner.Init(tabParent, val13, num, num2, isPausa); val3.SetActive(false); if (isPausa) { _descCanvasGO_Pausa = val3; _descTitulo_Pausa = (TMP_Text)(object)val20; _descCuerpo_Pausa = (TMP_Text)(object)val23; _descMask_Pausa = val14; } else { _descCanvasGO = val3; _descTitulo = (TMP_Text)(object)val20; _descCuerpo = (TMP_Text)(object)val23; _descMask = val14; } ControlDoblajePlugin.Log.LogInfo((object)("[Desc] Canvas overlay creado" + (isPausa ? " (pausa)" : "") + ".")); } private static void SetDesc(string titulo, string texto) { SetDescActivo(titulo, texto); } private static void LimpiarDesc() { LimpiarDescActivo(); } public static void TryAgregarPestana(MonoBehaviour __instance, bool value) { //IL_0cea: Unknown result type (might be due to invalid IL or missing references) //IL_0cef: Unknown result type (might be due to invalid IL or missing references) //IL_0cf5: Expected O, but got Unknown //IL_0dac: Unknown result type (might be due to invalid IL or missing references) //IL_0db1: Unknown result type (might be due to invalid IL or missing references) //IL_0db7: Expected O, but got Unknown //IL_075f: Unknown result type (might be due to invalid IL or missing references) if (!value || ((Object)((Component)__instance).gameObject).name != "Options") { return; } _botonNativoTemplate = null; int instanceID = ((Object)((Component)__instance).gameObject).GetInstanceID(); bool flag = parcheadas.Contains(instanceID); string? fullName = ((object)__instance).GetType().FullName; bool flag2 = (fullName != null && fullName.StartsWith("LMirman")) || ((object)__instance).GetType().Assembly.GetName().Name == "LMirman.Utilities"; if (flag) { try { TabGroupInput componentInChildren = ((Component)__instance).GetComponentInChildren<TabGroupInput>(true); if (!((Object)(object)componentInChildren == (Object)null)) { object? obj = typeof(TabGroupInput).GetField("tabGroup", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(componentInChildren); TabGroup val = (TabGroup)(((obj is TabGroup) ? obj : null) ?? ((Component)__instance).GetComponentInChildren<TabGroup>(true)); if (!((Object)(object)val == (Object)null) && GetField(((object)val).GetType(), "initialItems")?.GetValue(val) is IList list) { foreach (object item in list) { Tab val2 = (Tab)((item is Tab) ? item : null); if (!((Object)(object)val2 == (Object)null)) { string text = (GetField(typeof(Tab), "key")?.GetValue(val2) as string) ?? ""; if (!(text != "doblaje")) { if (flag2) { _nuestroTab_Pausa = val2; Transform val3 = ((Component)val2).transform.Find("Viewport"); if ((Object)(object)val3 != (Object)null) { CrearDescZona(((Component)val2).transform, val3, isPausa: true); } } break; } } } return; } } return; } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[TryAgregar-reconf] " + ex.Message)); return; } } try { TabGroupInput componentInChildren2 = ((Component)__instance).GetComponentInChildren<TabGroupInput>(true); if ((Object)(object)componentInChildren2 == (Object)null) { ControlDoblajePlugin.Log.LogWarning((object)"No se encontro TabGroupInput"); return; } object? obj2 = typeof(TabGroupInput).GetField("tabGroup", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(componentInChildren2); TabGroup val4 = (TabGroup)(((obj2 is TabGroup) ? obj2 : null) ?? ((Component)__instance).GetComponentInChildren<TabGroup>(true)); if ((Object)(object)val4 == (Object)null) { ControlDoblajePlugin.Log.LogWarning((object)"tabGroup es null"); } else { if (!(GetField(((object)val4).GetType(), "initialItems")?.GetValue(val4) is IList { Count: not 0 } list2)) { return; } object? obj3 = list2[0]; Tab val5 = (Tab)((obj3 is Tab) ? obj3 : null); if ((Object)(object)val5 == (Object)null) { return; } Tab val6 = null; foreach (object item2 in list2) { Tab val7 = (Tab)((item2 is Tab) ? item2 : null); if (!((Object)(object)val7 == (Object)null)) { string text2 = (GetField(typeof(Tab), "key")?.GetValue(val7) as string) ?? ""; if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[Tab] key='" + text2 + "' name='" + ((Object)((Component)val7).gameObject).name + "'")); } if (text2 == "audio" || ((Object)((Component)val7).gameObject).name.ToLower().Contains("audio")) { val6 = val7; } } } if ((Object)(object)val6 == (Object)null) { val6 = val5; } if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[Tab] Copiando de: " + ((Object)((Component)val6).gameObject).name)); } GameObject val8 = Object.Instantiate<GameObject>(((Component)val6).gameObject, ((Component)val6).transform.parent); ((Object)val8).name = "Tab_Doblaje"; val8.SetActive(false); Tab nt = val8.GetComponent<Tab>(); if ((Object)(object)nt == (Object)null) { return; } GetField(typeof(Tab), "key")?.SetValue(nt, "doblaje"); if (flag2) { _nuestroTab_Pausa = nt; } else { _nuestroTab = nt; _nuestroTabGroup = val4; } MonoBehaviour[] componentsInChildren = val8.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val9 in componentsInChildren) { if (((object)val9).GetType().Name == "AutoScroll") { ((Behaviour)val9).enabled = false; Object.DestroyImmediate((Object)(object)val9); } } LogChildren(val8.transform, 0); PresetManager.Cargar(); Layout.CalibrateFrom(((Component)val6).transform); ConfigurarDoblaje(val8.transform, flag2); ((UIGroup<Tab>)(object)val4).ItemChanged += delegate(Tab ct) { if ((Object)(object)ct != (Object)(object)nt) { LimpiarDesc(); OcultarDescCanvas(); return; } MostrarDescCanvas(); try { AvisoActualizacion.CanvasHint = ((Component)nt).GetComponentInParent<Canvas>(); ActualizacionChecker.LanzarUnaVez(); } catch (Exception ex6) { ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] disparo tab: " + ex6.Message)); } }; GameObject panelDescNativo = null; try { Canvas componentInParent = ((Component)__instance).GetComponentInParent<Canvas>(); Transform val10 = (((Object)(object)componentInParent != (Object)null) ? ((Component)(componentInParent.isRootCanvas ? componentInParent : componentInParent.rootCanvas)).transform : ((Component)__instance).transform); Transform val11 = ((IEnumerable<Transform>)((Component)val10).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "Setting Details Text" && (Object)(object)((Component)t).GetComponent<DoblejeUIMarker>() == (Object)null)); if ((Object)(object)val11 != (Object)null) { panelDescNativo = ((Component)val11).gameObject; ControlDoblajePlugin.Log.LogInfo((object)("[Desc] Footer nativo por nombre: '" + RutaDe(val11) + "'")); } if ((Object)(object)panelDescNativo == (Object)null) { TMP_Text val12 = null; float num = 0f; TMP_Text[] componentsInChildren2 = ((Component)val10).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val13 in componentsInChildren2) { if (!((Object)(object)val13 == (Object)null) && !((Object)(object)((Component)val13).GetComponentInParent<DoblejeUIMarker>() != (Object)null) && !((Object)(object)((Component)val13).GetComponentInParent<TMP_InputField>() != (Object)null)) { RectTransform rectTransform = val13.rectTransform; Vector3[] array = (Vector3[])(object)new Vector3[4]; rectTransform.GetWorldCorners(array); float num3 = (array[0].y + array[1].y) * 0.5f; float num4 = array[3].x - array[0].x; if ((rectTransform.anchorMax.y < 0.35f || num3 < (float)Screen.height * 0.3f) && num4 > num && num4 > (float)Screen.width * 0.3f) { val12 = val13; num = num4; } } } if ((Object)(object)val12 != (Object)null) { panelDescNativo = ((Component)val12).gameObject; ControlDoblajePlugin.Log.LogInfo((object)$"[Desc] Footer nativo (heurística): '{RutaDe(val12.transform)}' (ancho={num:F0})"); } else { ControlDoblajePlugin.Log.LogWarning((object)"[Desc] Footer nativo NO encontrado — usando máscara de respaldo."); } } } catch (Exception ex2) { ControlDoblajePlugin.Log.LogWarning((object)("[Desc] Error buscando footer nativo: " + ex2.Message)); } TMP_Text val14 = (((Object)(object)panelDescNativo != (Object)null) ? panelDescNativo.GetComponent<TMP_Text>() : null); if (flag2) { _sdtNativo_Pausa = val14; } else { _sdtNativo = val14; } if ((Object)(object)val14 != (Object)null) { panelDescNativo = null; } if (flag2) { _panelDescNativo_Pausa = panelDescNativo; } else { _panelDescNativo = panelDescNativo; } TabActiveMonitor tabActiveMonitor = val8.AddComponent<TabActiveMonitor>(); tabActiveMonitor.Init(delegate { if ((Object)(object)panelDescNativo != (Object)null) { panelDescNativo.SetActive(false); } MostrarDescCanvas(); }, delegate { LimpiarDesc(); OcultarDescCanvas(); if ((Object)(object)panelDescNativo != (Object)null) { panelDescNativo.SetActive(true); } }, panelDescNativo); FieldInfo field = GetField(((object)val4).GetType(), "items"); FieldInfo field2 = GetField(((object)val4).GetType(), "itemLookup"); IList list3 = field?.GetValue(val4) as IList; object obj4 = field2?.GetValue(val4); Transform val15 = ((Component)__instance).transform.Find("Tab Buttons"); object obj5; if (val15 == null) { obj5 = null; } else { Transform obj6 = val15.Find("Tab Button - Audio"); obj5 = ((obj6 != null) ? ((Component)obj6).gameObject : null); } GameObject val16 = (GameObject)obj5; int num5 = list2.IndexOf(val6); if (num5 >= 0) { list2.Insert(num5 + 1, nt); } else { list2.Add(nt); } ControlDoblajePlugin.Log.LogInfo((object)$"[TabNav] nt insertado en initialItems idx={((num5 >= 0) ? (num5 + 1) : (list2.Count - 1))} (audio={num5}, total={list2.Count})"); if (list3 != null && list3.Count > 0 && !list3.Contains(nt)) { int num6 = list3.IndexOf(val6); if (num6 >= 0) { list3.Insert(num6 + 1, nt); } else { list3.Add(nt); } try { ((object)val4).GetType().GetMethod("RebuildLookup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val4, null); ((object)val4).GetType().GetMethod("UpdateIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val4, null); ControlDoblajePlugin.Log.LogInfo((object)$"[TabNav] items ya poblado — insertado también en items idx={num6 + 1} + RebuildLookup/UpdateIndex"); } catch (Exception ex3) { ControlDoblajePlugin.Log.LogWarning((object)("[TabNav] RebuildLookup/UpdateIndex: " + ex3.Message)); } } if ((Object)(object)val15 != (Object)null && (Object)(object)val16 != (Object)null) { GameObject val17 = Object.Instantiate<GameObject>(val16, val15); ((Object)val17).name = "Tab Button - Turronish"; val17.AddComponent<DoblejeUIMarker>(); TMP_Text[] componentsInChildren3 = val17.GetComponentsInChildren<TMP_Text>(); foreach (TMP_Text val18 in componentsInChildren3) { val18.SetText("Turronish"); } TabButton tbtn = val17.GetComponent<TabButton>(); if ((Object)(object)tbtn != (Object)null) { GetField(typeof(TabButton), "tab")?.SetValue(tbtn, nt); GetField(typeof(TabButton), "tabGroup")?.SetValue(tbtn, val4); ((UIGroup<Tab>)(object)val4).ItemChanged += delegate(Tab ct) { typeof(TabButton).GetMethod("SetIsActive", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(tbtn, new object[1] { (Object)(object)ct == (Object)(object)nt }); }; } val17.transform.SetSiblingIndex(val16.transform.GetSiblingIndex() + 1); } try { Button[] array2 = Resources.FindObjectsOfTypeAll<Button>(); Button[] array3 = array2; foreach (Button val19 in array3) { if ((Object)(object)((Component)val19).GetComponent<DoblejeUIMarker>() != (Object)null) { continue; } TMP_Text componentInChildren3 = ((Component)val19).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren3 == (Object)null) { continue; } string input = componentInChildren3.text ?? ""; string text3 = Regex.Replace(input, "<[^>]*>", "").Trim().ToLower(); if (text3.Contains("guardar") || text3.Contains("save") || text3.Contains("apply") || text3.Contains("aceptar")) { ButtonClickedEvent onClick = val19.onClick; object obj7 = <>c.<>9__79_6; if (obj7 == null) { UnityAction val20 = delegate { try { ControlDoblajePlugin.GuardarConfig(); } catch (Exception ex6) { ManualLogSource log = ControlDoblajePlugin.Log; if (log != null) { log.LogWarning((object)("[Pref] Save hook: " + ex6.Message)); } } }; <>c.<>9__79_6 = val20; obj7 = (object)val20; } ((UnityEvent)onClick).AddListener((UnityAction)obj7); ControlDoblajePlugin.Log.LogInfo((object)("[Pref] Hooked SAVE button: " + ((Object)val19).name + " '" + componentInChildren3.text + "'")); } else { if (!text3.Contains("descartar") && !text3.Contains("discard") && !text3.Contains("revert") && !text3.Contains("cancel") && !text3.Contains("cancelar")) { continue; } ButtonClickedEvent onClick2 = val19.onClick; object obj8 = <>c.<>9__79_7; if (obj8 == null) { UnityAction val21 = delegate { try { typeof(ControlDoblajePlugin).GetMethod("CargarConfig", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(ControlDoblajePlugin.Instance, null); if ((Object)(object)_configParent != (Object)null) { ConfigRebuildHelper.Schedule(_configParent, _configIsPausa); } } catch (Exception ex6) { ManualLogSource log = ControlDoblajePlugin.Log; if (log != null) { log.LogWarning((object)("[Pref] Discard hook: " + ex6.Message)); } } }; <>c.<>9__79_7 = val21; obj8 = (object)val21; } ((UnityEvent)onClick2).AddListener((UnityAction)obj8); ControlDoblajePlugin.Log.LogInfo((object)("[Pref] Hooked DISCARD button: " + ((Object)val19).name + " '" + componentInChildren3.text + "'")); } } } catch (Exception ex4) { ControlDoblajePlugin.Log.LogWarning((object)("[Pref] Hook buttons error: " + ex4.Message)); } parcheadas.Add(instanceID); ControlDoblajePlugin.Log.LogInfo((object)$"Pestana Doblaje agregada (id={instanceID})"); } } catch (Exception ex5) { ControlDoblajePlugin.Log.LogError((object)("Error: " + ex5.Message + "\n" + ex5.StackTrace)); } static string RutaDe(Transform t) { StringBuilder stringBuilder = new StringBuilder(((Object)t).name); Transform parent = t.parent; int num9 = 0; while ((Object)(object)parent != (Object)null && num9++ < 7) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } private static void LogChildren(Transform t, int depth) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown string text = new string(' ', depth * 2); ControlDoblajePlugin.Log.LogInfo((object)(text + "[" + ((Object)t).name + "]")); RectTransform component = ((Component)t).GetComponent<RectTransform>(); TMP_Text component2 = ((Component)t).GetComponent<TMP_Text>(); if ((Object)(object)component2 != (Object)null) { ControlDoblajePlugin.Log.LogInfo((object)$"{text} TMP fs={component2.fontSize} txt='{component2.text}'"); } if (depth >= 3) { return; } foreach (Transform item in t) { Transform t2 = item; LogChildren(t2, depth + 1); } } public static void ConfigurarDoblaje(Transform parent, bool isPausa = false) { //IL_2333: Unknown result type (might be due to invalid IL or missing references) //IL_223f: Unknown result type (might be due to invalid IL or missing references) //IL_245c: Unknown result type (might be due to invalid IL or missing references) //IL_2463: Expected O, but got Unknown //IL_2483: Unknown result type (might be due to invalid IL or missing references) //IL_2490: Unknown result type (might be due to invalid IL or missing references) //IL_249f: Unknown result type (might be due to invalid IL or missing references) //IL_24a4: Unknown result type (might be due to invalid IL or missing references) //IL_24a5: Unknown result type (might be due to invalid IL or missing references) //IL_24ad: Unknown result type (might be due to invalid IL or missing references) //IL_24c0: Unknown result type (might be due to invalid IL or missing references) //IL_24f2: Unknown result type (might be due to invalid IL or missing references) //IL_250b: Unknown result type (might be due to invalid IL or missing references) //IL_2524: Unknown result type (might be due to invalid IL or missing references) //IL_2529: Unknown result type (might be due to invalid IL or missing references) //IL_254f: Unknown result type (might be due to invalid IL or missing references) //IL_2554: Unknown result type (might be due to invalid IL or missing references) //IL_255a: Expected O, but got Unknown //IL_2292: Unknown result type (might be due to invalid IL or missing references) //IL_22c6: Unknown result type (might be due to invalid IL or missing references) //IL_2613: Unknown result type (might be due to invalid IL or missing references) //IL_261a: Expected O, but got Unknown //IL_2665: Unknown result type (might be due to invalid IL or missing references) //IL_26a4: Unknown result type (might be due to invalid IL or missing references) //IL_26ab: Expected O, but got Unknown //IL_2706: Unknown result type (might be due to invalid IL or missing references) //IL_2736: Unknown result type (might be due to invalid IL or missing references) //IL_273d: Expected O, but got Unknown //IL_277e: Unknown result type (might be due to invalid IL or missing references) //IL_2788: Expected O, but got Unknown //IL_27d3: Unknown result type (might be due to invalid IL or missing references) //IL_27da: Expected O, but got Unknown //IL_281b: Unknown result type (might be due to invalid IL or missing references) //IL_2825: Expected O, but got Unknown //IL_25c2: Unknown result type (might be due to invalid IL or missing references) //IL_25d1: Unknown result type (might be due to invalid IL or missing references) //IL_2975: Unknown result type (might be due to invalid IL or missing references) //IL_299d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_29c5: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_08d2: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Expected O, but got Unknown //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0ea5: Unknown result type (might be due to invalid IL or missing references) //IL_0eac: Expected O, but got Unknown //IL_0ebd: Unknown result type (might be due to invalid IL or missing references) //IL_108d: Unknown result type (might be due to invalid IL or missing references) //IL_1094: Expected O, but got Unknown //IL_10b7: Unknown result type (might be due to invalid IL or missing references) //IL_0f4d: Unknown result type (might be due to invalid IL or missing references) //IL_0f54: Expected O, but got Unknown //IL_0f7e: Unknown result type (might be due to invalid IL or missing references) //IL_0f95: Unknown result type (might be due to invalid IL or missing references) //IL_0fac: Unknown result type (might be due to invalid IL or missing references) //IL_0fc3: Unknown result type (might be due to invalid IL or missing references) //IL_0fd5: Unknown result type (might be due to invalid IL or missing references) //IL_1371: Unknown result type (might be due to invalid IL or missing references) //IL_1103: Unknown result type (might be due to invalid IL or missing references) //IL_110a: Expected O, but got Unknown //IL_111b: Unknown result type (might be due to invalid IL or missing references) //IL_1435: Unknown result type (might be due to invalid IL or missing references) //IL_143c: Expected O, but got Unknown //IL_148d: Unknown result type (might be due to invalid IL or missing references) //IL_14fe: Unknown result type (might be due to invalid IL or missing references) //IL_11f0: Unknown result type (might be due to invalid IL or missing references) //IL_11f7: Expected O, but got Unknown //IL_1221: Unknown result type (might be due to invalid IL or missing references) //IL_1238: Unknown result type (might be due to invalid IL or missing references) //IL_124f: Unknown result type (might be due to invalid IL or missing references) //IL_1266: Unknown result type (might be due to invalid IL or missing references) //IL_1278: Unknown result type (might be due to invalid IL or missing references) //IL_15d4: Unknown result type (might be due to invalid IL or missing references) //IL_15db: Expected O, but got Unknown //IL_162c: Unknown result type (might be due to invalid IL or missing references) //IL_169d: Unknown result type (might be due to invalid IL or missing references) //IL_1728: Unknown result type (might be due to invalid IL or missing references) //IL_172f: Expected O, but got Unknown //IL_1780: Unknown result type (might be due to invalid IL or missing references) //IL_1944: Unknown result type (might be due to invalid IL or missing references) //IL_194b: Expected O, but got Unknown //IL_195a: Unknown result type (might be due to invalid IL or missing references) //IL_196a: Unknown result type (might be due to invalid IL or missing references) //IL_1971: Expected O, but got Unknown //IL_1991: Unknown result type (might be due to invalid IL or missing references) //IL_199e: Unknown result type (might be due to invalid IL or missing references) //IL_19ad: Unknown result type (might be due to invalid IL or missing references) //IL_19b2: Unknown result type (might be due to invalid IL or missing references) //IL_19b3: Unknown result type (might be due to invalid IL or missing references) //IL_19bb: Unknown result type (might be due to invalid IL or missing references) //IL_19f2: Unknown result type (might be due to invalid IL or missing references) //IL_1842: Unknown result type (might be due to invalid IL or missing references) //IL_1aaf: Unknown result type (might be due to invalid IL or missing references) //IL_1ab6: Expected O, but got Unknown //IL_1ad6: Unknown result type (might be due to invalid IL or missing references) //IL_1ae3: Unknown result type (might be due to invalid IL or missing references) //IL_1af2: Unknown result type (might be due to invalid IL or missing references) //IL_1af7: Unknown result type (might be due to invalid IL or missing references) //IL_1af8: Unknown result type (might be due to invalid IL or missing references) //IL_1b00: Unknown result type (might be due to invalid IL or missing references) //IL_1b13: Unknown result type (might be due to invalid IL or missing references) //IL_1b45: Unknown result type (might be due to invalid IL or missing references) //IL_1b5e: Unknown result type (might be due to invalid IL or missing references) //IL_1b77: Unknown result type (might be due to invalid IL or missing references) //IL_1b7c: Unknown result type (might be due to invalid IL or missing references) //IL_1b96: Unknown result type (might be due to invalid IL or missing references) //IL_1ba0: Expected O, but got Unknown //IL_1a7c: Unknown result type (might be due to invalid IL or missing references) //IL_1a8b: Unknown result type (might be due to invalid IL or missing references) //IL_18ac: Unknown result type (might be due to invalid IL or missing references) //IL_1c03: Unknown result type (might be due to invalid IL or missing references) //IL_1c12: Unknown result type (might be due to invalid IL or missing references) //IL_204a: Unknown result type (might be due to invalid IL or missing references) //IL_2051: Expected O, but got Unknown //IL_20a2: Unknown result type (might be due to invalid IL or missing references) //IL_2362: Unknown result type (might be due to invalid IL or missing references) //IL_2369: Expected O, but got Unknown //IL_237c: Unknown result type (might be due to invalid IL or missing references) //IL_2392: Unknown result type (might be due to invalid IL or missing references) //IL_2399: Expected O, but got Unknown //IL_23b9: Unknown result type (might be due to invalid IL or missing references) //IL_23c6: Unknown result type (might be due to invalid IL or missing references) //IL_23d5: Unknown result type (might be due to invalid IL or missing references) //IL_23da: Unknown result type (might be due to invalid IL or missing references) //IL_23db: Unknown result type (might be due to invalid IL or missing references) //IL_23e3: Unknown result type (might be due to invalid IL or missing references) //IL_241a: Unknown result type (might be due to invalid IL or missing references) //IL_216c: Unknown result type (might be due to invalid IL or missing references) //IL_21c1: Unknown result type (might be due to invalid IL or missing references) //IL_21cb: Expected O, but got Unknown Transform val = parent.Find("Viewport"); ScrollRect componentInChildren = ((Component)parent).GetComponentInChildren<ScrollRect>(true); if ((Object)(object)val == (Object)null) { ControlDoblajePlugin.Log.LogError((object)"[Doblaje] No se encontro Viewport."); return; } if ((Object)(object)((componentInChildren != null) ? componentInChildren.viewport : null) != (Object)null && (Object)(object)componentInChildren.viewport != (Object)(object)val) { RectMask2D component = ((Component)componentInChildren.viewport).GetComponent<RectMask2D>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } Transform val2 = parent; while ((Object)(object)val2 != (Object)null) { RectMask2D component2 = ((Component)val2).GetComponent<RectMask2D>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } if ((Object)(object)((Component)val2).GetComponent<Canvas>() != (Object)null) { break; } val2 = val2.parent; } CrearDescZona(parent, val, isPausa); Transform contentT = (Transform)(object)((componentInChildren != null) ? componentInChildren.content : null); if ((Object)(object)contentT == (Object)null) { contentT = val.Find("Content") ?? ((val.childCount > 0) ? val.GetChild(0) : null); } if ((Object)(object)contentT == (Object)null) { ControlDoblajePlugin.Log.LogError((object)"[Doblaje] No se encontro Content."); return; } List<GameObject> list = new List<GameObject>(); foreach (Transform item in contentT) { Transform val3 = item; list.Add(((Component)val3).gameObject); } foreach (GameObject item2 in list) { Object.DestroyImmediate((Object)(object)item2); } VerticalLayoutGroup component3 = ((Component)contentT).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } ContentSizeFitter component4 = ((Component)contentT).GetComponent<ContentSizeFitter>(); if ((Object)(object)component4 != (Object)null) { Object.DestroyImmediate((Object)(object)component4); } RectTransform contentRT = ((Component)contentT).GetComponent<RectTransform>(); if ((Object)(object)contentRT != (Object)null) { contentRT.anchorMin = new Vector2(0f, 1f); contentRT.anchorMax = new Vector2(1f, 1f); contentRT.pivot = new Vector2(0.5f, 1f); contentRT.offsetMin = Vector2.zero; contentRT.offsetMax = Vector2.zero; } if ((Object)(object)((Component)contentT).GetComponent<DoblejeUIMarker>() == (Object)null) { ((Component)contentT).gameObject.AddComponent<DoblejeUIMarker>(); } if (isPausa) { Canvas val4 = ((Component)parent).GetComponentInParent<Canvas>(); while ((Object)(object)val4 != (Object)null && !val4.isRootCanvas) { Transform parent2 = ((Component)val4).transform.parent; val4 = ((parent2 != null) ? ((Component)parent2).GetComponentInParent<Canvas>() : null); } if ((Object)(object)val4 != (Object)null) { float num = ((val4.scaleFactor > 0f) ? val4.scaleFactor : 1f); float num2 = 1f / num; if (Mathf.Abs(num2 - 1f) > 0.05f) { contentT.localScale = new Vector3(num2, num2, 1f); ControlDoblajePlugin.Log.LogInfo((object)$"[Pausa] scaleFactor={num:F3} → content.localScale={num2:F3}"); } } } GameObject val5 = new GameObject("_Popup"); val5.transform.SetParent(parent, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; Vector2 offsetMin = (val6.offsetMax = Vector2.zero); val6.offsetMin = offsetMin; Canvas val7 = val5.AddComponent<Canvas>(); val7.overrideSorting = true; val7.sortingOrder = 500; val5.AddComponent<GraphicRaycaster>(); val5.SetActive(false); val5.transform.SetAsLastSibling(); List<string> personajes = ControlDoblajePlugin.PersonajesDisponibles; int[] idxTexto = new int[1] { (!Traducciones.TextoEspanolActivo) ? 1 : 0 }; int[][] idxAud = new int[personajes.Count][]; for (int i = 0; i < idxAud.Length; i++) { bool value; bool flag = ControlDoblajePlugin.PersonajeActivo.TryGetValue(personajes[i], out value) && value; idxAud[i] = new int[1] { (!flag) ? 1 : 0 }; } TMP_Text lblIdiomaVivo = null; TMP_Text lblTextoVivo = null; TMP_Text lblVCVivo = null; TMP_Text lblIMVivo = null; TMP_Text lblM3DVivo = null; int[] idxVC = new int[1] { (!ControlDoblajePlugin.VideoClipsActivo) ? 1 : 0 }; int[] idxIM = new int[1] { (!ControlDoblajePlugin.ImagenesActivas) ? 1 : 0 }; int[] idxM3D = new int[1] { (!ControlDoblajePlugin.ModelosActivos) ? 1 : 0 }; TMP_Text[] lblsAudVivos = (TMP_Text[])(object)new TMP_Text[personajes.Count]; string[] opIdioma = new string[3]; string[] opTexto = new string[2]; string[] opAudio = new string[2]; List<string[]> charOpArrays = new List<string[]>(personajes.Count); for (int j = 0; j < personajes.Count; j++) { charOpArrays.Add(new string[2] { "", "" }); } ActualizarOpciones(); Action refrescarTab = delegate { ActualizarOpciones(); _actualizarIdiomaLabel?.Invoke(); if ((Object)(object)lblTextoVivo != (Object)null) { lblTextoVivo.SetText(opTexto[idxTexto[0]]); } if ((Object)(object)lblVCVivo != (Object)null) { lblVCVivo.SetText(opTexto[idxVC[0]]); } if ((Object)(object)lblIMVivo != (Object)null) { lblIMVivo.SetText(opTexto[idxIM[0]]); } if ((Object)(object)lblM3DVivo != (Object)null) { lblM3DVivo.SetText(opTexto[idxM3D[0]]); } for (int k = 0; k < lblsAudVivos.Length; k++) { if ((Object)(object)lblsAudVivos[k] != (Object)null) { string[] array4 = ((k < charOpArrays.Count) ? charOpArrays[k] : opAudio); lblsAudVivos[k].SetText(array4[idxAud[k][0]]); } } }; Traducciones.OnIdiomaChanged = null; Traducciones.OnIdiomaChanged = (Action)Delegate.Combine(Traducciones.OnIdiomaChanged, (Action)delegate { refrescarTab(); }); LabelsUI.RegRefresco(() => (Object)(object)lblTextoVivo != (Object)null, refrescarTab); float y = -8f; float anchoDropdownNormal = Layout.AnchoDropdownNormal; float anchoEtiqueta = Layout.AnchoEtiqueta; float anchoDropdownGrid = Layout.AnchoDropdownGrid; float anchoEtiquetaGrid = Layout.AnchoEtiquetaGrid; float anchoDropdownPreset = Layout.AnchoDropdownPreset; float anchoBoton = Layout.AnchoBoton; float anchoInput = Layout.AnchoInput; float anchoBotonBorrar = Layout.AnchoBotonBorrar; if (isPausa) { Layout.AnchoDropdownNormal = anchoDropdownNormal * 0.7f; Layout.AnchoEtiqueta = anchoEtiqueta * 0.8f; Layout.AnchoDropdownGrid = anchoDropdownGrid * 0.7f; Layout.AnchoEtiquetaGrid = anchoEtiquetaGrid * 0.8f; Layout.AnchoDropdownPreset = anchoDropdownPreset * 0.7f; Layout.AnchoBoton = anchoBoton * 0.7f; Layout.AnchoInput = anchoInput * 0.7f; Layout.AnchoBotonBorrar = anchoBotonBorrar * 0.7f; ControlDoblajePlugin.Log.LogInfo((object)$"[Pausa] Layout escalado SP={0.7f} SE={0.8f}"); } _solClipRT = null; _mulClipRT = null; _cabClipRT = null; _solGridH = 0f; _mulGridH = 0f; _cabGridH = 0f; _belowSolRTs.Clear(); _belowMulRTs.Clear(); _belowCabRTs.Clear(); _mainContentRT = contentRT; bool _tSol = false; bool _tMul = false; bool _tCab = false; (string, string) value2; bool flag2 = Traducciones.TextoEspanolActivo && personajes.Count > 0 && personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && value2); int[] array = new int[1] { (!flag2) ? 1 : 0 }; AddRow(CabeceraGO("IDIOMA GENERAL", "GENERAL LANGUAGE"), Layout.AltoCabecera); TMP_Text valLabel; GameObject go = FilaDDGO("Idioma general", "General language", opIdioma, array, val5, val6, out valLabel, "Idioma general", "General language", "Cambia el idioma del juego completamente.", "Switches the game language completely.", delegate(int idx) { if (idx != 2) { bool flag3 = idx == 0; bool textoEspanolActivo = Traducciones.TextoEspanolActivo; foreach (string item3 in personajes) { ControlDoblajePlugin.PersonajeActivo[item3] = flag3; } idxTexto[0] = idx; idxVC[0] = idx; idxIM[0] = idx; idxM3D[0] = idx; FijarSeleccionDD(lblTextoVivo, idx, opTexto); FijarSeleccionDD(lblVCVivo, idx, opTexto); FijarSeleccionDD(lblIMVivo, idx, opTexto); FijarSeleccionDD(lblM3DVivo, idx, opTexto); for (int k = 0; k < lblsAudVivos.Length; k++) { idxAud[k][0] = idx; if ((Object)(object)lblsAudVivos[k] != (Object)null) { string[] array4 = ((k < charOpArrays.Count) ? charOpArrays[k] : opAudio); lblsAudVivos[k].SetText(array4[idx]); } } ControlDoblajePlugin.VideoClipsActivo = flag3; ControlDoblajePlugin.ImagenesActivas = flag3; ControlDoblajePlugin.ModelosActivos = flag3; SpriteReemplazador.ReScanearTodosLosSprites(); if (!flag3) { ControlDoblajePlugin.WandererRadioMute?.Invoke(obj: true); } else { ControlDoblajePlugin.WandererRadioMute?.Invoke(obj: false); } if (flag3 && !textoEspanolActivo) { Traducciones.ActivarYAplicar(); } else if (!flag3 && textoEspanolActivo) { Traducciones.DesactivarYRevertir(); } ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } }); lblIdiomaVivo = valLabel; int[] captIdxIdioma = array; (_actualizarIdiomaLabel = delegate { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)lblIdiomaVivo == (Object)null)) { ActualizarOpciones(); bool flag3 = ControlDoblajePlugin.VideoClipsActivo && ControlDoblajePlugin.ImagenesActivas && ControlDoblajePlugin.ModelosActivos && Traducciones.TextoEspanolActivo && personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && value2); bool flag4 = !ControlDoblajePlugin.VideoClipsActivo && !ControlDoblajePlugin.ImagenesActivas && !ControlDoblajePlugin.ModelosActivos && !Traducciones.TextoEspanolActivo && personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && !value2); if (flag3) { captIdxIdioma[0] = 0; lblIdiomaVivo.SetText(opIdioma[0]); ((Graphic)lblIdiomaVivo).color = cBlanco; } else if (flag4) { captIdxIdioma[0] = 1; lblIdiomaVivo.SetText(opIdioma[1]); ((Graphic)lblIdiomaVivo).color = cBlanco; } else { captIdxIdioma[0] = 2; lblIdiomaVivo.SetText(opIdioma[2]); ((Graphic)lblIdiomaVivo).color = new Color(0.8f, 0.8f, 0.4f, 1f); } } })(); AddRow(go, Layout.AltoFila); AddSpace(4f); GameObject val8 = new GameObject("Desc_Presets"); val8.AddComponent<RectTransform>(); TextMeshProUGUI val9 = val8.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val9).SetText(UI("Guarda tu configuracion actual como preajuste o carga uno guardado.", "Save your current config as a preset or load a saved one.")); ((TMP_Text)val9).fontSize = Layout.FontEtiqueta * 0.88f; ((Graphic)val9).color = new Color(0.75f, 0.75f, 0.75f, 1f); ((TMP_Text)val9).alignment = (TextAlignmentOptions)514; AF((TMP_Text)(object)val9); RegUI((TMP_Text)(object)val9, "Guarda tu configuracion actual como preajuste o carga uno guardado.", "Save your current config as a preset or load a saved one."); AddRow(val8, Layout.AltoFila * 0.55f); AddRow(FilaPreajustesGO(val5, val6, () => lblIdiomaVivo, () => lblTextoVivo, () => lblsAudVivos, () => lblVCVivo, () => lblIMVivo, () => lblM3DVivo, idxTexto, idxVC, idxIM, idxM3D, idxAud, personajes, opIdioma, opTexto, opAudio, charOpArrays), Layout.AltoFila); AddSpace(8f); AddRow(CabeceraGO("TRADUCCION VISUAL", "VISUAL TRANSLATION"), Layout.AltoCabecera); TMP_Text valLabel2; GameObject go2 = FilaDDGO("Textos", "Texts", opTexto, idxTexto, val5, val6, out valLabel2, "Textos", "Texts", "Cambia solo el idioma de dialogos y textos.", "Changes only dialogue and text language.", delegate(int idx) { bool textoEspanolActivo = Traducciones.TextoEspanolActivo; if (idx == 0 && !textoEspanolActivo) { Traducciones.ActivarYAplicar(); } else if (idx != 0 && textoEspanolActivo) { Traducciones.DesactivarYRevertir(); } ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); }); lblTextoVivo = valLabel2; AddRow(go2, Layout.AltoFila); TMP_Text valLabel3; GameObject go3 = FilaDDGO("VideoClips", "Video Clips", opTexto, idxVC, val5, val6, out valLabel3, "VideoClips", "Video Clips", "Reemplaza los videos del juego por versiones en español.\n<color=#FFD24A>Nota: el cambio no se aplica hasta reiniciar la escena.</color>", "Replaces game videos with Spanish versions.\n<color=#FFD24A>Note: the change won't apply until the scene reloads.</color>", delegate(int idx) { ControlDoblajePlugin.VideoClipsActivo = idx == 0; ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); }); lblVCVivo = valLabel3; AddRow(go3, Layout.AltoFila); TMP_Text valLabel4; GameObject go4 = FilaDDGO("Imagenes", "Images", opTexto, idxIM, val5, val6, out valLabel4, "Imagenes", "Images", "Reemplaza las imagenes del juego por versiones en español.", "Replaces game images with Spanish versions.", delegate(int idx) { ControlDoblajePlugin.ImagenesActivas = idx == 0; SpriteReemplazador.ReScanearTodosLosSprites(); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); }); lblIMVivo = valLabel4; AddRow(go4, Layout.AltoFila); TMP_Text valLabel5; GameObject go5 = FilaDDGO("Modelos3D", "3D Models", opTexto, idxM3D, val5, val6, out valLabel5, "Modelos 3D", "3D Models", "Reemplaza los modelos 3D del juego por versiones en Turronish.\n<color=#FFD24A>Nota: algunos cambios no se aplican hasta reiniciar el juego.</color>", "Replaces game 3D models with Turronish versions.\n<color=#FFD24A>Note: some changes won't take effect until you restart the game.</color>", delegate(int idx) { bool flag3 = (ControlDoblajePlugin.ModelosActivos = idx == 0); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); if (flag3) { ControlDoblajePlugin.ModelosAplicar?.Invoke(); } else { ControlDoblajePlugin.ModelosRestaurar?.Invoke(); } }); lblM3DVivo = valLabel5; AddRow(go5, Layout.AltoFila); _configParent = parent; _configIsPausa = isPausa; AddSpace(8f); AddRow(CabeceraGO("AUDIO POR PERSONAJE", "AUDIO PER CHARACTER"), Layout.AltoCabecera); int[][] captIdxAud = idxAud; List<string> captPersonajes = personajes; TMP_Text[] captLbls = lblsAudVivos; string[] captOpAudio = opAudio; List<string[]> captCharOps = charOpArrays; Random captRng = new Random(); (string a, string b, string disES, string disEN)[] _paresVinc = new(string, string, string, string)[3] { ("Dratula", "Froggy", "⚠ Dratula y Froggy comparten pista de audio: el soporte es unicamente con su audio original. Cambiar uno al idioma original actualizara al otro automaticamente.", "⚠ Dratula and Froggy share an audio track: support is only available in their original audio. Switching one to the original language will update the other automatically."), ("CoralGlasses", "TaskiMaiden", "⚠ CoralGlasses y TaskiMaiden comparten pista de audio: el soporte es unicamente con su audio original. Cambiar uno al idioma original actualizara al otro automaticamente.", "⚠ CoralGlasses and TaskiMaiden share an audio track: support is only available in their original audio. Switching one to the original language will update the other automatically."), ("Shaman", "Salespersone", "⚠ Shaman y ENA Sales comparten pista de audio: el soporte es unicamente con su audio original. Cambiar uno al idioma original actualizara al otro automaticamente.", "⚠ Shaman and ENA Sales share an audio track: support is only available in their original audio. Switching one to the original language will update the other automatically.") }; GameObject val10 = CrearHeaderCapitulo("LA PUERTA SOLITARIA", "THE LONELY DOOR", _secSolitariaAbierta, delegate { _secSolitariaAbierta = !_secSolitariaAbierta; ChapterAnimHelper.ToggleSol(); }, "Despliega la lista de personajes de <style=Door>La puerta solitaria</style>.", "Expand the character list for <style=Door>The Lonely Door</style>."); _solArrowT = val10.transform.Find("Arrow"); AddRow(val10, Layout.AltoCabecera); float cy = 0f; RectTransform solClip = MakeClip("Clip_Solitaria"); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); (string, string, string, string)[] array2 = _paresVinc; for (int num3 = 0; num3 < array2.Length; num3++) { (string, string, string, string) tuple = array2[num3]; hashSet.Add(tuple.Item1); hashSet.Add(tuple.Item2); } List<int> list2 = new List<int>(); for (int num4 = 0; num4 < personajes.Count; num4++) { if (!hashSet.Contains(personajes[num4])) { list2.Add(num4); } } List<int> list3 = new List<int>(); (string, string, string, string)[] array3 = _paresVinc; for (int num5 = 0; num5 < array3.Length; num5++) { (string, string, string, string) tuple2 = array3[num5]; int num6 = personajes.IndexOf(tuple2.Item1); if (num6 >= 0) { list3.Add(num6); } int num7 = personajes.IndexOf(tuple2.Item2); if (num7 >= 0) { list3.Add(num7); } } for (int num8 = 0; num8 < list2.Count; num8 += 2) { int num9 = list2[num8]; GameObject val11 = new GameObject($"FD_R{num8}"); val11.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, Layout.AltoFilaGrid); CeldaPersonajeEnGrid(val11.transform, personajes[num9], idxAud[num9], val5, val6, (num9 < charOpArrays.Count) ? charOpArrays[num9] : opAudio, out var valLabel6, leftSide: true); lblsAudVivos[num9] = valLabel6; if (num8 + 1 < list2.Count) { int num10 = list2[num8 + 1]; GameObject val12 = new GameObject("Sep"); val12.transform.SetParent(val11.transform, false); RectTransform val13 = val12.AddComponent<RectTransform>(); val13.anchorMin = new Vector2(0.5f, 0f); val13.anchorMax = new Vector2(0.5f, 1f); val13.offsetMin = new Vector2(-1f, 4f); val13.offsetMax = new Vector2(1f, -4f); ((Graphic)val12.AddComponent<Image>()).color = cSep; CeldaPersonajeEnGrid(val11.transform, personajes[num10], idxAud[num10], val5, val6, (num10 < charOpArrays.Count) ? charOpArrays[num10] : opAudio, out var valLabel7, leftSide: false); lblsAudVivos[num10] = valLabel7; } ARS(val11, Layout.AltoFilaGrid); } if (list3.Count > 0) { ASS(6f); GameObject val14 = new GameObject("HSep"); val14.AddComponent<RectTransform>(); ((Graphic)val14.AddComponent<Image>()).color = new Color(0.35f, 0.35f, 0.35f, 0.6f); ARS(val14, 2f); ASS(4f); for (int num11 = 0; num11 < list3.Count; num11 += 2) { int num12 = list3[num11]; GameObject val15 = new GameObject($"FD_L{num11}"); val15.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, Layout.AltoFilaGrid); string text = personajes[num12]; var (partName, partPi, enlaceDescES, enlaceDescEN) = FindPartnerInfo(text); CeldaPersonajeEnGrid(val15.transform, text, idxAud[num12], val5, val6, (num12 < charOpArrays.Count) ? charOpArrays[num12] : opAudio, out var valLabel8, leftSide: true, MakeSyncAction(partPi, partName), enlaceDescES, enlaceDescEN); lblsAudVivos[num12] = valLabel8; string text2 = null; string text3 = null; int num13 = -1; string text4 = null; string text5 = null; if (num11 + 1 < list3.Count) { int num14 = list3[num11 + 1]; GameObject val16 = new GameObject("Sep"); val16.transform.SetParent(val15.transform, false); RectTransform val17 = val16.AddComponent<RectTransform>(); val17.anchorMin = new Vector2(0.5f, 0f); val17.anchorMax = new Vector2(0.5f, 1f); val17.offsetMin = new Vector2(-1f, 4f); val17.offsetMax = new Vector2(1f, -4f); ((Graphic)val16.AddComponent<Image>()).color = cSep; text2 = personajes[num14]; (text3, num13, text4, text5) = FindPartnerInfo(text2); CeldaPersonajeEnGrid(val15.transform, text2, idxAud[num14], val5, val6, (num14 < charOpArrays.Count) ? charOpArrays[num14] : opAudio, out var valLabel9, leftSide: false, MakeSyncAction(num13, text3), text4, text5); lblsAudVivos[num14] = valLabel9; } ARS(val15, Layout.AltoFilaGrid); } } _solGridH = 0f - cy; float num15 = (_secSolitariaAbierta ? _solGridH : 0f); solClip.sizeDelta = new Vector2(0f, num15); y -= num15; _solClipRT = solClip; _tSol = true; AddSpaceT(4f); GameObject val18 = CrearHeaderCapitulo("LA PUERTA DE LA MULTITUD", "THE CROWD DOOR", _secMultitudAbierta, delegate { _secMultitudAbierta = !_secMultitudAbierta; ChapterAnimHelper.ToggleMul(); }, "Despliega la lista de personajes de <style=Door>La puerta de la multitud</style>.", "Expand the character list for <style=Door>The Crowd Door</style>."); _mulArrowT = val18.transform.Find("Arrow"); AddRowT(val18, Layout.AltoCabecera); float cy2 = 0f; RectTransform mulClip = MakeClip("Clip_Multitud"); GameObject val19 = new GameObject("CS_Multitud"); val19.AddComponent<RectTransform>(); TextMeshProUGUI val20 = val19.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val20).SetText(UI("⚠ Proximamente — este capitulo esta en desarrollo.", "⚠ Coming soon — this chapter is in development.")); ((TMP_Text)val20).fontSize = Layout.FontEtiqueta * 0.88f; ((Graphic)val20).color = new Color(1f, 0.85f, 0.1f, 1f); ((TMP_Text)val20).alignment = (TextAlignmentOptions)514; AF((TMP_Text)(object)val20); RegUI((TMP_Text)(object)val20, "⚠ Proximamente — este capitulo esta en desarrollo.", "⚠ Coming soon — this chapter is in development."); ARM(val19, Layout.AltoFila); _mulGridH = 0f - cy2; float num16 = (_secMultitudAbierta ? _mulGridH : 0f); mulClip.sizeDelta = new Vector2(0f, num16); y -= num16; _mulClipRT = mulClip; _belowSolRTs.Add(mulClip); _tMul = true; AddSpaceT(4f); GameObject val21 = CrearHeaderCapitulo("LA PUERTA CABALLO", "THE HORSE DOOR", _secCaballoAbierta, delegate { _secCaballoAbierta = !_secCaballoAbierta; ChapterAnimHelper.ToggleCab(); }, "Despliega la lista de personajes de <style=Door>La puerta caballo</style>.", "Expand the character list for <style=Door>The Horse Door</style>."); _cabArrowT = val21.transform.Find("Arrow"); AddRowT(val21, Layout.AltoCabecera); float cy3 = 0f; RectTransform cabClip = MakeClip("