using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.TalentPace")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.17.0")] [assembly: AssemblyInformationalVersion("1.4.17+15344e0ba9bf8820fb4e0ee22cc1b9b0b4d70a87")] [assembly: AssemblyProduct("Cjayride.TalentPace")] [assembly: AssemblyTitle("Cjayride.TalentPace")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.17.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Cjayride.TalentPace { internal static class ActiveSkillRespec { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__23_0; internal void b__23_0() { TryRefund(Player.m_localPlayer); } } internal static ConfigEntry EnableRespec; internal static ConfigEntry AutoRefund; private static Type _pointService; private static Type _store; private static Type _reset; private static Type _ui; private static MethodInfo _getTotal; private static MethodInfo _getSpent; private static MethodInfo _resetActives; private static MethodInfo _resetSpent; private static MethodInfo _refreshUi; private static FieldInfo _rebirthButton; private static bool _patched; private static Button _button; internal static void Bind(ConfigFile config) { EnableRespec = config.Bind("Skills Reworked UI", "Free Active Skill respec when over budget", true, "When spent Active Skill points exceed what the current SkillsReworked config grants, show a free respec on the skills window. Refunds Active Skills only (not Level, Prestige, or Talent Tree). No coin or level cost."); AutoRefund = config.Bind("Skills Reworked UI", "Auto refund over-budget Active Skills", true, "On spawn, if spent Active Skill points exceed the current budget, refund them automatically (same as the free respec button)."); } internal static void Apply(Harmony harmony, Plugin plugin) { if ((EnableRespec.Value || AutoRefund.Value) && !PatchNow(harmony)) { ((MonoBehaviour)plugin).StartCoroutine(RetryPatch(harmony)); } } private static IEnumerator RetryPatch(Harmony harmony) { for (int i = 0; i < 60; i++) { if (_patched) { break; } yield return (object)new WaitForSeconds(1f); PatchNow(harmony); } } private static bool PatchNow(Harmony harmony) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown if (_patched) { return true; } if (!EnsureReflection()) { return false; } MethodInfo methodInfo = SR.Method(_ui, "RefreshRebirthResetButton"); if (methodInfo != null && EnableRespec.Value) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ActiveSkillRespec), "AfterRefreshButton", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(Player), "OnSpawned", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo2 != null && AutoRefund.Value) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(ActiveSkillRespec), "AfterSpawned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } _patched = true; Plugin.Log("Talent Pace: Active Skill over-budget respec hooked."); return true; } private static bool EnsureReflection() { if (_getTotal != null) { return true; } _pointService = SR.Type("SkillsReworked.Systems.Progression.SkillPointService"); _store = SR.Type("SkillsReworked.Persistence.PlayerProgressionStore"); _reset = SR.Type("SkillsReworked.Systems.Reset.ProgressionResetService"); _ui = SR.Type("SkillsReworked.UI.SkillPanel.SkillUiController"); if (_pointService == null || _store == null || _reset == null) { return false; } _getTotal = SR.Method(_pointService, "GetTotalPoints", typeof(Player)); _getSpent = SR.Method(_store, "GetSpentSkillPoints", typeof(Player)); _resetActives = SR.Method(_reset, "ResetActiveSkills", typeof(Skills)); _resetSpent = SR.Method(_reset, "ResetSpentPoints", typeof(Player)); _refreshUi = ((_ui == null) ? null : SR.Method(_ui, "RefreshAfterProgressionChange", typeof(Player))); _rebirthButton = ((_ui == null) ? null : SR.Field(_ui, "RebirthButton")); if (_getTotal != null && _getSpent != null && _resetActives != null) { return _resetSpent != null; } return false; } internal static bool NeedsRespec(Player player) { if ((Object)(object)player == (Object)null || !EnsureReflection()) { return false; } try { int num = Convert.ToInt32(_getTotal.Invoke(null, new object[1] { player })); return Convert.ToInt32(_getSpent.Invoke(null, new object[1] { player })) > num; } catch (Exception) { return false; } } internal static bool TryRefund(Player player) { if ((Object)(object)player == (Object)null || !NeedsRespec(player)) { return false; } Skills skills = ((Character)player).GetSkills(); if ((Object)(object)skills == (Object)null) { return false; } try { _resetActives.Invoke(null, new object[1] { skills }); _resetSpent.Invoke(null, new object[1] { player }); } catch (Exception ex) { Plugin.Log("Talent Pace: Active Skill refund failed: " + ex.Message); return false; } try { if (_refreshUi != null) { _refreshUi.Invoke(null, new object[1] { player }); } } catch (Exception) { } ((Character)player).Message((MessageType)2, "Active Skill points refunded (over new budget). Spend them again.", 0, (Sprite)null, false); Plugin.Log("Talent Pace: refunded over-budget Active Skills for " + player.GetPlayerName()); return true; } private static void AfterSpawned(Player __instance, bool spawnValkyrie) { if (AutoRefund.Value && !((Object)(object)__instance == (Object)null)) { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { TryRefund(__instance); } else if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { TryRefund(__instance); } } } private static void AfterRefreshButton() { if (!EnableRespec.Value || _rebirthButton == null) { return; } object? value = _rebirthButton.GetValue(null); Button val = (Button)((value is Button) ? value : null); if (!((Object)(object)val == (Object)null)) { Player localPlayer = Player.m_localPlayer; bool active = (Object)(object)localPlayer != (Object)null && NeedsRespec(localPlayer); EnsureButton(((Component)val).transform.parent); if ((Object)(object)_button != (Object)null) { ((Component)_button).gameObject.SetActive(active); } } } private static void EnsureButton(Transform parent) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0067: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0158: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown if ((Object)(object)parent == (Object)null) { return; } Transform val = parent.Find("TalentPace_ActiveRespec"); if ((Object)(object)val != (Object)null) { _button = ((Component)val).GetComponent