Decompiled source of Turronish v1.2.0
BepInEx/plugins/ControlDoblaje.dll
Decompiled a month 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.IgnoreSymbolStoreSequencePoints)] [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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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)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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0078: 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)) { 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; private static readonly string[][] ParesVinculados = new string[3][] { new string[2] { "Shaman", "Salespersone" }, new string[2] { "Dratula", "Froggy" }, new string[2] { "CoralGlasses", "TaskiMaiden" } }; 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 Dictionary<string, string> PersonajeIdioma { get; private set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); 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) { if (!NombresUI.TryGetValue(carpeta, out var value)) { return carpeta; } return value; } public static string DescripcionUIDePersonaje(string carpeta) { if (!(Traducciones.TextoEspanolActivo ? DescripcionesUI : DescripcionesUI_EN).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) { if (!KeyOverride.TryGetValue(carpeta, out var value)) { return carpeta; } return value; } 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") }; foreach (string text2 in array) { 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 static void CargarPacksTurronish() { try { string path = Path.Combine(Paths.BepInExRootPath, "PluginsTurronish"); if (!Directory.Exists(path)) { Log.LogInfo((object)"[Packs] sin carpeta PluginsTurronish"); return; } string[] directories = Directory.GetDirectories(path); foreach (string text in directories) { string path2 = Path.Combine(text, "pack.json"); if (!File.Exists(path2)) { continue; } try { string json = File.ReadAllText(path2, Encoding.UTF8); string text2 = PackCampo(json, "id"); if (string.IsNullOrEmpty(text2)) { Log.LogWarning((object)("[Packs] " + Path.GetFileName(text) + ": pack.json sin 'id'")); continue; } string text3 = PackCampo(json, "nombreES") ?? text2; string nombreEN = PackCampo(json, "nombreEN") ?? text3; List<string> list = PackArray(json, "personajes"); int num = AssetPack.CargarPackExterno(Path.Combine(text, "audio.dat")); TurronishIdiomas.RegistrarCobertura(text2, text3, nombreEN, list); Log.LogInfo((object)$"[Packs] '{text3}' (id={text2}) — {list.Count} personaje(s), {num} audio(s)"); } catch (Exception ex) { Log.LogWarning((object)("[Packs] error en " + Path.GetFileName(text) + ": " + ex.Message)); } } } catch (Exception ex2) { Log.LogWarning((object)("[Packs] CargarPacksTurronish: " + ex2.Message)); } } private static void RegistrarCastellano() { try { List<string> list = new List<string>(); foreach (string personajesDisponible in PersonajesDisponibles) { if (TieneAudioCastellano(personajesDisponible)) { list.Add(personajesDisponible); } } if (list.Count > 0) { TurronishIdiomas.RegistrarCobertura("cas", "Castellano", "Castilian", list); Log.LogInfo((object)("[Castellano] idioma 'cas' registrado para " + list.Count + " personaje(s): " + string.Join(", ", list.ToArray()))); } else { Log.LogInfo((object)"[Castellano] ningún personaje con audio _cas — 'cas' no registrado."); } } catch (Exception ex) { Log.LogWarning((object)("[Castellano] RegistrarCastellano: " + ex.Message)); } } private static bool TieneAudioCastellano(string personaje) { try { string text = Path.Combine(VoicesPath, personaje); if (Directory.Exists(text)) { string[] array = new string[2] { "*_cas.ogg", "*_cas.wav" }; foreach (string searchPattern in array) { if (Directory.GetFiles(text, searchPattern).Length != 0) { return true; } } } try { foreach (string item in AssetPack.Listar(text, new string[2] { ".ogg", ".wav" }, recurse: false)) { if (Path.GetFileNameWithoutExtension(item).EndsWith("_cas", StringComparison.OrdinalIgnoreCase)) { return true; } } } catch { } } catch { } return false; } private static string PackCampo(string json, string clave) { Match match = Regex.Match(json, "\"" + clave + "\"\\s*:\\s*\"([^\"]*)\""); if (!match.Success) { return null; } return match.Groups[1].Value; } private static List<string> PackArray(string json, string clave) { List<string> list = new List<string>(); Match match = Regex.Match(json, "\"" + clave + "\"\\s*:\\s*\\[(.*?)\\]", RegexOptions.Singleline); if (match.Success) { foreach (Match item in Regex.Matches(match.Groups[1].Value, "\"([^\"]*)\"")) { list.Add(item.Groups[1].Value); } } return list; } private void Awake() { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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"); CargarPacksTurronish(); EscanearPersonajes(); RegistrarCastellano(); CargarConfig(); CargarPersonajesConfig(); NormalizarParesVinculados(); 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0031: 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 val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null) { continue; } scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { Sprite val2 = SpriteReemplazador.Reemplazar(val.sprite); if ((Object)(object)val2 != (Object)(object)val.sprite) { val.sprite = val2; } } } SpriteRenderer[] array2 = Resources.FindObjectsOfTypeAll<SpriteRenderer>(); foreach (SpriteRenderer val3 in array2) { if ((Object)(object)val3 == (Object)null || (Object)(object)val3.sprite == (Object)null) { continue; } scene = ((Component)val3).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { Sprite val4 = SpriteReemplazador.Reemplazar(val3.sprite); if ((Object)(object)val4 != (Object)(object)val3.sprite) { val3.sprite = val4; } } } 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 i = 0; i < 85; i++) { yield return null; } VolcarDiagnostico(nombreEscena, "90f"); } } private void VolcarDiagnostico(string nombreEscena, string etiqueta) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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 val = GameObject.Find("Main Menu"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[Turronish] Logo: 'Main Menu' no encontrado"); yield break; } Transform val2 = val.transform.Find("Borders (Masked)") ?? val.transform.Find("Content (Masked)/Borders (Masked)") ?? val.transform.Find("Content (Masked)/Borders") ?? val.transform; Transform val3 = val.transform.Find("Content (Masked)/Main") ?? val.transform.Find("Main"); if ((Object)(object)val2 == (Object)null) { Log.LogWarning((object)"[Turronish] Logo: transform raíz nula, abortando"); yield break; } Log.LogInfo((object)$"[Turronish] Logo: borders='{((Object)val2).name}' main={(Object)(object)val3 != (Object)null}"); GameObject val4 = null; Button[] componentsInChildren = val.GetComponentsInChildren<Button>(true); foreach (Button val5 in componentsInChildren) { if (!((Object)((Component)val5).gameObject).name.ToLower().Contains("logo") && (Object)(object)((Component)val5).GetComponent<Image>() != (Object)null) { val4 = ((Component)val5).gameObject; break; } } GameObject val6; if ((Object)(object)val4 != (Object)null) { val6 = Object.Instantiate<GameObject>(val4, val2); ((Object)val6).name = "_TurronishLogoBtn"; string[] array = new string[3] { "JoelG.ENA4.UI.MainMenuLogo", "JoelG.ENA4.UI.MenuClickScaleVisualFeedback", "JoelG.ENA4.UI.MainMenuBordersAnimator" }; foreach (string text in array) { Component component = val6.GetComponent(text); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } EventTrigger[] componentsInChildren2 = val6.GetComponentsInChildren<EventTrigger>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } TMP_Text[] componentsInChildren3 = val6.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].SetText("T"); } Image component2 = val6.GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { ((Graphic)component2).raycastTarget = true; } RectTransform component3 = val6.GetComponent<RectTransform>(); if ((Object)(object)component3 != (Object)null) { component3.sizeDelta = new Vector2(380f, 220f); component3.anchoredPosition = new Vector2(1695f, 745f); } Log.LogInfo((object)("[Turronish] Clon emoji OK plantilla='" + ((Object)val4).name + "'")); } else { Log.LogWarning((object)"[Turronish] Logo: no se encontró botón emoji — usando fallback naranja"); val6 = new GameObject("_TurronishLogoBtn"); val6.transform.SetParent(val2, false); Transform val7 = val2.Find("Emoji 1"); if (!((Object)(object)val7 != (Object)null)) { new Vector2(500f, -80f); } else { _ = ((Component)val7).GetComponent<RectTransform>().anchoredPosition; } RectTransform obj = val6.AddComponent<RectTransform>(); Vector2 anchorMin = (obj.anchorMax = Vector2.zero); obj.anchorMin = anchorMin; obj.pivot = new Vector2(0.5f, 0.5f); obj.sizeDelta = new Vector2(380f, 220f); obj.anchoredPosition = new Vector2(1695f, 745f); ((Graphic)val6.AddComponent<Image>()).color = new Color(0.8f, 0.55f, 0.1f, 0.88f); GameObject val8 = new GameObject("T"); val8.transform.SetParent(val6.transform, false); RectTransform obj2 = val8.AddComponent<RectTransform>(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; anchorMin = (obj2.offsetMax = Vector2.zero); obj2.offsetMin = anchorMin; TextMeshProUGUI obj3 = val8.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj3).SetText("T"); ((TMP_Text)obj3).fontSize = 40f; ((Graphic)obj3).color = Color.white; ((TMP_Text)obj3).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj3).fontStyle = (FontStyles)1; } val6.layer = LayerMask.NameToLayer("UI"); string text2 = VideoExtensions.BuscarArchivo(VideoClipsPath, "vid_Menu_Logo_Turronish"); if (text2 != null) { RenderTexture val9 = new RenderTexture(512, 296, 0); val9.Create(); GameObject val10 = new GameObject("_VideoDisplay"); val10.transform.SetParent(val6.transform, false); RectTransform obj4 = val10.AddComponent<RectTransform>(); obj4.anchorMin = Vector2.zero; obj4.anchorMax = Vector2.one; Vector2 anchorMin = (obj4.offsetMax = Vector2.zero); obj4.offsetMin = anchorMin; RawImage obj5 = val10.AddComponent<RawImage>(); obj5.texture = (Texture)(object)val9; ((Graphic)obj5).raycastTarget = false; VideoPlayer obj6 = val10.AddComponent<VideoPlayer>(); obj6.url = text2; obj6.renderMode = (VideoRenderMode)2; obj6.targetTexture = val9; obj6.isLooping = true; obj6.playOnAwake = true; obj6.Play(); Image component4 = val6.GetComponent<Image>(); if ((Object)(object)component4 != (Object)null) { ((Graphic)component4).color = Color.clear; } CanvasGroup cgLogo = val6.GetComponent<CanvasGroup>() ?? val6.AddComponent<CanvasGroup>(); cgLogo.alpha = 0f; TMP_Text[] txtsLogo = val6.GetComponentsInChildren<TMP_Text>(true); obj6.prepareCompleted += (EventHandler)delegate { TMP_Text[] array2 = txtsLogo; foreach (TMP_Text val12 in array2) { if ((Object)(object)val12 != (Object)null) { ((Component)val12).gameObject.SetActive(false); } } cgLogo.alpha = 1f; Log.LogInfo((object)"[Turronish] Logo video preparado — botón visible"); }; val6.AddComponent<LogoRevealFailsafe>().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)); } val6.transform.SetSiblingIndex(0); if ((Object)(object)val3 != (Object)null) { GameObject val11 = new GameObject("_LogoVisProxy"); val11.transform.SetParent(val3, false); val11.AddComponent<TurronishLogoProxy>().Init(val6); Log.LogInfo((object)"[Turronish] Logo: proxy de visibilidad instalado en Main"); } val6.AddComponent<TurronishClickBlocker>().Init(val6); Log.LogInfo((object)("[Turronish] Logo instalado en " + ((Object)val2).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] != ']') { 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++; } continue; } break; } } 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 NormalizarParesVinculados() { string[][] paresVinculados = ParesVinculados; foreach (string[] obj in paresVinculados) { string text = obj[0]; string text2 = obj[1]; PersonajeActivo.TryGetValue(text, out var value); PersonajeActivo.TryGetValue(text2, out var value2); string value3; string text3 = (PersonajeIdioma.TryGetValue(text, out value3) ? value3 : null); string value4; string text4 = (PersonajeIdioma.TryGetValue(text2, out value4) ? value4 : null); if (value != value2 || !(text3 == text4)) { PersonajeActivo[text] = true; PersonajeActivo[text2] = true; string text5 = ((!string.IsNullOrEmpty(text3)) ? text3 : text4); if (!string.IsNullOrEmpty(text5) && text5 != "es") { PersonajeIdioma[text] = text5; PersonajeIdioma[text2] = text5; } else { PersonajeIdioma.Remove(text); PersonajeIdioma.Remove(text2); } Log.LogInfo((object)("[Pares] '" + text + "'/'" + text2 + "' estaban en idiomas distintos → forzados a doblado (evita doble de pista compartida).")); } } } 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.NormalizarParesVinculados(); 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; 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_0086: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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)) { lista = Lista; foreach (string text3 in lista) { 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000f: 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) _worldPos = pos; _worldRot = rot; _worldScale = scale; } public void Init(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0007: 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_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00b9: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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; 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0048: 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_005d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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 { if (!_idiomas.TryGetValue(IdiomaTextos, out var value)) { return null; } return value; } } 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) { if (!_idiomas.TryGetValue(idioma, out var value)) { return idioma; } return value.Nombre; } public static bool EsPassthrough(string idioma) { if (!(idioma == "en") && _idiomas.TryGetValue(idioma, out var value)) { return value.Nativo == null; } return true; } 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 { get { if (!string.IsNullOrEmpty("https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u")) { return !"https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u".StartsWith("REEMPLAZAR"); } return false; } } 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if ((Object)(object)_runner == (Object)null) { GameObject val = new GameObject("_TurronishReporteRunner"); Object.DontDestroyOnLoad((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[] array = null; string nombre = "report.txt"; string text = null; try { array = ConstruirReporte(nota, discord, incluirLogOutput, out nombre); } catch (Exception ex) { text = ex.Message; } if (text != null) { Enviando = false; onResult?.Invoke(arg1: false, "Error armando reporte: " + text); yield break; } string s = "Nuevo reporte" + (string.IsNullOrWhiteSpace(discord) ? "" : (" de " + discord.Trim())) + (string.IsNullOrWhiteSpace(nota) ? "" : (": " + ((nota.Trim().Length > 180) ? nota.Trim().Substring(0, 180) : nota.Trim()))); List<IMultipartFormSection> list = new List<IMultipartFormSection> { (IMultipartFormSection)new MultipartFormDataSection("payload_json", "{\"content\":" + JsonEscape(s) + "}"), (IMultipartFormSection)new MultipartFormFileSection("files[0]", array, nombre, "text/plain") }; UnityWebRequest req = UnityWebRequest.Post("https://discord.com/api/webhooks/1523378344593195068/UEEu2qgv28_tkajjRrgdbdOOPBLukNjtsss6fxvfKRajpI8-e5CdnWC-PMNSGym3i01u", list); try { yield return req.SendWebRequest(); bool num = (int)req.result == 1; Enviando = false; if (num) { 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 text = ((req.downloadHandler != null) ? req.downloadHandler.text : null); if (string.IsNullOrEmpty(text)) { yield break; } string text2 = ExtraerCampo(text, "version"); string text3 = ExtraerCampo(text, "url"); string text4 = ExtraerCampo(text, "changelog"); string versionTraduccionLocal = Traducciones.VersionTraduccionLocal; if (string.IsNullOrEmpty(text2)) { ControlDoblajePlugin.Log.LogInfo((object)"[Actualiz] JSON sin 'version' — se ignora."); yield break; } int num = CompararVersiones(text2, versionTraduccionLocal); ControlDoblajePlugin.Log.LogInfo((object)$"[Actualiz] local='{versionTraduccionLocal}' remota='{text2}' cmp={num}"); if (num <= 0) { yield break; } Action<string, string, string, string> uIMostrarAvisoActualizacion = ControlDoblajePlugin.UIMostrarAvisoActualizacion; if (uIMostrarAvisoActualizacion != null) { try { uIMostrarAvisoActualizacion(versionTraduccionLocal, text2, text3 ?? "", text4 ?? ""); } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Actualiz] hook de UI falló: " + ex.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) { if (!string.Equals(a?.Trim(), b?.Trim(), StringComparison.OrdinalIgnoreCase)) { return string.Compare(a?.Trim(), b?.Trim(), StringComparison.OrdinalIgnoreCase); } return 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) { if (num2 <= num3) { return -1; } return 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.EsPassthroughActual; } 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 string JSONPathCastellano { get { string text = Path.Combine(Path.GetDirectoryName(typeof(Traducciones).Assembly.Location), "traducciones_cas.json"); if (File.Exists(text)) { return text; } return Path.Combine(Paths.ConfigPath, "traducciones_cas.json"); } } 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); Dictionary<string, string> dictionary2 = CargarOverridesCastellano(); Dictionary<string, string> dictionary3 = new Dictionary<string, string>(dictionary, StringComparer.Ordinal); foreach (KeyValuePair<string, string> item in dictionary2) { dictionary3[item.Key] = item.Value; } Localizacion.RegistrarIdioma("cas", "Castellano", dictionary3); ControlDoblajePlugin.Log.LogInfo((object)$"[Traducciones] Castellano registrado: {dictionary2.Count} override(s) sobre {dictionary.Count} base."); 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(); } private static Dictionary<string, string> CargarOverridesCastellano() { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); try { string jSONPathCastellano = JSONPathCastellano; if (!File.Exists(jSONPathCastellano)) { ControlDoblajePlugin.Log.LogInfo((object)"[Traducciones] traducciones_cas.json no encontrado — castellano usará español como base."); return dictionary; } string text = File.ReadAllText(jSONPathCastellano, Encoding.UTF8); int num = text.IndexOf("\"traducciones\""); if (num < 0) { return dictionary; } num = text.IndexOf('{', num); if (num < 0) { return dictionary; } int i = num + 1; while (i < text.Length) { for (; i < text.Length && text[i] != '"' && text[i] != '}'; i++) { } if (i < text.Length && text[i] != '}') { 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) { if (text2 != "__version_traduccion__" && !text2.StartsWith("---") && !text2.StartsWith("//") && text3.Length > 0) { dictionary[text2.Replace("\r\n", "\n")] = text3.Replace("\r\n", "\n"); } for (; i < text.Length && text[i] != ',' && text[i] != '}'; i++) { } if (i < text.Length && text[i] == ',') { i++; } continue; } break; } break; } } catch (Exception ex) { ControlDoblajePlugin.Log.LogWarning((object)("[Traducciones] cas: " + ex.Message)); } return dictionary; } public static void CambiarIdiomaTextos(string target) { if (string.IsNullOrEmpty(target) || target == Localizacion.IdiomaTextos) { return; } Localizacion.IdiomaTextos = target; Cache.Clear(); bool esPassthroughActual = Localizacion.EsPassthroughActual; 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 = Localizacion.AIngles(text); string text3 = (esPassthroughActual ? text2 : Aplicar(text2)); if (!string.Equals(text3, text, StringComparison.Ordinal)) { ((TMP_Text)val).SetText(text3); } } } RefrescarDropdownsNativos(); OnIdiomaChanged?.Invoke(); Localizacion.NotificarCambio(); ControlDoblajePlugin.Log.LogInfo((object)("[Traducciones] Idioma textos → " + target)); } 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 text = TraducirTiempoRelativo(norm.Substring("Last Saved: ".Length).Trim()); if (text == null) { return null; } return "Último guardado: " + text; } private static string AplicarPatronTimeAgo(string norm) { string text = TraducirTiempoRelativo(norm); if (text == null || !(text != norm)) { return null; } return text; } 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(); switch (text) { case "less than a minute ago": return "Hace menos de un minuto"; case "just now": case "a moment ago": return "Ahora mismo"; 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; } if (!EstiloAPersonaje.TryGetValue(texto.Substring(7, num - 7), out var value)) { return null; } return value; } 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++; } } } if (num > 0) { return num2 * 2 > num; } return false; } 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); lista = Lista; foreach (string text5 in lista) { 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 TurronishIdiomas { public class Idioma { public string Id; public string NombreES; public string NombreEN; public HashSet<string> Personajes; } private static readonly List<Idioma> _orden = new List<Idioma>(); private static readonly Dictionary<string, Idioma> _porId = new Dictionary<string, Idioma>(String
BepInEx/plugins/TurronishAudio.dll
Decompiled a month 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.IgnoreSymbolStoreSequencePoints)] [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_00c3: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004c: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_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_002f: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Object.FindObjectOfType<VideoTimescaleWatcher>() == (Object)null && (Object)(object)GameObject.Find("_VideoTimescaleWatcher") == (Object)null) { GameObject val2 = new GameObject("_VideoTimescaleWatcher"); Object.DontDestroyOnLoad((Object)val2); val2.AddComponent<VideoTimescaleWatcher>(); } CinematicaMultiPistaPlayer.RefrescarCacheWAV(); CinematicaMultiPistaPlayer.CargarBanksTurronish(); WandererGestor.LimpiarInstancia(); WandererGestor.DesmuteearRadio(); CinematicaDuckingManager.ResetWandererFade(); 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; try { Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (!string.Equals(name, "Boot", StringComparison.OrdinalIgnoreCase) && !string.Equals(name, "Menu", StringComparison.OrdinalIgnoreCase) && name.IndexOf("Credit", StringComparison.OrdinalIgnoreCase) < 0) { CinematicaMultiPistaPlayer.PrecargarTodasLasCines(); } } catch { } }); 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; 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>(); foreach (AudioSource val in array) { 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00dc: 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:/" }; Bus val4 = default(Bus); ChannelGroup val5 = default(ChannelGroup); foreach (string text2 in array) { 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_0015: 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_0015: 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; private float _cacheTimer; 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 float _fadeOrbInicio = -1f; private static float _fadeOrbDur = 3f; 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 float WandererFadeExtra { get { if (_fadeOrbInicio < 0f) { return 1f; } float num = 1f - (Time.realtimeSinceStartup - _fadeOrbInicio) / _fadeOrbDur; if (!(num < 0f)) { if (!(num > 1f)) { return num; } return 1f; } return 0f; } } public static void FadeWanderersOrb(float dur) { _fadeOrbDur = ((dur > 0.1f) ? dur : 3f); _fadeOrbInicio = Time.realtimeSinceStartup; ControlDoblajePlugin.Log.LogInfo((object)("[Wanderer] fade-out OrbAscension iniciado (" + _fadeOrbDur.ToString("F1") + "s)")); } public static void ResetWandererFade() { _fadeOrbInicio = -1f; } 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; } } } goto IL_01c9; } int num5; float num6; if (posMs >= duckingConfig.InicioMs) { num5 = ((posMs < duckingConfig.FinMs) ? 1 : 0); if (num5 != 0) { num6 = 0f; goto IL_01ab; } } else { num5 = 0; } num6 = 1f; goto IL_01ab; IL_01c9: float num7 = Mathf.MoveTowards(_nivelDuck, num, num2 * Time.unscaledDeltaTime); if (!Mathf.Approximately(num7, _nivelDuck)) { _nivelDuck = num7; AplicarBuses(duckingConfig, _nivelDuck); WandererDuckFactor = (duckingConfig.DuckearWanderers ? _nivelDuck : 1f); } return; IL_01ab: num = num6; num2 = ((num5 != 0) ? (1f / duckingConfig.FadeDuckSec) : (1f / duckingConfig.FadeRestoreSec)); goto IL_01c9; } 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0036: 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[6] { "bus:/Music", "bus:/Ambience", "bus:/SFX/Ambience", "bus:/SFX/Music", "bus:/SFX", "bus:/FX" }; } return new string[2] { "bus:/Music", "bus:/SFX/Music" }; } private static void AplicarBuses(DuckingConfig cfg, float duckFactor) { string[] array = ObtenerBuses(cfg); for (int i = 0; i < array.Length; i++) { SetBusVol(array[i], duckFactor); } } private static void SetBusVol(string busPath, float duckFactor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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; 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Invalid comparison between Unknown and I4 //IL_004d: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_015b: 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_0168: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Invalid comparison between Unknown and I4 //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Invalid comparison between Unknown and I4 //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Invalid comparison between Unknown and I4 //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00ec: 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_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_001e: Expected O, but got Unknown if (!((Object)(object)_instancia != (Object)null)) { GameObject val = new GameObject("_WandererGestor"); Object.DontDestroyOnLoad((Object)val); _instancia = val.AddComponent<WandererGestor>(); ControlDoblajePlugin.Log.LogInfo((object)"[WandererGestor] Inyectado correctamente."); } } private static void SilenciarEmitter(StudioEventEmitter emitter) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_01cd: 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_01e1: 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 val = default(ChannelGroup); ((System)(ref coreSystem)).getMasterChannelGroup(ref val); ControlDoblajePlugin.Log.LogInfo((object)"[WandererRadio] Bus=CoreMaster (stable root)"); if (tieneDry) { CREATESOUNDEXINFO ex = default(CREATESOUNDEXINFO); ex.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(ex); RESULT val2 = AudioPack.CrearSound(RuntimeManager.CoreSystem, rutaDryR, modo, ref ex, out sDry); ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] createSound Dry=" + ((object)(*(RESULT*)(&val2))/*cast due to .constrained prefix*/).ToString())); if ((int)val2 == 0) { coreSystem = RuntimeManager.CoreSystem; ((System)(ref coreSystem)).playSound(sDry, val, false, ref cDry); ((Channel)(ref cDry)).setVolume(0f); ((Channel)(ref cDry)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sDry, cDry)); int instanceID = ((Object)emitter).GetInstanceID(); bool flag = false; if (!_posicionGuardada.TryGetValue(instanceID, out var value) || value == 0) { PosicionNatural(instanceID, out value); } if (value != 0) { try { uint num = 0u; ((Sound)(ref sDry)).getLength(ref num, (TIMEUNIT)1); uint num2 = ((num > 500) ? (value % num) : value); ((Channel)(ref cDry)).setPosition(num2, (TIMEUNIT)1); flag = true; } catch { } } if (!flag) { try { FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EventInstance val3 = (EventInstance)field.GetValue(emitter); if (((EventInstance)(ref val3)).isValid()) { int num3 = 0; ((EventInstance)(ref val3)).getTimelinePosition(ref num3); if (num3 > 0) { ((Channel)(ref cDry)).setPosition((uint)num3, (TIMEUNIT)1); } } } } catch { } } } else { tieneDry = false; } } if (tieneWet) { CREATESOUNDEXINFO ex2 = default(CREATESOUNDEXINFO); ex2.cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(ex2); RESULT val4 = AudioPack.CrearSound(RuntimeManager.CoreSystem, rutaWetR, modo, ref ex2, out sWet); ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] createSound Wet=" + ((object)(*(RESULT*)(&val4))/*cast due to .constrained prefix*/).ToString())); if ((int)val4 == 0) { coreSystem = RuntimeManager.CoreSystem; ((System)(ref coreSystem)).playSound(sWet, val, false, ref cWet); ((Channel)(ref cWet)).setVolume(0f); ((Channel)(ref cWet)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sWet, cWet)); try { if (tieneDry) { uint num4 = 0u; ((Channel)(ref cDry)).getPosition(ref num4, (TIMEUNIT)1); if (num4 != 0) { ((Channel)(ref cWet)).setPosition(num4, (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 num5 = 0u; if (tieneDry) { ((Sound)(ref sDry)).getLength(ref num5, (TIMEUNIT)1); } else if (tieneWet) { ((Sound)(ref sWet)).getLength(ref num5, (TIMEUNIT)1); } int num6 = 0; FieldInfo field2 = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { EventInstance val5 = (EventInstance)field2.GetValue(emitter); EventDescription val6 = default(EventDescription); if (((EventInstance)(ref val5)).isValid() && (int)((EventInstance)(ref val5)).getDescription(ref val6) == 0 && ((EventDescription)(ref val6)).isValid()) { ((EventDescription)(ref val6)).getLength(ref num6); } } if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio-DIAG] lenDub=" + num5 + "ms lenEventoNativo=" + num6 + "ms")); } } catch { } bool estabaPausado = false; bool muteAnterior = _muteado; int tick = 0; float rampElapsed = 0f; int num7 = default(int); uint num20 = default(uint); uint num21 = default(uint); while ((Object)(object)emitter != (Object)null && ((Component)emitter).gameObject.activeInHierarchy && _yaReemplazados.Contains(((Object)emitter).GetInstanceID())) { SilenciarEmitter(emitter); bool flag2 = Time.timeScale == 0f; if (flag2 != estabaPausado) { if (tieneDry) { ((Channel)(ref cDry)).setPaused(flag2); } if (tieneWet) { ((Channel)(ref cWet)).setPaused(flag2); } estabaPausado = flag2; } if (muteAnterior && !_muteado) { try { uint posMs = 0u; bool flag3 = false; FieldInfo field3 = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field3 != null) { EventInstance val7 = (EventInstance)field3.GetValue(emitter); if (((EventInstance)(ref val7)).isValid() && (int)((EventInstance)(ref val7)).getTimelinePosition(ref num7) == 0 && num7 > 0) { posMs = (uint)num7; flag3 = true; } } if (!flag3) { PosicionNatural(((Object)emitter).GetInstanceID(), out posMs); } if (posMs != 0) { uint num8 = 0u; if (tieneDry) { ((Sound)(ref sDry)).getLength(ref num8, (TIMEUNIT)1); } else if (tieneWet) { ((Sound)(ref sWet)).getLength(ref num8, (TIMEUNIT)1); } uint num9 = ((num8 > 500) ? (posMs % num8) : posMs); if (tieneDry) { ((Channel)(ref cDry)).setPosition(num9, (TIMEUNIT)1); } if (tieneWet) { ((Channel)(ref cWet)).setPosition(num9, (TIMEUNIT)1); } _posicionGuardada[((Object)emitter).GetInstanceID()] = num9; ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio] Dub anclado al handoff: " + num9 + "ms (fuente=" + (flag3 ? "nativo" : "reloj") + ")")); } } catch { } rampElapsed = 0f; } muteAnterior = _muteado; if (!flag2) { rampElapsed += 0.1f; float num10 = ((rampElapsed < 1f) ? Mathf.SmoothStep(0f, 1f, rampElapsed / 1f) : 1f); Vector3 position = ((Component)emitter).transform.position; VECTOR val8 = new VECTOR { x = position.x, y = position.y, z = position.z }; VECTOR val9 = new VECTOR { x = 0f, y = 0f, z = 0f }; if (tieneDry) { ((Channel)(ref cDry)).set3DAttributes(ref val8, ref val9); } if (tieneWet) { ((Channel)(ref cWet)).set3DAttributes(ref val8, ref val9); } StudioListener val10 = ListenerCache.Get(); Vector3 val11 = (((Object)(object)val10 != (Object)null) ? ((Component)val10).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : position)); float num11 = Vector3.Distance(val11, position); float num12 = Mathf.Clamp01((num11 - 5f) / 25f); float num13 = Mathf.Clamp01(5f / Mathf.Max(num11, 0.1f)); if (num13 > 0.05f && num11 > 1f) { try { Vector3 val12 = val11 + Vector3.up * 0.5f; Vector3 val13 = position - val12; Vector3 normalized = ((Vector3)(ref val13)).normalized; float num14 = Mathf.Max(num11 - 0.5f, 0.1f); RaycastHit[] array = Physics.RaycastAll(val12, normalized, num14); int num15 = 0; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val14 = array2[i]; if (!((Object)(object)((RaycastHit)(ref val14)).collider == (Object)null) && !((RaycastHit)(ref val14)).collider.isTrigger) { Bounds bounds = ((RaycastHit)(ref val14)).collider.bounds; if (Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z }) > 1f) { num15++; } } } if (num15 > 0) { num13 *= Mathf.Pow(0.5f, (float)num15); } } catch { } } float num16 = MultiPistaRunner.LeerVolBus("bus:/Ambience") * MultiPistaRunner.LeerVolBus("bus:/"); float num17 = (_muteado ? 0f : (num16 * CinematicaDuckingManager.WandererDuckFactor * CinematicaDuckingManager.WandererFadeExtra)); if (num11 > 45f) { num13 *= Mathf.Clamp01((55f - num11) / 10f); } float num18 = (tieneDry ? (num13 * (1f - num12) * num17 * num10) : 0f); float num19 = (tieneWet ? (num13 * num12 * num17 * num10) : 0f); if (tieneDry) { ((Channel)(ref cDry)).setVolume(num18 * 2.4f); } if (tieneWet) { ((Channel)(ref cWet)).setVolume(num19 * 2.4f); } if (tieneDry) { try { if ((int)((Channel)(ref cDry)).getPosition(ref num20, (TIMEUNIT)1) == 0 && num20 != 0) { _posicionGuardada[((Object)emitter).GetInstanceID()] = num20; if (tieneWet && tick % 10 == 0 && (int)((Channel)(ref cWet)).getPosition(ref num21, (TIMEUNIT)1) == 0) { long num22 = (long)num20 - (long)num21; if (num22 < 0) { num22 = -num22; } if (num22 > 60) { ((Channel)(ref cWet)).setPosition(num20, (TIMEUNIT)1); } } } } catch { } } if (tick % 30 == 0) { bool flag4 = false; bool flag5 = false; float num23 = -1f; float num24 = -1f; try { if (tieneDry) { ((Channel)(ref cDry)).isPlaying(ref flag4); ((Channel)(ref cDry)).getAudibility(ref num23); } } catch { } try { if (tieneWet) { ((Channel)(ref cWet)).isPlaying(ref flag5); ((Channel)(ref cWet)).getAudibility(ref num24); } } catch { } if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[WandererRadio-DIAG] dist=" + num11.ToString("F1") + " wetT=" + num12.ToString("F2") + " volDry=" + num18.ToString("F2") + " volWet=" + num19.ToString("F2") + " bus=" + num16.ToString("F2") + " duck=" + CinematicaDuckingManager.WandererDuckFactor.ToString("F2") + " mute=" + _muteado + " dry[play=" + flag4 + " aud=" + num23.ToString("F2") + "] wet[play=" + flag5 + " aud=" + num24.ToString("F2") + "]")); } if ((tieneDry || tieneWet) && !flag4 && !flag5) { 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 instanceID2 = ((Object)emitter).GetInstanceID(); try { uint num25 = 0u; if (tieneDry) { ((Channel)(ref cDry)).getPosition(ref num25, (TIMEUNIT)1); } if (num25 != 0) { _posicionGuardada[instanceID2] = num25; } } catch { } } _yaReemplazados.Remove(((Object)(object)emitter != (Object)null) ? ((Object)emitter).GetInstanceID() : (-1)); for (int num26 = _todosLosCanales.Count - 1; num26 >= 0; num26--) { (Sound, Channel) tuple = _todosLosCanales[num26]; if ((tieneDry && tuple.Item1.handle == sDry.handle) || (tieneWet && tuple.Item1.handle == sWet.handle)) { _todosLosCanales.RemoveAt(num26); } } 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002e: 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) 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; 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_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_001e: Expected O, but got Unknown if (!((Object)(object)_instancia != (Object)null)) { GameObject val = new GameObject("_HeadtombsGestor"); Object.DontDestroyOnLoad((Object)val); _instancia = val.AddComponent<HeadtombsGestor>(); ControlDoblajePlugin.Log.LogInfo((object)"[HeadtombsGestor] Inyectado."); } } public static void LimpiarInstancia() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002e: 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) 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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 val = default(ChannelGroup); ((System)(ref coreSystem)).getMasterChannelGroup(ref val); 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 val2 = AudioPack.CrearSound(RuntimeManager.CoreSystem, wavPath, modo, ref ex, out sound); ControlDoblajePlugin.Log.LogInfo((object)("[HeadtombsGestor] createSound=" + ((object)(*(RESULT*)(&val2))/*cast due to .constrained prefix*/).ToString())); if ((int)val2 != 0) { _yaReemplazados.Remove(((Object)emitter).GetInstanceID()); yield break; } coreSystem = RuntimeManager.CoreSystem; Channel canal = default(Channel); ((System)(ref coreSystem)).playSound(sound, val, false, ref canal); ((Channel)(ref canal)).setVolume(0f); ((Channel)(ref canal)).set3DMinMaxDistance(100f, 10000f); _todosLosCanales.Add((sound, canal)); try { FieldInfo field = typeof(StudioEventEmitter).GetField("instance", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EventInstance val3 = (EventInstance)field.GetValue(emitter); if (((EventInstance)(ref val3)).isValid()) { int num = 0; ((EventInstance)(ref val3)).getTimelinePosition(ref num); if (num > 0) { ((Channel)(ref canal)).setPosition((uint)num, (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 flag = Time.timeScale == 0f; if (flag != estabaPausado) { ((Channel)(ref canal)).setPaused(flag); estabaPausado = flag; } if (!flag) { rampElapsed += 0.1f; float num2 = ((rampElapsed < 0.5f) ? Mathf.SmoothStep(0f, 1f, rampElapsed / 0.5f) : 1f); Vector3 position = ((Component)emitter).transform.position; VECTOR val4 = new VECTOR { x = position.x, y = position.y, z = position.z }; VECTOR val5 = new VECTOR { x = 0f, y = 0f, z = 0f }; ((Channel)(ref canal)).set3DAttributes(ref val4, ref val5); StudioListener val6 = ListenerCache.Get(); float num3 = Vector3.Distance(((Object)(object)val6 != (Object)null) ? ((Component)val6).transform.position : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : position), position); float num4 = ((num3 <= 12.25f) ? 1f : ((!(num3 >= 24.84f)) ? (1f - (num3 - 12.25f) / 12.59f) : 0f)); float num5 = MultiPistaRunner.LeerVolBus("bus:/Ambience") * MultiPistaRunner.LeerVolBus("bus:/"); ((Channel)(ref canal)).setVolume(num4 * num2 * 1f * num5); if (tick % 30 == 0 && ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[HeadtombsGestor] dist=" + num3.ToString("F1") + " vol=" + num4.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 num6 = _todosLosCanales.Count - 1; num6 >= 0; num6--) { if (_todosLosCanales[num6].s.handle == sound.handle) { _todosLosCanales.RemoveAt(num6); } } 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_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0366: 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_03b6: 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_03ba: 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_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: 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); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text[0] == '#') { continue; } string[] array2 = text.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) { foreach ((int, int, int) k2 in item) { 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 m = 0; m < list2.Count; m++) { val7.SetTriangles(list2[m], m); } 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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++; int num2 = int.Parse(array[num].Trim().Split(new char[1] { ' ' })[1]); num++; Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[num2]; for (int i = 0; i < num2; i++) { string[] array3 = array[num++].Trim().Split(new char[1] { ' ' }); array2[i] = new Matrix4x4 { m00 = float.Parse(array3[0], CultureInfo.InvariantCulture), m01 = float.Parse(array3[1], CultureInfo.InvariantCulture), m02 = float.Parse(array3[2], CultureInfo.InvariantCulture), m03 = float.Parse(array3[3], CultureInfo.InvariantCulture), m10 = float.Parse(array3[4], CultureInfo.InvariantCulture), m11 = float.Parse(array3[5], CultureInfo.InvariantCulture), m12 = float.Parse(array3[6], CultureInfo.InvariantCulture), m13 = float.Parse(array3[7], CultureInfo.InvariantCulture), m20 = float.Parse(array3[8], CultureInfo.InvariantCulture), m21 = float.Parse(array3[9], CultureInfo.InvariantCulture), m22 = float.Parse(array3[10], CultureInfo.InvariantCulture), m23 = float.Parse(array3[11], CultureInfo.InvariantCulture), m30 = float.Parse(array3[12], CultureInfo.InvariantCulture), m31 = float.Parse(array3[13], CultureInfo.InvariantCulture), m32 = float.Parse(array3[14], CultureInfo.InvariantCulture), m33 = float.Parse(array3[15], CultureInfo.InvariantCulture) }; } int num3 = int.Parse(array[num].Trim().Split(new char[1] { ' ' })[1]); num++; BoneDataEntry[] array4 = new BoneDataEntry[num3]; for (int j = 0; j < num3; j++) { string[] array5 = array[num++].Trim().Split(new char[1] { ' ' }); float num4 = float.Parse(array5[0], CultureInfo.InvariantCulture); float num5 = float.Parse(array5[1], CultureInfo.InvariantCulture); float num6 = float.Parse(array5[2], CultureInfo.InvariantCulture); int boneIdx = int.Parse(array5[3]); array4[j] = new BoneDataEntry { pos = new Vector3(num4, num5, num6), boneIdx = boneIdx }; } BoneDataFile value2 = new BoneDataFile { bindposes = array2, vertices = array4 }; _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_0866: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_0872: 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_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0708: 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) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07ef: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_0826: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_1037: Unknown result type (might be due to invalid IL or missing references) //IL_1041: Unknown result type (might be due to invalid IL or missing references) //IL_1046: Unknown result type (might be due to invalid IL or missing references) //IL_104b: Unknown result type (might be due to invalid IL or missing references) //IL_1054: Unknown result type (might be due to invalid IL or missing references) //IL_105e: Unknown result type (might be due to invalid IL or missing references) //IL_1063: Unknown result type (might be due to invalid IL or missing references) //IL_1068: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0342: 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_0317: Unknown result type (might be due to invalid IL or missing references) //IL_1113: Unknown result type (might be due to invalid IL or missing references) //IL_112e: 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_0bb8: Unknown result type (might be due to invalid IL or missing references) //IL_0bbd: Unknown result type (might be due to invalid IL or missing references) //IL_0bbf: Unknown result type (might be due to invalid IL or missing references) //IL_0bc4: Unknown result type (might be due to invalid IL or missing references) //IL_125c: Unknown result type (might be due to invalid IL or missing references) //IL_1261: Unknown result type (might be due to invalid IL or missing references) //IL_1267: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_0f6e: Unknown result type (might be due to invalid IL or missing references) //IL_0f73: Unknown result type (might be due to invalid IL or missing references) //IL_0f75: Unknown result type (might be due to invalid IL or missing references) //IL_0f7a: Unknown result type (might be due to invalid IL or missing references) //IL_0bda: Unknown result type (might be due to invalid IL or missing references) //IL_0be0: Unknown result type (might be due to invalid IL or missing references) //IL_0be5: Unknown result type (might be due to invalid IL or missing references) //IL_0bea: Unknown result type (might be due to invalid IL or missing references) //IL_0c28: Unknown result type (might be due to invalid IL or missing references) //IL_0c2d: Unknown result type (might be due to invalid IL or missing references) //IL_0c32: Unknown result type (might be due to invalid IL or missing references) //IL_0bfd: Unknown result type (might be due to invalid IL or missing references) //IL_0c03: Unknown result type (might be due to invalid IL or missing references) //IL_0c08: Unknown result type (might be due to invalid IL or missing references) //IL_0c0d: Unknown result type (might be due to invalid IL or missing references) //IL_0c39: Unknown result type (might be due to invalid IL or missing references) //IL_0c3e: Unknown result type (might be due to invalid IL or missing references) //IL_0c43: Unknown result type (might be due to invalid IL or missing references) //IL_12a8: Unknown result type (might be due to invalid IL or missing references) //IL_12ad: Unknown result type (might be due to invalid IL or missing references) //IL_12af: Unknown result type (might be due to invalid IL or missing references) //IL_12b4: Unknown result type (might be due to invalid IL or missing references) //IL_0ec7: Unknown result type (might be due to invalid IL or missing references) //IL_0ecc: Unknown result type (might be due to invalid IL or missing references) //IL_0ece: Unknown result type (might be due to invalid IL or missing references) //IL_0ed8: 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_0eed: Unknown result type (might be due to invalid IL or missing references) //IL_1366: Unknown result type (might be due to invalid IL or missing references) //IL_136f: Unknown result type (might be due to invalid IL or missing references) //IL_1374: Unknown result type (might be due to invalid IL or missing references) //IL_1342: 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_0488: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0f14: 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_0fb9: Unknown result type (might be due to invalid IL or missing references) //IL_0fbf: Unknown result type (might be due to invalid IL or missing references) //IL_0fc4: Unknown result type (might be due to invalid IL or missing references) //IL_0fc9: Unknown result type (might be due to invalid IL or missing references) //IL_0f99: Unknown result type (might be due to invalid IL or missing references) //IL_0f9f: Unknown result type (might be due to invalid IL or missing references) //IL_0fa4: Unknown result type (might be due to invalid IL or missing references) //IL_0fa9: 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_0fe9: Unknown result type (might be due to invalid IL or missing references) //IL_0fee: Unknown result type (might be due to invalid IL or missing references) //IL_0cc2: Unknown result type (might be due to invalid IL or missing references) //IL_0cc7: Unknown result type (might be due to invalid IL or missing references) //IL_0cc9: Unknown result type (might be due to invalid IL or missing references) //IL_0cce: Unknown result type (might be due to invalid IL or missing references) //IL_0ff5: Unknown result type (might be due to invalid IL or missing references) //IL_0ffa: Unknown result type (might be due to invalid IL or missing references) //IL_0fff: Unknown result type (might be due to invalid IL or missing references) //IL_13d0: Unknown result type (might be due to invalid IL or missing references) //IL_13e4: Unknown result type (might be due to invalid IL or missing references) //IL_0c6d: Unknown result type (might be due to invalid IL or missing references) //IL_0c73: Unknown result type (might be due to invalid IL or missing references) //IL_0c78: Unknown result type (might be due to invalid IL or missing references) //IL_0c7d: Unknown result type (might be due to invalid IL or missing references) //IL_0c88: Unknown result type (might be due to invalid IL or missing references) //IL_0c8e: Unknown result type (might be due to invalid IL or missing references) //IL_0c93: Unknown result type (might be due to invalid IL or missing references) //IL_0c98: Unknown result type (might be due to invalid IL or missing references) //IL_0cf6: Unknown result type (might be due to invalid IL or missing references) //IL_0cfc: Unknown result type (might be due to invalid IL or missing references) //IL_0d01: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0ce2: Unknown result type (might be due to invalid IL or missing references) //IL_0ce7: Unknown result type (might be due to invalid IL or missing references) //IL_0cec: Unknown result type (might be due to invalid IL or missing references) //IL_0d21: Unknown result type (might be due to invalid IL or missing references) //IL_0d26: Unknown result type (might be due to invalid IL or missing references) //IL_0d2b: Unknown result type (might be due to invalid IL or missing references) //IL_0d5a: Unknown result type (might be due to invalid IL or missing references) //IL_0d69: Unknown result type (might be due to invalid IL or missing references) //IL_0d82: 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_0da8: Unknown result type (might be due to invalid IL or missing references) //IL_0daf: Unknown result type (might be due to invalid IL or missing references) //IL_0d32: Unknown result type (might be due to invalid IL or missing references) //IL_0d37: Unknown result type (might be due to invalid IL or missing references) //IL_0d3c: Unknown result type (might be due to invalid IL or missing references) //IL_0dcd: Unknown result type (might be due to invalid IL or missing references) //IL_0dd4: Unknown result type (might be due to invalid IL or missing references) //IL_1487: Unknown result type (might be due to invalid IL or missing references) //IL_1490: Unknown result type (might be due to invalid IL or missing references) //IL_1495: Unknown result type (might be due to invalid IL or missing references) //IL_149a: 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_1569: Unknown result type (might be due to invalid IL or missing references) //IL_1572: Unknown result type (might be due to invalid IL or missing references) //IL_157b: Unknown result type (might be due to invalid IL or missing references) //IL_1580: Unknown result type (might be due to invalid IL or missing references) //IL_1585: Unknown result type (might be due to invalid IL or missing references) //IL_158a: Unknown result type (might be due to invalid IL or missing references) //IL_16ee: Unknown result type (might be due to invalid IL or missing references) //IL_16f7: Unknown result type (might be due to invalid IL or missing references) //IL_16fc: Unknown result type (might be due to invalid IL or missing references) //IL_170e: Unknown result type (might be due to invalid IL or missing references) //IL_1717: Unknown result type (might be due to invalid IL or missing references) //IL_171c: Unknown result type (might be due to invalid IL or missing references) //IL_16c8: Unknown result type (might be due to invalid IL or missing references) //IL_16da: Unknown result type (might be due to invalid IL or missing references) //IL_1622: Unknown result type (might be due to invalid IL or missing references) //IL_1770: Unknown result type (might be due to invalid IL or missing references) //IL_1788: Unknown result type (might be due to invalid IL or missing references) //IL_17a3: Unknown result type (might be due to invalid IL or missing references) //IL_17bb: Unknown result type (might be due to invalid IL or missing references) //IL_17d6: Unknown result type (might be due to invalid IL or missing references) //IL_17ee: Unknown result type (might be due to invalid IL or missing references) //IL_1643: Unknown result type (might be due to invalid IL or missing references) //IL_163c: Unknown result type (might be due to invalid IL or missing references) //IL_1898: Unknown result type (might be due to invalid IL or missing references) //IL_189f: Unknown result type (might be due to invalid IL or missing references) //IL_18a4: Unknown result type (might be due to invalid IL or missing references) //IL_18b6: Unknown result type (might be due to invalid IL or missing references) //IL_18bd: Unknown result type (might be due to invalid IL or missing references) //IL_18c2: Unknown result type (might be due to invalid IL or missing references) //IL_1874: Unknown result type (might be due to invalid IL or missing references) //IL_1884: Unknown result type (might be due to invalid IL or missing references) //IL_1916: Unknown result type (might be due to invalid IL or missing references) //IL_192e: Unknown result type (might be due to invalid IL or missing references) //IL_1949: Unknown result type (might be due to invalid IL or missing references) //IL_1961: Unknown result type (might be due to invalid IL or missing references) //IL_197c: Unknown result type (might be due to invalid IL or missing references) //IL_1994: 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 k = 0; k < vertices2.Length; k++) { BoneDataEntry boneDataEntry = vertices2[k]; 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 l = 0; l < vertices.Length; l++) { float num8 = float.MaxValue; int num9 = 0; for (int m = 0; m < list2.Count; m++) { val4 = vertices[l] - list2[m]; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num8) { num8 = sqrMagnitude; num9 = list3[m]; } } array9[l] = ((num9 != 0) ? 1 : 0); } int num10 = 0; int num11 = 0; val5 = Vector3.zero; Vector3 val6 = Vector3.zero; for (int n = 0; n < vertices.Length; n++) { if (array9[n] == 0) { val5 += vertices[n]; num10++; } else { val6 += vertices[n]; 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 num12 = 0; num12 < vertices.Length; num12++) { Vector3 val7 = vertices[num12]; long key2 = ((long)Mathf.RoundToInt(val7.x * 100000f) * 73856093L) ^ ((long)Mathf.RoundToInt(
BepInEx/plugins/TurronishContenido.dll
Decompiled a month 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.IgnoreSymbolStoreSequencePoints)] [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_0005: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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)) { string name = ((Object)__instance.sprite).name; if (!name.StartsWith("ex_turronish_", StringComparison.OrdinalIgnoreCase) && !name.StartsWith("ex_Turronish_", StringComparison.Ordinal) && ImageExtensions.BuscarArchivo(ControlDoblajePlugin.ImagesPath, name) != 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_0070: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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 month 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.IgnoreSymbolStoreSequencePoints)] [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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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; 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_00b1: 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_00e3: 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_00fb: 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_0117: 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) if ((Object)(object)tmp == (Object)null || textoFinal == null || Regex.Replace(textoFinal, "<[^>]+>", string.Empty).Trim() != "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>(); foreach (Component val in components) { 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 month 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.IgnoreSymbolStoreSequencePoints)] [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 month 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.IgnoreSymbolStoreSequencePoints)] [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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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; PatchAllSafe(new Harmony("com.turronish.ui")); 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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 obj = delegate { try { Application.OpenURL(discord); } catch { } }; Canvas val2 = (((Object)(object)CanvasHint != (Object)null) ? CanvasHint : Object.FindObjectOfType<Canvas>()); UIFunctions.CreateConfirmationWindow(new Request(obj, action, text, text11, text7, text6), val, val2); try { ConfirmationWindow mostRecentConfirmation = UIFunctions.MostRecentConfirmation; TMP_Text val3 = null; if ((Object)(object)mostRecentConfirmation != (Object)null) { TMP_Text[] componentsInChildren = ((Component)mostRecentConfirmation).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)null && val4.text == text11) { val3 = val4; break; } } } if ((Object)(object)val3 != (Object)null && ConstruirNumeroDividido(val3, text10, arriba, abajo)) { val3.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; } } } if (num2 >= 0) { return s.Substring(0, num2) + "\n" + s.Substring(num2 + 1); } return s; } private static bool ConstruirNumeroDividido(TMP_Text descTMP, string numero, Color32 arriba, Color32 abajo) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_013d: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0193: 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 obj = val4.AddComponent<RectTransform>(); Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.5f, 0.5f); obj.anchorMax = val5; obj.anchorMin = val5; obj.pivot = new Vector2(0.5f, 0.5f); obj.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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a4: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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) 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 obj = val5.AddComponent<RectTransform>(); ((Vector2)(ref val3))..ctor(0.5f, esArriba ? 0f : 1f); obj.anchorMax = val3; obj.anchorMin = val3; obj.pivot = new Vector2(0.5f, 0.5f); obj.sizeDelta = tamCont; obj.anchoredPosition = Vector2.zero; TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val6).SetText(numero); ((Graphic)val6).color = Color32.op_Implicit(col); ((TMP_Text)val6).fontSize = fs; if ((Object)(object)font != (Object)null) { ((TMP_Text)val6).font = font; } ((TMP_Text)val6).alignment = (TextAlignmentOptions)514; ((TMP_Text)val6).textWrappingMode = (TextWrappingModes)0; ((Graphic)val6).raycastTarget = false; } } public static class DoblajeTabHelper { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<string> <>9__53_0; public static Func<string> <>9__53_2; public static Func<Transform, bool> <>9__81_4; public static UnityAction <>9__81_6; public static UnityAction <>9__81_7; public static Func<string, bool> <>9__83_11; public static Predicate<Idioma> <>9__83_23; public static Predicate<Idioma> <>9__83_24; public static Func<string, bool> <>9__83_25; public static Func<string, bool> <>9__83_26; public static Action<int> <>9__83_27; public static Action<int> <>9__83_28; public static Action<int> <>9__83_29; public static Action<int> <>9__83_30; public static Action <>9__83_32; public static Action <>9__83_35; public static Action <>9__83_37; public static Func<string> <>9__83_41; public static Func<string> <>9__83_42; public static Action<int> <>9__83_43; public static Action<int> <>9__83_46; public static Action<int> <>9__83_49; public static Action<int> <>9__83_52; public static UnityAction <>9__83_55; public static Func<string> <>9__83_56; public static Func<string> <>9__83_57; public static Action<int> <>9__87_1; public static Func<Preset, string> <>9__87_5; public static Action<int> <>9__88_2; internal bool <CrearDropdownNativo>b__53_0(string op) { if (!op.Contains("Personaliz")) { return op.Contains("Custom"); } return true; } internal string <CrearDropdownNativo>b__53_2() { return ""; } internal bool <TryAgregarPestana>b__81_4(Transform t) { if (((Object)t).name == "Setting Details Text") { return (Object)(object)((Component)t).GetComponent<DoblejeUIMarker>() == (Object)null; } return false; } internal void <TryAgregarPestana>b__81_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__81_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__83_11(string p) { bool value; return ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value) && value; } internal bool <ConfigurarDoblaje>b__83_23(Idioma l) { return string.Equals(l.Id, "cas", StringComparison.OrdinalIgnoreCase); } internal bool <ConfigurarDoblaje>b__83_24(Idioma l) { return string.Equals(l.Id, "cas", StringComparison.OrdinalIgnoreCase); } internal bool <ConfigurarDoblaje>b__83_25(string p) { bool value; return ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value) && value; } internal bool <ConfigurarDoblaje>b__83_26(string p) { if (ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out var value)) { return !value; } return false; } internal void <ConfigurarDoblaje>b__83_27(int idx) { Traducciones.CambiarIdiomaTextos(idx switch { 1 => "cas", 0 => "es", _ => "en", }); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__83_28(int idx) { ControlDoblajePlugin.VideoClipsActivo = idx == 0; ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__83_29(int idx) { ControlDoblajePlugin.ImagenesActivas = idx == 0; SpriteReemplazador.ReScanearTodosLosSprites(); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); } internal void <ConfigurarDoblaje>b__83_30(int idx) { bool num = (ControlDoblajePlugin.ModelosActivos = idx == 0); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); if (num) { ControlDoblajePlugin.ModelosAplicar?.Invoke(); } else { ControlDoblajePlugin.ModelosRestaurar?.Invoke(); } } internal void <ConfigurarDoblaje>b__83_32() { _secSolitariaAbierta = !_secSolitariaAbierta; ChapterAnimHelper.ToggleSol(); } internal void <ConfigurarDoblaje>b__83_35() { _secMultitudAbierta = !_secMultitudAbierta; ChapterAnimHelper.ToggleMul(); } internal void <ConfigurarDoblaje>b__83_37() { _secCaballoAbierta = !_secCaballoAbierta; ChapterAnimHelper.ToggleCab(); } internal string <ConfigurarDoblaje>b__83_41() { return UI("Mixear Voces", "Mix Voices"); } internal string <ConfigurarDoblaje>b__83_42() { 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__83_43(int idx) { ControlDoblajePlugin.VarianteENA = idx; ControlDoblajePlugin.GuardarConfig(); VarianteENAPatcher.ReevalAll(); } internal void <ConfigurarDoblaje>b__83_46(int idx) { ControlDoblajePlugin.VarianteTaxi = idx; ControlDoblajePlugin.GuardarConfig(); VarianteTaxiPatcher.ReevalAll(); } internal void <ConfigurarDoblaje>b__83_49(int idx) { ControlDoblajePlugin.VarianteYowadama = idx; ControlDoblajePlugin.GuardarConfig(); } internal void <ConfigurarDoblaje>b__83_52(int idx) { ControlDoblajePlugin.LogoBtnActivo = idx == 0; ControlDoblajePlugin.GuardarConfig(); } internal void <ConfigurarDoblaje>b__83_55() { ControlDoblajePlugin.Log.LogInfo((object)"[Discord] Click!"); Application.OpenURL("https://discord.gg/nhUEmxqTyv"); } internal string <ConfigurarDoblaje>b__83_56() { return UI("Discord", "Discord"); } internal string <ConfigurarDoblaje>b__83_57() { return UI("Abre el servidor de Discord en tu navegador.", "Opens the Discord server in your browser."); } internal void <FilaPreajustesGO>b__87_1(int _) { } internal string <FilaPreajustesGO>b__87_5(Preset p) { return p.Nombre; } internal void <CeldaPersonajeEnGrid>b__88_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") }, { "HehIto", ("Español", "Spanish") } }; private static readonly HashSet<string> _soloOriginal = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "HehIto" }; private static readonly HashSet<string> _charDubCastellano = new HashSet<string>(StringComparer.OrdinalIgnoreCase); 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; } } } array3 = array; foreach (Sprite val2 in array3) { 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) 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) { if (((Object)item).name == "Border") { flag = true; } if (((Object)item).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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00d8: 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) 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) { if (((Object)item).name == "Border") { flag = true; } if (((Object)item).name == "Title Label") { flag2 = true; } if (((Object)item).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_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) { switch (((object)val5).GetType().Name) { case "OptionsSettingData": case "DropdownSetting": case "FontSizeRectController": Object.DestroyImmediate((Object)(object)val5); break; } } Component component = val.GetComponent("JoelG.ENA4.UI.CustomDropdown"); MonoBehaviour val6 = (MonoBehaviour)(object)((component is MonoBehaviour) ? component : null); if ((Object)(object)val6 != (Object)null) { try { ((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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Expected O, but got Unknown //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: 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_03f4: 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_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_0664: 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 obj = val3.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = Vector2.zero; obj.offsetMax = Vector2.zero; obj.pivot = Vector2.zero; Canvas val4 = val3.AddComponent<Canvas>(); val4.overrideSorting = true; val4.sortingOrder = val.sortingOrder + 200; val3.AddComponent<GraphicRaycaster>(); ControlDoblajePlugin.Log.LogInfo((object)$"[Desc] Adjuntado a canvas raiz '{((Object)val).name}' sortingOrder={val4.sortingOrder}"); } else { val3 = new GameObject("_DescCanvas_Pausa"); val3.AddComponent<DoblejeUIMarker>(); Canvas obj2 = val3.AddComponent<Canvas>(); obj2.renderMode = (RenderMode)0; obj2.sortingOrder = 999; val3.AddComponent<CanvasScaler>(); ControlDoblajePlugin.Log.LogInfo((object)"[Desc] Fallback: overlay independiente sortingOrder=999"); } } else { Canvas val5 = null; Transform val6 = tabParent; while ((Object)(object)val6 != (Object)null) { Canvas component3 = ((Component)val6).GetComponent<Canvas>(); if ((Object)(object)component3 != (Object)null && component3.isRootCanvas) { val5 = component3; break; } val6 = val6.parent; } if ((Object)(object)val5 != (Object)null) { val3 = new GameObject("_DescCanvas"); val3.AddComponent<DoblejeUIMarker>(); val3.transform.SetParent(((Component)val5).transform, false); RectTransform obj3 = val3.AddComponent<RectTransform>(); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.offsetMin = Vector2.zero; obj3.offsetMax = Vector2.zero; obj3.pivot = Vector2.zero; val3.AddComponent<Canvas>().overrideSorting = false; val3.AddComponent<GraphicRaycaster>(); int num3 = -1; for (int i = 0; i < ((Component)val5).transform.childCount; i++) { string name = ((Object)((Component)val5).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)val5).name}' siblingIdx={val3.transform.GetSiblingIndex()} (borders={num3})"); } else { val3 = new GameObject("_DescCanvas"); val3.AddComponent<DoblejeUIMarker>(); Canvas obj4 = val3.AddComponent<Canvas>(); obj4.renderMode = (RenderMode)0; obj4.sortingOrder = 5; val3.AddComponent<CanvasScaler>(); ControlDoblajePlugin.Log.LogInfo((object)"[Desc] Fallback overlay main sortingOrder=5"); } } GameObject val7 = new GameObject("Panel"); val7.transform.SetParent(val3.transform, false); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(0f, 0f); val8.pivot = new Vector2(0f, 1f); val8.sizeDelta = new Vector2(900f, num); val8.anchoredPosition = new Vector2(200f, 200f); GameObject val9 = new GameObject("MascaraDesc"); val9.transform.SetParent((Transform)(object)val8, false); RectTransform obj5 = val9.AddComponent<RectTransform>(); obj5.anchorMin = Vector2.zero; obj5.anchorMax = Vector2.one; obj5.offsetMin = new Vector2(-40f, -55f); obj5.offsetMax = new Vector2(40f, 55f); Image obj6 = val9.AddComponent<Image>(); ((Graphic)obj6).color = new Color(0.04f, 0.04f, 0.04f, 1f); ((Graphic)obj6).raycastTarget = false; val9.SetActive(false); Canvas obj7 = val7.AddComponent<Canvas>(); obj7.overrideSorting = true; obj7.sortingOrder = 32000; GameObject val10 = new GameObject("T"); val10.transform.SetParent((Transform)(object)val8, false); RectTransform obj8 = val10.AddComponent<RectTransform>(); obj8.anchorMin = new Vector2(0f, 0.48f); obj8.anchorMax = Vector2.one; Vector2 offsetMin = (obj8.offsetMax = Vector2.zero); obj8.offsetMin = offsetMin; TextMeshProUGUI val11 = val10.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val11).SetText(""); ((TMP_Text)val11).fontSize = Layout.FontDescTitulo; ((Graphic)val11).color = new Color(0.95f, 0.95f, 0.95f, 1f); ((TMP_Text)val11).fontStyle = (FontStyles)1; ((TMP_Text)val11).alignment = (TextAlignmentOptions)1025; if ((Object)(object)Fuente != (Object)null) { ((TMP_Text)val11).font = Fuente; } GameObject val12 = new GameObject("B"); val12.transform.SetParent((Transform)(object)val8, false); RectTransform obj9 = val12.AddComponent<RectTransform>(); obj9.anchorMin = Vector2.zero; obj9.anchorMax = new Vector2(1f, 0.46f); offsetMin = (obj9.offsetMax = Vector2.zero); obj9.offsetMin = offsetMin; TextMeshProUGUI val13 = val12.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val13).SetText(""); ((TMP_Text)val13).enableAutoSizing = true; ((TMP_Text)val13).fontSizeMin = 10f; ((TMP_Text)val13).fontSizeMax = Layout.FontDescTexto; ((TMP_Text)val13).fontSize = Layout.FontDescTexto; ((Graphic)val13).color = new Color(0.72f, 0.72f, 0.72f, 1f); ((TMP_Text)val13).alignment = (TextAlignmentOptions)257; ((TMP_Text)val13).overflowMode = (TextOverflowModes)1; if ((Object)(object)Fuente != (Object)null) { ((TMP_Text)val13).font = Fuente; } val3.AddComponent<DescZonaPositioner>().Init(tabParent, val8, num, num2, isPausa); val3.SetActive(false); if (isPausa) { _descCanvasGO_Pausa = val3; _descTitulo_Pausa = (TMP_Text)(object)val11; _descCuerpo_Pausa = (TMP_Text)(object)val13; _descMask_Pausa = val9; } else { _descCanvasGO = val3; _descTitulo = (TMP_Text)(object)val11; _descCuerpo = (TMP_Text)(object)val13; _descMask = val9; } 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_0b6a: Unknown result type (might be due to invalid IL or missing references) //IL_0b6f: Unknown result type (might be due to invalid IL or missing references) //IL_0b75: Expected O, but got Unknown //IL_0c21: Unknown result type (might be due to invalid IL or missing references) //IL_0c26: Unknown result type (might be due to invalid IL or missing references) //IL_0c2c: Expected O, but got Unknown //IL_0671: 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 num = parcheadas.Contains(instanceID); string? fullName = ((object)__instance).GetType().FullName; bool flag = (fullName != null && fullName.StartsWith("LMirman")) || ((object)__instance).GetType().Assembly.GetName().Name == "LMirman.Utilities"; if (num) { 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) && !(((GetField(typeof(Tab), "key")?.GetValue(val2) as string) ?? "") != "doblaje")) { if (flag) { _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 text = (GetField(typeof(Tab), "key")?.GetValue(val7) as string) ?? ""; if (ControlDoblajePlugin.LogVerboso) { ControlDoblajePlugin.Log.LogInfo((object)("[Tab] key='" + text + "' name='" + ((Object)((Component)val7).gameObject).name + "'")); } if (text == "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 (flag) { _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, flag); ((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 num2 = 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 > num2 && num4 > (float)Screen.width * 0.3f) { val12 = val13; num2 = num4; } } } if ((Object)(object)val12 != (Object)null) { panelDescNativo = ((Component)val12).gameObject; ControlDoblajePlugin.Log.LogInfo((object)$"[Desc] Footer nativo (heurística): '{RutaDe(val12.transform)}' (ancho={num2: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 (flag) { _sdtNativo_Pausa = val14; } else { _sdtNativo = val14; } if ((Object)(object)val14 != (Object)null) { panelDescNativo = null; } if (flag) { _panelDescNativo_Pausa = panelDescNativo; } else { _panelDescNativo = panelDescNativo; } val8.AddComponent<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; field2?.GetValue(val4); Transform val15 = ((Component)__instance).transform.Find("Tab Buttons"); object obj4; if (val15 == null) { obj4 = null; } else { Transform obj5 = val15.Find("Tab Button - Audio"); obj4 = ((obj5 != null) ? ((Component)obj5).gameObject : null); } GameObject val16 = (GameObject)obj4; 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[] componentsInChildren2 = val17.GetComponentsInChildren<TMP_Text>(); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].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); } InyectarCreditoEsquina(); try { Button[] array2 = Resources.FindObjectsOfTypeAll<Button>(); foreach (Button val18 in array2) { if ((Object)(object)((Component)val18).GetComponent<DoblejeUIMarker>() != (Object)null) { continue; } TMP_Text componentInChildren3 = ((Component)val18).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren3 == (Object)null) { continue; } string text2 = Regex.Replace(componentInChildren3.text ?? "", "<[^>]*>", "").Trim().ToLower(); if (text2.Contains("guardar") || text2.Contains("save") || text2.Contains("apply") || text2.Contains("aceptar")) { ButtonClickedEvent onClick = val18.onClick; object obj6 = <>c.<>9__81_6; if (obj6 == null) { UnityAction val19 = delegate { try { ControlDoblajePlugin.GuardarConfig(); } catch (Exception ex6) { ManualLogSource log = ControlDoblajePlugin.Log; if (log != null) { log.LogWarning((object)("[Pref] Save hook: " + ex6.Message)); } } }; <>c.<>9__81_6 = val19; obj6 = (object)val19; } ((UnityEvent)onClick).AddListener((UnityAction)obj6); ControlDoblajePlugin.Log.LogInfo((object)("[Pref] Hooked SAVE button: " + ((Object)val18).name + " '" + componentInChildren3.text + "'")); } else { if (!text2.Contains("descartar") && !text2.Contains("discard") && !text2.Contains("revert") && !text2.Contains("cancel") && !text2.Contains("cancelar")) { continue; } ButtonClickedEvent onClick2 = val18.onClick; object obj7 = <>c.<>9__81_7; if (obj7 == null) { UnityAction val20 = 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__81_7 = val20; obj7 = (object)val20; } ((UnityEvent)onClick2).AddListener((UnityAction)obj7); ControlDoblajePlugin.Log.LogInfo((object)("[Pref] Hooked DISCARD button: " + ((Object)val18).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 num7 = 0; while ((Object)(object)parent != (Object)null && num7++ < 7) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } private static void LogChildren(Transform t, int depth) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown string text = new string(' ', depth * 2); ControlDoblajePlugin.Log.LogInfo((object)(text + "[" + ((Object)t).name + "]")); ((Component)t).GetComponent<RectTransform>(); TMP_Text component = ((Component)t).GetComponent<TMP_Text>(); if ((Object)(object)component != (Object)null) { ControlDoblajePlugin.Log.LogInfo((object)$"{text} TMP fs={component.fontSize} txt='{component.text}'"); } if (depth >= 3) { return; } foreach (Transform item in t) { LogChildren(item, depth + 1); } } public static void ConfigurarDoblaje(Transform parent, bool isPausa = false) { //IL_228a: Unknown result type (might be due to invalid IL or missing references) //IL_228f: Unknown result type (might be due to invalid IL or missing references) //IL_22a2: Unknown result type (might be due to invalid IL or missing references) //IL_22a9: Unknown result type (might be due to invalid IL or missing references) //IL_22b4: Unknown result type (might be due to invalid IL or missing references) //IL_22bf: Unknown result type (might be due to invalid IL or missing references) //IL_22c4: Unknown result type (might be due to invalid IL or missing references) //IL_22c5: Unknown result type (might be due to invalid IL or missing references) //IL_22cc: Unknown result type (might be due to invalid IL or missing references) //IL_22d3: Unknown result type (might be due to invalid IL or missing references) //IL_22dd: Unknown result type (might be due to invalid IL or missing references) //IL_2304: Unknown result type (might be due to invalid IL or missing references) //IL_231d: Unknown result type (might be due to invalid IL or missing references) //IL_2336: Unknown result type (might be due to invalid IL or missing references) //IL_233b: Unknown result type (might be due to invalid IL or missing references) //IL_2187: Unknown result type (might be due to invalid IL or missing references) //IL_20ac: Unknown result type (might be due to invalid IL or missing references) //IL_235e: Unknown result type (might be due to invalid IL or missing references) //IL_2363: Unknown result type (might be due to invalid IL or missing references) //IL_2369: Expected O, but got Unknown //IL_20f3: Unknown result type (might be due to invalid IL or missing references) //IL_2122: Unknown result type (might be due to invalid IL or missing references) //IL_2415: Unknown result type (might be due to invalid IL or missing references) //IL_241c: Expected O, but got Unknown //IL_2460: Unknown result type (might be due to invalid IL or missing references) //IL_2497: Unknown result type (might be due to invalid IL or missing references) //IL_249e: Expected O, but got Unknown //IL_24f7: Unknown result type (might be due to invalid IL or missing references) //IL_2523: Unknown result type (might be due to invalid IL or missing references) //IL_252a: Expected O, but got Unknown //IL_255f: Unknown result type (might be due to invalid IL or missing references) //IL_2569: Expected O, but got Unknown //IL_25ae: Unknown result type (might be due to invalid IL or missing references) //IL_25b5: Expected O, but got Unknown //IL_25ea: Unknown result type (might be due to invalid IL or missing references) //IL_25f4: Expected O, but got Unknown //IL_23ca: Unknown result type (might be due to invalid IL or missing references) //IL_23d9: Unknown result type (might be due to invalid IL or missing references) //IL_2726: Unknown result type (might be due to invalid IL or missing references) //IL_274e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_2776: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Expected O, but got Unknown //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039a: 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_0929: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Expected O, but got Unknown //IL_097a: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Unknown result type (might be due to invalid IL or missing references) //IL_0eb7: Expected O, but got Unknown //IL_0ec8: Unknown result type (might be due to invalid IL or missing references) //IL_106a: Unknown result type (might be due to invalid IL or missing references) //IL_106f: Unknown result type (might be due to invalid IL or missing references) //IL_1076: Unknown result type (might be due to invalid IL or missing references) //IL_1090: Unknown result type (might be due to invalid IL or missing references) //IL_10a6: Expected O, but got Unknown //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_0f67: Unknown result type (might be due to invalid IL or missing references) //IL_0f78: Unknown result type (might be due to invalid IL or missing references) //IL_0f8d: Unknown result type (might be due to invalid IL or missing references) //IL_0fa2: 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_131d: Unknown result type (might be due to invalid IL or missing references) //IL_10d6: Unknown result type (might be due to invalid IL or missing references) //IL_10dd: Expected O, but got Unknown //IL_10ee: Unknown result type (might be due to invalid IL or missing references) //IL_13d9: Unknown result type (might be due to invalid IL or missing references) //IL_13de: Unknown result type (might be due to invalid IL or missing references) //IL_13e5: Unknown result type (might be due to invalid IL or missing references) //IL_1426: Unknown result type (might be due to invalid IL or missing references) //IL_145d: Expected O, but got Unknown //IL_148d: Unknown result type (might be due to invalid IL or missing references) //IL_11ba: Unknown result type (might be due to invalid IL or missing references) //IL_11bf: Unknown result type (might be due to invalid IL or missing references) //IL_11d2: Unknown result type (might be due to invalid IL or missing references) //IL_11e3: 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_120d: Unknown result type (might be due to invalid IL or missing references) //IL_1221: Unknown result type (might be due to invalid IL or missing references) //IL_1230: Unknown result type (might be due to invalid IL or missing references) //IL_155a: Unknown result type (might be due to invalid IL or missing references) //IL_155f: Unknown result type (might be due to invalid IL or missing references) //IL_1566: Unknown result type (might be due to invalid IL or missing references) //IL_15a7: Unknown result type (might be due to invalid IL or missing references) //IL_15de: Expected O, but got Unknown //IL_160e: Unknown result type (might be due to invalid IL or missing references) //IL_1691: Unknown result type (might be due to invalid IL or missing references) //IL_1698: Expected O, but got Unknown //IL_16e2: Unknown result type (might be due to invalid IL or missing references) //IL_1874: Unknown result type (might be due to invalid IL or missing references) //IL_187b: Expected O, but got Unknown //IL_188a: Unknown result type (might be due to invalid IL or missing references) //IL_1899: Unknown result type (might be due to invalid IL or missing references) //IL_189e: Unknown result type (might be due to invalid IL or missing references) //IL_18b1: Unknown result type (might be due to invalid IL or missing references) //IL_18b8: Unknown result type (might be due to invalid IL or missing references) //IL_18c3: Unknown result type (might be due to invalid IL or missing references) //IL_18ce: Unknown result type (might be due to invalid IL or missing references) //IL_18d3: Unknown result type (might be due to invalid IL or missing references) //IL_18d4: Unknown result type (might be due to invalid IL or missing references) //IL_18db: Unknown result type (might be due to invalid IL or missing references) //IL_1908: Unknown result type (might be due to invalid IL or missing references) //IL_178e: 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_19c5: Unknown result type (might be due to invalid IL or missing references) //IL_19cc: Unknown result type (might be due to invalid IL or missing references) //IL_19d7: Unknown result type (might be due to invalid IL or missing references) //IL_19e2: Unknown result type (might be due to invalid IL or missing references) //IL_19e7: Unknown result type (might be due to invalid IL or missing references) //IL_19e8: Unknown result type (might be due to invalid IL or missing references) //IL_19ef: Unknown result type (might be due to invalid IL or missing references) //IL_19f6: Unknown result type (might be due to invalid IL or missing references) //IL_1a00: Unknown result type (might be due to invalid IL or missing references) //IL_1a27: Unknown result type (might be due to invalid IL or missing references) //IL_1a40: Unknown result type (might be due to invalid IL or missing references) //IL_1a59: Unknown result type (might be due to invalid IL or missing references) //IL_1a5e: Unknown result type (might be due to invalid IL or missing references) //IL_1a75: Unknown result type (might be due to invalid IL or missing references) //IL_1a7f: Expected O, but got Unknown //IL_197c: Unknown result type (might be due to invalid IL or missing references) //IL_198b: Unknown result type (might be due to invalid IL or missing references) //IL_17e9: Unknown result type (might be due to invalid IL or missing references) //IL_1adb: Unknown result type (might be due to invalid IL or missing references) //IL_1aea: Unknown result type (might be due to invalid IL or missing references) //IL_1ef1: Unknown result type (might be due to invalid IL or missing references) //IL_1ef8: Expected O, but got Unknown //IL_1f42: Unknown result type (might be due to invalid IL or missing references) //IL_21b1: Unknown result type (might be due to invalid IL or missing references) //IL_21b8: Expected O, but got Unknown //IL_21c8: Unknown result type (might be due to invalid IL or missing references) //IL_21da: Unknown result type (might be due to invalid IL or missing references) //IL_21df: Unknown result type (might be due to invalid IL or missing references) //IL_21f2: Unknown result type (might be due to invalid IL or missing references) //IL_21f9: Unknown result type (might be due to invalid IL or missing references) //IL_2204: Unknown result type (might be due to invalid IL or missing references) //IL_220f: Unknown result type (might be due to invalid IL or missing references) //IL_2214: Unknown result type (might be due to invalid IL or missing references) //IL_2215: Unknown result type (might be due to invalid IL or missing references) //IL_221c: Unknown result type (might be due to invalid IL or missing references) //IL_2223: Unknown result type (might be due to invalid IL or missing references) //IL_224f: Unknown result type (might be due to invalid IL or missing references) //IL_2285: Expected O, but got Unknown //IL_1ff7: Unknown result type (might be due to invalid IL or missing references) //IL_2041: Unknown result type (might be due to invalid IL or missing references) //IL_204b: 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 obj = val5.AddComponent<Canvas>(); obj.overrideSorting = true; obj.sortingOrder = 500; val5.AddComponent<GraphicRaycaster>(); val5.SetActive(false); val5.transform.SetAsLastSibling(); List<string> personajes = ControlDoblajePlugin.PersonajesDisponibles; int[] idxTexto = new int[1] { (!(Localizacion.IdiomaTextos == "es")) ? ((Localizacion.IdiomaTextos == "cas") ? 1 : 2) : 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; bool flag2 = _soloOriginal.Contains(personajes[i]); int num3 = ((!flag2 && !flag) ? 1 : 0); if (ControlDoblajePlugin.PersonajeIdioma.TryGetValue(personajes[i], out var _pil) && !string.IsNullOrEmpty(_pil)) { int num4 = TurronishIdiomas.ParaPersonaje(personajes[i]).FindIndex((Idioma l) => string.Equals(l.Id, _pil, StringComparison.OrdinalIgnoreCase)); if (num4 >= 0) { num3 = (flag2 ? 1 : 2) + num4; } } idxAud[i] = new int[1] { num3 }; } 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[4]; string[] opTexto = new string[2]; string[] opAudio = new string[2]; string[] opTextoIdioma = new string[3]; List<string[]> charOpArrays = new List<string[]>(personajes.Count); List<List<Idioma>> charLangs = new List<List<Idioma>>(personajes.Count); for (int num5 = 0; num5 < personajes.Count; num5++) { List<Idioma> list2 = TurronishIdiomas.ParaPersonaje(personajes[num5]); charLangs.Add(list2); int num6 = (_soloOriginal.Contains(personajes[num5]) ? 1 : 2); charOpArrays.Add(new string[num6 + list2.Count]); } ActualizarOpciones(); Action refrescarTab = delegate { ActualizarOpciones(); _actualizarIdiomaLabel?.Invoke(); if ((Object)(object)lblTextoVivo != (Object)null) { lblTextoVivo.SetText(opTextoIdioma[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 j = 0; j < lblsAudVivos.Length; j++) { if ((Object)(object)lblsAudVivos[j] != (Object)null) { string[] array3 = ((j < charOpArrays.Count) ? charOpArrays[j] : opAudio); lblsAudVivos[j].SetText(array3[idxAud[j][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 flag3 = Traducciones.TextoEspanolActivo && personajes.Count > 0 && personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && value2); int[] array = new int[1] { flag3 ? ((Localizacion.IdiomaTextos == "cas") ? 1 : 0) : 3 }; 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) { int num22; switch (idx) { case 3: return; default: num22 = ((idx == 1) ? 1 : 0); break; case 0: num22 = 1; break; } bool flag4 = (byte)num22 != 0; bool flag5 = idx == 1; int num23 = ((!flag4) ? 1 : 0); foreach (string item3 in personajes) { ControlDoblajePlugin.PersonajeActivo[item3] = flag4; } foreach (string item4 in personajes) { if (flag5 && TurronishIdiomas.ParaPersonaje(item4).Exists((Idioma l) => string.Equals(l.Id, "cas", StringComparison.OrdinalIgnoreCase))) { ControlDoblajePlugin.PersonajeIdioma[item4] = "cas"; } else { ControlDoblajePlugin.PersonajeIdioma.Remove(item4); } } idxTexto[0] = idx switch { 1 => 1, 0 => 0, _ => 2, }; idxVC[0] = num23; idxIM[0] = num23; idxM3D[0] = num23; FijarSeleccionDD(lblTextoVivo, idxTexto[0], opTextoIdioma); FijarSeleccionDD(lblVCVivo, num23, opTexto); FijarSeleccionDD(lblIMVivo, num23, opTexto); FijarSeleccionDD(lblM3DVivo, num23, opTexto); for (int num24 = 0; num24 < lblsAudVivos.Length; num24++) { int num25; if (num24 < personajes.Count && _soloOriginal.Contains(personajes[num24])) { num25 = 0; } else if (!flag4) { num25 = 1; } else { num25 = 0; if (flag5) { int num26 = ((num24 < charLangs.Count) ? charLangs[num24] : null)?.FindIndex((Idioma l) => string.Equals(l.Id, "cas", StringComparison.OrdinalIgnoreCase)) ?? (-1); if (num26 >= 0) { num25 = 2 + num26; } } } idxAud[num24][0] = num25; if ((Object)(object)lblsAudVivos[num24] != (Object)null) { string[] array3 = ((num24 < charOpArrays.Count) ? charOpArrays[num24] : opAudio); lblsAudVivos[num24].SetText(array3[Math.Min(num25, array3.Length - 1)]); } } ControlDoblajePlugin.VideoClipsActivo = flag4; ControlDoblajePlugin.ImagenesActivas = flag4; ControlDoblajePlugin.ModelosActivos = flag4; SpriteReemplazador.ReScanearTodosLosSprites(); ControlDoblajePlugin.WandererRadioMute?.Invoke(!flag4); Traducciones.CambiarIdiomaTextos(idx switch { 1 => "cas", 0 => "es", _ => "en", }); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); }); lblIdiomaVivo = valLabel; int[] captIdxIdioma = array; (_actualizarIdiomaLabel = delegate { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)lblIdiomaVivo == (Object)null)) { ActualizarOpciones(); bool num22 = ControlDoblajePlugin.VideoClipsActivo && ControlDoblajePlugin.ImagenesActivas && ControlDoblajePlugin.ModelosActivos; bool flag4 = !ControlDoblajePlugin.VideoClipsActivo && !ControlDoblajePlugin.ImagenesActivas && !ControlDoblajePlugin.ModelosActivos; bool flag5 = personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && value2); bool flag6 = personajes.All((string p) => ControlDoblajePlugin.PersonajeActivo.TryGetValue(p, out value2) && !value2); string idiomaTextos = Localizacion.IdiomaTextos; bool flag7 = num22 && idiomaTextos == "es" && flag5; bool flag8 = num22 && idiomaTextos == "cas" && flag5; bool flag9 = flag4 && idiomaTextos == "en" && flag6; if (flag7) { captIdxIdioma[0] = 0; lblIdiomaVivo.SetText(opIdioma[0]); ((Graphic)lblIdiomaVivo).color = cBlanco; } else if (flag8) { captIdxIdioma[0] = 1; lblIdiomaVivo.SetText(opIdioma[1]); ((Graphic)lblIdiomaVivo).color = cBlanco; } else if (flag9) { captIdxIdioma[0] = 2; lblIdiomaVivo.SetText(opIdioma[2]); ((Graphic)lblIdiomaVivo).color = cBlanco; } else { captIdxIdioma[0] = 3; lblIdiomaVivo.SetText(opIdioma[3]); ((Graphic)lblIdiomaVivo).color = new Color(0.8f, 0.8f, 0.4f, 1f); } } })(); AddRow(go, Layout.AltoFila); AddSpace(4f); GameObject val7 = new GameObject("Desc_Presets"); val7.AddComponent<RectTransform>(); TextMeshProUGUI obj2 = val7.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj2).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)obj2).fontSize = Layout.FontEtiqueta * 0.88f; ((Graphic)obj2).color = new Color(0.75f, 0.75f, 0.75f, 1f); ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; AF((TMP_Text)(object)obj2); RegUI((TMP_Text)(object)obj2, "Guarda tu configuracion actual como preajuste o carga uno guardado.", "Save your current config as a preset or load a saved one."); AddRow(val7, Layout.AltoFila * 0.55f); AddRow(FilaPreajustesGO(val5, val6, () => lblIdiomaVivo, () => lblTextoVivo, () => lblsAudVivos, () => lblVCVivo, () => lblIMVivo, () => lblM3DVivo, idxTexto, idxVC, idxIM, idxM3D, idxAud, personajes, opIdioma, opTexto, opTextoIdioma, opAudio, charOpArrays), Layout.AltoFila); AddSpace(8f); AddRow(CabeceraGO("TRADUCCION VISUAL", "VISUAL TRANSLATION"), Layout.AltoCabecera); TMP_Text valLabel2; GameObject go2 = FilaDDGO("Textos", "Texts", opTextoIdioma, idxTexto, val5, val6, out valLabel2, "Textos", "Texts", "Cambia solo el idioma de dialogos y textos.", "Changes only dialogue and text language.", delegate(int idx) { Traducciones.CambiarIdiomaTextos(idx switch { 1 => "cas", 0 => "es", _ => "en", }); 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 Turronish.\n<color=#FFD24A>Nota: el cambio no se aplica hasta reiniciar la escena.</color>", "Replaces game videos with Turronish 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 Turronish.", "Replaces game images with Turronish 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: el cambio no se aplica hasta reiniciar la escena.</color>", "Replaces game 3D models with Turronish versions.\n<color=#FFD24A>Note: the change won't apply until the scene reloads.</color>", delegate(int idx) { bool num22 = (ControlDoblajePlugin.ModelosActivos = idx == 0); ControlDoblajePlugin.GuardarConfig(); _actualizarIdiomaLabel?.Invoke(); if (num22) { 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 val8 = 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 = val8.transform.Find("Arrow"); AddRow(val8, 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 num7 = 0; num7 < array2.Length; num7++) { (string, string, string, string) tuple = array2[num7]; hashSet.Add(tuple.Item1); hashSet.Add(tuple.Item2); } List<int> list3 = new List<int>(); for (int num8 = 0; num8 < personajes.Count; num8++) { if (!hashSet.Contains(personajes[num8])) { list3.Add(num8); } } List<int> list4 = new List<int>(); array2 = _paresVinc; for (int num7 = 0; num7 < array2.Length; num7++) { (string, string, string, string) tuple2 = array2[num7]; int num9 = personajes.IndexOf(tuple2.Item1); if (num9 >= 0) { list4.Add(num9); } int num10 = personajes.IndexOf(tuple2.Item2); if (num10 >= 0) { list4.Add(num10); } } for (int num11 = 0; num11 < list3.Count; num11 += 2) { int num12 = list3[num11]; GameObject val9 = new GameObject($"FD_R{num11}"); val9.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, Layout.AltoFilaGrid); CeldaPersonajeEnGrid(val9.transform, personajes[num12], idxAud[num12], val5, val6, (num12 < charOpArrays.Count) ? charOpArrays[num12] : opAudio, out var valLabel6, leftSide: true); lblsAudVivos[num12] = valLabel6; if (num11 + 1 < list3.Count) { int num13 = list3[num11 + 1]; GameObject val10 = new GameObject("Sep"); val10.transform.SetParent(val9.transform, false); RectTransform obj3 = val10.AddComponent<RectTransform>(); obj3.anchorMin = new Vector2(0.5f, 0f); obj3.anchorMax = new Vector2(0.5f, 1f); obj3.offsetMin = new Vector2(-1f, 4f); obj3.offsetMax = new Vector2(1f, -4f); ((Graphic)val10