Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Vanablade v0.1.1
Vanablade.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using Vanablade.TalentTree; using Vanablade.TalentTree.Effects; using Vanablade.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyCompany("Vanablade")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ae6e4555945ad7d526958a632e886379469f7eb2")] [assembly: AssemblyProduct("Vanablade")] [assembly: AssemblyTitle("Vanablade")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Vanablade { [BepInPlugin("com.vanablade.core", "Vanablade", "0.1.0")] public class VanabladePlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <WaitForPlayer>d__13 : global::System.Collections.Generic.IEnumerator<object>, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private object <>2__current; public VanabladePlugin <>4__this; object global::System.Collections.Generic.IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForPlayer>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void global::System.IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Player.m_localPlayer != (Object)null)); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.AttachPlayerStats(Player.m_localPlayer); return false; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } } private TalentTreeUI _talentUI = null; private StatAllocationUI _statUI = null; private PlayerStats _playerStats = null; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static ManualLogSource Log { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static Harmony Harmony { [CompilerGenerated] get; [CompilerGenerated] private set; } private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("com.vanablade.core"); Log.LogInfo((object)"Vanablade initializing..."); TalentTreeManager.Instance.Initialize(Log); TalentTreeData.Instance.Initialize(); Log.LogInfo((object)"Talent tree registered. Cleave node available (req: Might 5)."); GameObject val = new GameObject("VanabladeUI"); _talentUI = val.AddComponent<TalentTreeUI>(); _statUI = val.AddComponent<StatAllocationUI>(); Object.DontDestroyOnLoad((Object)(object)val); SetupPlayer(); Harmony.Patch((MethodBase)(object)AccessTools.Method(typeof(Skills), "RaiseSkill", (global::System.Type[])null, (global::System.Type[])null), new HarmonyMethod(typeof(LevelUpPatch), "Prefix", (global::System.Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.PatchAll(typeof(PlayerAttackSpeedPatch)); Harmony.PatchAll(typeof(DualWieldEquipPatch)); Log.LogInfo((object)"Harmony patches applied."); Log.LogInfo((object)"Vanablade ready. F4 for stat allocation, F5 for talent tree."); } private void SetupPlayer() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { AttachPlayerStats(localPlayer); } else { ((MonoBehaviour)this).StartCoroutine(WaitForPlayer()); } } [IteratorStateMachine(typeof(<WaitForPlayer>d__13))] private global::System.Collections.IEnumerator WaitForPlayer() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPlayer>d__13(0) { <>4__this = this }; } private void AttachPlayerStats(Player player) { _playerStats = ((Component)player).GetComponent<PlayerStats>(); if ((Object)(object)_playerStats == (Object)null) { _playerStats = ((Component)player).gameObject.AddComponent<PlayerStats>(); } _playerStats.Initialize(); TalentTreeManager.Instance.SetStats(_playerStats); Log.LogInfo((object)$"PlayerStats attached to {player.GetPlayerName()}. Might={_playerStats.Might}, Mind={_playerStats.Mind}, Agility={_playerStats.Agility}, Points={_playerStats.AvailableStatPoints}"); } private void Update() { if (Input.GetKeyDown((KeyCode)285)) { _statUI?.Toggle(); } if (Input.GetKeyDown((KeyCode)286)) { _talentUI?.Toggle(); } } } public static class LevelUpPatch { public static void Prefix(Skills self, SkillType skill, float floatParameter) { Player component = ((Component)self).GetComponent<Player>(); PlayerStats playerStats = ((component != null) ? ((Component)component).GetComponent<PlayerStats>() : null); if ((Object)(object)playerStats != (Object)null) { playerStats.AwardStatPoints(1); TalentTreeManager.Log.LogInfo((object)$"Level up! Awarded 1 stat point. Total: {playerStats.AvailableStatPoints}"); } } } } namespace Vanablade.UI { public class StatAllocationUI : MonoBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<int> <>9__14_0; public static Action <>9__14_1; public static Func<int> <>9__14_2; public static Action <>9__14_3; public static Func<int> <>9__14_4; public static Action <>9__14_5; internal int <CreatePanel>b__14_0() { return TalentTreeManager.Instance.Stats.Might; } internal void <CreatePanel>b__14_1() { TalentTreeManager.Instance.AllocateStat(StatType.Might); } internal int <CreatePanel>b__14_2() { return TalentTreeManager.Instance.Stats.Mind; } internal void <CreatePanel>b__14_3() { TalentTreeManager.Instance.AllocateStat(StatType.Mind); } internal int <CreatePanel>b__14_4() { return TalentTreeManager.Instance.Stats.Agility; } internal void <CreatePanel>b__14_5() { TalentTreeManager.Instance.AllocateStat(StatType.Agility); } } private GameObject? _panel; private Text? _pointsText; private Text? _mightText = null; private Text? _mindText = null; private Text? _agilityText = null; private bool _isOpen; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static StatAllocationUI Instance { [CompilerGenerated] get; [CompilerGenerated] private set; } private void Awake() { Instance = this; } private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GUIManager.OnCustomGUIAvailable += new Action(OnGUIAvailable); } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GUIManager.OnCustomGUIAvailable -= new Action(OnGUIAvailable); } private void OnGUIAvailable() { CreatePanel(); } private void CreatePanel() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00a0: 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) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown if ((Object)(object)_panel != (Object)null) { return; } Transform transform = GUIManager.CustomGUIFront.transform; _panel = GUIManager.Instance.CreateWoodpanel(transform, new Vector2(0.35f, 0.15f), new Vector2(0.65f, 0.5f), Vector2.zero, 350f, 280f); ((Object)_panel).name = "VanabladeStatAllocation"; GameObject val = GUIManager.Instance.CreateText("Stat Allocation", _panel.transform, new Vector2(0.1f, 0.82f), new Vector2(0.9f, 0.95f), Vector2.zero, GUIManager.Instance.NorseBold, 24, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); ((Object)val).name = "Title"; GameObject val2 = GUIManager.Instance.CreateText($"Points Available: {TalentTreeManager.Instance.AvailableStatPoints}", _panel.transform, new Vector2(0.05f, 0.65f), new Vector2(0.95f, 0.75f), Vector2.zero, GUIManager.Instance.Norse, 18, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); ((Object)val2).name = "PointsText"; _pointsText = val2.GetComponent<Text>(); Func<int> getValue = () => TalentTreeManager.Instance.Stats.Might; object obj = <>c.<>9__14_1; if (obj == null) { Action val3 = delegate { TalentTreeManager.Instance.AllocateStat(StatType.Might); }; <>c.<>9__14_1 = val3; obj = (object)val3; } CreateStatRow("Might", getValue, (Action)obj, 0.62f); Func<int> getValue2 = () => TalentTreeManager.Instance.Stats.Mind; object obj2 = <>c.<>9__14_3; if (obj2 == null) { Action val4 = delegate { TalentTreeManager.Instance.AllocateStat(StatType.Mind); }; <>c.<>9__14_3 = val4; obj2 = (object)val4; } CreateStatRow("Mind", getValue2, (Action)obj2, 0.46f); Func<int> getValue3 = () => TalentTreeManager.Instance.Stats.Agility; object obj3 = <>c.<>9__14_5; if (obj3 == null) { Action val5 = delegate { TalentTreeManager.Instance.AllocateStat(StatType.Agility); }; <>c.<>9__14_5 = val5; obj3 = (object)val5; } CreateStatRow("Agility", getValue3, (Action)obj3, 0.3f); GameObject val6 = GUIManager.Instance.CreateButton("X", _panel.transform, new Vector2(0.93f, 0.85f), new Vector2(1f, 0.95f), Vector2.zero, 35f, 35f); Button component = val6.GetComponent<Button>(); if (component != null) { ((UnityEvent)component.onClick).AddListener((UnityAction)([CompilerGenerated] () => { Hide(); })); } _panel.SetActive(false); } private void CreateStatRow(string name, Func<int> getValue, Action allocate, float yPos) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown Action allocate2 = allocate; GameObject val = new GameObject(name + "Row"); val.transform.SetParent(_panel.transform); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(0.05f, yPos); val2.anchorMax = new Vector2(0.95f, yPos + 0.12f); val2.anchoredPosition = Vector2.zero; val2.sizeDelta = Vector2.zero; HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; GameObject val4 = GUIManager.Instance.CreateText(name + ": " + getValue.Invoke(), val.transform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, GUIManager.Instance.Norse, 16, Color.white, false, Color.black, 0f, 0f, false); ((Object)val4).name = name + "ValueText"; Text component = val4.GetComponent<Text>(); if (name == "Might") { _mightText = component; } if (name == "Mind") { _mindText = component; } if (name == "Agility") { _agilityText = component; } GameObject val5 = GUIManager.Instance.CreateButton("+", val.transform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, 40f, 40f); Button component2 = val5.GetComponent<Button>(); if (component2 != null) { ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { allocate2.Invoke(); Refresh(); }); } } public void Show() { if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(true); _isOpen = true; Refresh(); } } public void Hide() { if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(false); _isOpen = false; } } public void Toggle() { if (_isOpen) { Hide(); } else { Show(); } } public void Refresh() { if (!((Object)(object)_panel == (Object)null)) { if ((Object)(object)_pointsText != (Object)null) { _pointsText.text = $"Points Available: {TalentTreeManager.Instance.AvailableStatPoints}"; } PlayerStats stats = TalentTreeManager.Instance.Stats; SetStatText(_mightText, "Might", stats.Might); SetStatText(_mindText, "Mind", stats.Mind); SetStatText(_agilityText, "Agility", stats.Agility); } } private static void SetStatText(Text? text, string name, int value) { if ((Object)(object)text != (Object)null) { text.text = $"{name}: {value}"; } } } public class TalentTreeUI : MonoBehaviour { private GameObject? _panel; private GameObject? _content; private readonly List<GameObject> _nodeObjects = new List<GameObject>(); private bool _isOpen; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static TalentTreeUI Instance { [CompilerGenerated] get; [CompilerGenerated] private set; } private void Awake() { Instance = this; } private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GUIManager.OnCustomGUIAvailable += new Action(OnGUIAvailable); } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GUIManager.OnCustomGUIAvailable -= new Action(OnGUIAvailable); } private void OnGUIAvailable() { CreatePanel(); } private void CreatePanel() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel != (Object)null) { return; } Transform transform = GUIManager.CustomGUIFront.transform; _panel = GUIManager.Instance.CreateWoodpanel(transform, new Vector2(0.2f, 0.2f), new Vector2(0.8f, 0.8f), Vector2.zero, 400f, 300f); ((Object)_panel).name = "VanabladeTalentTree"; GameObject val = GUIManager.Instance.CreateButton("X", _panel.transform, new Vector2(0.97f, 0.92f), new Vector2(1f, 1f), Vector2.zero, 40f, 40f); Button component = val.GetComponent<Button>(); if (component != null) { ((UnityEvent)component.onClick).AddListener((UnityAction)([CompilerGenerated] () => { Hide(); })); } GUIManager.Instance.CreateText("Talent Tree", _panel.transform, new Vector2(0.35f, 0.88f), new Vector2(0.65f, 0.97f), Vector2.zero, GUIManager.Instance.NorseBold, 28, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); CreateStatDisplay(); GameObject val2 = GUIManager.Instance.CreateScrollView(_panel.transform, false, true, 10f, 10f, GUIManager.Instance.ValheimScrollbarHandleColorBlock, new Color(0.1f, 0.1f, 0.1f, 0.9f), 20f, 50f); Transform obj = val2.transform.Find("Viewport/Content"); _content = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)_content != (Object)null) { _content.AddComponent<VerticalLayoutGroup>(); } _panel.SetActive(false); } private void CreateStatDisplay() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) PlayerStats stats = TalentTreeManager.Instance.Stats; GUIManager.Instance.CreateText($"Might: {stats.Might}", _panel.transform, new Vector2(0.02f, 0.42f), new Vector2(0.25f, 0.48f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); GUIManager.Instance.CreateText($"Mind: {stats.Mind}", _panel.transform, new Vector2(0.28f, 0.42f), new Vector2(0.51f, 0.48f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); GUIManager.Instance.CreateText($"Agility: {stats.Agility}", _panel.transform, new Vector2(0.54f, 0.42f), new Vector2(0.77f, 0.48f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); } public void Show() { if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(true); _isOpen = true; Refresh(); } } public void Hide() { if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(false); _isOpen = false; } } public void Toggle() { if (_isOpen) { Hide(); } else { Show(); } } public void Refresh() { //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) ClearNodes(); if ((Object)(object)_content == (Object)null) { return; } Enumerator<TalentNode> enumerator = TalentTreeData.Instance.AllNodes.GetEnumerator(); try { while (enumerator.MoveNext()) { TalentNode current = enumerator.Current; CreateNodeRow(current); } } finally { ((global::System.IDisposable)enumerator).Dispose(); } } private void ClearNodes() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Enumerator<GameObject> enumerator = _nodeObjects.GetEnumerator(); try { while (enumerator.MoveNext()) { GameObject current = enumerator.Current; Object.Destroy((Object)(object)current); } } finally { ((global::System.IDisposable)enumerator).Dispose(); } _nodeObjects.Clear(); } private void CreateNodeRow(TalentNode node) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown TalentNode node2 = node; if ((Object)(object)_content == (Object)null) { return; } GameObject val = new GameObject("NodeRow"); val.transform.SetParent(_content.transform); HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = false; bool flag = TalentTreeManager.Instance.UnlockedTalents.Contains(node2.Id); bool flag2 = TalentTreeManager.Instance.CanUnlock(node2) && !flag; Color val3 = (flag ? Color.green : (flag2 ? Color.yellow : Color.gray)); GUIManager.Instance.CreateText(node2.Name, val.transform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, GUIManager.Instance.Norse, 16, Color.white, false, Color.black, 0f, 0f, false); GUIManager.Instance.CreateText(flag ? "[Active]" : (flag2 ? "[Available]" : "[Locked]"), val.transform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, GUIManager.Instance.Norse, 14, val3, false, Color.black, 0f, 0f, false); if (flag2) { GameObject val4 = GUIManager.Instance.CreateButton("Unlock", val.transform, Vector2.zero, new Vector2(1f, 1f), Vector2.zero, 80f, 30f); Button component = val4.GetComponent<Button>(); if (component != null) { ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { TalentTreeManager.Instance.Unlock(node2); Refresh(); }); } _nodeObjects.Add(val4); } _nodeObjects.Add(val); } } } namespace Vanablade.TalentTree { public class CleaveNode { public static TalentNode Instance { get { TalentNode obj = new TalentNode { Id = "might_cleave", Name = "Cleave", Description = "Master the art of dual wielding. +15% attack speed while holding two one-handed weapons.", Branch = StatType.Might, Cost = 1, Prerequisites = new List<string>() }; List<StatRequirement> obj2 = new List<StatRequirement>(); obj2.Add(new StatRequirement { Stat = StatType.Might, Minimum = 5 }); obj.StatRequirements = obj2; List<TalentEffect> obj3 = new List<TalentEffect>(); obj3.Add((TalentEffect)new AttackSpeedBonus(0.15f)); obj3.Add((TalentEffect)new DualWieldEnabled()); obj.Effects = obj3; return obj; } } } public class PlayerStats : MonoBehaviour { private const string ZDO_MIGHT = "vanablade_might"; private const string ZDO_MIND = "vanablade_mind"; private const string ZDO_AGILITY = "vanablade_agility"; private const string ZDO_POINTS = "vanablade_statpoints"; private static readonly FieldRef<Player, ZNetView> _nviewRef = AccessTools.FieldRefAccess<Player, ZNetView>("m_nview"); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int Might { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int Mind { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int Agility { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int AvailableStatPoints { [CompilerGenerated] get; [CompilerGenerated] private set; } public void Initialize() { Load(); } public void Load() { ZDO playerZDO = GetPlayerZDO(); if (playerZDO != null) { Might = playerZDO.GetInt("vanablade_might", 0); Mind = playerZDO.GetInt("vanablade_mind", 0); Agility = playerZDO.GetInt("vanablade_agility", 0); AvailableStatPoints = playerZDO.GetInt("vanablade_statpoints", 0); } } public void Save() { ZDO playerZDO = GetPlayerZDO(); if (playerZDO != null) { playerZDO.Set("vanablade_might", Might); playerZDO.Set("vanablade_mind", Mind); playerZDO.Set("vanablade_agility", Agility); playerZDO.Set("vanablade_statpoints", AvailableStatPoints); } } private ZDO? GetPlayerZDO() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return null; } ZNetView val = _nviewRef.Invoke(localPlayer); if ((Object)(object)val == (Object)null) { return null; } return val.GetZDO(); } public bool AllocateStat(StatType stat) { if (AvailableStatPoints <= 0) { return false; } switch (stat) { case StatType.Might: Might++; break; case StatType.Mind: Mind++; break; case StatType.Agility: Agility++; break; default: return false; } AvailableStatPoints--; Save(); Debug.Log((object)$"[Vanablade] Allocated 1 {stat}. {AvailableStatPoints} points remaining."); return true; } public void AwardStatPoints(int count) { AvailableStatPoints += count; Save(); Debug.Log((object)$"[Vanablade] Awarded {count} stat points. Total available: {AvailableStatPoints}"); } } public enum StatType { Might, Mind, Agility } public abstract class TalentEffect { public abstract string EffectId { get; } } public class TalentNode { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public string Id { [CompilerGenerated] get; [CompilerGenerated] set; } = ""; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public string Name { [CompilerGenerated] get; [CompilerGenerated] set; } = ""; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public string Description { [CompilerGenerated] get; [CompilerGenerated] set; } = ""; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public StatType Branch { [CompilerGenerated] get; [CompilerGenerated] set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int Cost { [CompilerGenerated] get; [CompilerGenerated] set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<string> Prerequisites { [CompilerGenerated] get; [CompilerGenerated] set; } = new List<string>(); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<StatRequirement> StatRequirements { [CompilerGenerated] get; [CompilerGenerated] set; } = new List<StatRequirement>(); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<TalentEffect> Effects { [CompilerGenerated] get; [CompilerGenerated] set; } = new List<TalentEffect>(); } public class StatRequirement { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public StatType Stat { [CompilerGenerated] get; [CompilerGenerated] set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public int Minimum { [CompilerGenerated] get; [CompilerGenerated] set; } } public class TalentConnection { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public string FromId { [CompilerGenerated] get; [CompilerGenerated] set; } = ""; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public string ToId { [CompilerGenerated] get; [CompilerGenerated] set; } = ""; } public class TalentTreeData { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static TalentTreeData Instance { [CompilerGenerated] get; [CompilerGenerated] private set; } = new TalentTreeData(); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<TalentNode> AllNodes { [CompilerGenerated] get; [CompilerGenerated] set; } = new List<TalentNode>(); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<TalentConnection> Connections { [CompilerGenerated] get; [CompilerGenerated] set; } = new List<TalentConnection>(); public void Initialize() { RegisterNodes(); RegisterConnections(); } private void RegisterNodes() { AllNodes.Add(CleaveNode.Instance); List<TalentNode> allNodes = AllNodes; TalentNode obj = new TalentNode { Id = "might_ironwill", Name = "Iron Will", Description = "Reduced stamina drain while dual wielding.", Branch = StatType.Might, Cost = 1 }; List<string> obj2 = new List<string>(); obj2.Add("might_cleave"); obj.Prerequisites = obj2; List<StatRequirement> obj3 = new List<StatRequirement>(); obj3.Add(new StatRequirement { Stat = StatType.Might, Minimum = 10 }); obj.StatRequirements = obj3; obj.Effects = new List<TalentEffect>(); allNodes.Add(obj); List<TalentNode> allNodes2 = AllNodes; TalentNode obj4 = new TalentNode { Id = "might_brutalsweep", Name = "Brutal Sweep", Description = "Cleave strikes hit all nearby enemies.", Branch = StatType.Might, Cost = 1 }; List<string> obj5 = new List<string>(); obj5.Add("might_cleave"); obj4.Prerequisites = obj5; List<StatRequirement> obj6 = new List<StatRequirement>(); obj6.Add(new StatRequirement { Stat = StatType.Might, Minimum = 10 }); obj4.StatRequirements = obj6; obj4.Effects = new List<TalentEffect>(); allNodes2.Add(obj4); List<TalentNode> allNodes3 = AllNodes; TalentNode obj7 = new TalentNode { Id = "might_titansgrip", Name = "Titan's Grip", Description = "One-hand weapons that normally require two hands.", Branch = StatType.Might, Cost = 1 }; List<string> obj8 = new List<string>(); obj8.Add("might_ironwill"); obj8.Add("might_brutalsweep"); obj7.Prerequisites = obj8; List<StatRequirement> obj9 = new List<StatRequirement>(); obj9.Add(new StatRequirement { Stat = StatType.Might, Minimum = 20 }); obj7.StatRequirements = obj9; obj7.Effects = new List<TalentEffect>(); allNodes3.Add(obj7); } private void RegisterConnections() { Connections.Add(new TalentConnection { FromId = "might_cleave", ToId = "might_ironwill" }); Connections.Add(new TalentConnection { FromId = "might_cleave", ToId = "might_brutalsweep" }); Connections.Add(new TalentConnection { FromId = "might_ironwill", ToId = "might_titansgrip" }); Connections.Add(new TalentConnection { FromId = "might_brutalsweep", ToId = "might_titansgrip" }); } } public class TalentTreeManager { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static TalentTreeManager Instance { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static ManualLogSource Log { [CompilerGenerated] get; [CompilerGenerated] private set; } [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public PlayerStats Stats { [CompilerGenerated] get; [CompilerGenerated] private set; } = null; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public HashSet<string> UnlockedTalents { [CompilerGenerated] get; } = new HashSet<string>(); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public List<TalentNode> AllTalents { [CompilerGenerated] get; } = new List<TalentNode>(); public int AvailableStatPoints => Stats?.AvailableStatPoints ?? 0; public void Initialize(ManualLogSource log) { Instance = this; Log = log; RegisterTalents(); Log.LogInfo((object)$"TalentTreeManager initialized with {AllTalents.Count} talents."); } public void SetStats(PlayerStats stats) { Stats = stats; } private void RegisterTalents() { AllTalents.Add(CleaveNode.Instance); } public bool CanUnlock(TalentNode node) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (UnlockedTalents.Contains(node.Id)) { return false; } Enumerator<StatRequirement> enumerator = node.StatRequirements.GetEnumerator(); try { while (enumerator.MoveNext()) { StatRequirement current = enumerator.Current; StatType stat = current.Stat; if (1 == 0) { } int num = stat switch { StatType.Might => Stats.Might, StatType.Mind => Stats.Mind, StatType.Agility => Stats.Agility, _ => 0, }; if (1 == 0) { } int num2 = num; if (num2 < current.Minimum) { return false; } } } finally { ((global::System.IDisposable)enumerator).Dispose(); } Enumerator<string> enumerator2 = node.Prerequisites.GetEnumerator(); try { while (enumerator2.MoveNext()) { string current2 = enumerator2.Current; if (!UnlockedTalents.Contains(current2)) { return false; } } } finally { ((global::System.IDisposable)enumerator2).Dispose(); } return true; } public void Unlock(TalentNode node) { if (CanUnlock(node)) { UnlockedTalents.Add(node.Id); ApplyEffects(node); Log.LogInfo((object)("Unlocked talent: " + node.Name)); } } public bool AllocateStat(StatType stat) { return Stats?.AllocateStat(stat) ?? false; } private void ApplyEffects(TalentNode node) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Enumerator<TalentEffect> enumerator = node.Effects.GetEnumerator(); try { while (enumerator.MoveNext()) { TalentEffect current = enumerator.Current; if (current is AttackSpeedBonus effect) { ApplyAttackSpeedBonus(effect); } else if (current is DualWieldEnabled) { ApplyDualWieldEnabled(); } } } finally { ((global::System.IDisposable)enumerator).Dispose(); } } private void ApplyAttackSpeedBonus(AttackSpeedBonus effect) { PlayerAttackSpeedPatch.AttackSpeedBonus += effect.BonusPercent; Log.LogInfo((object)$"Attack speed bonus applied. Total bonus: {PlayerAttackSpeedPatch.AttackSpeedBonus * 100f}%"); } private void ApplyDualWieldEnabled() { DualWieldEquipPatch.Enabled = true; Log.LogInfo((object)"Dual wield enabled."); } } } namespace Vanablade.TalentTree.Effects { public class AttackSpeedBonus : TalentEffect { public override string EffectId => "attack_speed_bonus"; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public float BonusPercent { [CompilerGenerated] get; [CompilerGenerated] set; } public AttackSpeedBonus(float bonusPercent) { BonusPercent = bonusPercent; } } public class DualWieldEnabled : TalentEffect { public override string EffectId => "dual_wield_enabled"; } public static class DualWieldEquipPatch { [HarmonyPatch] public static class VisEquipmentSetLeftItemPatch { [HarmonyPrefix] [HarmonyPatch(typeof(VisEquipment), "SetLeftItem")] public static void SetLeftItemPrefix(VisEquipment __instance, string name, int variant) { if (Enabled && !string.IsNullOrEmpty(name)) { } } } [HarmonyPatch] public static class VisEquipmentSetRightItemPatch { [HarmonyPrefix] [HarmonyPatch(typeof(VisEquipment), "SetRightItem")] public static void SetRightItemPrefix(VisEquipment __instance, string name, int variant) { if (Enabled && !string.IsNullOrEmpty(name) && name != _leftItemRef.Invoke(__instance) && !string.IsNullOrEmpty(_leftItemRef.Invoke(__instance))) { __instance.SetLeftBackItem("", 0); } } } [HarmonyPatch] public static class HumanoidEquipItemPatch { [HarmonyPrefix] [HarmonyPatch(typeof(Humanoid), "EquipItem", new global::System.Type[] { typeof(ItemData), typeof(bool) })] public static bool EquipItemPrefix(Humanoid __instance, ItemData item, bool triggerEquipEffects, ref bool __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 if (!Enabled || item == null) { return true; } if ((int)item.m_shared.m_itemType != 3) { return true; } ItemData val = _rightItemRef.Invoke(__instance); ItemData val2 = _leftItemRef2.Invoke(__instance); if (val != null && (int)val.m_shared.m_itemType == 3 && val2 != null && (int)val2.m_shared.m_itemType == 3) { return true; } return true; } } private static readonly FieldRef<VisEquipment, string> _leftItemRef = AccessTools.FieldRefAccess<VisEquipment, string>("m_leftItem"); private static readonly FieldRef<Humanoid, ItemData> _rightItemRef = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_rightItem"); private static readonly FieldRef<Humanoid, ItemData> _leftItemRef2 = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_leftItem"); [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static bool Enabled { [CompilerGenerated] get; [CompilerGenerated] set; } } public class DualWieldSpeedEffect : TalentEffect { public override string EffectId => "dual_wield_speed"; [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public float SpeedBonus { [CompilerGenerated] get; [CompilerGenerated] set; } public DualWieldSpeedEffect(float speedBonus) { SpeedBonus = speedBonus; } } [HarmonyPatch] public static class PlayerAttackSpeedPatch { [field: CompilerGenerated] [field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public static float AttackSpeedBonus { [CompilerGenerated] get; [CompilerGenerated] set; } [HarmonyPatch("Player", "GetTotalAttackSpeed")] [HarmonyPrefix] public static void GetTotalAttackSpeedPrefix(ref float __result) { if (AttackSpeedBonus > 0f) { __result *= 1f + AttackSpeedBonus; } } } }