Decompiled source of LifeSync Games Valheim v0.1.3
LifeSync-Games-Valheim.dll
Decompiled 2 weeks 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.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using LifeSync.Valheim.Config; using LifeSync.Valheim.Controllers; using LifeSync.Valheim.Models; using LifeSync.Valheim.Services; using LifeSync.Valheim.UI; using Newtonsoft.Json; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("LifeSync-Games-Valheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LifeSync-Games-Valheim")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ae94fb50-7a19-489c-90d1-142ac4878a2c")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LifeSync.Valheim { [BepInPlugin("com.lifesyncgames.valheim", "LifeSyncGames Plugin", "0.1.0")] public class Main : BaseUnityPlugin { public static Harmony Harmony; public static UserLifeSyncController Users; public static PointsService Points; public static BuffService Buffs; public static SessionTrackingService SessionTracking; private GameObject uiRoot; public static ConfigEntry<float> LevelsPerPoint; private void Awake() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_011b: 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_0130: Expected O, but got Unknown Game.isModded = true; try { _ = typeof(JsonConvert).Assembly; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LifeSync] Newtonsoft error: " + ex.Message)); } LevelsPerPoint = ((BaseUnityPlugin)this).Config.Bind<float>("LifeSync", "LevelsPerPoint", 1f, "How many levels are gained per point spent in the UI. Default is 1 (1 point = 1 level, 2 points = 2 levels, etc)."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LifeSync] starting..."); Harmony = new Harmony("com.lifesyncgames.valheim"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); Users = new UserLifeSyncController(); Points = new PointsService(() => Users.UserLifeSyncModel); Buffs = new BuffService(() => Users.UserLifeSyncModel); Buffs.InitializeEffectService(); uiRoot = new GameObject("LifeSync.UI"); uiRoot.AddComponent<LoginUI>(); uiRoot.AddComponent<PointsUI>(); GameObject val = new GameObject("LifeSync.SessionTracking"); SessionTracking = val.AddComponent<SessionTrackingService>(); Object.DontDestroyOnLoad((Object)val); uiRoot.AddComponent<LifeSyncQuickAccessUI>(); Object.DontDestroyOnLoad((Object)(object)uiRoot); Users.LoadCredentials(); } private void Update() { } private void OnDestroy() { try { Buffs?.SaveActiveBuffs(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LifeSync] Error al guardar buffs: " + ex.Message)); } } private void OnApplicationQuit() { try { Buffs?.SaveActiveBuffs(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LifeSync] Error al guardar buffs: " + ex.Message)); } } } } namespace LifeSync.Valheim.UI { internal class LoginUI : MonoBehaviour { [CompilerGenerated] private sealed class <CenterMousePositionCoroutine>d__23 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public LoginUI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CenterMousePositionCoroutine>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; LoginUI loginUI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; try { int x = Screen.width / 2; int y = Screen.height / 2; loginUI.SetCursorPosition(x, y); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] Error al centrar el mouse: " + ex.Message)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoginFlow>d__16 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public LoginUI <>4__this; public string user; public string pass; private Task<int> <tCheck>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoginFlow>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <tCheck>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; LoginUI loginUI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; loginUI.isSubmitting = true; loginUI.statusText = "Checking credentials..."; Debug.Log((object)("[LifeSync][LOGIN] Intentando login: " + user)); <tCheck>5__2 = Main.Users.UserCheck(user, pass); <>2__current = WaitTask(<tCheck>5__2); <>1__state = 1; return true; case 1: <>1__state = -1; switch (<tCheck>5__2.Result) { case 1: { Debug.Log((object)("[LifeSync][LOGIN] Autenticación OK: " + user)); loginUI.statusText = "Loading user..."; Task task = Main.Users.SaveUserLifeSync(user, pass); <>2__current = WaitTask(task); <>1__state = 2; return true; } case 3: Debug.LogWarning((object)"[LifeSync][LOGIN] Usuario o contraseña vacíos."); loginUI.statusText = "Please enter username and password."; break; default: Debug.LogWarning((object)("[LifeSync][LOGIN] Credenciales inválidas para: " + user)); loginUI.statusText = "Invalid credentials."; break; } break; case 2: { <>1__state = -1; loginUI.isLoggedIn = true; loginUI.showLogin = false; Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; loginUI.ResumeGame(); Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] Welcome, " + user); } Object.FindFirstObjectByType<PointsUI>()?.Open(); break; } } loginUI.isSubmitting = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ResetCursorPosition>d__26 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetCursorPosition>d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; Cursor.lockState = (CursorLockMode)1; Cursor.lockState = (CursorLockMode)0; Cursor.lockState = (CursorLockMode)1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitTask>d__17 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Task task; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitTask>d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (!task.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } if (task.Exception != null) { throw task.Exception; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private UserLifeSyncController userCtrl = new UserLifeSyncController(); public bool showLogin; private string username = ""; private string password = ""; public bool isLoggedIn; private bool initialized; private bool isSubmitting; private string statusText = ""; private Rect windowRect = new Rect(20f, 20f, 300f, 220f); public static void ForceLogout() { LoginUI loginUI = Object.FindFirstObjectByType<LoginUI>(); if ((Object)(object)loginUI != (Object)null) { loginUI.ApplyLogoutUI(); } } public void ApplyLogoutUI() { isLoggedIn = false; showLogin = false; username = string.Empty; password = string.Empty; statusText = "Logged out."; if (!showLogin) { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; ResumeGame(); } } private void Start() { if (initialized) { return; } try { Task<int> task = userCtrl.LoadCredentials(); ((MonoBehaviour)this).StartCoroutine(WaitTask(task)); task.ContinueWith(delegate(Task<int> t) { if (!t.IsFaulted && t.Result > 0) { isLoggedIn = true; showLogin = false; statusText = "User logged in!"; } }); } catch (Exception ex) { Debug.LogError((object)((object)this).Equals((object?)("[LifeSync] Error initializing LoginUI: " + ex.Message))); } } public void ToggleLoginWindow() { showLogin = !showLogin; Cursor.visible = showLogin; Cursor.lockState = (CursorLockMode)((!showLogin) ? 1 : 0); if (showLogin) { PauseGame(); return; } ((MonoBehaviour)this).StartCoroutine(ResetCursorPosition()); ResumeGame(); } private void Update() { if (Input.GetKeyDown((KeyCode)288) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!isLoggedIn) { ToggleLoginWindow(); } else { PointsUI pointsUI = Object.FindFirstObjectByType<PointsUI>(); if ((Object)(object)pointsUI != (Object)null) { pointsUI.Open(); } } } if (showLogin) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private void OnGUI() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_00a5: 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_00c5: Expected O, but got Unknown //IL_00c0: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!initialized) { ((Rect)(ref windowRect)).x = ((float)Screen.width - ((Rect)(ref windowRect)).width) / 2f; ((Rect)(ref windowRect)).y = ((float)Screen.height - ((Rect)(ref windowRect)).height) / 2f; initialized = true; } if (showLogin && (int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { ToggleLoginWindow(); Event.current.Use(); } else if (showLogin) { windowRect = GUILayout.Window(7701, windowRect, new WindowFunction(DrawLoginWindow), "Login to LifeSync", Array.Empty<GUILayoutOption>()); } } } private void DrawLoginWindow(int id) { GUI.enabled = !isSubmitting; GUILayout.Label("Username:", Array.Empty<GUILayoutOption>()); username = GUILayout.TextField(username, 64, Array.Empty<GUILayoutOption>()); GUILayout.Label("Password:", Array.Empty<GUILayoutOption>()); password = GUILayout.PasswordField(password, '*', 64, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(isSubmitting ? "Logging in..." : "Login to LifeSync-Games", Array.Empty<GUILayoutOption>()) && !isSubmitting) { ((MonoBehaviour)this).StartCoroutine(LoginFlow(username, password)); } if (GUILayout.Button("Cancel", Array.Empty<GUILayoutOption>())) { showLogin = false; Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; ((MonoBehaviour)this).StartCoroutine(ResetCursorPosition()); ResumeGame(); } GUI.enabled = true; if (!string.IsNullOrEmpty(statusText)) { GUILayout.Space(6f); GUILayout.Label(statusText, Array.Empty<GUILayoutOption>()); } GUI.DragWindow(); } [IteratorStateMachine(typeof(<LoginFlow>d__16))] private IEnumerator LoginFlow(string user, string pass) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoginFlow>d__16(0) { <>4__this = this, user = user, pass = pass }; } [IteratorStateMachine(typeof(<WaitTask>d__17))] private static IEnumerator WaitTask(Task task) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitTask>d__17(0) { task = task }; } private void PauseGame() { try { if (!Game.IsPaused()) { Game.Pause(); Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; BlockCamera(); } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo pausar el juego: " + ex.Message)); } } private void ResumeGame() { try { if (Game.IsPaused()) { Game.Unpause(); Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; UnblockCamera(); RestoreMousePosition(); } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo reanudar el juego: " + ex.Message)); } } private void BlockCamera() { try { if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = false; } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo bloquear la cámara: " + ex.Message)); } } private void UnblockCamera() { try { if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = true; } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo desbloquear la cámara: " + ex.Message)); } } private void RestoreMousePosition() { try { ((MonoBehaviour)this).StartCoroutine(CenterMousePositionCoroutine()); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo centrar el mouse: " + ex.Message)); } } [IteratorStateMachine(typeof(<CenterMousePositionCoroutine>d__23))] private IEnumerator CenterMousePositionCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CenterMousePositionCoroutine>d__23(0) { <>4__this = this }; } [DllImport("user32.dll")] private static extern bool SetCursorPos(int x, int y); private void SetCursorPosition(int x, int y) { SetCursorPos(x, y); } [IteratorStateMachine(typeof(<ResetCursorPosition>d__26))] private IEnumerator ResetCursorPosition() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetCursorPosition>d__26(0); } } internal class LifeSyncQuickAccessUI : MonoBehaviour { [CompilerGenerated] private sealed class <CheckInitialLoginStatus>d__9 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public LifeSyncQuickAccessUI <>4__this; private Task<bool> <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CheckInitialLoginStatus>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <t>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; LifeSyncQuickAccessUI lifeSyncQuickAccessUI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; lifeSyncQuickAccessUI.checking = true; <t>5__2 = lifeSyncQuickAccessUI.userCtrl.IsLoggedInAsync(); break; case 1: <>1__state = -1; break; } if (!<t>5__2.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } lifeSyncQuickAccessUI.isLoggedIn = !<t>5__2.IsFaulted && <t>5__2.Result; lifeSyncQuickAccessUI.statusText = (lifeSyncQuickAccessUI.isLoggedIn ? "Conectado" : "Desconectado"); lifeSyncQuickAccessUI.checking = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <CheckLoginStatus>d__11 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public LifeSyncQuickAccessUI <>4__this; private Task<bool> <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CheckLoginStatus>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <t>5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; LifeSyncQuickAccessUI lifeSyncQuickAccessUI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; lifeSyncQuickAccessUI.checking = true; <t>5__2 = lifeSyncQuickAccessUI.userCtrl.IsLoggedInAsync(); break; case 1: <>1__state = -1; break; } if (!<t>5__2.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } bool flag = !<t>5__2.IsFaulted && <t>5__2.Result; if (flag != lifeSyncQuickAccessUI.isLoggedIn) { lifeSyncQuickAccessUI.isLoggedIn = flag; lifeSyncQuickAccessUI.statusText = (lifeSyncQuickAccessUI.isLoggedIn ? "Conectado" : "Desconectado"); } lifeSyncQuickAccessUI.checking = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private UserLifeSyncController userCtrl = new UserLifeSyncController(); private bool checking; private GUIStyle statusStyle; private bool stylesInitialized; private Rect statusRect; private bool isLoggedIn; private string statusText = ""; private void Start() { InitializeButtonPositions(); ((MonoBehaviour)this).StartCoroutine(CheckInitialLoginStatus()); } private void InitializeButtonPositions() { //IL_001c: 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) statusRect = new Rect((float)(Screen.width - 220), 20f, 200f, 20f); } [IteratorStateMachine(typeof(<CheckInitialLoginStatus>d__9))] private IEnumerator CheckInitialLoginStatus() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CheckInitialLoginStatus>d__9(0) { <>4__this = this }; } private void Update() { if ((float)Screen.width != ((Rect)(ref statusRect)).x + ((Rect)(ref statusRect)).width + 20f) { InitializeButtonPositions(); } if (!checking && Time.frameCount % 300 == 0) { ((MonoBehaviour)this).StartCoroutine(CheckLoginStatus()); } } [IteratorStateMachine(typeof(<CheckLoginStatus>d__11))] private IEnumerator CheckLoginStatus() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CheckLoginStatus>d__11(0) { <>4__this = this }; } private void InitializeStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!stylesInitialized) { statusStyle = new GUIStyle(GUI.skin.label); statusStyle.fontSize = 12; statusStyle.normal.textColor = Color.white; stylesInitialized = true; } } private void OnGUI() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { InitializeStyles(); InitializeButtonPositions(); DrawKeybindText(); DrawStatusText(); } } private void DrawKeybindText() { //IL_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 9 }; val.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 0.7f); val.alignment = (TextAnchor)6; GUIStyle val2 = val; string text = ((!isLoggedIn) ? "LifeSync-Games Mod\nF7: Login" : "LifeSync-Games Mod\nF7: Menu"); GUI.Label(new Rect(20f, (float)(Screen.height - 100), 250f, 80f), text, val2); } private void DrawStatusText() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0046: 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) Color textColor = statusStyle.normal.textColor; if (isLoggedIn) { statusStyle.normal.textColor = Color.green; } else { statusStyle.normal.textColor = Color.red; } GUI.Label(statusRect, statusText, statusStyle); statusStyle.normal.textColor = textColor; } } internal class PointsUI : MonoBehaviour { [CompilerGenerated] private sealed class <CenterMousePositionCoroutine>d__39 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PointsUI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CenterMousePositionCoroutine>d__39(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; PointsUI pointsUI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; try { int num2 = Screen.width / 2; int num3 = Screen.height / 2; pointsUI.SetCursorPosition(num2, num3); Debug.Log((object)$"[LifeSync] Mouse centrado en: {num2}, {num3}"); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] Error al centrar el mouse: " + ex.Message)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadLogoCoroutine>d__22 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private string[] <>7__wrap1; private int <>7__wrap2; private byte[] <fileData>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadLogoCoroutine>d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <fileData>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; bool flag = false; logoTexture = new Texture2D(2, 2); try { Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule"); if (type != null) { MethodInfo method = type.GetMethod("LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }); if (method != null) { method.Invoke(null, new object[2] { logoTexture, <fileData>5__4 }); flag = ((Texture)logoTexture).width > 2 && ((Texture)logoTexture).height > 2; Debug.Log((object)$"[LifeSync] Logo cargado con ImageConversion: {((Texture)logoTexture).width}x{((Texture)logoTexture).height}"); } } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] ImageConversion no disponible: " + ex.Message)); } if (!flag) { try { MethodInfo method2 = typeof(Texture2D).GetMethod("LoadImage", new Type[1] { typeof(byte[]) }); if (method2 != null) { flag = (bool)method2.Invoke(logoTexture, new object[1] { <fileData>5__4 }); } } catch (Exception ex2) { Debug.LogWarning((object)("[LifeSync] LoadImage no disponible: " + ex2.Message)); } } if (flag && (Object)(object)logoTexture != (Object)null && ((Texture)logoTexture).width > 2 && ((Texture)logoTexture).height > 2) { logoLoaded = true; return false; } if ((Object)(object)logoTexture != (Object)null) { Object.Destroy((Object)(object)logoTexture); logoTexture = null; } <fileData>5__4 = null; goto IL_041f; } <>1__state = -1; string text = null; string text2 = null; try { text = Assembly.GetExecutingAssembly().Location; text2 = Path.GetDirectoryName(text); Debug.Log((object)("[LifeSync] Assembly path: " + text)); Debug.Log((object)("[LifeSync] Assembly directory: " + text2)); } catch (Exception ex3) { Debug.LogError((object)("[LifeSync] Error al obtener ruta del assembly: " + ex3.Message)); logoLoaded = true; return false; } string[] array = new string[6] { Path.Combine(text2, "ITO-iso.png"), Path.Combine(text2, "LifeSync-Games-Valheim", "ITO-iso.png"), Path.Combine(Path.GetDirectoryName(Application.dataPath), "BepInEx", "plugins", "LifeSync-Games-Valheim", "ITO-iso.png"), Path.Combine(Path.GetDirectoryName(Application.dataPath), "BepInEx", "plugins", "ITO-iso.png"), Path.Combine(text2, "..", "ITO-iso.png"), Path.Combine(text2, "..", "..", "ITO-iso.png") }; for (int i = 0; i < array.Length; i++) { try { array[i] = Path.GetFullPath(array[i]); } catch (Exception ex4) { Debug.LogWarning((object)("[LifeSync] Error al normalizar ruta " + array[i] + ": " + ex4.Message)); } } Debug.Log((object)$"[LifeSync] Buscando logo en {array.Length} ubicaciones posibles:"); string[] array2 = array; foreach (string text3 in array2) { Debug.Log((object)$"[LifeSync] - {text3} (existe: {File.Exists(text3)})"); } <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_042d; IL_042d: if (<>7__wrap2 < <>7__wrap1.Length) { string text4 = <>7__wrap1[<>7__wrap2]; if (File.Exists(text4)) { Debug.Log((object)("[LifeSync] Intentando cargar logo desde: " + text4)); <fileData>5__4 = null; try { <fileData>5__4 = File.ReadAllBytes(text4); } catch (Exception ex5) { Debug.LogWarning((object)("[LifeSync] Error al leer archivo " + text4 + ": " + ex5.Message)); goto IL_041f; } if (<fileData>5__4 != null && <fileData>5__4.Length != 0) { <>2__current = null; <>1__state = 1; return true; } } goto IL_041f; } <>7__wrap1 = null; Debug.LogWarning((object)"[LifeSync] No se pudo cargar ITO-iso.png"); logoLoaded = true; return false; IL_041f: <>7__wrap2++; goto IL_042d; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ResetCursorPosition>d__46 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetCursorPosition>d__46(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; Cursor.lockState = (CursorLockMode)1; Cursor.lockState = (CursorLockMode)0; Cursor.lockState = (CursorLockMode)1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public bool open; private Rect win; private int selectedTab; private readonly string[] tabNames = new string[3] { "Subir Nivel", "Potenciadores", "Sesiones" }; private GUIStyle tabStyle; private GUIStyle activeTabStyle; private GUIStyle boxStyle; private bool stylesInitialized; private Vector2 scrollPosition = Vector2.zero; private UserLifeSyncController userCtrl = new UserLifeSyncController(); private static Texture2D texBg; private static Texture2D texFill; private static Texture2D texPreview; private static Texture2D logoTexture; private static bool logoLoaded = false; private readonly Dictionary<SkillType, float> previewPerSkill = new Dictionary<SkillType, float>(); private const float defaultPreview = 0.2f; private static readonly BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private readonly Dictionary<string, SkillType[]> attributeMap; private static bool TryGetLevelAndAccumulator(Skills skills, SkillType type, out int levelI, out float frac) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) levelI = 0; frac = 0f; FieldInfo field = typeof(Skills).GetField("m_skills", BF); IEnumerable enumerable = ((field != null) ? (field.GetValue(skills) as IEnumerable) : null); if (enumerable == null) { return false; } foreach (object item in enumerable) { FieldInfo field2 = item.GetType().GetField("m_info", BF); object obj = ((field2 != null) ? field2.GetValue(item) : null); if (obj == null) { continue; } FieldInfo field3 = obj.GetType().GetField("m_skill", BF); if (!(field3 == null) && (SkillType)field3.GetValue(obj) == type) { FieldInfo field4 = item.GetType().GetField("m_level", BF); FieldInfo field5 = item.GetType().GetField("m_accumulator", BF); if (field4 == null || field5 == null) { return false; } levelI = Mathf.FloorToInt((float)field4.GetValue(item)); frac = Mathf.Clamp01((float)field5.GetValue(item)); return true; } } return false; } private void EnsureTextures() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0037: 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_0057: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)texBg == (Object)null) { texBg = new Texture2D(1, 1); texBg.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.35f)); texBg.Apply(); texFill = new Texture2D(1, 1); texFill.SetPixel(0, 0, new Color(0.2f, 0.8f, 0.2f, 0.9f)); texFill.Apply(); texPreview = new Texture2D(1, 1); texPreview.SetPixel(0, 0, new Color(1f, 0.9f, 0.2f, 0.65f)); texPreview.Apply(); } if (!logoLoaded) { LoadLogo(); } } private void LoadLogo() { ((MonoBehaviour)this).StartCoroutine(LoadLogoCoroutine()); } [IteratorStateMachine(typeof(<LoadLogoCoroutine>d__22))] private IEnumerator LoadLogoCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadLogoCoroutine>d__22(0); } public void Open() { open = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; PauseGame(); InitializeWindow(); } private void InitializeWindow() { //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) float num = Screen.width; float num2 = Screen.height; float num3 = Mathf.Min(600f, num * 0.4f); float num4 = Mathf.Min(700f, num2 * 0.6f); win = new Rect((num - num3) / 2f, (num2 - num4) / 2f, num3, num4); } public void Close() { open = false; Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; ((MonoBehaviour)this).StartCoroutine(ResetCursorPosition()); ResumeGame(); } private void Update() { if (!((Object)(object)Player.m_localPlayer == (Object)null) && open) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; Main.Buffs?.UpdateActiveBuffs(); } } private void InitializeStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00bf: 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_00de: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown if (!stylesInitialized) { tabStyle = new GUIStyle(GUI.skin.button); tabStyle.fontSize = 14; tabStyle.normal.textColor = Color.white; tabStyle.hover.textColor = Color.yellow; tabStyle.padding = new RectOffset(10, 10, 8, 8); tabStyle.margin = new RectOffset(2, 2, 0, 0); activeTabStyle = new GUIStyle(tabStyle); activeTabStyle.normal.background = GUI.skin.button.active.background; activeTabStyle.normal.textColor = Color.yellow; boxStyle = new GUIStyle(GUI.skin.box); boxStyle.padding = new RectOffset(8, 8, 8, 8); boxStyle.margin = new RectOffset(4, 4, 4, 4); stylesInitialized = true; } } private void OnGUI() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_002f: Invalid comparison between Unknown and I4 if (open && !((Object)(object)Player.m_localPlayer == (Object)null)) { if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Close(); Event.current.Use(); } else { EnsureTextures(); InitializeStyles(); win = GUILayout.Window(7702, win, new WindowFunction(Draw), "LifeSync Points", Array.Empty<GUILayoutOption>()); } } } private void Draw(int id) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) PointsService points = Main.Points; BuffService buffs = Main.Buffs; if ((Object)(object)logoTexture != (Object)null && ((Texture)logoTexture).width > 2 && ((Texture)logoTexture).height > 2) { Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.3f); float num = 20f; float width = ((Rect)(ref win)).width; float num2 = ((Rect)(ref win)).height - num; float num3 = Mathf.Min(width, num2) * 0.6f; float num4 = (width - num3) / 2f; float num5 = num + (num2 - num3) / 2f; GUI.DrawTexture(new Rect(num4, num5, num3, num3), (Texture)(object)logoTexture, (ScaleMode)2, true); GUI.color = color; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < tabNames.Length; i++) { if (GUILayout.Button(tabNames[i], (i == selectedTab) ? activeTabStyle : tabStyle, Array.Empty<GUILayoutOption>())) { selectedTab = i; } } GUILayout.EndHorizontal(); GUILayout.Space(10f); if (selectedTab == 0) { DrawSkillsTab(points); } else if (selectedTab == 1) { DrawBuffsTab(buffs, points); } else if (selectedTab == 2) { DrawSessionsTab(); } if (GUILayout.Button("Close", Array.Empty<GUILayoutOption>())) { Close(); } if (GUILayout.Button("Logout", Array.Empty<GUILayoutOption>())) { userCtrl.ClearCredentials(); LoginUI.ForceLogout(); Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] You have been logged out."); } Close(); } GUI.DragWindow(); } private void DrawSkillsTab(PointsService svc) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Gasta puntos de atributos para subir habilidades. El costo aumenta según el nivel actual.", Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>()); PointsLifeSyncModel[] attributes = svc.GetAttributes(); for (int i = 0; i < attributes.Length; i++) { string name = attributes[i].Name; int points = svc.GetPoints(name); GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"{name}: {points} puntos", GUI.skin.box, Array.Empty<GUILayoutOption>()); if (attributeMap.TryGetValue(name, out var value)) { SkillType[] array = value; foreach (SkillType skill in array) { DrawSkillRow(name, skill, points, svc); points = svc.GetPoints(name); } } else { GUILayout.Label("No hay habilidades mapeadas para este atributo.", Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); GUILayout.Space(6f); } GUILayout.EndScrollView(); } private void DrawBuffsTab(BuffService buffService, PointsService pointsService) { //IL_0063: 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_0072: Unknown result type (might be due to invalid IL or missing references) if (buffService == null) { GUILayout.Label("Servicio de potenciadores no disponible.", Array.Empty<GUILayoutOption>()); return; } GUILayout.Label("Gasta puntos de atributos para activar potenciadores temporales (máximo 5 minutos).", Array.Empty<GUILayoutOption>()); GUILayout.Label("Solo puedes tener 1 potenciador activo a la vez.", GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); ActiveBuff currentActiveBuff = buffService.GetCurrentActiveBuff(); if (currentActiveBuff != null) { DrawActiveBuffDisplay(currentActiveBuff, buffService); GUILayout.Space(10f); } scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>()); foreach (string key in attributeMap.Keys) { List<BuffModel> buffsForDimension = buffService.GetBuffsForDimension(key); if (buffsForDimension.Count == 0) { continue; } GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label($"{key}: {pointsService.GetPoints(key)} puntos", GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); foreach (BuffModel item in buffsForDimension) { DrawBuffItem(item, pointsService, buffService, currentActiveBuff); } GUILayout.EndVertical(); GUILayout.Space(6f); } GUILayout.EndScrollView(); } private void DrawActiveBuffDisplay(ActiveBuff activeBuff, BuffService buffService) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); Color color = GUI.color; GUI.color = Color.green; GUILayout.Label("POTENCIADOR ACTIVO: " + activeBuff.Name, GUI.skin.box, Array.Empty<GUILayoutOption>()); GUI.color = color; GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.Label("Efectos: " + string.Join(", ", activeBuff.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}: +{(e.Value - 1f) * 100f:F0}%")), GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); string text = FormatTime(activeBuff.RemainingTime); GUILayout.Label("Tiempo restante: " + text, GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); if (GUILayout.Button("DESACTIVAR", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(25f) })) { buffService.DeactivateCurrentBuff(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private string FormatTime(float seconds) { int num = Mathf.FloorToInt(seconds / 60f); int num2 = Mathf.FloorToInt(seconds % 60f); return $"{num:00}:{num2:00}"; } private void PauseGame() { try { if (!Game.IsPaused()) { Game.Pause(); Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; BlockCamera(); Debug.Log((object)"[LifeSync] Juego pausado - menú abierto"); } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo pausar el juego: " + ex.Message)); } } private void ResumeGame() { try { if (Game.IsPaused()) { Game.Unpause(); Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; UnblockCamera(); RestoreMousePosition(); Debug.Log((object)"[LifeSync] Juego reanudado - menú cerrado"); } } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo reanudar el juego: " + ex.Message)); } } private void BlockCamera() { try { if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = false; } Debug.Log((object)"[LifeSync] Cámara bloqueada"); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo bloquear la cámara: " + ex.Message)); } } private void UnblockCamera() { try { if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = true; } Debug.Log((object)"[LifeSync] Cámara desbloqueada"); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo desbloquear la cámara: " + ex.Message)); } } private void RestoreMousePosition() { try { ((MonoBehaviour)this).StartCoroutine(CenterMousePositionCoroutine()); } catch (Exception ex) { Debug.LogWarning((object)("[LifeSync] No se pudo centrar el mouse: " + ex.Message)); } } [IteratorStateMachine(typeof(<CenterMousePositionCoroutine>d__39))] private IEnumerator CenterMousePositionCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CenterMousePositionCoroutine>d__39(0) { <>4__this = this }; } [DllImport("user32.dll")] private static extern bool SetCursorPos(int x, int y); private void SetCursorPosition(int x, int y) { SetCursorPos(x, y); } private void DrawBuffItem(BuffModel buff, PointsService pointsService, BuffService buffService, ActiveBuff currentActiveBuff) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.Label("<b>" + buff.Name + "</b>", GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.Label(buff.Description, GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.Label($"Duración: {buff.Duration} minutos", GUI.skin.label, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); bool flag = pointsService.GetPoints(buff.Dimension) >= buff.Cost; bool flag2 = currentActiveBuff != null; GUILayout.Label($"Costo: {buff.Cost} {buff.Dimension}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUI.enabled = flag && !flag2; if (GUILayout.Button(flag2 ? "OTRO ACTIVO" : "ACTIVAR", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(25f) })) { buffService.TryActivateBuff(buff.Id, pointsService); } GUI.enabled = true; if (flag2) { GUILayout.Label("Otro activo", GUI.skin.label, Array.Empty<GUILayoutOption>()); } else if (!flag) { GUILayout.Label("Sin puntos", GUI.skin.label, Array.Empty<GUILayoutOption>()); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(2f); } private void DrawSkillRow(string attrName, SkillType skill, int availableAttrPoints, PointsService svc) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Skills skills = ((Character)localPlayer).GetSkills(); if (!((Object)(object)skills == (Object)null)) { int num = Mathf.FloorToInt(skills.GetSkillLevel(skill)); int num2 = CalculateDynamicCost(num); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(((object)(SkillType)(ref skill)).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) }); GUILayout.FlexibleSpace(); GUILayout.Label($"Lvl: {num}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); bool flag2 = (GUI.enabled = availableAttrPoints >= num2); if (GUILayout.Button($"+1 (-{num2} {attrName})", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) })) { svc.TryUpgradeFrom(attrName, skill, num2, 0f, out var _); } GUI.enabled = true; GUILayout.EndHorizontal(); if (!flag2) { GUILayout.Label($" Necesitas {num2} puntos de {attrName} (tienes {availableAttrPoints})", GUI.skin.label, Array.Empty<GUILayoutOption>()); } GUILayout.Space(4f); } } private int CalculateDynamicCost(int currentLevel) { if (currentLevel <= 10) { return 1; } if (currentLevel <= 25) { return 2; } if (currentLevel <= 50) { return 3; } return 4; } private void DrawSessionsTab() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) SessionTrackingService sessionTracking = Main.SessionTracking; if ((Object)(object)sessionTracking == (Object)null) { GUILayout.Label("Servicio de sesiones no disponible.", Array.Empty<GUILayoutOption>()); return; } SessionConfigModel config = sessionTracking.GetConfig(); if (config == null) { GUILayout.Label("Configuración de sesiones no disponible.", Array.Empty<GUILayoutOption>()); return; } scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>()); GUILayout.Label("Sistema de Bienestar Digital", GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Estado Actual de la Sesión", GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label("Tiempo de sesión: " + sessionTracking.GetFormattedSessionTime(), Array.Empty<GUILayoutOption>()); GUILayout.Label("Sesión activa: " + (config.IsEnabled ? "Sí" : "No"), Array.Empty<GUILayoutOption>()); GUILayout.Label("Actividad actual: " + sessionTracking.GetCurrentActivity(), Array.Empty<GUILayoutOption>()); List<string> currentActivityDimensions = sessionTracking.GetCurrentActivityDimensions(); GUILayout.Label("Dimensiones afectadas: " + string.Join(", ", currentActivityDimensions), Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Configuración", GUI.skin.box, Array.Empty<GUILayoutOption>()); bool flag = GUILayout.Toggle(config.IsEnabled, "Activar sistema de bienestar digital", Array.Empty<GUILayoutOption>()); if (flag != config.IsEnabled) { config.IsEnabled = flag; sessionTracking.UpdateConfig(config); } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Tiempo límite saludable (min):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (int.TryParse(GUILayout.TextField(config.MinSessionMinutes.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }), out var result) && result > 0 && result != config.MinSessionMinutes) { config.MinSessionMinutes = result; sessionTracking.UpdateConfig(config); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Intervalo de recordatorios (min):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (int.TryParse(GUILayout.TextField(config.DiscountIntervalMinutes.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }), out var result2) && result2 > 0 && result2 != config.DiscountIntervalMinutes) { config.DiscountIntervalMinutes = result2; sessionTracking.UpdateConfig(config); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Impacto inicial:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (int.TryParse(GUILayout.TextField(config.BasePointsToDeduct.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }), out var result3) && result3 >= 0 && result3 != config.BasePointsToDeduct) { config.BasePointsToDeduct = result3; sessionTracking.UpdateConfig(config); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Impacto adicional:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (int.TryParse(GUILayout.TextField(config.AdditionalPointsPerInterval.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }), out var result4) && result4 >= 0 && result4 != config.AdditionalPointsPerInterval) { config.AdditionalPointsPerInterval = result4; sessionTracking.UpdateConfig(config); } GUILayout.EndHorizontal(); bool flag2 = GUILayout.Toggle(config.ShowNotifications, "Mostrar notificaciones", Array.Empty<GUILayoutOption>()); if (flag2 != config.ShowNotifications) { config.ShowNotifications = flag2; sessionTracking.UpdateConfig(config); } GUILayout.Space(4f); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Áreas de Bienestar Afectadas", GUI.skin.box, Array.Empty<GUILayoutOption>()); string[] array = new string[5] { "Fisico", "Mental", "Afectivo", "Linguistico", "Social" }; foreach (string dimension in array) { bool flag3 = config.AffectedDimensions.Any((string d) => string.Equals(d, dimension, StringComparison.OrdinalIgnoreCase)); bool flag4 = GUILayout.Toggle(flag3, dimension, Array.Empty<GUILayoutOption>()); if (flag4 == flag3) { continue; } if (flag4) { if (!config.AffectedDimensions.Any((string d) => string.Equals(d, dimension, StringComparison.OrdinalIgnoreCase))) { config.AffectedDimensions.Add(dimension); Debug.Log((object)("[LifeSync][UI] Dimensión agregada: " + dimension)); } } else { int num = config.AffectedDimensions.RemoveAll((string d) => string.Equals(d, dimension, StringComparison.OrdinalIgnoreCase)); Debug.Log((object)$"[LifeSync][UI] Dimensión removida: {dimension} ({num} ocurrencias)"); } sessionTracking.UpdateConfig(config); } GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.EndScrollView(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Guardar Configuración", Array.Empty<GUILayoutOption>())) { sessionTracking.UpdateConfig(config); Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] Configuración de sesiones guardada."); } } if (GUILayout.Button("Reiniciar Sesión", Array.Empty<GUILayoutOption>())) { sessionTracking.StartSession(); Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).AddString("[LifeSync] Sesión reiniciada."); } } GUILayout.EndHorizontal(); } [IteratorStateMachine(typeof(<ResetCursorPosition>d__46))] private IEnumerator ResetCursorPosition() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetCursorPosition>d__46(0); } public PointsUI() { //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) Dictionary<string, SkillType[]> dictionary = new Dictionary<string, SkillType[]>(); SkillType[] array = new SkillType[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); dictionary.Add("Fisico", (SkillType[])(object)array); dictionary.Add("Mental", (SkillType[])(object)new SkillType[2] { (SkillType)6, (SkillType)8 }); dictionary.Add("Afectivo", (SkillType[])(object)new SkillType[1] { (SkillType)101 }); dictionary.Add("Linguistico", (SkillType[])(object)new SkillType[1] { (SkillType)2 }); dictionary.Add("Social", (SkillType[])(object)new SkillType[1] { (SkillType)11 }); attributeMap = dictionary; ((MonoBehaviour)this)..ctor(); } } } namespace LifeSync.Valheim.Services { public class ApiPointsService : MonoBehaviour { [CompilerGenerated] private sealed class <SavePointsCoroutine>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string playerId; public string attributeId; public int newPoints; private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SavePointsCoroutine>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Invalid comparison between Unknown and I4 try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; string text = "https://lsg.diinf.usach.cl/post-routes/player_attributes_single"; string text2 = JsonConvert.SerializeObject((object)new { id_player = int.Parse(playerId), id_attributes = int.Parse(attributeId), new_data = newPoints }); byte[] bytes = Encoding.UTF8.GetBytes(text2); Debug.Log((object)"[LifeSync][API] Enviando puntos a la API:"); Debug.Log((object)("[LifeSync][API] URL: " + text)); Debug.Log((object)("[LifeSync][API] Payload: " + text2)); <request>5__2 = new UnityWebRequest(text, "PUT"); <>1__state = -3; <request>5__2.uploadHandler = (UploadHandler)new UploadHandlerRaw(bytes); <request>5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); <request>5__2.SetRequestHeader("Content-Type", "application/json"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: <>1__state = -3; if ((int)<request>5__2.result == 1) { Debug.Log((object)("[LifeSync][API] Puntos guardados exitosamente: " + <request>5__2.downloadHandler.text)); } else { Debug.LogError((object)("[LifeSync][API] Error al guardar puntos: " + <request>5__2.error)); Debug.LogError((object)("[LifeSync][API] Response: " + <request>5__2.downloadHandler.text)); } <>m__Finally1(); <request>5__2 = null; return false; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string API_BASE_URL = "https://lsg.diinf.usach.cl/post-routes/"; private const string ENDPOINT = "player_attributes_single"; public void SavePointsToApi(string playerId, string attributeId, int newPoints) { ((MonoBehaviour)this).StartCoroutine(SavePointsCoroutine(playerId, attributeId, newPoints)); } [IteratorStateMachine(typeof(<SavePointsCoroutine>d__3))] private IEnumerator SavePointsCoroutine(string playerId, string attributeId, int newPoints) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SavePointsCoroutine>d__3(0) { playerId = playerId, attributeId = attributeId, newPoints = newPoints }; } public void SaveAllPointsToApi(UserLifeSyncModel user) { if (user?.Points == null) { return; } foreach (PointsLifeSyncModel point in user.Points) { if (int.TryParse(point.Data, out var result)) { SavePointsToApi(user.Id_players, point.Id_attributes, result); } } } } public class BuffEffectService : MonoBehaviour { private Player player; private Dictionary<BuffType, float> originalValues = new Dictionary<BuffType, float>(); private Dictionary<BuffType, ActiveBuff> activeEffects = new Dictionary<BuffType, ActiveBuff>(); private int frameCounter; private const int UPDATE_INTERVAL = 30; private void Start() { player = Player.m_localPlayer; Debug.Log((object)"[LifeSync][SISTEMA] BuffEffectService inicializado"); } private void Update() { frameCounter++; if (frameCounter >= 30) { frameCounter = 0; if ((Object)(object)player == (Object)null) { player = Player.m_localPlayer; } else if (!Game.IsPaused()) { ReapplyActiveEffects(); MaintainSpeedBoost(); UpdateActiveEffects(); } } } public void ApplyBuffEffects(ActiveBuff buff) { if (!((Object)(object)player == (Object)null)) { if (!originalValues.ContainsKey(buff.Type)) { StoreOriginalValues(buff.Type); } switch (buff.Type) { case BuffType.HealthBoost: ApplyHealthBoost(buff); break; case BuffType.StaminaBoost: ApplyStaminaBoost(buff); break; case BuffType.DamageBoost: ApplyDamageBoost(buff); break; case BuffType.SpeedBoost: ApplySpeedBoost(buff); break; case BuffType.DefenseBoost: ApplyDefenseBoost(buff); break; case BuffType.SkillBoost: ApplySkillBoost(buff); break; case BuffType.CarryWeightBoost: ApplyCarryWeightBoost(buff); break; } activeEffects[buff.Type] = buff; Debug.Log((object)$"[LifeSync][SISTEMA] Buff {buff.Name} guardado en activeEffects. Total activos: {activeEffects.Count}"); } } public void RemoveBuffEffects(ActiveBuff buff) { if (!((Object)(object)player == (Object)null)) { switch (buff.Type) { case BuffType.HealthBoost: RestoreHealthBoost(); break; case BuffType.StaminaBoost: RestoreStaminaBoost(); break; case BuffType.DamageBoost: RestoreDamageBoost(); break; case BuffType.SpeedBoost: RestoreSpeedBoost(); break; case BuffType.DefenseBoost: RestoreDefenseBoost(); break; case BuffType.SkillBoost: RestoreSkillBoost(); break; case BuffType.CarryWeightBoost: RestoreCarryWeightBoost(); break; } activeEffects.Remove(buff.Type); Debug.Log((object)$"[LifeSync][SISTEMA] Buff {buff.Name} removido de activeEffects. Total activos: {activeEffects.Count}"); } } private void ReapplyActiveEffects() { foreach (KeyValuePair<BuffType, ActiveBuff> activeEffect in activeEffects) { if (!activeEffect.Value.IsExpired) { switch (activeEffect.Value.Type) { case BuffType.HealthBoost: ReapplyHealthBoost(activeEffect.Value); break; case BuffType.StaminaBoost: ReapplyStaminaBoost(activeEffect.Value); break; case BuffType.SpeedBoost: ReapplySpeedBoost(activeEffect.Value); break; } } } } private void MaintainSpeedBoost() { if (!IsBuffActive(BuffType.SpeedBoost)) { return; } ActiveBuff activeBuff = GetActiveBuff(BuffType.SpeedBoost); if (activeBuff == null || activeBuff.IsExpired) { return; } float originalValue = GetOriginalValue(BuffType.SpeedBoost); if (activeBuff.Effects.TryGetValue("speed_multiplier", out var value)) { float num = originalValue * value; if (Mathf.Abs(((Character)player).m_runSpeed - num) > 0.01f) { ((Character)player).m_runSpeed = num; } } } private void UpdateActiveEffects() { List<BuffType> list = new List<BuffType>(); foreach (KeyValuePair<BuffType, ActiveBuff> activeEffect in activeEffects) { if (activeEffect.Value.IsExpired) { RemoveBuffEffects(activeEffect.Value); list.Add(activeEffect.Key); } } foreach (BuffType item in list) { activeEffects.Remove(item); } } private void StoreOriginalValues(BuffType type) { switch (type) { case BuffType.HealthBoost: originalValues[type] = GetBaseHealth(); break; case BuffType.StaminaBoost: originalValues[type] = GetBaseStamina(); break; case BuffType.SpeedBoost: originalValues[type] = ((Character)player).m_runSpeed; break; default: originalValues[type] = 1f; break; } } private float GetBaseHealth() { if ((Object)(object)player != (Object)null) { return player.GetBaseFoodHP(); } return 25f; } private float GetBaseStamina() { if ((Object)(object)player != (Object)null) { return player.m_baseStamina; } return 75f; } private void ApplyHealthBoost(ActiveBuff buff) { if (buff.Effects.TryGetValue("health_multiplier", out var value)) { float baseHealth = GetBaseHealth(); float num = 0f; List<Food> foods = player.GetFoods(); if (foods != null) { for (int i = 0; i < foods.Count; i++) { num += foods[i].m_health; } } float num2 = baseHealth * value + num; float health = ((Character)player).GetHealth(); Debug.Log((object)"[LifeSync][VIGOR] Aplicando potenciador de salud:"); Debug.Log((object)$"[LifeSync][VIGOR] - Salud base (sin comida): {baseHealth}"); Debug.Log((object)$"[LifeSync][VIGOR] - Bonus de comida: {num}"); Debug.Log((object)$"[LifeSync][VIGOR] - Multiplicador: {value}x"); Debug.Log((object)$"[LifeSync][VIGOR] - Nuevo máximo calculado: {num2}"); Debug.Log((object)$"[LifeSync][VIGOR] - Salud actual antes: {health}"); player.SetMaxHealth(num2, false); ((Character)player).Heal(num2 - health, true); Debug.Log((object)$"[LifeSync][VIGOR] - Salud máxima después: {((Character)player).GetMaxHealth()}"); Debug.Log((object)$"[LifeSync][VIGOR] - Salud actual después: {((Character)player).GetHealth()}"); } else { Debug.LogWarning((object)"[LifeSync][VIGOR] No se encontró health_multiplier en los efectos del buff"); } } private void RestoreHealthBoost() { if (originalValues.TryGetValue(BuffType.HealthBoost, out var value)) { Debug.Log((object)$"[LifeSync][VIGOR] Restaurando salud a valor original: {value}"); player.SetMaxHealth(value, false); Debug.Log((object)$"[LifeSync][VIGOR] Salud restaurada - Máximo: {((Character)player).GetMaxHealth()}, Actual: {((Character)player).GetHealth()}"); } } private void ApplyStaminaBoost(ActiveBuff buff) { if (buff.Effects.TryGetValue("stamina_multiplier", out var value)) { float baseStamina = GetBaseStamina(); float num = 0f; List<Food> foods = player.GetFoods(); if (foods != null) { for (int i = 0; i < foods.Count; i++) { num += foods[i].m_stamina; } } float num2 = baseStamina * value + num; float stamina = player.GetStamina(); Debug.Log((object)"[LifeSync][RESISTENCIA] Aplicando potenciador de resistencia:"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Stamina base (sin comida): {baseStamina}"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Bonus de comida: {num}"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Multiplicador: {value}x"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Nuevo máximo calculado: {num2}"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Stamina actual antes: {stamina}"); player.SetMaxStamina(num2, false); ((Character)player).AddStamina(num2 - stamina); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Stamina máxima después: {((Character)player).GetMaxStamina()}"); Debug.Log((object)$"[LifeSync][RESISTENCIA] - Stamina actual después: {player.GetStamina()}"); } else { Debug.LogWarning((object)"[LifeSync][RESISTENCIA] No se encontró stamina_multiplier en los efectos del buff"); } } private void RestoreStaminaBoost() { if (originalValues.TryGetValue(BuffType.StaminaBoost, out var value)) { Debug.Log((object)$"[LifeSync][RESISTENCIA] Restaurando stamina a valor original: {value}"); player.SetMaxStamina(value, false); Debug.Log((object)$"[LifeSync][RESISTENCIA] Stamina restaurada - Máximo: {((Character)player).GetMaxStamina()}, Actual: {player.GetStamina()}"); } } private void ReapplyHealthBoost(ActiveBuff buff) { if (!buff.Effects.TryGetValue("health_multiplier", out var value)) { return; } float baseHealth = GetBaseHealth(); float num = 0f; List<Food> foods = player.GetFoods(); if (foods != null) { for (int i = 0; i < foods.Count; i++) { num += foods[i].m_health; } } float num2 = baseHealth * value + num; float maxHealth = ((Character)player).GetMaxHealth(); if (Mathf.Abs(maxHealth - num2) > 0.1f) { Debug.Log((object)$"[LifeSync][VIGOR] Reaplicando salud: {maxHealth:F1} -> {num2:F1}"); player.SetMaxHealth(num2, false); } } private void ReapplyStaminaBoost(ActiveBuff buff) { if (!buff.Effects.TryGetValue("stamina_multiplier", out var value)) { return; } float baseStamina = GetBaseStamina(); float num = 0f; List<Food> foods = player.GetFoods(); if (foods != null) { for (int i = 0; i < foods.Count; i++) { num += foods[i].m_stamina; } } float num2 = baseStamina * value + num; float maxStamina = ((Character)player).GetMaxStamina(); if (Mathf.Abs(maxStamina - num2) > 0.1f) { Debug.Log((object)$"[LifeSync][RESISTENCIA] Reaplicando stamina: {maxStamina:F1} -> {num2:F1}"); player.SetMaxStamina(num2, false); } } private void ReapplySpeedBoost(ActiveBuff buff) { if (buff.Effects.TryGetValue("speed_multiplier", out var value)) { float num = originalValues[BuffType.SpeedBoost] * value; float runSpeed = ((Character)player).m_runSpeed; if (Mathf.Abs(runSpeed - num) > 0.01f) { Debug.Log((object)$"[LifeSync][VELOCIDAD] Reaplicando velocidad: {runSpeed:F2} -> {num:F2}"); ((Character)player).m_runSpeed = num; } } } private void ApplySpeedBoost(ActiveBuff buff) { if (buff.Effects.TryGetValue("speed_multiplier", out var value)) { float num = originalValues[BuffType.SpeedBoost]; float num2 = num * value; Debug.Log((object)"[LifeSync][VELOCIDAD] Aplicando potenciador de velocidad:"); Debug.Log((object)$"[LifeSync][VELOCIDAD] - Velocidad original: {num}"); Debug.Log((object)$"[LifeSync][VELOCIDAD] - Multiplicador: {value}x"); Debug.Log((object)$"[LifeSync][VELOCIDAD] - Nueva velocidad: {num2}"); ((Character)player).m_runSpeed = num2; Debug.Log((object)$"[LifeSync][VELOCIDAD] - Velocidad aplicada: {((Character)player).m_runSpeed}"); } } private void RestoreSpeedBoost() { if (originalValues.TryGetValue(BuffType.SpeedBoost, out var value)) { Debug.Log((object)$"[LifeSync][VELOCIDAD] Restaurando velocidad a valor original: {value}"); ((Character)player).m_runSpeed = value; Debug.Log((object)$"[LifeSync][VELOCIDAD] Velocidad restaurada: {((Character)player).m_runSpeed}"); } } private void ApplyDamageBoost(ActiveBuff buff) { } private void RestoreDamageBoost() { } private void ApplyDefenseBoost(ActiveBuff buff) { } private void RestoreDefenseBoost() { } private void ApplySkillBoost(ActiveBuff buff) { } private void RestoreSkillBoost() { } private void ApplyCarryWeightBoost(ActiveBuff buff) { } private void RestoreCarryWeightBoost() { } public float GetBuffMultiplier(BuffType type, string effectKey) { if (activeEffects.TryGetValue(type, out var value) && value.Effects.TryGetValue(effectKey, out var value2)) { return value2; } return 1f; } public bool IsBuffActive(BuffType type) { if (activeEffects.ContainsKey(type)) { return !activeEffects[type].IsExpired; } return false; } public ActiveBuff GetActiveBuff(BuffType type) { if (!activeEffects.ContainsKey(type)) { return null; } return activeEffects[type]; } public float GetOriginalValue(BuffType type) { if (!originalValues.ContainsKey(type)) { return GetDefaultValue(type); } return originalValues[type]; } private float GetDefaultValue(BuffType type) { return type switch { BuffType.HealthBoost => 25f, BuffType.StaminaBoost => 50f, BuffType.SpeedBoost => 6f, _ => 1f, }; } } public class BuffService { private readonly Func<UserLifeSyncModel> _getUser; private readonly List<ActiveBuff> _activeBuffs = new List<ActiveBuff>(); private readonly Dictionary<string, BuffModel> _availableBuffs = new Dictionary<string, BuffModel>(); private BuffEffectService _effectService; private PersistenceService _persistenceService; public BuffService(Func<UserLifeSyncModel> getUser) { _getUser = getUser; InitializeBuffs(); } public void InitializeEffectService() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown if ((Object)(object)_effectService == (Object)null) { GameObject val = new GameObject("BuffEffectService"); _effectService = val.AddComponent<BuffEffectService>(); Object.DontDestroyOnLoad((Object)(object)val); } if ((Object)(object)_persistenceService == (Object)null) { GameObject val2 = new GameObject("PersistenceService"); _persistenceService = val2.AddComponent<PersistenceService>(); Object.DontDestroyOnLoad((Object)(object)val2); LoadSavedBuffs(); } } private void InitializeBuffs() { _availableBuffs["phys_health"] = new BuffModel { Id = "phys_health", Name = "Vigor Mejorado", Description = "Aumenta la salud máxima en +20%", Dimension = "Fisico", Cost = 2, Duration = 4f, Type = BuffType.HealthBoost, Effects = new Dictionary<string, float> { { "health_multiplier", 1.2f } } }; _availableBuffs["phys_stamina"] = new BuffModel { Id = "phys_stamina", Name = "Resistencia Superior", Description = "Aumenta la resistencia máxima en +25%", Dimension = "Fisico", Cost = 2, Duration = 4f, Type = BuffType.StaminaBoost, Effects = new Dictionary<string, float> { { "stamina_multiplier", 1.25f } } }; _availableBuffs["phys_damage"] = new BuffModel { Id = "phys_damage", Name = "Fuerza Bruta", Description = "Aumenta el daño físico en +15%", Dimension = "Fisico", Cost = 2, Duration = 3f, Type = BuffType.DamageBoost, Effects = new Dictionary<string, float> { { "damage_multiplier", 1.15f } } }; _availableBuffs["cog_skill"] = new BuffModel { Id = "cog_skill", Name = "Aprendizaje Acelerado", Description = "Aumenta la experiencia ganada en +30%", Dimension = "Mental", Cost = 2, Duration = 5f, Type = BuffType.SkillBoost, Effects = new Dictionary<string, float> { { "skill_exp_multiplier", 1.3f } } }; _availableBuffs["cog_precision"] = new BuffModel { Id = "cog_precision", Name = "Precisión Mental", Description = "Aumenta el daño a distancia en +20%", Dimension = "Mental", Cost = 2, Duration = 3f, Type = BuffType.DamageBoost, Effects = new Dictionary<string, float> { { "ranged_damage_multiplier", 1.2f } } }; _availableBuffs["aff_luck"] = new BuffModel { Id = "aff_luck", Name = "Fortuna del Corazón", Description = "Aumenta la suerte en drops en +20%", Dimension = "Afectivo", Cost = 2, Duration = 5f, Type = BuffType.LuckBoost, Effects = new Dictionary<string, float> { { "luck_multiplier", 1.2f } } }; _availableBuffs["aff_stealth"] = new BuffModel { Id = "aff_stealth", Name = "Sigilo Emocional", Description = "Mejora la capacidad de sigilo en +25%", Dimension = "Afectivo", Cost = 2, Duration = 4f, Type = BuffType.SpeedBoost, Effects = new Dictionary<string, float> { { "stealth_multiplier", 1.25f } } }; _availableBuffs["ling_speed"] = new BuffModel { Id = "ling_speed", Name = "Agilidad Verbal", Description = "Aumenta la velocidad de movimiento en +15%", Dimension = "Linguistico", Cost = 2, Duration = 4f, Type = BuffType.SpeedBoost, Effects = new Dictionary<string, float> { { "speed_multiplier", 1.15f } } }; _availableBuffs["ling_carry"] = new BuffModel { Id = "ling_carry", Name = "Carga Lingüística", Description = "Aumenta la capacidad de carga en +30%", Dimension = "Linguistico", Cost = 2, Duration = 5f, Type = BuffType.CarryWeightBoost, Effects = new Dictionary<string, float> { { "carry_weight_multiplier", 1.3f } } }; _availableBuffs["soc_defense"] = new BuffModel { Id = "soc_defense", Name = "Protección Grupal", Description = "Aumenta la defensa en +25%", Dimension = "Social", Cost = 2, Duration = 4f, Type = BuffType.DefenseBoost, Effects = new Dictionary<string, float> { { "defense_multiplier", 1.25f } } }; _availableBuffs["soc_leadership"] = new BuffModel { Id = "soc_leadership", Name = "Liderazgo Inspirador", Description = "Mejora todas las estadísticas en +10%", Dimension = "Social", Cost = 2, Duration = 3f, Type = BuffType.HealthBoost, Effects = new Dictionary<string, float> { { "health_multiplier", 1.1f }, { "stamina_multiplier", 1.1f }, { "damage_multiplier", 1.1f } } }; } public List<BuffModel> GetBuffsForDimension(string dimension) { return _availableBuffs.Values.Where((BuffModel buff) => string.Equals(buff.Dimension, dimension, StringComparison.OrdinalIgnoreCase)).ToList(); } public List<BuffModel> GetAllBuffs() { return _availableBuffs.Values.ToList(); } public List<ActiveBuff> GetActiveBuffs() { return _activeBuffs.Where((ActiveBuff buff) => !buff.IsExpired).ToList(); } public bool TryActivateBuff(string buffId, PointsService pointsService) { if (!_availableBuffs.TryGetValue(buffId, out var value)) { return false; } ActiveBuff activeBuff = _activeBuffs.FirstOrDefault((ActiveBuff ab) => !ab.IsExpired); if (activeBuff != null) { Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] Ya tienes un potenciador activo: " + activeBuff.Name + ". Desactívalo primero."); } return false; } if (!pointsService.SpendFrom(value.Dimension, value.Cost)) { Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).AddString("[LifeSync] No tienes suficientes puntos de " + value.Dimension + "."); } return false; } ActiveBuff activeBuff2 = new ActiveBuff { BuffId = value.Id, Name = value.Name, StartTime = Time.time, Duration = value.Duration * 60f, Type = value.Type, Effects = new Dictionary<string, float>(value.Effects) }; _activeBuffs.Add(activeBuff2); ApplyBuffEffects(activeBuff2); SaveActiveBuffs(); Chat instance3 = Chat.instance; if (instance3 != null) { ((Terminal)instance3).AddString($"[LifeSync] ¡{value.Name} activado! Duración: {value.Duration} minutos."); } Debug.Log((object)string.Format("[LifeSync] Potenciador activado: {0} (ID: {1}) - Duración: {2} minutos - Efectos: {3}", value.Name, value.Id, value.Duration, string.Join(", ", value.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); return true; } private void ApplyBuffEffects(ActiveBuff buff) { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { InitializeEffectService(); _effectService?.ApplyBuffEffects(buff); Debug.Log((object)("[LifeSync] Aplicando efectos de " + buff.Name + ": " + string.Join(", ", buff.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); } } public void UpdateActiveBuffs() { List<ActiveBuff> list = _activeBuffs.Where((ActiveBuff buff) => buff.IsExpired).ToList(); if (list.Count <= 0) { return; } foreach (ActiveBuff item in list) { RemoveBuffEffects(item); _activeBuffs.Remove(item); Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] " + item.Name + " ha expirado."); } } SaveActiveBuffs(); } private void RemoveBuffEffects(ActiveBuff buff) { _effectService?.RemoveBuffEffects(buff); } public float GetBuffRemainingTime(BuffType type) { return _activeBuffs.FirstOrDefault((ActiveBuff ab) => ab.Type == type && !ab.IsExpired)?.RemainingTime ?? 0f; } public bool IsBuffActive(BuffType type) { return _activeBuffs.Any((ActiveBuff ab) => ab.Type == type && !ab.IsExpired); } public bool DeactivateCurrentBuff() { ActiveBuff activeBuff = _activeBuffs.FirstOrDefault((ActiveBuff ab) => !ab.IsExpired); if (activeBuff == null) { Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString("[LifeSync] No tienes ningún potenciador activo."); } return false; } RemoveBuffEffects(activeBuff); _activeBuffs.Remove(activeBuff); SaveActiveBuffs(); Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).AddString("[LifeSync] " + activeBuff.Name + " desactivado."); } return true; } public ActiveBuff GetCurrentActiveBuff() { return _activeBuffs.FirstOrDefault((ActiveBuff ab) => !ab.IsExpired); } public void LogActiveBuffsStatus() { List<ActiveBuff> activeBuffs = GetActiveBuffs(); if (activeBuffs.Count == 0) { Debug.Log((object)"[LifeSync][ESTADO] No hay potenciadores activos"); return; } Debug.Log((object)$"[LifeSync][ESTADO] Potenciadores activos ({activeBuffs.Count}):"); foreach (ActiveBuff item in activeBuffs) { float num = item.RemainingTime / 60f; Debug.Log((object)$"[LifeSync][ESTADO] - {item.Name}: {num:F1} minutos restantes"); Debug.Log((object)("[LifeSync][ESTADO] Efectos: " + string.Join(", ", item.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); } } public void DebugBuffStatus(BuffType buffType) { ActiveBuff activeBuff = _activeBuffs.FirstOrDefault((ActiveBuff ab) => ab.Type == buffType && !ab.IsExpired); if (activeBuff != null) { Debug.Log((object)$"[LifeSync][DEBUG] Buff {buffType} está ACTIVO:"); Debug.Log((object)("[LifeSync][DEBUG] - Nombre: " + activeBuff.Name)); Debug.Log((object)$"[LifeSync][DEBUG] - Tiempo restante: {activeBuff.RemainingTime:F1} segundos"); Debug.Log((object)("[LifeSync][DEBUG] - Efectos: " + string.Join(", ", activeBuff.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); } else { Debug.Log((object)$"[LifeSync][DEBUG] Buff {buffType} NO está activo"); } } public void DebugCarryWeightBuff() { Debug.Log((object)"[LifeSync][DEBUG] === ESTADO DEL BUFF DE CAPACIDAD DE CARGA ==="); BuffModel buffModel = _availableBuffs.Values.FirstOrDefault((BuffModel b) => b.Type == BuffType.CarryWeightBoost); if (buffModel != null) { Debug.Log((object)("[LifeSync][DEBUG] - Buff disponible: " + buffModel.Name)); Debug.Log((object)("[LifeSync][DEBUG] - ID: " + buffModel.Id)); Debug.Log((object)("[LifeSync][DEBUG] - Dimensión: " + buffModel.Dimension)); Debug.Log((object)$"[LifeSync][DEBUG] - Costo: {buffModel.Cost} puntos"); Debug.Log((object)$"[LifeSync][DEBUG] - Duración: {buffModel.Duration} minutos"); Debug.Log((object)("[LifeSync][DEBUG] - Efectos: " + string.Join(", ", buffModel.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); } else { Debug.Log((object)"[LifeSync][DEBUG] - Buff de capacidad de carga NO encontrado en buffs disponibles"); } ActiveBuff activeBuff = _activeBuffs.FirstOrDefault((ActiveBuff ab) => ab.Type == BuffType.CarryWeightBoost && !ab.IsExpired); if (activeBuff != null) { Debug.Log((object)("[LifeSync][DEBUG] - Buff ACTIVO: " + activeBuff.Name)); Debug.Log((object)$"[LifeSync][DEBUG] - Tiempo restante: {activeBuff.RemainingTime:F1} segundos"); Debug.Log((object)("[LifeSync][DEBUG] - Efectos activos: " + string.Join(", ", activeBuff.Effects.Select((KeyValuePair<string, float> e) => $"{e.Key}={e.Value}")))); } else { Debug.Log((object)"[LifeSync][DEBUG] - Buff de capacidad de carga NO está activo"); } } private void LoadSavedBuffs() { if ((Object)(object)_persistenceService == (Object)null) { return; } try { List<ActiveBuff> list = _persistenceService.LoadActiveBuffs(); foreach (ActiveBuff item in list) { _activeBuffs.Add(item); if ((Object)(object)_effectService != (Object)null) { _effectService.ApplyBuffEffects(item); } } if (list.Count > 0) { Debug.Log((object)$"[LifeSync][PERSISTENCIA] Se restauraron {list.Count} potenciadores activos"); } } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al cargar buffs guardados: " + ex.Message)); } } public void SaveActiveBuffs() { if ((Object)(object)_persistenceService == (Object)null) { return; } try { _persistenceService.SaveActiveBuffs(_activeBuffs); Debug.Log((object)$"[LifeSync][PERSISTENCIA] Buffs activos guardados: {_activeBuffs.Count}"); } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al guardar buffs: " + ex.Message)); } } public void ClearSaveData() { if ((Object)(object)_persistenceService == (Object)null) { return; } try { _persistenceService.ClearSaveData(); Debug.Log((object)"[LifeSync][PERSISTENCIA] Datos de guardado eliminados"); } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al limpiar datos: " + ex.Message)); } } } public class PersistenceService : MonoBehaviour { private const string SAVE_FILE_NAME = "lifesync_save.json"; private string SaveFilePath => Path.Combine(Application.persistentDataPath, "lifesync_save.json"); public void SaveActiveBuffs(List<ActiveBuff> activeBuffs) { try { LifeSyncSaveData lifeSyncSaveData = new LifeSyncSaveData(); foreach (ActiveBuff activeBuff in activeBuffs) { if (!activeBuff.IsExpired) { lifeSyncSaveData.ActiveBuffs.Add(PersistentBuffData.FromActiveBuff(activeBuff)); } } string contents = JsonConvert.SerializeObject((object)lifeSyncSaveData, (Formatting)1); File.WriteAllText(SaveFilePath, contents); Debug.Log((object)$"[LifeSync][PERSISTENCIA] Guardados {lifeSyncSaveData.ActiveBuffs.Count} potenciadores activos"); Debug.Log((object)("[LifeSync][PERSISTENCIA] Archivo guardado en: " + SaveFilePath)); } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al guardar: " + ex.Message)); } } public List<ActiveBuff> LoadActiveBuffs() { try { if (!File.Exists(SaveFilePath)) { Debug.Log((object)"[LifeSync][PERSISTENCIA] No hay archivo de guardado existente"); return new List<ActiveBuff>(); } LifeSyncSaveData lifeSyncSaveData = JsonConvert.DeserializeObject<LifeSyncSaveData>(File.ReadAllText(SaveFilePath)); if (lifeSyncSaveData?.ActiveBuffs == null) { Debug.Log((object)"[LifeSync][PERSISTENCIA] Datos de guardado inválidos"); return new List<ActiveBuff>(); } List<ActiveBuff> list = new List<ActiveBuff>(); foreach (PersistentBuffData activeBuff2 in lifeSyncSaveData.ActiveBuffs) { ActiveBuff activeBuff = activeBuff2.ToActiveBuff(); float num = activeBuff2.Duration - activeBuff2.StartTime; if (num > 0f) { activeBuff.StartTime = Time.time; activeBuff.Duration = num; list.Add(activeBuff); Debug.Log((object)$"[LifeSync][PERSISTENCIA] Restaurado buff: {activeBuff.Name} (tiempo restante: {activeBuff.RemainingTime:F1}s)"); } else { Debug.Log((object)("[LifeSync][PERSISTENCIA] Buff expirado durante la carga: " + activeBuff.Name)); } } Debug.Log((object)$"[LifeSync][PERSISTENCIA] Cargados {list.Count} potenciadores activos de {lifeSyncSaveData.ActiveBuffs.Count} guardados"); return list; } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al cargar: " + ex.Message)); return new List<ActiveBuff>(); } } public void ClearSaveData() { try { if (File.Exists(SaveFilePath)) { File.Delete(SaveFilePath); Debug.Log((object)"[LifeSync][PERSISTENCIA] Archivo de guardado eliminado"); } } catch (Exception ex) { Debug.LogError((object)("[LifeSync][PERSISTENCIA] Error al eliminar archivo: " + ex.Message)); } } public bool HasSaveData() { return File.Exists(SaveFilePath); } } public class PointsService { private readonly Func<UserLifeSyncModel> _getUser; private ApiPointsService _apiService; private static readonly BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public PointsService(Func<UserLifeSyncModel> getUser) { _getUser = getUser; } public void InitializeApiService() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if ((Object)(object)_apiService == (Object)null) { GameObject val = new GameObject("ApiPointsService"); _apiService = val.AddComponent<ApiPointsService>(); Object.DontDestroyOnLoad((Object)(object)val); } } public PointsLifeSyncModel[] GetAttributes() { return _getUser()?.Points?.ToArray() ?? Array.Empty<PointsLifeSyncModel>(); } private static bool TryGetLevelAndAccumulator(Skills skills, SkillType type, out float level, out float acc) { //IL_00bc: 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) level = 0f; acc = 0f; FieldInfo field = typeof(Skills).GetField("m_skills", BF); IEnumerable enumerable = ((field != null) ? (field.GetValue(skills) as IEnumerable) : null); if (enumerable == null) { return false; } foreach (object item in enumerable) { FieldInfo field2 = item.GetType().GetField("m_info", BF); object obj = ((field2 != null) ? field2.GetValue(item) : null); if (obj == null) { continue; } FieldInfo field3 = obj.GetType().GetField("m_skill", BF); if (!(field3 == null) && (SkillType)field3.GetValue(obj) == type) { FieldInfo field4 = item.GetType().GetField("m_level", BF); FieldInfo field5 = item.GetType().GetField("m_accumulator", BF); if (field4 == null || field5 == null) { return false; } level = (float)field4.GetValue(item); acc = Mathf.Clamp01((float)field5.GetValue(item)); return true; } } return false; } public int GetPoints(string attrName) { PointsLifeSyncModel pointsLifeSyncModel = _getUser()?.Points?.FirstOrDefault((PointsLifeSyncModel x) => string.Equals(x.Name, attrName, StringComparison.OrdinalIgnoreCase)); if (pointsLifeSyncModel == null || !int.TryParse(pointsLifeSyncModel.Data, out var result)) { return 0; } return result; } public bool SpendFrom(string attrName, int cost) { UserLifeSyncModel userLifeSyncModel = _getUser(); if (userLifeSyncModel == null) { return false; } PointsLifeSyncModel pointsLifeSyncModel = userLifeSyncModel.Points?.FirstOrDefault((PointsLifeSyncModel x) => string.Equals(x.Name, attrName, StringComparison.OrdinalIgnoreCase)); if (pointsLifeSyncModel == null) { return false; } if (!int.TryParse(pointsLifeSyncModel.Data, out var result) || result < cost) { return false; } int newPoints = result - cost; pointsLifeSyncModel.Data = newPoints.ToString(); SavePointsToApi(userLifeSyncModel.Id_players, pointsLifeSyncModel.Id_attributes, newPoints); return true; } private void SavePointsToApi(string playerId, string attributeId, int newPoints) { InitializeApiService(); _apiService?.SavePointsToApi(playerId, attributeId, newPoints); } public bool TryUpgradeFrom(string attrName, SkillType type, int cost, float gain, out float progressDelta) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_010c: 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_00e8: 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) progressDelta = 0f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } Skills skills = ((Character)localPlayer).GetSkills(); if ((Object)(object)skills == (Object)null) { return false; } int num = Mathf.FloorToInt(skills.GetSkillLevel(type)); int num2 = CalculateDynamicCost(num); if (!SpendFrom(attrName, num2)) { Chat instance = Chat.instance; if (instance != null) { ((Terminal)instance).AddString($"[LifeSync] Necesitas {num2} puntos de {attrName} para subir de nivel {num}."); } return false; } float num3 = Mathf.Max(0f, Main.LevelsPerPoint.Value); if (num3 <= 0f) { return false; } if (!TryGetLevelAndAccumulator(skills, type, out var level, out var acc)) { level = skills.GetSkillLevel(type); acc = 0f; } int num4 = Mathf.FloorToInt(level); int num5 = 0; float num6 = level + num3; float num7 = Mathf.Max(0.01f, num3 / 50f); float num8 = level; while (num8 + 0.0001f < num6 && num5 < 4096) { skills.RaiseSkill(type, num7); num8 = skills.GetSkillLevel(type); num5++; } if (!TryGetLevelAndAccumulator(skills, type, out var level2, out var acc2)) { level2 = num8; acc2 = 0f; } if (Mathf.FloorToInt(level2) > num4) { progressDelta = 1f - acc + acc2; } else { progressDelta = Mathf.Max(0f, acc2 - acc); } Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).AddString($"[LifeSync] {attrName}: {type} +{num3:0.##} lvl (~{progressDelta:P0}) - Costo: {num2} puntos"); } return true; } private int CalculateDynamicCost(int currentLevel) { if (currentLevel <= 10) { return 1; } if (currentLevel <= 25) { return 2; } if (currentLevel <= 50) { return 3; } return 4; } } public class SessionTrackingService : MonoBehaviour { private SessionConfigModel config; private PointsService pointsService; private float sessionStartTime; private float lastUpdateTime; private bool isSessionActive; private string configPath; private void Start() { Debug.Log((object)"[LifeSync][SESIONES] Iniciando SessionTrackingService..."); configPath = Path.Combine(Application.persistentDataPath, "LifeSync", "session_config.json"); LoadConfig(); pointsService = Main.Points; if (pointsService == null) { Debug.LogError((object)"[LifeSync][SESIONES] PointsService no encontrado"); return; } Debug.Log((object)"[LifeSync][SESIONES] PointsService encontrado correctamente"); StartSession(); Debug.Log((object)"[LifeSync][SESIONES] SessionTrackingServi