Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of VitaSync v1.0.0
VitaSync.dll
Decompiled 5 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("VitaSync")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VitaSync")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("03be851d-d716-4088-9f09-0015b76be97a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace VitaSync; public static class LifeSyncClient { public class PhysicalProfile { public int Puntos { get; set; } public int CostoStamina { get; private set; } public int CostoGrip { get; private set; } public int CostoHealth { get; private set; } public int CostoSpeed { get; private set; } public int CanjesUsados { get; set; } public int CanjesMax { get; set; } public bool PuedeCanjeaMas => CanjesUsados < CanjesMax; public PhysicalProfile() { Puntos = 0; CostoStamina = 20; CostoGrip = 20; CostoHealth = 30; CostoSpeed = 30; CanjesUsados = 0; CanjesMax = 2; } public static PhysicalProfile FromPoints(int pts) { return new PhysicalProfile { Puntos = pts }; } public bool PuedePagar(int costo) { return PuedeCanjeaMas && Puntos >= costo; } public override string ToString() { return "Puntos=" + Puntos + " | Canjes=" + CanjesUsados + "/" + CanjesMax; } } internal static string ExtractString(string json, string key) { string text = "\"" + key + "\""; int num = json.IndexOf(text, StringComparison.Ordinal); if (num < 0) { return null; } int num2 = json.IndexOf(':', num + text.Length); if (num2 < 0) { return null; } int i; for (i = num2 + 1; i < json.Length && char.IsWhiteSpace(json[i]); i++) { } if (i >= json.Length) { return null; } if (json[i] == '"') { int num3 = json.IndexOf('"', i + 1); return (num3 < 0) ? null : json.Substring(i + 1, num3 - i - 1); } int j; for (j = i; j < json.Length && json[j] != ',' && json[j] != '}' && json[j] != ']'; j++) { } return json.Substring(i, j - i).Trim(); } internal static int ParseDimensionBalance(string json, string dimId) { int startIndex = 0; while (true) { int num = json.IndexOf("\"id_point_dimension\"", startIndex, StringComparison.Ordinal); if (num < 0) { break; } int num2 = json.IndexOf('}', num); if (num2 < 0) { break; } string json2 = json.Substring(num, num2 - num + 1); string text = ExtractString(json2, "id_point_dimension"); if (text == dimId) { string s = ExtractString(json2, "balance"); if (int.TryParse(s, out var result)) { return result; } } startIndex = num2 + 1; } return 0; } } public class LoginHUDPanel : MonoBehaviour { private class CursorKeeper : MonoBehaviour { private void Update() { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private static LoginHUDPanel _instance; private GameObject _canvasGO; private InputField _userInput; private InputField _passInput; private Text _statusText; private Button _loginBtn; private bool _loginInProgress = false; private bool _passVisible = false; private static readonly string[] SPIN = new string[4] { "/", "-", "\\", "|" }; private int _spinIdx = 0; private float _spinTimer = 0f; private const float SPIN_DT = 0.12f; private static readonly Color C_BG = new Color(0.13f, 0.11f, 0.09f, 0.93f); private static readonly Color C_HDR = new Color(0.18f, 0.14f, 0.1f, 0.97f); private static readonly Color C_GOLD = new Color(0.78f, 0.6f, 0.18f, 1f); private static readonly Color C_TEXT = new Color(0.8f, 0.76f, 0.7f, 1f); private static readonly Color C_DIM = new Color(0.48f, 0.44f, 0.38f, 1f); private static readonly Color C_INPUT_BG = new Color(0.1f, 0.09f, 0.07f, 1f); private static readonly Color C_INPUT_TXT = new Color(0.86f, 0.82f, 0.74f, 1f); private static readonly Color C_INPUT_PH = new Color(0.35f, 0.31f, 0.26f, 1f); private static readonly Color C_INPUT_LINE = new Color(0.78f, 0.6f, 0.18f, 0.5f); private static readonly Color C_BTN_OK = new Color(0.12f, 0.2f, 0.08f, 1f); private static readonly Color C_BTN_OK_T = new Color(0.8f, 0.76f, 0.7f, 1f); private static readonly Color C_BTN_SKIP = new Color(0.16f, 0.13f, 0.1f, 1f); private static readonly Color C_BTN_SKIP_T = new Color(0.45f, 0.41f, 0.35f, 1f); private static readonly Color C_BTN_EYE = new Color(0.2f, 0.16f, 0.11f, 1f); private static readonly Color C_BTN_EYE_T = new Color(0.78f, 0.6f, 0.18f, 1f); private static readonly Color C_ERROR = new Color(0.9f, 0.25f, 0.18f, 1f); private static readonly Color C_WARN = new Color(0.78f, 0.6f, 0.18f, 1f); public static void Initialize() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null) { GameObject val = new GameObject("VitaSync_EventSystem"); val.AddComponent<EventSystem>(); val.AddComponent<StandaloneInputModule>(); Object.DontDestroyOnLoad((Object)(object)val); } GameObject val2 = new GameObject("VitaSync_LoginHUD"); Object.DontDestroyOnLoad((Object)(object)val2); _instance = val2.AddComponent<LoginHUDPanel>(); _instance.BuildUI(); } } public static void DestroyIfExists() { if (!((Object)(object)_instance == (Object)null)) { if ((Object)(object)_instance._canvasGO != (Object)null) { Object.Destroy((Object)(object)_instance._canvasGO); } Object.Destroy((Object)(object)((Component)_instance).gameObject); _instance = null; } } private void Update() { if ((Object)(object)_canvasGO != (Object)null && _canvasGO.activeSelf) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (_loginInProgress && (Object)(object)_statusText != (Object)null) { _spinTimer += Time.deltaTime; if (_spinTimer >= 0.12f) { _spinTimer = 0f; _spinIdx = (_spinIdx + 1) % SPIN.Length; string text = _statusText.text; if (text.Length > 0 && Array.IndexOf(SPIN, text[text.Length - 1].ToString()) >= 0) { _statusText.text = text.Substring(0, text.Length - 1) + SPIN[_spinIdx]; } } } if (_loginInProgress) { return; } if (Input.GetKeyDown((KeyCode)9)) { if ((Object)(object)_userInput != (Object)null && _userInput.isFocused) { InputField passInput = _passInput; if (passInput != null) { ((Selectable)passInput).Select(); } } else { InputField userInput = _userInput; if (userInput != null) { ((Selectable)userInput).Select(); } } } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { HandleLogin(); } } private static Font GetFont() { return Resources.GetBuiltinResource<Font>("Arial.ttf"); } private void BuildUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_007e: 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_00ac: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00d6: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Expected O, but got Unknown //IL_03d0: 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_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Expected O, but got Unknown //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0510: 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_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) _canvasGO = new GameObject("VitaSync_LoginCanvas"); Object.DontDestroyOnLoad((Object)(object)_canvasGO); Canvas val = _canvasGO.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 9999; _canvasGO.AddComponent<CanvasScaler>(); _canvasGO.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("Panel"); val2.transform.SetParent(_canvasGO.transform, false); ((Graphic)val2.AddComponent<Image>()).color = C_BG; RectTransform component = val2.GetComponent<RectTransform>(); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); component.pivot = val3; Vector2 anchorMin = (component.anchorMax = val3); component.anchorMin = anchorMin; component.sizeDelta = new Vector2(360f, 310f); component.anchoredPosition = Vector2.zero; MakeRect(val2.transform, "Accent", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(3f, 0f), Vector2.zero, C_GOLD); GameObject val5 = new GameObject("Hdr"); val5.transform.SetParent(val2.transform, false); ((Graphic)val5.AddComponent<Image>()).color = C_HDR; RectTransform component2 = val5.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); component2.sizeDelta = new Vector2(0f, 42f); component2.anchoredPosition = Vector2.zero; MakeRect(val5.transform, "HdrLine", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 2f), Vector2.zero, C_GOLD); MakeLbl(val5.transform, "LIFESYNC GAMES - ACCESO", new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(360f, 42f), 14, C_GOLD, bold: true, (TextAnchor)4); MakeLbl(val2.transform, "USUARIO", new Vector2(0.5f, 0.5f), new Vector2(0f, 96f), new Vector2(320f, 18f), 11, C_GOLD, bold: true, (TextAnchor)3); _userInput = MakeInput(val2.transform, "User", "[email protected]", new Vector2(0f, 72f), new Vector2(320f, 30f), isPass: false, 12); MakeLbl(val2.transform, "CLAVE", new Vector2(0.5f, 0.5f), new Vector2(0f, 38f), new Vector2(320f, 18f), 11, C_GOLD, bold: true, (TextAnchor)3); float num = 280f; float num2 = -20f; _passInput = MakeInput(val2.transform, "Pass", "••••••••", new Vector2(num2, 14f), new Vector2(num, 30f), isPass: true, 12); GameObject val6 = MakeBtn(val2.transform, "BtnEye", "VER", new Vector2(145f, 14f), new Vector2(34f, 30f), C_BTN_EYE, C_BTN_EYE_T, 9); ((UnityEvent)val6.GetComponent<Button>().onClick).AddListener(new UnityAction(TogglePassVisibility)); MakeRect(val2.transform, "Sep", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(340f, 1f), new Vector2(0f, -12f), new Color(C_GOLD.r, C_GOLD.g, C_GOLD.b, 0.25f)); _statusText = MakeLbl(val2.transform, "LISTO PARA AUTENTICAR", new Vector2(0.5f, 0.5f), new Vector2(0f, -30f), new Vector2(340f, 18f), 10, C_DIM, bold: false, (TextAnchor)4); GameObject val7 = MakeBtn(val2.transform, "BtnLogin", "INICIAR SESION", new Vector2(-54f, -80f), new Vector2(196f, 34f), C_BTN_OK, C_BTN_OK_T, 12); _loginBtn = val7.GetComponent<Button>(); ((UnityEvent)_loginBtn.onClick).AddListener(new UnityAction(HandleLogin)); ((UnityEvent)MakeBtn(val2.transform, "BtnSkip", "OMITIR", new Vector2(116f, -80f), new Vector2(84f, 34f), C_BTN_SKIP, C_BTN_SKIP_T).GetComponent<Button>().onClick).AddListener(new UnityAction(HidePanel)); MakeLbl(val2.transform, "lsg.diinf.usach.cl · DIINF USACH", new Vector2(0.5f, 0.5f), new Vector2(0f, -128f), new Vector2(340f, 14f), 8, C_DIM, bold: false, (TextAnchor)4); } private void TogglePassVisibility() { _passVisible = !_passVisible; if ((Object)(object)_passInput != (Object)null) { _passInput.inputType = (InputType)((!_passVisible) ? 2 : 0); } InputField passInput = _passInput; if (passInput != null) { passInput.ForceLabelUpdate(); } } private void HidePanel() { VitaSyncPlugin.Log.LogInfo((object)"[Login] Omitido. Modo pasivo."); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; if ((Object)(object)_canvasGO != (Object)null) { Object.Destroy((Object)(object)_canvasGO); } Object.Destroy((Object)(object)((Component)this).gameObject); _instance = null; } private void HandleLogin() { //IL_005f: 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) if (!_loginInProgress) { if (string.IsNullOrEmpty(_userInput.text) || string.IsNullOrEmpty(_passInput.text)) { SetStatus("COMPLETE AMBOS CAMPOS", C_ERROR); return; } SetStatus("CONECTANDO " + SPIN[0], C_WARN); _spinIdx = 0; _spinTimer = 0f; _loginInProgress = true; ((Selectable)_loginBtn).interactable = false; ((MonoBehaviour)this).StartCoroutine(LoginFlow(_userInput.text.Trim(), _passInput.text)); } } private IEnumerator LoginFlow(string user, string pass) { string token = null; WWWForm form = new WWWForm(); form.AddField("username", user); form.AddField("password", pass); form.AddField("grant_type", ""); form.AddField("scope", ""); form.AddField("client_id", ""); form.AddField("client_secret", ""); UnityWebRequest req = UnityWebRequest.Post("https://lsg.diinf.usach.cl/lsg-auth/login", form); try { req.SetRequestHeader("Accept", "application/json"); req.timeout = 8; yield return req.SendWebRequest(); if ((int)req.result == 2) { OnNetErr("SIN CONEXION CON SERVIDOR"); yield break; } if (req.responseCode == 401 || req.responseCode == 400 || (int)req.result != 1) { OnLoginErr("CREDENCIALES INCORRECTAS"); yield break; } token = LifeSyncClient.ExtractString(req.downloadHandler.text, "access_token"); } finally { ((IDisposable)req)?.Dispose(); } if (string.IsNullOrEmpty(token)) { OnLoginErr("ERROR EN RESPUESTA"); yield break; } int playerId = -1; UnityWebRequest req2 = UnityWebRequest.Get("https://lsg.diinf.usach.cl/lsg-auth/whoami"); try { req2.SetRequestHeader("Authorization", "Bearer " + token); req2.SetRequestHeader("Accept", "application/json"); req2.timeout = 8; yield return req2.SendWebRequest(); if ((int)req2.result == 1) { string ids = LifeSyncClient.ExtractString(req2.downloadHandler.text, "id_players"); int.TryParse(ids, out playerId); } } finally { ((IDisposable)req2)?.Dispose(); } if (playerId < 0) { OnLoginErr("ID DE JUGADOR NO ENCONTRADO"); yield break; } UnityWebRequest req3 = UnityWebRequest.Get("https://lsg.diinf.usach.cl/lsg-core-api/players/" + playerId + "/points/balance"); try { req3.SetRequestHeader("Authorization", "Bearer " + token); req3.SetRequestHeader("Accept", "application/json"); req3.timeout = 8; yield return req3.SendWebRequest(); if ((int)req3.result != 1) { OnLoginErr("ERROR AL OBTENER BALANCE"); yield break; } int puntos = ParseBalance(req3.downloadHandler.text, "2"); SessionManager.Save(token, playerId); LifeSyncClient.PhysicalProfile p = new LifeSyncClient.PhysicalProfile { Puntos = puntos, CanjesUsados = 0, CanjesMax = 2 }; VitaSyncPlugin.Instance.SetActiveProfile(p); SessionLogger.StartSession(); VitaSyncPlugin.Log.LogInfo((object)("[LSG] Login exitoso. Balance: " + puntos)); ShowSessionToast(puntos); } finally { ((IDisposable)req3)?.Dispose(); } if ((Object)(object)_canvasGO != (Object)null) { Object.Destroy((Object)(object)_canvasGO); } Object.Destroy((Object)(object)((Component)this).gameObject); _instance = null; } private void OnLoginErr(string msg) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SetStatus(msg, C_ERROR); _passInput.text = ""; _loginInProgress = false; ((Selectable)_loginBtn).interactable = true; ((Selectable)_passInput).Select(); VitaSyncPlugin.Log.LogWarning((object)("[Login] " + msg)); } private void OnNetErr(string msg) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) SetStatus(msg, C_WARN); _loginInProgress = false; ((Selectable)_loginBtn).interactable = true; VitaSyncPlugin.Log.LogError((object)("[Login] " + msg)); } private void SetStatus(string msg, Color col) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_statusText == (Object)null)) { _statusText.text = msg; ((Graphic)_statusText).color = col; } } private static int ParseBalance(string json, string dimId) { int startIndex = 0; while (true) { int num = json.IndexOf("\"id_point_dimension\"", startIndex, StringComparison.Ordinal); if (num < 0) { break; } int num2 = json.IndexOf('}', num); if (num2 < 0) { break; } string json2 = json.Substring(num, num2 - num + 1); string text = LifeSyncClient.ExtractString(json2, "id_point_dimension"); if (text == dimId) { string s = LifeSyncClient.ExtractString(json2, "balance"); if (int.TryParse(s, out var result)) { return result; } } startIndex = num2 + 1; } return 0; } private static void ShowSessionToast(int puntos) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_015b: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null) { GameObject val = new GameObject("VitaSync_EventSystem"); val.AddComponent<EventSystem>(); val.AddComponent<StandaloneInputModule>(); Object.DontDestroyOnLoad((Object)(object)val); } GameObject canvasGO = new GameObject("VitaSync_SessionToast"); Object.DontDestroyOnLoad((Object)(object)canvasGO); Canvas val2 = canvasGO.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 9999; canvasGO.AddComponent<CanvasScaler>(); canvasGO.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("Panel"); val3.transform.SetParent(canvasGO.transform, false); ((Graphic)val3.AddComponent<Image>()).color = C_BG; RectTransform component = val3.GetComponent<RectTransform>(); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); component.pivot = val4; Vector2 anchorMin = (component.anchorMax = val4); component.anchorMin = anchorMin; component.sizeDelta = new Vector2(360f, 160f); component.anchoredPosition = Vector2.zero; MakeRect(val3.transform, "Accent", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(3f, 0f), Vector2.zero, C_GOLD); MakeLbl(val3.transform, "SESIÓN INICIADA CORRECTAMENTE", new Vector2(0.5f, 1f), new Vector2(0f, -28f), new Vector2(336f, 20f), 12, C_GOLD, bold: true, (TextAnchor)4); MakeLbl(val3.transform, "Puntos disponibles: " + puntos, new Vector2(0.5f, 1f), new Vector2(0f, -60f), new Vector2(336f, 18f), 13, C_TEXT, bold: false, (TextAnchor)4); GameObject val6 = MakeBtn(val3.transform, "BtnOk", "ACEPTAR", new Vector2(0f, -52f), new Vector2(110f, 30f), C_BTN_OK, C_BTN_OK_T); CursorKeeper keeper = canvasGO.AddComponent<CursorKeeper>(); ((UnityEvent)val6.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { ((Behaviour)keeper).enabled = false; Object.Destroy((Object)(object)canvasGO); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; }); } private static void MakeRect(Transform p, string name, Vector2 aMin, Vector2 aMax, Vector2 size, Vector2 pos, Color col) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) GameObject val = new GameObject(name); val.transform.SetParent(p, false); ((Graphic)val.AddComponent<Image>()).color = col; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = aMin; component.anchorMax = aMax; component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = size; component.anchoredPosition = pos; } private static Text MakeLbl(Transform p, string text, Vector2 anchor, Vector2 pos, Vector2 size, int fs, Color col, bool bold, TextAnchor align) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0077: 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_0088: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("T"); val.transform.SetParent(p, false); Text val2 = val.AddComponent<Text>(); val2.font = GetFont(); val2.text = text; val2.fontSize = fs; ((Graphic)val2).color = col; val2.fontStyle = (FontStyle)(bold ? 1 : 0); val2.alignment = align; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = anchor; component.anchorMax = anchor; component.pivot = anchor; component.sizeDelta = size; component.anchoredPosition = pos; return val2; } private static InputField MakeInput(Transform p, string name, string ph, Vector2 pos, Vector2 size, bool isPass, int fs) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0026: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_016a: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Inp_" + name); val.transform.SetParent(p, false); ((Graphic)val.AddComponent<Image>()).color = C_INPUT_BG; RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.sizeDelta = size; component.anchoredPosition = pos; MakeRect(val.transform, "Line", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), Vector2.zero, C_INPUT_LINE); InputField val4 = val.AddComponent<InputField>(); GameObject val5 = new GameObject("PH"); val5.transform.SetParent(val.transform, false); Text val6 = val5.AddComponent<Text>(); val6.font = GetFont(); val6.text = ph; ((Graphic)val6).color = C_INPUT_PH; val6.fontSize = fs - 1; val6.alignment = (TextAnchor)3; RectTransform component2 = val5.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = new Vector2(-12f, -4f); GameObject val7 = new GameObject("TX"); val7.transform.SetParent(val.transform, false); Text val8 = val7.AddComponent<Text>(); val8.font = GetFont(); ((Graphic)val8).color = C_INPUT_TXT; val8.fontSize = fs; val8.alignment = (TextAnchor)3; RectTransform component3 = val7.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.sizeDelta = new Vector2(-12f, -4f); val4.placeholder = (Graphic)(object)val6; val4.textComponent = val8; if (isPass) { val4.inputType = (InputType)2; } return val4; } private static GameObject MakeBtn(Transform p, string name, string label, Vector2 pos, Vector2 size, Color bg, Color fg, int fs = 11) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(p, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = bg; Button val3 = val.AddComponent<Button>(); ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock; ((ColorBlock)(ref defaultColorBlock)).normalColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(1.22f, 1.22f, 1.22f, 1f); ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.78f, 0.78f, 0.78f, 1f); ((ColorBlock)(ref defaultColorBlock)).disabledColor = new Color(0.5f, 0.5f, 0.5f, 1f); ((ColorBlock)(ref defaultColorBlock)).colorMultiplier = 1f; ((Selectable)val3).colors = defaultColorBlock; ((Selectable)val3).targetGraphic = (Graphic)(object)val2; RectTransform component = val.GetComponent<RectTransform>(); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); component.pivot = val4; Vector2 anchorMin = (component.anchorMax = val4); component.anchorMin = anchorMin; component.sizeDelta = size; component.anchoredPosition = pos; GameObject val6 = new GameObject("L"); val6.transform.SetParent(val.transform, false); Text val7 = val6.AddComponent<Text>(); val7.font = GetFont(); val7.text = label; val7.fontSize = fs; ((Graphic)val7).color = fg; val7.fontStyle = (FontStyle)1; val7.alignment = (TextAnchor)4; RectTransform component2 = val6.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; return val; } } [BepInPlugin("com.diinf.vitasync", "VitaSync", "1.0.0")] public class VitaSyncPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(MenuPageMain), "Start")] public static class MenuPageMainStartPatch { private static void Postfix() { Monitor?.ResetUpgrades(); SessionLogger.EndSession(); if (!SessionManager.IsActive) { Log.LogInfo((object)"[Login] MenuPageMain: desplegando HUD."); LoginHUDPanel.Initialize(); } } } [HarmonyPatch(typeof(MenuPageLobby), "Start")] public static class MenuPageLobbyStartPatch { private static void Postfix() { if (!SessionManager.IsActive) { Log.LogInfo((object)"[Login] MenuPageLobby: desplegando HUD."); LoginHUDPanel.Initialize(); } } } [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] public static class ShopInitializePatch { private static void Postfix() { if (!SemiFunc.RunIsShop()) { return; } LifeSyncClient.PhysicalProfile activeProfile = Instance.GetActiveProfile(); if (activeProfile != null && SessionManager.IsActive) { if (!SessionManager.BaselineCapturado) { CapturarBaselineUpgrades(); } activeProfile.CanjesUsados = 0; SessionLogger.LogShopOpen(activeProfile.Puntos); TokenRefresher.TryRefresh(); ShopCanjePanel.EnsureInstance(activeProfile); } } } [HarmonyPatch(typeof(RunManager), "AllPlayersDeadSet")] public static class AllPlayersDeadSetPatch { private static void Postfix(bool _set) { if (SessionManager.IsActive && _set) { int niveles = RunManager.instance?.levelsCompleted ?? 0; SessionLogger.LogTeamDead(niveles); } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] public static class ChangeLevelPatch { private static void Prefix(bool _completedLevel, bool _levelFailed) { if (!SessionManager.IsActive) { return; } if (SemiFunc.RunIsLevel()) { RunManager instance = RunManager.instance; object obj; if (instance == null) { obj = null; } else { Level levelCurrent = instance.levelCurrent; obj = ((levelCurrent != null) ? ((Object)levelCurrent).name : null); } if (obj == null) { obj = "unknown"; } string level = (string)obj; SessionLogger.LogLevelEnd(level); } if (SemiFunc.RunIsShop()) { SessionLogger.LogShopClose(Instance.GetActiveProfile()?.CanjesUsados ?? 0); } if (SessionManager.TieneUpgradesPendientes && !((Object)(object)RunManager.instance == (Object)null) && SemiFunc.RunIsLobby() && !_levelFailed) { Monitor?.AplicarUpgradesSync(); } } private static void Postfix() { if (SessionManager.IsActive) { RunManager instance = RunManager.instance; object obj; if (instance == null) { obj = null; } else { Level levelCurrent = instance.levelCurrent; obj = ((levelCurrent != null) ? ((Object)levelCurrent).name : null); } if (obj == null) { obj = ""; } string text = (string)obj; if (!text.Contains("Lobby") && !text.Contains("Shop")) { SessionLogger.LogLevelStart(text); } } } } [HarmonyPatch(typeof(RunManager), "UpdateLevel")] public static class UpdateLevelPatch { private static bool EsClienteMP() { return SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClientOrSingleplayer(); } private static void Prefix() { if (!EsClienteMP() || !SessionManager.IsActive) { return; } if (SemiFunc.RunIsLevel()) { RunManager instance = RunManager.instance; object obj; if (instance == null) { obj = null; } else { Level levelCurrent = instance.levelCurrent; obj = ((levelCurrent != null) ? ((Object)levelCurrent).name : null); } if (obj == null) { obj = "unknown"; } string level = (string)obj; SessionLogger.LogLevelEnd(level); } if (SemiFunc.RunIsShop()) { SessionLogger.LogShopClose(Instance.GetActiveProfile()?.CanjesUsados ?? 0); } if (SessionManager.TieneUpgradesPendientes && !((Object)(object)RunManager.instance == (Object)null) && SemiFunc.RunIsLobby()) { Monitor?.AplicarUpgradesSync(); } } private static void Postfix() { if (EsClienteMP() && SessionManager.IsActive) { RunManager instance = RunManager.instance; object obj; if (instance == null) { obj = null; } else { Level levelCurrent = instance.levelCurrent; obj = ((levelCurrent != null) ? ((Object)levelCurrent).name : null); } if (obj == null) { obj = ""; } string text = (string)obj; if (!text.Contains("Lobby") && !text.Contains("Shop")) { SessionLogger.LogLevelStart(text); } } } } private LifeSyncClient.PhysicalProfile _activeProfile; public const string AUTH_URL = "https://lsg.diinf.usach.cl/lsg-auth/login"; public const string AUTH_WHOAMI = "https://lsg.diinf.usach.cl/lsg-auth/whoami"; public const string AUTH_REFRESH = "https://lsg.diinf.usach.cl/lsg-auth/token/refresh"; public const string CORE_URL = "https://lsg.diinf.usach.cl/lsg-core-api"; public static VitaSyncPlugin Instance { get; private set; } public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; public static SceneMonitor Monitor { get; private set; } private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Instance = this; Harmony val = new Harmony("com.diinf.vitasync"); val.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; GameObject val2 = new GameObject("VitaSync_Monitor"); Monitor = val2.AddComponent<SceneMonitor>(); Object.DontDestroyOnLoad((Object)(object)val2); Log.LogInfo((object)"VitaSync v1.0.0 cargado."); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if ((!(((Scene)(ref scene)).name == "Main") || (int)mode != 1) && !((Scene)(ref scene)).name.Contains("Shop")) { ShopCanjePanel.DestroyInstance(); } } private void OnApplicationQuit() { SessionLogger.EndSession(); } public void SetActiveProfile(LifeSyncClient.PhysicalProfile p) { _activeProfile = p; } public LifeSyncClient.PhysicalProfile GetActiveProfile() { return _activeProfile; } private static void CapturarBaselineUpgrades() { if (!((Object)(object)StatsManager.instance == (Object)null)) { string text = ObtenerSteamIdLocal(); if (!string.IsNullOrEmpty(text)) { int value = 0; int value2 = 0; int value3 = 0; int value4 = 0; StatsManager.instance.playerUpgradeStamina.TryGetValue(text, out value); StatsManager.instance.playerUpgradeStrength.TryGetValue(text, out value2); StatsManager.instance.playerUpgradeHealth.TryGetValue(text, out value3); StatsManager.instance.playerUpgradeSpeed.TryGetValue(text, out value4); SessionManager.CapturarBaseline(value, value2, value3, value4); Log.LogInfo((object)("[LSG] Línea base capturada: Stamina=" + value + " Grip=" + value2 + " Health=" + value3 + " Speed=" + value4)); } } } private static string ObtenerSteamIdLocal() { PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript != (Object)null) { return SemiFunc.PlayerGetSteamID(instance.playerAvatarScript); } PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); return ((Object)(object)val != (Object)null) ? SemiFunc.PlayerGetSteamID(val) : null; } } public class SceneMonitor : MonoBehaviour { private float _timer = 0f; private void Update() { _timer += Time.deltaTime; if (_timer >= 2f) { _timer = 0f; if (!SemiFunc.RunIsShop()) { ShopCanjePanel.DestroyInstance(); } } } public void ResetUpgrades() { SessionManager.ClearUpgrades(); } public void AplicarUpgradesSync() { string text = null; PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript != (Object)null) { text = SemiFunc.PlayerGetSteamID(instance.playerAvatarScript); } if (string.IsNullOrEmpty(text)) { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)val != (Object)null) { text = SemiFunc.PlayerGetSteamID(val); } } if (string.IsNullOrEmpty(text)) { VitaSyncPlugin.Log.LogWarning((object)"[LSG] steamID no disponible. Abortando."); return; } if ((Object)(object)PunManager.instance == (Object)null || (Object)(object)StatsManager.instance == (Object)null) { VitaSyncPlugin.Log.LogWarning((object)"[LSG] PunManager o StatsManager nulos. Abortando."); return; } StatsManager.instance.playerUpgradeStamina.TryGetValue(text, out var value); StatsManager.instance.playerUpgradeStrength.TryGetValue(text, out var value2); StatsManager.instance.playerUpgradeHealth.TryGetValue(text, out var value3); StatsManager.instance.playerUpgradeSpeed.TryGetValue(text, out var value4); int num = SessionManager.BaselineStamina + SessionManager.UpgradesStamina - value; int num2 = SessionManager.BaselineGrip + SessionManager.UpgradesGrip - value2; int num3 = SessionManager.BaselineHealth + SessionManager.UpgradesHealth - value3; int num4 = SessionManager.BaselineSpeed + SessionManager.UpgradesSpeed - value4; if (num <= 0 && num2 <= 0 && num3 <= 0 && num4 <= 0) { VitaSyncPlugin.Log.LogInfo((object)"[LSG] Upgrades ya al día, nada que aplicar."); return; } if (num > 0) { PunManager.instance.UpgradePlayerEnergy(text, num); } if (num2 > 0) { PunManager.instance.UpgradePlayerGrabStrength(text, num2); } if (num3 > 0) { PunManager.instance.UpgradePlayerHealth(text, num3); StatsManager.instance.playerUpgradeHealth.TryGetValue(text, out var value5); int num5 = 100 + value5 * 20; StatsManager.instance.SetPlayerHealth(text, num5, false); VitaSyncPlugin.Log.LogInfo((object)("[LSG] Health persistido=" + num5 + " RunIsShop=" + SemiFunc.RunIsShop())); } if (num4 > 0) { PunManager.instance.UpgradePlayerSprintSpeed(text, num4); } SessionLogger.LogUpgradesApplied(Mathf.Max(0, num3), Mathf.Max(0, num), Mathf.Max(0, num2), Mathf.Max(0, num4)); VitaSyncPlugin.Log.LogInfo((object)("[LSG] Upgrades re-sincronizados localmente. sid=" + text + " (+Stamina=" + Mathf.Max(0, num) + " +Grip=" + Mathf.Max(0, num2) + " +Health=" + Mathf.Max(0, num3) + " +Speed=" + Mathf.Max(0, num4) + ")")); } } public static class SessionLogger { private static string _sessionId = null; private static string _sessionStart = null; private static string _sessionStartUtc = null; private static bool _active = false; private static bool _teamDeadRegistrado = false; private static string _ultimoNivelStart = null; private static string _ultimoNivelEnd = null; private static bool _sessionEraMP = false; private static int _sessionJugadores = 1; private static List<string> _sessionEventsJson = null; private const int VIDEOGAME_ID = 22; private static string _csvPath = null; private static string _pendingDir = null; private static FieldInfo _gameOverField; private static readonly HttpClient _httpClient = new HttpClient(); private static string CsvPath { get { if (_csvPath != null) { return _csvPath; } try { _csvPath = Path.Combine(Paths.BepInExRootPath, "VitaSync_Events.csv"); } catch { _csvPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "VitaSync_Events.csv"); } return _csvPath; } } private static string PendingDir { get { if (_pendingDir != null) { return _pendingDir; } try { _pendingDir = Path.Combine(Paths.BepInExRootPath, "VitaSync_Logs"); Directory.CreateDirectory(_pendingDir); } catch { _pendingDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "VitaSync_Logs"); try { Directory.CreateDirectory(_pendingDir); } catch { } } return _pendingDir; } } private static void RefreshModoCache() { try { bool flag = (_sessionEraMP = SemiFunc.IsMultiplayer()); if (flag && (Object)(object)GameDirector.instance != (Object)null) { _sessionJugadores = GameDirector.instance.PlayerList.Count; } else if (!flag) { _sessionJugadores = 1; } } catch { } } private static void EnsureActive() { if (!_active && SessionManager.IsActive) { StartSession(); } } public static void StartSession() { if (!_active) { _sessionId = DateTime.UtcNow.Ticks.ToString(); _sessionStart = LocalNow(); _sessionStartUtc = UtcNow(); _active = true; _teamDeadRegistrado = false; _ultimoNivelStart = null; _ultimoNivelEnd = null; RefreshModoCache(); _sessionEventsJson = new List<string>(); Write("session_start", "modo=" + (_sessionEraMP ? "multiplayer" : "singleplayer") + "|jugadores=" + _sessionJugadores); VitaSyncPlugin.Log.LogInfo((object)("[SL] Sesión iniciada. id=" + _sessionId)); } } public static void EndSession() { if (_active) { bool gameOver = GetGameOver(); int num = 0; try { num = RunManager.instance?.levelsCompleted ?? 0; } catch { } Write("session_end", "niveles=" + num + "|game_over=" + (gameOver ? "true" : "false") + "|modo=" + (_sessionEraMP ? "multiplayer" : "singleplayer") + "|jugadores=" + _sessionJugadores); string sessionId = _sessionId; string sessionStartUtc = _sessionStartUtc; List<string> eventos = _sessionEventsJson ?? new List<string>(); int playerId = SessionManager.PlayerId; _active = false; _sessionId = null; _sessionStart = null; _sessionStartUtc = null; _teamDeadRegistrado = false; _ultimoNivelStart = null; _ultimoNivelEnd = null; _sessionEraMP = false; _sessionJugadores = 1; _sessionEventsJson = null; VitaSyncPlugin.Log.LogInfo((object)"[SL] Sesión cerrada."); if (!string.IsNullOrEmpty(sessionId)) { string json = BuildJson(playerId, sessionStartUtc, UtcNow(), eventos); GuardarLogLocal(sessionId, json); EnviarJson(sessionId, json); } } } public static void LogLevelStart(string level) { EnsureActive(); if (!_active) { return; } RefreshModoCache(); if (!(_ultimoNivelStart == level)) { _ultimoNivelStart = level; _ultimoNivelEnd = null; _teamDeadRegistrado = false; int num = 0; try { num = RunManager.instance?.levelsCompleted ?? 0; } catch { } Write("level_start", "level=" + Esc(level) + "|niveles=" + num); } } public static void LogLevelEnd(string level) { EnsureActive(); if (!_active) { return; } RefreshModoCache(); if (!(_ultimoNivelStart != level) && !(_ultimoNivelEnd == level)) { _ultimoNivelEnd = level; bool gameOver = GetGameOver(); int num = 0; try { num = RunManager.instance?.levelsCompleted ?? 0; } catch { } Write("level_end", "level=" + Esc(level) + "|niveles=" + num + "|game_over=" + (gameOver ? "true" : "false")); } } public static void LogShopOpen(int puntos) { EnsureActive(); if (_active) { RefreshModoCache(); int num = 0; try { num = RunManager.instance?.levelsCompleted ?? 0; } catch { } Write("shop_open", "puntos=" + puntos + "|despues_nivel=" + num); } } public static void LogShopClose(int canjes) { EnsureActive(); if (_active) { RefreshModoCache(); Write("shop_close", "canjes=" + canjes); } } public static void LogUpgradeRedeemed(string attr, int costo, int puntosRestantes) { EnsureActive(); if (_active) { RefreshModoCache(); Write("upgrade_redeemed", "atributo=" + Esc(attr) + "|costo=" + costo + "|puntos_restantes=" + puntosRestantes); } } public static void LogUpgradesApplied(int hp, int stamina, int grip, int speed) { EnsureActive(); if (_active) { RefreshModoCache(); Write("upgrades_applied", "health=" + hp + "|stamina=" + stamina + "|grip=" + grip + "|speed=" + speed); } } public static void LogTeamDead(int niveles) { EnsureActive(); if (_active) { RefreshModoCache(); if (!_teamDeadRegistrado) { _teamDeadRegistrado = true; Write("team_dead", "niveles=" + niveles + "|modo=" + (_sessionEraMP ? "multiplayer" : "singleplayer") + "|jugadores=" + _sessionJugadores); } } } private static void Write(string eventType, string data) { try { string csvPath = CsvPath; bool flag = File.Exists(csvPath); string value = (_sessionId ?? "?") + "," + (_sessionStart ?? "?") + "," + LocalNow() + "," + SessionManager.PlayerId + "," + eventType + ",\"" + data.Replace("\"", "\"\"") + "\""; using (StreamWriter streamWriter = new StreamWriter(csvPath, append: true, Encoding.UTF8)) { if (!flag) { streamWriter.WriteLine("session_id,session_start,timestamp,player_id,event_type,data"); } streamWriter.WriteLine(value); } _sessionEventsJson?.Add("{\"type\":\"" + JsonEscape(eventType) + "\",\"timestamp\":\"" + UtcNow() + "\",\"data\":\"" + JsonEscape(data) + "\"}"); } catch (Exception ex) { VitaSyncPlugin.Log.LogWarning((object)("[SL] Error CSV: " + ex.GetType().Name + ": " + ex.Message)); } } private static bool GetGameOver() { try { if ((Object)(object)RunManager.instance == (Object)null) { return false; } if (_gameOverField == null) { _gameOverField = typeof(RunManager).GetField("gameOver", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_gameOverField == null) { return false; } return (bool)_gameOverField.GetValue(RunManager.instance); } catch { return false; } } private static string LocalNow() { return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } private static string UtcNow() { return DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); } private static string Esc(string s) { return (s == null) ? "" : s.Replace(",", ";").Replace("\"", "'"); } private static string BuildJson(int playerId, string sessionStartUtc, string sessionEndUtc, List<string> eventos) { string s = "[" + string.Join(",", eventos) + "]"; return "{\"player_id\":" + playerId + ",\"videogame_id\":" + 22 + ",\"session_start\":\"" + JsonEscape(ToSqlDateTime(sessionStartUtc)) + "\",\"session_end\":\"" + JsonEscape(ToSqlDateTime(sessionEndUtc)) + "\",\"raw_log\":\"" + JsonEscape(s) + "\"}"; } private static string ToSqlDateTime(string isoUtc) { if (string.IsNullOrEmpty(isoUtc)) { return ""; } string text = isoUtc; if (text.EndsWith("Z")) { text = text.Substring(0, text.Length - 1); } return text.Replace("T", " "); } private static void GuardarLogLocal(string sessionId, string json) { try { string path = Path.Combine(PendingDir, sessionId + ".json"); File.WriteAllText(path, json, Encoding.UTF8); } catch (Exception ex) { VitaSyncPlugin.Log.LogWarning((object)("[SL] No se pudo guardar la copia local del JSON: " + ex.GetType().Name + ": " + ex.Message)); } } private static void EnviarJson(string sessionId, string json) { EnviarJsonAsync(sessionId, json); } private static async Task EnviarJsonAsync(string sessionId, string json) { try { string url = "https://lsg.diinf.usach.cl/lsg-core-api/game-logs/sessions"; HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, url); try { req.Content = (HttpContent)new StringContent(json, Encoding.UTF8); req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); if (!string.IsNullOrEmpty(SessionManager.BearerToken)) { req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", SessionManager.BearerToken); } using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(8.0)); HttpResponseMessage resp = await ((HttpMessageInvoker)_httpClient).SendAsync(req, cts.Token).ConfigureAwait(continueOnCapturedContext: false); string cuerpoRespuesta = ""; try { cuerpoRespuesta = await resp.Content.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false); } catch { } if (resp.IsSuccessStatusCode) { VitaSyncPlugin.Log.LogInfo((object)("[SL] Envío OK. session_id=" + sessionId + " HTTP=" + (int)resp.StatusCode)); return; } VitaSyncPlugin.Log.LogWarning((object)("[SL] Envío FALLÓ. session_id=" + sessionId + " HTTP=" + (int)resp.StatusCode + " body=" + cuerpoRespuesta)); } finally { ((IDisposable)req)?.Dispose(); } } catch (Exception ex) { Exception ex2 = ex; VitaSyncPlugin.Log.LogWarning((object)("[SL] Envío FALLÓ (excepción). session_id=" + sessionId + ": " + ex2.GetType().Name + ": " + ex2.Message)); } } private static string JsonEscape(string s) { if (string.IsNullOrEmpty(s)) { return ""; } StringBuilder stringBuilder = new StringBuilder(s.Length); foreach (char c in s) { switch (c) { case '"': stringBuilder.Append("\\\""); break; case '\\': stringBuilder.Append("\\\\"); break; case '\n': stringBuilder.Append("\\n"); break; case '\t': stringBuilder.Append("\\t"); break; default: stringBuilder.Append(c); break; case '\r': break; } } return stringBuilder.ToString(); } } public static class SessionManager { public static string BearerToken { get; private set; } = null; public static int PlayerId { get; private set; } = -1; public static bool IsActive => !string.IsNullOrEmpty(BearerToken) && PlayerId >= 0; public static int UpgradesStamina { get; private set; } = 0; public static int UpgradesGrip { get; private set; } = 0; public static int UpgradesHealth { get; private set; } = 0; public static int UpgradesSpeed { get; private set; } = 0; public static int BaselineStamina { get; private set; } = 0; public static int BaselineGrip { get; private set; } = 0; public static int BaselineHealth { get; private set; } = 0; public static int BaselineSpeed { get; private set; } = 0; public static bool BaselineCapturado { get; private set; } = false; public static bool TieneUpgradesPendientes => UpgradesStamina > 0 || UpgradesGrip > 0 || UpgradesHealth > 0 || UpgradesSpeed > 0; public static void CapturarBaseline(int stamina, int grip, int health, int speed) { if (!BaselineCapturado) { BaselineStamina = stamina; BaselineGrip = grip; BaselineHealth = health; BaselineSpeed = speed; BaselineCapturado = true; } } public static void Save(string token, int playerId) { BearerToken = token; PlayerId = playerId; VitaSyncPlugin.Log.LogInfo((object)("[Session] Sesión guardada. PlayerID=" + playerId)); } public static void UpdateToken(string newToken) { BearerToken = newToken; VitaSyncPlugin.Log.LogInfo((object)"[Session] Token JWT refrescado correctamente."); } public static void Clear() { BearerToken = null; PlayerId = -1; ClearUpgrades(); VitaSyncPlugin.Log.LogInfo((object)"[Session] Sesión limpiada."); } public static void AddUpgrade(int idx) { switch (idx) { case 0: UpgradesStamina++; break; case 1: UpgradesGrip++; break; case 2: UpgradesHealth++; break; case 3: UpgradesSpeed++; break; } } public static void ClearUpgrades() { UpgradesStamina = 0; UpgradesGrip = 0; UpgradesHealth = 0; UpgradesSpeed = 0; BaselineStamina = 0; BaselineGrip = 0; BaselineHealth = 0; BaselineSpeed = 0; BaselineCapturado = false; } } public class ShopCanjePanel : MonoBehaviour { private static ShopCanjePanel _instance; private GameObject _canvasGO; private Text _balanceText; private Text _slotsText; private Button[] _attrButtons; private Text[] _attrNameLabels; private Text[] _attrPriceLabels; private Image[] _attrRowImages; private Text _processingText; private LifeSyncClient.PhysicalProfile _profile; private bool _syncInProgress = false; private static readonly string[] ATTR_NAMES = new string[4] { "STAMINA", "GRIP", "HEALTH", "SPEED" }; private static readonly string[] PROC = new string[4] { "", ".", "..", "..." }; private int _procIdx = 0; private float _procTimer = 0f; private const float PROC_DT = 0.3f; private static readonly Color C_BG = new Color(0.13f, 0.11f, 0.09f, 0.93f); private static readonly Color C_HDR = new Color(0.18f, 0.14f, 0.1f, 0.97f); private static readonly Color C_GOLD = new Color(0.78f, 0.6f, 0.18f, 1f); private static readonly Color C_TEXT = new Color(0.8f, 0.76f, 0.7f, 1f); private static readonly Color C_DIM = new Color(0.48f, 0.44f, 0.38f, 1f); private static readonly Color C_WHITE = new Color(0.94f, 0.9f, 0.84f, 1f); private static readonly Color C_ROW_ON = new Color(0.2f, 0.17f, 0.13f, 1f); private static readonly Color C_ROW_OFF = new Color(0.12f, 0.1f, 0.08f, 1f); private static readonly Color C_LOCKED = new Color(0.3f, 0.27f, 0.22f, 1f); private static readonly Color C_PRICE_ON = new Color(0.78f, 0.6f, 0.18f, 1f); private static readonly Color C_BTN_RED = new Color(0.32f, 0.08f, 0.06f, 1f); private static readonly Color C_BTN_RED_T = new Color(0.88f, 0.44f, 0.38f, 1f); private static readonly Color C_BTN_BRN = new Color(0.26f, 0.16f, 0.06f, 1f); private static readonly Color C_BTN_BRN_T = new Color(0.88f, 0.64f, 0.28f, 1f); public static void EnsureInstance(LifeSyncClient.PhysicalProfile profile) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if ((Object)(object)_instance != (Object)null) { _instance.Refresh(profile); return; } GameObject val = new GameObject("VitaSync_ShopPanel"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent<ShopCanjePanel>(); _instance.Build(profile); } public static void DestroyInstance() { if (!((Object)(object)_instance == (Object)null)) { if ((Object)(object)_instance._canvasGO != (Object)null) { Object.Destroy((Object)(object)_instance._canvasGO); } Object.Destroy((Object)(object)((Component)_instance).gameObject); _instance = null; VitaSyncPlugin.Log.LogInfo((object)"[Shop] Panel destruido de forma limpia."); } } private void Build(LifeSyncClient.PhysicalProfile profile) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: 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_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0432: 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_0448: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Expected O, but got Unknown //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0538: 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_055d: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Expected O, but got Unknown //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_074f: 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_0786: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07df: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Expected O, but got Unknown //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_0813: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Expected O, but got Unknown _profile = profile; _canvasGO = new GameObject("VitaSync_CanjeCanvas"); Object.DontDestroyOnLoad((Object)(object)_canvasGO); Canvas val = _canvasGO.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 3000; _canvasGO.AddComponent<CanvasScaler>(); _canvasGO.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("Panel"); val2.transform.SetParent(_canvasGO.transform, false); ((Graphic)val2.AddComponent<Image>()).color = C_BG; RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0.5f); component.anchorMax = new Vector2(1f, 0.5f); component.pivot = new Vector2(1f, 0.5f); component.sizeDelta = new Vector2(240f, 400f); component.anchoredPosition = new Vector2(-14f, 0f); MakeRect(val2.transform, "Accent", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(3f, 0f), Vector2.zero, C_GOLD); GameObject val3 = new GameObject("Hdr"); val3.transform.SetParent(val2.transform, false); ((Graphic)val3.AddComponent<Image>()).color = C_HDR; RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); component2.sizeDelta = new Vector2(0f, 42f); component2.anchoredPosition = Vector2.zero; MakeRect(val3.transform, "HdrLine", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 2f), Vector2.zero, C_GOLD); MakeLbl(val3.transform, "LIFESYNC STORE", new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(240f, 42f), 13, C_GOLD, bold: true, (TextAnchor)4); MakeLbl(val2.transform, "PTS", new Vector2(0f, 0.5f), new Vector2(14f, 126f), new Vector2(36f, 28f), 9, C_DIM, bold: false, (TextAnchor)3); _balanceText = MakeLbl(val2.transform, "---", new Vector2(1f, 0.5f), new Vector2(-14f, 126f), new Vector2(100f, 28f), 22, C_WHITE, bold: true, (TextAnchor)5); MakeLbl(val2.transform, "CANJES", new Vector2(0f, 0.5f), new Vector2(14f, 98f), new Vector2(56f, 20f), 9, C_DIM, bold: false, (TextAnchor)3); _slotsText = MakeLbl(val2.transform, "0/2", new Vector2(1f, 0.5f), new Vector2(-14f, 98f), new Vector2(50f, 20f), 11, C_TEXT, bold: true, (TextAnchor)5); MakeRect(val2.transform, "Sep1", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(222f, 1f), new Vector2(0f, 78f), new Color(C_GOLD.r, C_GOLD.g, C_GOLD.b, 0.3f)); _processingText = MakeLbl(val2.transform, "", new Vector2(0.5f, 0.5f), new Vector2(0f, 62f), new Vector2(220f, 16f), 9, C_GOLD, bold: false, (TextAnchor)4); int[] array = new int[4] { profile.CostoStamina, profile.CostoGrip, profile.CostoHealth, profile.CostoSpeed }; _attrButtons = (Button[])(object)new Button[4]; _attrNameLabels = (Text[])(object)new Text[4]; _attrPriceLabels = (Text[])(object)new Text[4]; _attrRowImages = (Image[])(object)new Image[4]; for (int i = 0; i < 4; i++) { int idx = i; float num = 52f - (float)i * 40f; GameObject val4 = new GameObject("Row_" + ATTR_NAMES[i]); val4.transform.SetParent(val2.transform, false); Image val5 = val4.AddComponent<Image>(); ((Graphic)val5).color = C_ROW_OFF; Button val6 = val4.AddComponent<Button>(); ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock; ((ColorBlock)(ref defaultColorBlock)).normalColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(1.25f, 1.25f, 1.25f, 1f); ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.78f, 0.78f, 0.78f, 1f); ((ColorBlock)(ref defaultColorBlock)).disabledColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).colorMultiplier = 1f; ((Selectable)val6).colors = defaultColorBlock; ((Selectable)val6).targetGraphic = (Graphic)(object)val5; RectTransform component3 = val4.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.sizeDelta = new Vector2(226f, 34f); component3.anchoredPosition = new Vector2(4f, num); Text val7 = MakeLbl(val4.transform, ATTR_NAMES[i], new Vector2(0f, 0.5f), new Vector2(10f, 0f), new Vector2(120f, 34f), 11, C_LOCKED, bold: true, (TextAnchor)3); Text val8 = MakeLbl(val4.transform, array[i] + " PTS", new Vector2(1f, 0.5f), new Vector2(-10f, 0f), new Vector2(72f, 34f), 10, C_LOCKED, bold: false, (TextAnchor)5); ((UnityEvent)val6.onClick).AddListener((UnityAction)delegate { OnRedeemClick(idx); }); _attrButtons[i] = val6; _attrNameLabels[i] = val7; _attrPriceLabels[i] = val8; _attrRowImages[i] = val5; } MakeRect(val2.transform, "Sep2", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(222f, 1f), new Vector2(0f, -93f), new Color(C_GOLD.r, C_GOLD.g, C_GOLD.b, 0.3f)); ((UnityEvent)MakeBtn(val2.transform, "BtnClose", "OCULTAR", new Vector2(4f, -130f), new Vector2(226f, 30f), C_BTN_RED, C_BTN_RED_T).GetComponent<Button>().onClick).AddListener(new UnityAction(DestroyInstance)); ((UnityEvent)MakeBtn(val2.transform, "BtnLogout", "CERRAR SESION", new Vector2(4f, -166f), new Vector2(226f, 30f), C_BTN_BRN, C_BTN_BRN_T).GetComponent<Button>().onClick).AddListener(new UnityAction(OnLogoutClick)); RefreshUI(); } private void Update() { if ((Object)(object)_canvasGO != (Object)null && _canvasGO.activeInHierarchy) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (_syncInProgress && (Object)(object)_processingText != (Object)null) { _procTimer += Time.deltaTime; if (_procTimer >= 0.3f) { _procTimer = 0f; _procIdx = (_procIdx + 1) % PROC.Length; _processingText.text = "SINCRONIZANDO" + PROC[_procIdx]; } } } private void OnLogoutClick() { SessionManager.Clear(); VitaSyncPlugin.Instance.SetActiveProfile(null); DestroyInstance(); } private void OnRedeemClick(int idx) { if (_profile == null || _syncInProgress) { return; } int num = idx switch { 2 => _profile.CostoHealth, 1 => _profile.CostoGrip, 0 => _profile.CostoStamina, _ => _profile.CostoSpeed, }; if (_profile.PuedePagar(num)) { SessionManager.AddUpgrade(idx); _profile.Puntos -= num; _profile.CanjesUsados++; SessionLogger.LogUpgradeRedeemed(ATTR_NAMES[idx], num, _profile.Puntos); if (SessionManager.IsActive) { ((MonoBehaviour)this).StartCoroutine(EnviarDescuento(SessionManager.PlayerId, SessionManager.BearerToken, num, ATTR_NAMES[idx])); } RefreshUI(); } } private IEnumerator EnviarDescuento(int playerId, string token, int cantidad, string attr) { _syncInProgress = true; _procIdx = 0; _procTimer = 0f; _processingText.text = "SINCRONIZANDO"; SetButtonsInteractable(v: false); string url = "https://lsg.diinf.usach.cl/lsg-core-api/players/" + playerId + "/points/adjust"; string body = "{\"point_dimension_id\":2,\"direction\":\"DEBIT\",\"amount\":" + cantidad + ",\"reason\":\"VitaSync: " + attr + "\",\"videogame_id\":22}"; UnityWebRequest req = new UnityWebRequest(url, "POST"); try { byte[] raw = Encoding.UTF8.GetBytes(body); req.uploadHandler = (UploadHandler)new UploadHandlerRaw(raw); req.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); req.SetRequestHeader("Authorization", "Bearer " + token); req.SetRequestHeader("Content-Type", "application/json"); req.SetRequestHeader("Accept", "application/json"); req.timeout = 8; yield return req.SendWebRequest(); if ((int)req.result == 1) { VitaSyncPlugin.Log.LogInfo((object)("[LSG] Cloud -" + cantidad + " pts.")); } else { VitaSyncPlugin.Log.LogError((object)("[LSG] Error HTTP " + req.responseCode)); } } finally { ((IDisposable)req)?.Dispose(); } _syncInProgress = false; _processingText.text = ""; SetButtonsInteractable(v: true); RefreshUI(); } public void Refresh(LifeSyncClient.PhysicalProfile profile) { _profile = profile; RefreshUI(); } private void RefreshUI() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) if (_profile != null) { _balanceText.text = _profile.Puntos.ToString(); _slotsText.text = _profile.CanjesUsados + "/" + _profile.CanjesMax; int[] array = new int[4] { _profile.CostoStamina, _profile.CostoGrip, _profile.CostoHealth, _profile.CostoSpeed }; for (int i = 0; i < 4; i++) { bool flag = _profile.Puntos >= array[i] && _profile.CanjesUsados < _profile.CanjesMax && !_syncInProgress; ((Selectable)_attrButtons[i]).interactable = flag; ((Graphic)_attrRowImages[i]).color = (flag ? C_ROW_ON : C_ROW_OFF); ((Graphic)_attrNameLabels[i]).color = (flag ? C_TEXT : C_LOCKED); ((Graphic)_attrPriceLabels[i]).color = (flag ? C_PRICE_ON : C_LOCKED); } } } private void SetButtonsInteractable(bool v) { Button[] attrButtons = _attrButtons; foreach (Button val in attrButtons) { if ((Object)(object)val != (Object)null) { ((Selectable)val).interactable = v; } } } private void OnDestroy() { if ((Object)(object)_canvasGO != (Object)null) { Object.Destroy((Object)(object)_canvasGO); } } private static Font GetFont() { return Resources.GetBuiltinResource<Font>("Arial.ttf"); } private static void MakeRect(Transform p, string name, Vector2 aMin, Vector2 aMax, Vector2 size, Vector2 pos, Color col) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) GameObject val = new GameObject(name); val.transform.SetParent(p, false); ((Graphic)val.AddComponent<Image>()).color = col; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = aMin; component.anchorMax = aMax; component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = size; component.anchoredPosition = pos; } private static Text MakeLbl(Transform p, string text, Vector2 anchor, Vector2 pos, Vector2 size, int fs, Color col, bool bold, TextAnchor align) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0077: 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_0088: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("T"); val.transform.SetParent(p, false); Text val2 = val.AddComponent<Text>(); val2.font = GetFont(); val2.text = text; val2.fontSize = fs; ((Graphic)val2).color = col; val2.fontStyle = (FontStyle)(bold ? 1 : 0); val2.alignment = align; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = anchor; component.anchorMax = anchor; component.pivot = anchor; component.sizeDelta = size; component.anchoredPosition = pos; return val2; } private static GameObject MakeBtn(Transform p, string name, string label, Vector2 pos, Vector2 size, Color bg, Color fg) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(p, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = bg; Button val3 = val.AddComponent<Button>(); ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock; ((ColorBlock)(ref defaultColorBlock)).normalColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(1.2f, 1.2f, 1.2f, 1f); ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.78f, 0.78f, 0.78f, 1f); ((ColorBlock)(ref defaultColorBlock)).disabledColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).colorMultiplier = 1f; ((Selectable)val3).colors = defaultColorBlock; ((Selectable)val3).targetGraphic = (Graphic)(object)val2; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = size; component.anchoredPosition = pos; GameObject val4 = new GameObject("L"); val4.transform.SetParent(val.transform, false); Text val5 = val4.AddComponent<Text>(); val5.font = GetFont(); val5.text = label; val5.fontSize = 11; ((Graphic)val5).color = fg; val5.fontStyle = (FontStyle)1; val5.alignment = (TextAnchor)4; RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; return val; } } public static class TokenRefresher { private static bool _refreshInProgress; public static void TryRefresh() { if (_refreshInProgress) { return; } if (!SessionManager.IsActive) { VitaSyncPlugin.Log.LogWarning((object)"[Refresh] Sesión inactiva. Omitido."); return; } SceneMonitor monitor = VitaSyncPlugin.Monitor; if ((Object)(object)monitor == (Object)null) { VitaSyncPlugin.Log.LogWarning((object)"[Refresh] Monitor nulo. Omitido."); } else { ((MonoBehaviour)monitor).StartCoroutine(RefreshCoroutine((MonoBehaviour)(object)monitor)); } } private static IEnumerator RefreshCoroutine(MonoBehaviour runner) { _refreshInProgress = true; string jsonBody = "{\"token\":\"" + SessionManager.BearerToken + "\"}"; UnityWebRequest req = new UnityWebRequest("https://lsg.diinf.usach.cl/lsg-auth/token/refresh", "POST"); try { byte[] raw = Encoding.UTF8.GetBytes(jsonBody); req.uploadHandler = (UploadHandler)new UploadHandlerRaw(raw); req.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); req.SetRequestHeader("Authorization", "Bearer " + SessionManager.BearerToken); req.SetRequestHeader("Content-Type", "application/json"); req.SetRequestHeader("Accept", "application/json"); req.timeout = 8; yield return req.SendWebRequest(); if ((int)req.result == 1) { string newToken = LifeSyncClient.ExtractString(req.downloadHandler.text, "access_token"); if (!string.IsNullOrEmpty(newToken)) { SessionManager.UpdateToken(newToken); VitaSyncPlugin.Log.LogInfo((object)"[Refresh] Token actualizado."); } else { VitaSyncPlugin.Log.LogWarning((object)"[Refresh] Token vacío en respuesta 200."); } } else { VitaSyncPlugin.Log.LogWarning((object)("[Refresh] Error HTTP " + req.responseCode + ": " + req.error)); } } finally { ((IDisposable)req)?.Dispose(); } _refreshInProgress = false; } }