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 SkillTalentTrees v0.3.0
plugins/SkillTalentTrees/SkillTalentTrees.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace SkillTalentTrees; public sealed class TalentState { public const int Count = 8; public static readonly int[][] Parents; public int HighestLevel; public readonly int[] Ranks = new int[8]; public bool ReadOnly; public int Earned => HighestLevel / 5 + ((HighestLevel >= 100) ? 5 : 0); public int Spent { get { int num = 0; int[] ranks = Ranks; foreach (int num2 in ranks) { num += num2; } return num; } } public int Available => Earned - Spent; public void Observe(float level) { if (!ReadOnly && !float.IsNaN(level) && !float.IsInfinity(level)) { HighestLevel = Math.Max(HighestLevel, Math.Max(0, Math.Min(100, (int)level))); } } public bool Buy(int index) { if (ReadOnly || index < 0 || index >= 8 || Available <= 0 || Ranks[index] >= 5) { return false; } if (!Unlocked(index)) { return false; } Ranks[index]++; return true; } public void Reset() { if (!ReadOnly) { Array.Clear(Ranks, 0, 8); } } public bool Unlocked(int index) { switch (index) { default: return false; case 0: return true; case 1: case 2: case 3: case 4: case 5: case 6: case 7: { int[] array = Parents[index]; foreach (int num in array) { if (Ranks[num] == 5) { return true; } } return false; } } } public string Encode() { return "2;" + HighestLevel.ToString(CultureInfo.InvariantCulture) + ";" + string.Join(";", Array.ConvertAll(Ranks, (int r) => r.ToString(CultureInfo.InvariantCulture))); } public static TalentState Decode(string text) { TalentState talentState = new TalentState(); if (string.IsNullOrEmpty(text)) { return talentState; } string[] array = text.Split(';'); bool flag = array.Length == 6 && array[0] == "1"; if ((!flag && (array.Length != 10 || array[0] != "2")) || !int.TryParse(array[1], out var result) || result < 0 || result > 100) { TalentState talentState2 = new TalentState(); talentState2.ReadOnly = true; return talentState2; } talentState.HighestLevel = result; for (int i = 0; i < (flag ? 4 : 8); i++) { if (!int.TryParse(array[i + 2], out var result2) || result2 < 0 || result2 > 5) { TalentState talentState3 = new TalentState(); talentState3.ReadOnly = true; return talentState3; } talentState.Ranks[i] = result2; } if (talentState.Spent > talentState.Earned) { TalentState talentState4 = new TalentState(); talentState4.ReadOnly = true; return talentState4; } if (flag) { if ((talentState.Ranks[2] > 0 || talentState.Ranks[3] > 0) && talentState.Ranks[0] + talentState.Ranks[1] < 5) { TalentState talentState5 = new TalentState(); talentState5.ReadOnly = true; return talentState5; } talentState.Reset(); } else { for (int j = 0; j < 8; j++) { if (talentState.Ranks[j] > 0 && !talentState.Unlocked(j)) { TalentState talentState6 = new TalentState(); talentState6.ReadOnly = true; return talentState6; } } } return talentState; } public static float WoodChance(int rank) { return (float)Math.Max(0, Math.Min(5, rank)) * 0.1f; } public static float StaminaMultiplier(int rank) { return 1f - (float)Math.Max(0, Math.Min(5, rank)) * 0.08f; } public static float DurabilityMultiplier(int rank) { return 1f - (float)Math.Max(0, Math.Min(5, rank)) * 0.1f; } public static float WeightMultiplier(int rank) { return 1f - (float)Math.Max(0, Math.Min(5, rank)) * 0.1f; } public static float PorterMultiplier(int rank) { return 1f - (float)Math.Max(0, Math.Min(5, rank)) * 0.08f; } public static float ExperienceMultiplier(int rank) { return 1f + (float)Math.Max(0, Math.Min(5, rank)) * 0.2f; } static TalentState() { int[][] array = new int[8][] { new int[0], null, null, null, null, null, null, null }; int[] array2 = new int[1]; array[1] = array2; int[] array3 = new int[1]; array[2] = array3; array[3] = new int[1] { 1 }; array[4] = new int[2] { 1, 2 }; array[5] = new int[1] { 2 }; array[6] = new int[2] { 3, 4 }; array[7] = new int[2] { 4, 5 }; Parents = array; } } [BepInIncompatibility("brothers.woodcuttingtalents")] [BepInPlugin("brothers.skilltalenttrees", "SkillTalentTrees", "0.3.0")] [BepInIncompatibility("brothers.miningtalents")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency("com.jotunn.jotunn", "2.30.2")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Skills), "RaiseSkill")] private static class ExperiencePatch { private static void Prefix(Skills __instance, SkillType __0, ref float __1) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && (Object)(object)((Character)localPlayer).GetSkills() == (Object)(object)__instance && (int)__0 == 13) { __1 *= TalentState.ExperienceMultiplier(Rank(localPlayer, 5)); } } } [HarmonyPatch(typeof(Player), "Load")] private static class LoadPatch { private static void Postfix(Player __instance) { states.Remove(__instance); } } [HarmonyPatch(typeof(Player), "Save")] private static class SavePatch { private static void Prefix(Player __instance) { Persist(__instance); } } [HarmonyPatch(typeof(Skills), "OnDeath")] private static class DeathPatch { private static void Prefix(Skills __instance) { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && (Object)(object)((Character)localPlayer).GetSkills() == (Object)(object)__instance) { Persist(localPlayer); } } } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] private static class StaminaPatch { private static void Postfix(Humanoid ___m_character, ItemData ___m_weapon, ref float __result) { if ((Object)(object)___m_character == (Object)(object)Player.m_localPlayer && IsAxe(___m_weapon)) { __result *= TalentState.StaminaMultiplier(Rank(Player.m_localPlayer, 0)); } } } internal sealed class Swing { internal Swing Previous; internal string Token; internal ItemData Weapon; internal float Durability; internal int Rank; } [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] private static class SwingPatch { private static void Prefix(Humanoid ___m_character, ItemData ___m_weapon, out Swing __state) { __state = null; if (!((Object)(object)___m_character != (Object)(object)Player.m_localPlayer) && IsAxe(___m_weapon)) { __state = new Swing { Previous = CurrentSwing, Token = Guid.NewGuid().ToString("N"), Weapon = ___m_weapon, Durability = ___m_weapon.m_durability, Rank = Rank(Player.m_localPlayer, 1) }; CurrentSwing = __state; } } private static void Finalizer(Swing __state) { if (__state != null) { float num = Mathf.Max(0f, __state.Durability - __state.Weapon.m_durability); ItemData weapon = __state.Weapon; weapon.m_durability += num * (1f - TalentState.DurabilityMultiplier(__state.Rank)); CurrentSwing = __state.Previous; } } } [HarmonyPatch(typeof(Inventory), "GetTotalWeight")] private static class WeightPatch { private static void Postfix(Inventory __instance, ref float __result) { Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || ((Humanoid)localPlayer).GetInventory() != __instance) { return; } int num = Rank(localPlayer, 3); int num2 = Rank(localPlayer, 6); if (num == 0 && num2 == 0) { return; } float num3 = 0f; foreach (ItemData allItem in __instance.GetAllItems()) { if (Object.op_Implicit((Object)(object)allItem.m_dropPrefab) && Wood.IsWood(((Object)allItem.m_dropPrefab).name)) { num3 += allItem.GetWeight(-1) * (1f - TalentState.WeightMultiplier(num) * TalentState.PorterMultiplier(num2)); } } __result = Mathf.Max(0f, __result - num3); } } public const string Id = "brothers.skilltalenttrees"; public const string Version = "0.3.0"; private const string SaveKey = "brothers.skilltalenttrees.woodcutting.v1"; private const string LegacySaveKey = "brothers.woodcuttingtalents.v1"; internal static Plugin Instance; private static ConditionalWeakTable<Player, TalentState> states = new ConditionalWeakTable<Player, TalentState>(); private Harmony harmony; private Player activePlayer; private float nextObserve; internal bool Practice; internal TalentState PracticeState; [ThreadStatic] internal static Swing CurrentSwing; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; harmony = new Harmony("brothers.skilltalenttrees"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SkillTalentTrees 0.3.0 loaded (Woodcutting). Open Skills, then the arrow beside Woodcutting."); } private void Update() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)(object)activePlayer) { activePlayer = localPlayer; Practice = false; PracticeState = null; TalentUI.Hide(); } if (Object.op_Implicit((Object)(object)localPlayer)) { if (Time.unscaledTime >= nextObserve) { Persist(localPlayer); TalentUI.Refresh(); nextObserve = Time.unscaledTime + 0.5f; } if (((Character)localPlayer).IsDead()) { TalentUI.Hide(); } TalentUI.KeepOnScreen(); } } private void OnGUI() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (Practice && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { GUI.Box(new Rect(12f, 12f, 255f, 26f), "WOODCUTTING PRACTICE ACTIVE"); } } private void OnDestroy() { TalentUI.Destroy(); if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } internal static TalentState State(Player p) { return states.GetValue(p, delegate(Player player) { if (!player.m_customData.TryGetValue("brothers.skilltalenttrees.woodcutting.v1", out var value)) { player.m_customData.TryGetValue("brothers.woodcuttingtalents.v1", out value); } TalentState talentState = TalentState.Decode(value); talentState.Observe(((Character)player).GetSkillLevel((SkillType)13)); if (talentState.ReadOnly) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)"Unknown woodcutting save data preserved without changes."); } return talentState; }); } internal static TalentState ActiveState() { if (!Instance.Practice) { return State(Player.m_localPlayer); } return Instance.PracticeState; } internal static void Persist(Player p) { TalentState talentState = State(p); talentState.Observe(((Character)p).GetSkillLevel((SkillType)13)); if (!talentState.ReadOnly) { p.m_customData["brothers.skilltalenttrees.woodcutting.v1"] = talentState.Encode(); } } internal static int Rank(Player p, int index) { if (!Object.op_Implicit((Object)(object)p) || (Object)(object)p != (Object)(object)Player.m_localPlayer) { return 0; } TalentState talentState = ActiveState(); if (!talentState.ReadOnly) { return talentState.Ranks[index]; } return 0; } internal static void TogglePractice() { Instance.Practice = !Instance.Practice; Instance.PracticeState = (Instance.Practice ? new TalentState { HighestLevel = 100 } : null); } internal static bool IsAxe(ItemData item) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (item != null) { return (int)item.m_shared.m_skillType == 7; } return false; } } internal static class Wood { [HarmonyPatch(typeof(TreeBase), "Awake")] private static class TreeRegister { private static void Postfix(TreeBase __instance) { Register((Component)(object)__instance); } } [HarmonyPatch(typeof(TreeLog), "Awake")] private static class LogRegister { private static void Postfix(TreeLog __instance) { Register((Component)(object)__instance); } } [HarmonyPatch(typeof(TreeBase), "Damage")] private static class TreeHit { private static bool Prefix(TreeBase __instance, HitData hit) { return Send((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(TreeLog), "Damage")] private static class LogHit { private static bool Prefix(TreeLog __instance, HitData hit) { return Send((Component)(object)__instance, hit); } } private const string Rpc = "BrothersWoodcutting_Hit_v2"; private static readonly HashSet<string> Woods = new HashSet<string>(StringComparer.Ordinal) { "Wood", "RoundLog", "FineWood", "YggdrasilWood", "Blackwood" }; internal static bool IsWood(string name) { return Woods.Contains(name); } private static void FindWood(GameObject prefab, Dictionary<GameObject, float> result, HashSet<GameObject> visited, int depth) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)prefab) || depth > 8 || !visited.Add(prefab)) { return; } TreeBase component = prefab.GetComponent<TreeBase>(); TreeLog component2 = prefab.GetComponent<TreeLog>(); DropTable val = (Object.op_Implicit((Object)(object)component) ? component.m_dropWhenDestroyed : (Object.op_Implicit((Object)(object)component2) ? component2.m_dropWhenDestroyed : null)); if (val != null) { foreach (DropData drop in val.m_drops) { if (Object.op_Implicit((Object)(object)drop.m_item) && IsWood(((Object)drop.m_item).name) && drop.m_weight > 0f) { result.TryGetValue(drop.m_item, out var value); result[drop.m_item] = value + drop.m_weight; } } } if (Object.op_Implicit((Object)(object)component)) { FindWood(component.m_logPrefab, result, visited, depth + 1); } if (Object.op_Implicit((Object)(object)component2)) { FindWood(component2.m_subLogPrefab, result, visited, depth + 1); } } private static Dictionary<GameObject, float> WoodDrops(Component target) { Dictionary<GameObject, float> result = new Dictionary<GameObject, float>(); FindWood(target.gameObject, result, new HashSet<GameObject>(), 0); return result; } private static void Register(Component target) { ZNetView view = target.GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)view) && view.IsValid()) { view.Register<ZPackage>("BrothersWoodcutting_Hit_v2", (Action<long, ZPackage>)delegate(long sender, ZPackage package) { Receive(target, view, sender, package); }); } } private static bool Send(Component target, HitData hit) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (Plugin.CurrentSwing == null || hit == null || (Object)(object)hit.GetAttacker() != (Object)(object)Player.m_localPlayer || hit.m_damage.m_chop <= 0f) { return true; } int num = Plugin.Rank(Player.m_localPlayer, 2); int num2 = Plugin.Rank(Player.m_localPlayer, 4); int num3 = Plugin.Rank(Player.m_localPlayer, 7); if (num == 0 && num2 == 0 && num3 == 0) { return true; } ZNetView component = target.GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { return true; } ZPackage val = new ZPackage(); val.Write(Plugin.CurrentSwing.Token); val.Write(num); val.Write(num2); val.Write(num3); hit.Serialize(ref val); component.InvokeRPC("BrothersWoodcutting_Hit_v2", new object[1] { val }); return false; } private static void Receive(Component target, ZNetView view, long sender, ZPackage package) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_012d: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)view) || !view.IsValid() || !view.IsOwner()) { return; } string text = package.ReadString(); int num = package.ReadInt(); int num2 = package.ReadInt(); int num3 = package.ReadInt(); HitData val = new HitData(); val.Deserialize(ref package); Character attacker = val.GetAttacker(); Player val2 = (Player)(object)((attacker is Player) ? attacker : null); if (!Object.op_Implicit((Object)(object)val2) || text.Length != 32 || num < 0 || num > 5 || num2 < 0 || num2 > 5 || num3 < 0 || num3 > 5 || val.m_damage.m_chop <= 0f) { return; } ZNetView component = ((Component)val2).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid() || component.GetZDO().GetOwner() != sender) { return; } TreeBase val3 = (TreeBase)(object)((target is TreeBase) ? target : null); TreeLog val4 = (TreeLog)(object)((target is TreeLog) ? target : null); ZDO zDO = view.GetZDO(); float num4 = (Object.op_Implicit((Object)(object)val3) ? val3.m_health : 0f); float num5 = zDO.GetFloat(ZDOVars.s_health, num4); Dictionary<GameObject, float> dictionary = WoodDrops(target); HitData val5 = val.Clone(); DamageModifier val6 = default(DamageModifier); val5.ApplyResistance(Object.op_Implicit((Object)(object)val3) ? val3.m_damageModifiers : val4.m_damages, ref val6); bool flag = num5 > 0f && dictionary.Count > 0 && val5.GetTotalDamage() > 0f && val5.CheckToolTier(Object.op_Implicit((Object)(object)val3) ? val3.m_minToolTier : val4.m_minToolTier, true); string text2 = "brothers.wt.last." + val2.GetPlayerID(); bool flag2 = zDO.GetString(text2, "") == text; if (flag && !flag2) { zDO.Set(text2, text); } Vector3 val7 = val.m_point - ((Vector3)(ref val.m_dir)).normalized * 0.6f + Vector3.up * 0.4f; bool cheated = ((Humanoid)val2).GetInventory().CheatedDamagingItemEquipped(); AccessTools.Method(Object.op_Implicit((Object)(object)val3) ? typeof(TreeBase) : typeof(TreeLog), "RPC_Damage", (Type[])null, (Type[])null).Invoke(target, new object[2] { sender, val }); float num6 = ((!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)view) || !view.IsValid()) ? 0f : zDO.GetFloat(ZDOVars.s_health, num4)); if (!flag || flag2 || num6 >= num5) { return; } if (num2 > 0 && Random.value < (float)num2 * 0.2f) { Spawn(ObjectDB.instance.GetItemPrefab("Wood"), val7, cheated); } if (num3 > 0 && Random.value < (float)num3 * 0.1f) { Spawn(ObjectDB.instance.GetItemPrefab("Resin"), val7 + Vector3.right * 0.2f, cheated); } if (Random.value >= TalentState.WoodChance(num)) { return; } float num7 = 0f; foreach (float value in dictionary.Values) { float num8 = value; num7 += num8; } float num9 = Random.value * num7; GameObject prefab = null; foreach (KeyValuePair<GameObject, float> item in dictionary) { prefab = item.Key; num9 -= item.Value; if (num9 <= 0f) { break; } } Spawn(prefab, val7, cheated); } private static void Spawn(GameObject prefab, Vector3 location, bool cheated) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)prefab)) { GameObject val = Object.Instantiate<GameObject>(prefab, location, Quaternion.identity); ItemDrop component = val.GetComponent<ItemDrop>(); if (Object.op_Implicit((Object)(object)component)) { component.m_itemData.m_stack = 1; } ItemDrop.OnCreateNew(val, cheated); } } } internal static class TalentUI { [HarmonyPatch(typeof(SkillsDialog), "Setup")] private static class SetupPatch { private static void Prefix(Player player) { AccessTools.Method(typeof(Skills), "GetSkill", (Type[])null, (Type[])null).Invoke(((Character)player).GetSkills(), new object[1] { (object)(SkillType)13 }); } private static void Postfix(SkillsDialog __instance, Player player, List<GameObject> ___m_elements) { Setup(__instance, player, ___m_elements); } } [HarmonyPatch(typeof(SkillsDialog), "OnClose")] private static class ClosePatch { private static void Postfix() { Hide(); } } private static SkillsDialog dialog; private static RectTransform frame; private static GameObject panel; private static TMP_FontAsset font; private static TMP_Text summary; private static TMP_Text detail; private static TMP_Text hint; private static Button reset; private static Button practice; private static readonly Button[] nodes = (Button[])(object)new Button[8]; private static readonly TMP_Text[] ranks = (TMP_Text[])(object)new TMP_Text[8]; private static int selected; private static bool confirmReset; private static readonly Color Gold = new Color(0.95f, 0.69f, 0.26f, 1f); private static readonly Color Cream = new Color(0.9f, 0.84f, 0.7f, 1f); private static readonly string[] Names = new string[8] { "Steady Swing", "Careful Edge", "Lucky Chop", "Timber Haul", "Kindling", "Seasoned Cutter", "Woodland Porter", "Resin Tapper" }; private static readonly string[] Descriptions = new string[8] { "Axe attacks cost 8% less stamina per rank.\nMaximum: 40% less stamina.", "Axes lose 10% less durability per rank.\nMaximum: 50% less durability loss.", "Each successful axe hit has a 10% chance per rank to drop +1 matching wood.\nMaximum: 50% per hit on a tree or log.", "Carried wood weighs 10% less per rank.\nMaximum: 50% less weight in your inventory.", "20% chance per rank to gain +1 ordinary wood per damaging tree/log hit. Maximum: guaranteed extra wood.", "Gain 20% more Woodcutting XP per rank. Maximum: double XP from normal skill gains.", "Reduce remaining carried wood weight by 8% per rank. Maximum: 40%; combines with Timber Haul for 70% total.", "10% chance per rank to collect +1 resin on each damaging axe hit against a tree or log. Maximum: 50%." }; private static void Setup(SkillsDialog owner, Player p, List<GameObject> rows) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Invalid comparison between Unknown and I4 //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dialog != (Object)(object)owner) { Destroy(); dialog = owner; } List<Skill> skillList = ((Character)p).GetSkills().GetSkillList(); TMP_Text componentInChildren = owner.m_elementPrefab.GetComponentInChildren<TMP_Text>(true); font = (Object.op_Implicit((Object)(object)componentInChildren) ? componentInChildren.font : GUIManager.Instance.TMP_AveriaSansLibre); for (int i = 0; i < skillList.Count && i < rows.Count; i++) { GameObject val = rows[i]; Transform val2 = val.transform.Find("WoodcuttingTalentArrow"); Button val3; if (!Object.op_Implicit((Object)(object)val2)) { val3 = NativeButton(val.transform, ">", 0f, 0f, 23f, 22f, null); ((Object)((Component)val3).gameObject).name = "WoodcuttingTalentArrow"; RectTransform val4 = (RectTransform)((Component)val3).transform; Vector2 anchorMin = (val4.anchorMax = new Vector2(1f, 0.5f)); val4.anchorMin = anchorMin; val4.pivot = new Vector2(1f, 0.5f); val4.anchoredPosition = Vector2.zero; string[] array = new string[3] { "levelbar_total", "levelbar", "currentlevel" }; foreach (string text in array) { Transform val6 = Utils.FindChild(val.transform, text, (IterativeSearchType)0); RectTransform val7 = (RectTransform)(object)((val6 is RectTransform) ? val6 : null); if (Object.op_Implicit((Object)(object)val7)) { if (val7.anchorMin.x != val7.anchorMax.x) { val7.offsetMax -= new Vector2(26f, 0f); continue; } Rect rect = val7.rect; val7.SetSizeWithCurrentAnchors((Axis)0, Mathf.Max(10f, ((Rect)(ref rect)).width - 26f)); val7.anchoredPosition -= new Vector2(13f, 0f); } } Transform val8 = Utils.FindChild(val.transform, "leveltext", (IterativeSearchType)0); if (Object.op_Implicit((Object)(object)val8)) { RectTransform val9 = (RectTransform)val8; val9.anchoredPosition -= new Vector2(13f, 0f); } } else { val3 = ((Component)val2).GetComponent<Button>(); } bool flag = (int)skillList[i].m_info.m_skill == 13; ((UnityEventBase)val3.onClick).RemoveAllListeners(); ((Selectable)val3).interactable = flag; if (flag) { ((UnityEvent)val3.onClick).AddListener((UnityAction)delegate { Open(); }); } UITooltip val10 = ((Component)val3).GetComponent<UITooltip>() ?? ((Component)val3).gameObject.AddComponent<UITooltip>(); val10.Set("Talents", flag ? "Open the Woodcutting talent tree" : "This skill's talent tree is not built yet.", owner.m_tooltipAnchor, Vector2.zero); } Hide(); } private static RectTransform FindFrame() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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) Transform transform = ((Component)dialog).transform; RectTransform result = (RectTransform)(object)((transform is RectTransform) ? transform : null); float num = 0f; Image[] componentsInChildren = ((Component)dialog).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { if (Object.op_Implicit((Object)(object)panel) && ((Component)val).transform.IsChildOf(panel.transform)) { continue; } RectTransform rectTransform = ((Graphic)val).rectTransform; Rect rect = rectTransform.rect; float width = ((Rect)(ref rect)).width; Rect rect2 = rectTransform.rect; float num2 = width * ((Rect)(ref rect2)).height; if (!Object.op_Implicit((Object)(object)val.sprite)) { continue; } Rect rect3 = rectTransform.rect; if (!(((Rect)(ref rect3)).width >= 220f)) { continue; } Rect rect4 = rectTransform.rect; if (((Rect)(ref rect4)).width <= 650f) { Rect rect5 = rectTransform.rect; if (((Rect)(ref rect5)).height >= 300f && num2 > num) { result = rectTransform; num = num2; } } } return result; } private static void Open() { if (Object.op_Implicit((Object)(object)dialog) && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!Object.op_Implicit((Object)(object)panel)) { Build(); } panel.SetActive(true); panel.transform.SetAsLastSibling(); confirmReset = false; Refresh(); KeepOnScreen(); } } private static void Build() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Expected O, but got Unknown //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Expected O, but got Unknown //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Expected O, but got Unknown frame = FindFrame(); panel = GUIManager.Instance.CreateWoodpanel(((Component)dialog).transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 286f, 540f, false); ((Object)panel).name = "WoodcuttingTalentSidePanel"; ((RectTransform)panel.transform).pivot = new Vector2(0f, 0.5f); TMP_Text val = Text(panel.transform, "WOODCUTTING", 135f, 26f, 232f, 30f, 23, Gold); if (Object.op_Implicit((Object)(object)GUIManager.Instance.TMP_Norse)) { val.font = GUIManager.Instance.TMP_Norse; } NativeButton(panel.transform, "x", 264f, 24f, 23f, 23f, new UnityAction(Hide)); summary = Text(panel.transform, "", 143f, 59f, 260f, 38f, 14, Cream); float[] array = new float[8] { 143f, 94f, 192f, 45f, 143f, 241f, 94f, 192f }; float[] array2 = new float[8] { 108f, 181f, 181f, 254f, 254f, 254f, 327f, 327f }; for (int i = 1; i < 8; i++) { int[] array3 = TalentState.Parents[i]; foreach (int num in array3) { Line(new Vector2(array[num], array2[num] + 22f), new Vector2(array[i], array2[i] - 22f)); } } string[] array4 = new string[8] { "AxeStone", "AxeBronze", "Wood", "RoundLog", "FineWood", "AxeIron", "BeltStrength", "Resin" }; for (int k = 0; k < 8; k++) { int captured = k; nodes[k] = NativeButton(panel.transform, "", array[k], array2[k], 48f, 48f, (UnityAction)delegate { selected = captured; TalentState talentState = Plugin.ActiveState(); if (talentState.Buy(captured) && !Plugin.Instance.Practice) { Plugin.Persist(Player.m_localPlayer); } confirmReset = false; Refresh(); }); EventTrigger val2 = ((Component)nodes[k]).gameObject.AddComponent<EventTrigger>(); Entry val3 = new Entry(); val3.eventID = (EventTriggerType)0; Entry val4 = val3; ((UnityEvent<BaseEventData>)(object)val4.callback).AddListener((UnityAction<BaseEventData>)delegate { selected = captured; Refresh(); }); val2.triggers.Add(val4); Entry val5 = new Entry(); val5.eventID = (EventTriggerType)9; Entry val6 = val5; ((UnityEvent<BaseEventData>)(object)val6.callback).AddListener((UnityAction<BaseEventData>)delegate { selected = captured; Refresh(); }); val2.triggers.Add(val6); GameObject val7 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(array4[k]) : null); ItemDrop val8 = (Object.op_Implicit((Object)(object)val7) ? val7.GetComponent<ItemDrop>() : null); if (Object.op_Implicit((Object)(object)val8) && val8.m_itemData.m_shared.m_icons.Length > 0) { GameObject val9 = new GameObject("Icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val9.transform.SetParent(((Component)nodes[k]).transform, false); Image component = val9.GetComponent<Image>(); component.sprite = val8.m_itemData.m_shared.m_icons[0]; component.preserveAspect = true; ((Graphic)component).raycastTarget = false; Place((RectTransform)val9.transform, 24f, 21f, 32f, 32f); } ranks[k] = Text(((Component)nodes[k]).transform, "0/5", 24f, 43f, 48f, 18f, 12, Cream); } detail = Text(panel.transform, "", 143f, 407f, 254f, 104f, 13, Cream); detail.alignment = (TextAlignmentOptions)257; reset = NativeButton(panel.transform, "Reset talents (free)", 143f, 476f, 246f, 25f, (UnityAction)delegate { if (confirmReset) { Plugin.ActiveState().Reset(); if (!Plugin.Instance.Practice) { Plugin.Persist(Player.m_localPlayer); } confirmReset = false; } else { confirmReset = true; } Refresh(); }); practice = NativeButton(panel.transform, "", 143f, 506f, 246f, 25f, (UnityAction)delegate { Plugin.TogglePractice(); confirmReset = false; Refresh(); }); hint = Text(panel.transform, "", 143f, 529f, 266f, 17f, 10, Cream); } private static void Place(RectTransform r, float x, float y, float w, float h) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 anchorMin = (r.anchorMax = new Vector2(0f, 1f)); r.anchorMin = anchorMin; r.pivot = new Vector2(0.5f, 0.5f); r.sizeDelta = new Vector2(w, h); r.anchoredPosition = new Vector2(x, 0f - y); } private static TMP_Text Text(Transform parent, string value, float x, float y, float w, float h, int size, Color color) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Label", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); Place((RectTransform)val.transform, x, y, w, h); TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = font; ((TMP_Text)component).fontSize = size; ((Graphic)component).color = color; ((TMP_Text)component).alignment = (TextAlignmentOptions)514; ((TMP_Text)component).textWrappingMode = (TextWrappingModes)1; ((Graphic)component).raycastTarget = false; ((TMP_Text)component).text = value; return (TMP_Text)(object)component; } private static Button NativeButton(Transform parent, string text, float x, float y, float w, float h, UnityAction click) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject val = GUIManager.Instance.CreateButton(text, parent, Vector2.zero, Vector2.zero, Vector2.zero, w, h); Place((RectTransform)val.transform, x, y, w, h); Button component = val.GetComponent<Button>(); ((UnityEventBase)component.onClick).RemoveAllListeners(); if (click != null) { ((UnityEvent)component.onClick).AddListener(click); } SetButtonText(component, text); return component; } private static void SetButtonText(Button button, string value) { //IL_0023: 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) TMP_Text componentInChildren = ((Component)button).GetComponentInChildren<TMP_Text>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.text = value; componentInChildren.fontSize = 14f; ((Graphic)componentInChildren).color = Gold; } Text componentInChildren2 = ((Component)button).GetComponentInChildren<Text>(true); if (Object.op_Implicit((Object)(object)componentInChildren2)) { componentInChildren2.text = value; componentInChildren2.fontSize = 14; ((Graphic)componentInChildren2).color = Gold; } } private static void Line(Vector2 from, Vector2 to) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Branch", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(panel.transform, false); Vector2 val2 = (from + to) * 0.5f; Place((RectTransform)val.transform, val2.x, val2.y, Vector2.Distance(from, to), 1.5f); val.transform.localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(0f - (to.y - from.y), to.x - from.x) * 57.29578f); ((Graphic)val.GetComponent<Image>()).color = new Color(0.65f, 0.45f, 0.18f, 0.7f); ((Graphic)val.GetComponent<Image>()).raycastTarget = false; } internal static void Refresh() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)panel) && panel.activeInHierarchy && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { TalentState talentState = Plugin.ActiveState(); summary.text = string.Format("Level {0:0} | Points: {1}\n{2}", ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)13), talentState.Available, Plugin.Instance.Practice ? "PRACTICE ALLOCATIONS" : "1 point / 5 levels | +5 at level 100"); for (int i = 0; i < 8; i++) { ranks[i].text = talentState.Ranks[i] + "/5"; ColorBlock colors = ((Selectable)nodes[i]).colors; ((ColorBlock)(ref colors)).normalColor = (Color)((i == selected) ? new Color(1f, 0.8f, 0.42f) : (talentState.Unlocked(i) ? Color.white : new Color(0.42f, 0.42f, 0.42f))); ((Selectable)nodes[i]).colors = colors; } bool flag = talentState.Unlocked(selected); detail.text = "<color=#efb042><b>" + Names[selected] + " " + talentState.Ranks[selected] + "/5</b></color>\n" + Descriptions[selected]; string text = ""; int[] array = TalentState.Parents[selected]; foreach (int num in array) { text = text + ((text.Length > 0) ? " or " : "") + Names[num] + " 5/5"; } TMP_Text obj = detail; obj.text = obj.text + "\n<color=#efb042>" + ((!flag) ? ("Requires " + text) : ((talentState.Ranks[selected] == 5) ? "Fully trained" : ((talentState.Available <= 0) ? "No available points" : "Click this node to invest 1 point"))) + "</color>"; ((Selectable)reset).interactable = !talentState.ReadOnly && talentState.Spent > 0; SetButtonText(reset, confirmReset ? "Confirm reset" : "Reset talents (free)"); SetButtonText(practice, Plugin.Instance.Practice ? "Leave practice mode" : "Practice with temporary points"); hint.text = (talentState.ReadOnly ? "Save data preserved; see game log." : (Plugin.Instance.Practice ? "Use a test world: extra wood remains afterward." : "25 points at level 100. Click nodes to invest.")); } } internal static void KeepOnScreen() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0076: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)panel) || !panel.activeInHierarchy || !Object.op_Implicit((Object)(object)frame)) { return; } RectTransform val = (RectTransform)panel.transform; RectTransform obj = frame; Rect rect = frame.rect; float num = ((Rect)(ref rect)).xMax + 10f; Rect rect2 = frame.rect; ((Transform)val).position = ((Transform)obj).TransformPoint(new Vector3(num, ((Rect)(ref rect2)).center.y, 0f)); Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Canvas componentInParent = panel.GetComponentInParent<Canvas>(); Camera val2 = ((Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (RectTransformUtility.WorldToScreenPoint(val2, array[2]).x > (float)(Screen.width - 8)) { RectTransform obj2 = frame; Rect rect3 = frame.rect; float xMin = ((Rect)(ref rect3)).xMin; Rect rect4 = val.rect; float num2 = xMin - ((Rect)(ref rect4)).width - 10f; Rect rect5 = frame.rect; ((Transform)val).position = ((Transform)obj2).TransformPoint(new Vector3(num2, ((Rect)(ref rect5)).center.y, 0f)); } val.GetWorldCorners(array); Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val2, array[0]); Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val2, array[2]); float num3 = Mathf.Max(0f, 8f - val3.x) - Mathf.Max(0f, val4.x - (float)Screen.width + 8f); float num4 = Mathf.Max(0f, 8f - val3.y) - Mathf.Max(0f, val4.y - (float)Screen.height + 8f); if (Mathf.Abs(num3) + Mathf.Abs(num4) > 0.1f) { Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val2, ((Transform)val).position); Vector3 position = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle((RectTransform)((Transform)val).parent, val5 + new Vector2(num3, num4), val2, ref position)) { ((Transform)val).position = position; } } } internal static void Hide() { if (Object.op_Implicit((Object)(object)panel)) { panel.SetActive(false); } confirmReset = false; } internal static void Destroy() { if (Object.op_Implicit((Object)(object)panel)) { Object.Destroy((Object)(object)panel); } panel = null; dialog = null; frame = null; } }