Decompiled source of BlacksmithingExpanded v1.1.2
BlacksmithingExpanded.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using ItemDataManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using SkillManager; using TMPro; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BlacksmithingExpanded")] [assembly: AssemblyDescription("")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("D181CDA7-EF07-4BBC-B975-2B80FC6BBFAE")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyProduct("BlacksmithingExpanded")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace BlacksmithingExpanded { [BepInPlugin("org.bepinex.plugins.blacksmithingexpanded", "Blacksmithing Expanded", "1.1.2")] public class BlacksmithingExpanded : BaseUnityPlugin { private struct ItemBaseStats { public float armor; public DamageTypes damages; public float durability; public List<DamageModPair> resistances; public bool isCached; } public class WorkstationInfusion { public int tier; public float timestamp; public float originalSpeed; public float bonusSpeed; public bool wasActive; public bool IsExpired => Time.time - timestamp > cfg_InfusionExpireTime.Value; public float RemainingTime => Mathf.Max(0f, cfg_InfusionExpireTime.Value - (Time.time - timestamp)); } private class ItemFilterConfig { public List<string> Whitelist { get; set; } = new List<string>(); public List<string> Blacklist { get; set; } = new List<string>(); } public static class ItemEligibilityCache { private static readonly Dictionary<string, bool> eligibilityCache = new Dictionary<string, bool>(); private static readonly Dictionary<string, bool> allowedCache = new Dictionary<string, bool>(); private const int MAX_CACHE_SIZE = 200; public static bool IsEligibleForBlacksmithingBonuses(ItemData item) { if (item?.m_shared == null) { return false; } string name = item.m_shared.m_name; if (eligibilityCache.TryGetValue(name, out var value)) { return value; } bool flag = CalculateEligibility(item); if (eligibilityCache.Count >= 200) { string key = eligibilityCache.Keys.First(); eligibilityCache.Remove(key); } eligibilityCache[name] = flag; return flag; } public static bool IsItemAllowed(ItemData item) { if (!cfg_UseYamlFiltering.Value) { return true; } if (item?.m_shared == null) { return false; } string name = item.m_shared.m_name; if (allowedCache.TryGetValue(name, out var value)) { return value; } bool flag = BlacksmithingExpanded.IsItemAllowed(item); if (allowedCache.Count >= 200) { string key = allowedCache.Keys.First(); allowedCache.Remove(key); } allowedCache[name] = flag; return flag; } private static bool CalculateEligibility(ItemData item) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 if (!item.IsWeapon() && (int)item.m_shared.m_itemType != 5 && (int)item.m_shared.m_itemType != 6 && (int)item.m_shared.m_itemType != 7 && (int)item.m_shared.m_itemType != 11 && (int)item.m_shared.m_itemType != 17) { return false; } if (item.m_shared.m_maxStackSize > 1) { return false; } if (!IsItemAllowed(item)) { return false; } return true; } public static void ClearCache() { eligibilityCache.Clear(); allowedCache.Clear(); } } private class BlacksmithingItemData : ItemData { public static readonly Dictionary<SharedData, BlacksmithingItemData> activeItems = new Dictionary<SharedData, BlacksmithingItemData>(); [SerializeField] public int level = 0; [SerializeField] public int lastKnownQuality = 0; [SerializeField] public string infusion = ""; [SerializeField] public float baseDurability = 0f; [SerializeField] public float maxDurability = 0f; [SerializeField] public float armorBonus = 0f; [SerializeField] public float damageBlunt = 0f; [SerializeField] public float damageSlash = 0f; [SerializeField] public float damagePierce = 0f; [SerializeField] public float damageFire = 0f; [SerializeField] public float damageFrost = 0f; [SerializeField] public float damageLightning = 0f; [SerializeField] public float damagePoison = 0f; [SerializeField] public float damageSpirit = 0f; [SerializeField] public float blockPowerBonus = 0f; [SerializeField] public float timedBlockBonus = 0f; [SerializeField] public bool statsApplied = false; protected override bool AllowStackingIdenticalValues { get; set; } = true; ~BlacksmithingItemData() { activeItems.Remove(base.Item.m_shared); } public override void Load() { base.Load(); activeItems[base.Item.m_shared] = this; if (!base.IsCloned && level > 0) { ApplyStoredStats(); statsApplied = true; } } private void ApplyStoredStats() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00e1: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Invalid comparison between Unknown and I4 ItemBaseStats baseStats = GetBaseStats(base.Item); if (!baseStats.isCached) { return; } SharedData shared = base.Item.m_shared; base.Item.m_shared = (SharedData)((object)shared).GetType().GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(shared, null); if (maxDurability > 0f) { base.Item.m_shared.m_maxDurability = maxDurability; base.Item.m_durability = Mathf.Min(base.Item.m_durability, maxDurability); } if (armorBonus > 0f) { base.Item.m_shared.m_armor = baseStats.armor + armorBonus; } base.Item.m_shared.m_damages.m_blunt = baseStats.damages.m_blunt + damageBlunt; base.Item.m_shared.m_damages.m_slash = baseStats.damages.m_slash + damageSlash; base.Item.m_shared.m_damages.m_pierce = baseStats.damages.m_pierce + damagePierce; base.Item.m_shared.m_damages.m_fire = baseStats.damages.m_fire + damageFire; base.Item.m_shared.m_damages.m_frost = baseStats.damages.m_frost + damageFrost; base.Item.m_shared.m_damages.m_lightning = baseStats.damages.m_lightning + damageLightning; base.Item.m_shared.m_damages.m_poison = baseStats.damages.m_poison + damagePoison; base.Item.m_shared.m_damages.m_spirit = baseStats.damages.m_spirit + damageSpirit; if ((int)base.Item.m_shared.m_itemType == 5) { if (blockPowerBonus > 0f) { SharedData shared2 = base.Item.m_shared; shared2.m_blockPower += blockPowerBonus; } if (timedBlockBonus > 0f) { SharedData shared3 = base.Item.m_shared; shared3.m_timedBlockBonus += timedBlockBonus; } } } public override void Unload() { activeItems.Remove(base.Item.m_shared); } private void ResetToBaseStats(ItemBaseStats baseStats) { } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static class Patch_Crafting { private static void Prefix(InventoryGui __instance, out Recipe __state) { __state = __instance.m_craftRecipe; } private static void Postfix(InventoryGui __instance, Recipe __state) { Player localPlayer = Player.m_localPlayer; if (((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null) == null || (Object)(object)__state?.m_item == (Object)null) { return; } EnsureSkillInitialized(localPlayer); int playerBlacksmithingLevel = GetPlayerBlacksmithingLevel(localPlayer); ItemData val = FindMostRecentCraftedItem(localPlayer, __state); if (val == null) { return; } ApplyCraftingBonuses(val, Math.Max(playerBlacksmithingLevel, 1)); BlacksmithingItemData blacksmithingItemData = val.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData != null && blacksmithingItemData.maxDurability > 0f) { val.m_durability = blacksmithingItemData.maxDurability; } float num = HandleCraftingXP(localPlayer, val); if (num >= 1f) { Debug.Log((object)$"[BlacksmithingExpanded] Crafted {val.m_shared.m_name}: level={playerBlacksmithingLevel}, quality={val.m_quality}, xp={num:F2}"); } if (ItemEligibilityCache.IsEligibleForBlacksmithingBonuses(val)) { float num2 = cfg_ChanceExtraItemAt100.Value * ((float)playerBlacksmithingLevel / 100f); if (Random.value <= num2) { ItemData val2 = val.Clone(); ((Humanoid)localPlayer).GetInventory().AddItem(val2); ((Character)localPlayer).Message((MessageType)1, "Masterwork crafting created an extra item!", 0, (Sprite)null); } } } private static ItemData FindMostRecentCraftedItem(Player player, Recipe recipe) { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null || (Object)(object)recipe?.m_item == (Object)null) { return null; } ItemData templateItem = ((Component)recipe.m_item).GetComponent<ItemDrop>()?.m_itemData; if (templateItem?.m_shared == null) { return null; } List<ItemData> list = (from item in inventory.GetAllItems() where item.m_shared.m_name == templateItem.m_shared.m_name where item.m_quality == templateItem.m_quality orderby item.m_durability descending select item).ToList(); foreach (ItemData item in list) { BlacksmithingItemData blacksmithingItemData = item.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData == null || blacksmithingItemData.level == 0) { return item; } } return null; } } [HarmonyPatch(typeof(CraftingStation), "GetLevel")] public static class Patch_CraftingStationLevel { private static void Postfix(CraftingStation __instance, ref int __result) { if (__instance.m_craftRequireRoof || !(__instance.m_rangeBuild > 0f)) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { int playerBlacksmithingLevel = GetPlayerBlacksmithingLevel(localPlayer); int num = CalculateWorkbenchBonus(__instance.m_name, playerBlacksmithingLevel); if (num > 0) { __result += num; } } } private static int CalculateWorkbenchBonus(string stationName, int level) { string text = stationName.ToLower(); if (text.Contains("workbench")) { if (level >= 20) { return 2; } if (level >= 10) { return 1; } } else if (text.Contains("forge") && !text.Contains("black")) { if (level >= 40) { return 2; } if (level >= 30) { return 1; } } else if (text.Contains("black") || text.Contains("galdr")) { if (level >= 60) { return 2; } if (level >= 50) { return 1; } } return 0; } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static class Patch_UpgradeDetection_Alternative { private static void Postfix(InventoryGui __instance) { Player localPlayer = Player.m_localPlayer; if (((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null) == null) { return; } foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems()) { if (ItemEligibilityCache.IsEligibleForBlacksmithingBonuses(allItem)) { BlacksmithingItemData blacksmithingItemData = allItem.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData != null && blacksmithingItemData.lastKnownQuality < allItem.m_quality) { int playerBlacksmithingLevel = GetPlayerBlacksmithingLevel(localPlayer); GiveBlacksmithingXP(localPlayer, cfg_XPPerUpgrade.Value); ApplyCraftingBonuses(allItem, playerBlacksmithingLevel); } } } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] public static class Patch_Tooltip { public static void Postfix(ItemData item, bool crafting, ref string __result) { if (item == null) { return; } BlacksmithingItemData blacksmithingItemData = item.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData != null && blacksmithingItemData.level > 0) { if (cfg_ShowBlacksmithLevelInTooltip.Value) { __result += $"\n<color=orange>Forged at Blacksmithing {blacksmithingItemData.level}</color>"; } if (cfg_ShowInfusionInTooltip.Value && !string.IsNullOrEmpty(blacksmithingItemData.infusion)) { __result = __result + "\n<color=#87CEEB>Elemental Infusion: " + blacksmithingItemData.infusion + "</color>"; } } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Patch_UpgradeDetection { public static readonly Dictionary<long, Dictionary<string, int>> playerItemQualities = new Dictionary<long, Dictionary<string, int>>(); private static float lastUpdateTime = 0f; private const float UPDATE_INTERVAL = 2f; private static void Postfix(Player __instance) { if (!(Time.time - lastUpdateTime < 2f)) { lastUpdateTime = Time.time; CheckForUpgrades(__instance); } } private static void CheckForUpgrades(Player player) { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return; } long playerID = player.GetPlayerID(); if (!playerItemQualities.TryGetValue(playerID, out var value)) { value = new Dictionary<string, int>(); playerItemQualities[playerID] = value; } HashSet<string> currentItems = new HashSet<string>(); foreach (ItemData allItem in inventory.GetAllItems()) { if (!ItemEligibilityCache.IsEligibleForBlacksmithingBonuses(allItem)) { continue; } string text = $"{allItem.m_shared.m_name}_{((object)allItem).GetHashCode()}"; currentItems.Add(text); if (value.TryGetValue(text, out var value2)) { if (allItem.m_quality > value2) { Debug.Log((object)$"[BlacksmithingExpanded] UPGRADE DETECTED: {allItem.m_shared.m_name} from quality {value2} to {allItem.m_quality}"); GiveBlacksmithingXP(player, cfg_XPPerUpgrade.Value); int playerBlacksmithingLevel = GetPlayerBlacksmithingLevel(player); Debug.Log((object)$"[BlacksmithingExpanded] Applying upgrade bonuses at level {playerBlacksmithingLevel}"); ApplyCraftingBonuses(allItem, playerBlacksmithingLevel); value[text] = allItem.m_quality; Debug.Log((object)("[BlacksmithingExpanded] Upgrade processing complete for " + allItem.m_shared.m_name)); } } else { value[text] = allItem.m_quality; } } if (!(Time.time % 20f < 2f)) { return; } List<string> list = value.Keys.Where((string key) => !currentItems.Contains(key)).ToList(); foreach (string item in list) { value.Remove(item); } } } [HarmonyPatch(typeof(Smelter), "OnAddOre")] public static class Patch_Smelter_AddOre { private static void Postfix(Smelter __instance, Humanoid user, bool __result) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return; } Player val = (Player)(object)((user is Player) ? user : null); if (val == null) { return; } GiveBlacksmithingXP(val, cfg_XPPerSmelt.Value); ZNetView nview = __instance.m_nview; ZDO val2 = ((nview != null) ? nview.GetZDO() : null); if (val2 == null) { return; } bool flag = __instance.m_name.Contains("charcoal_kiln"); bool flag2 = __instance.m_name.Contains("blastfurnace"); int playerBlacksmithingLevel = GetPlayerBlacksmithingLevel(val); int num = playerBlacksmithingLevel / cfg_InfusionTierInterval.Value; if (num <= 0) { return; } float num2 = (flag ? cfg_KilnSpeedBonusPerTier.Value : cfg_SmeltingSpeedBonusPerTier.Value); float num3 = 1f + (float)num * num2; WorkstationInfusion workstationInfusion = new WorkstationInfusion { tier = num, timestamp = Time.time, originalSpeed = __instance.m_secPerProduct, bonusSpeed = __instance.m_secPerProduct / num3 }; bool flag3 = false; if (flag) { if (kilnInfusions.ContainsKey(val2.m_uid)) { kilnInfusions[val2.m_uid].timestamp = Time.time; kilnInfusions[val2.m_uid].tier = num; } else { kilnInfusions[val2.m_uid] = workstationInfusion; flag3 = true; } } else if (flag2) { blastFurnaceInfusions[val2.m_uid] = workstationInfusion; flag3 = true; } else { smelterInfusions[val2.m_uid] = workstationInfusion; flag3 = true; } if (!flag) { float num4 = cfg_SmelterSaveOreChanceAt100.Value * ((float)playerBlacksmithingLevel / 100f); if (Random.value <= num4 && __instance.GetFuel() < (float)__instance.m_maxFuel) { __instance.m_nview.GetZDO().Set("fuel", __instance.GetFuel() + 1f); } } __instance.m_secPerProduct = workstationInfusion.bonusSpeed; if (flag3) { ManageInfusionGlow(((Component)__instance).transform, val2.m_uid, enable: true); } } } [HarmonyPatch(typeof(Smelter), "UpdateSmelter")] public static class Patch_Smelter_Update { private static void Prefix(Smelter __instance) { ZNetView nview = __instance.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val != null) { bool flag = __instance.m_name.Contains("charcoal_kiln"); bool flag2 = __instance.m_name.Contains("blastfurnace"); if (flag) { HandleKilnInfusion(__instance, val); } else if (flag2) { HandleBlastFurnaceInfusion(__instance, val); } else { HandleSmelterInfusion(__instance, val); } } } private static void HandleBlastFurnaceInfusion(Smelter blastFurnace, ZDO zdo) { //IL_0007: 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_001f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if (!originalBlastFurnaceSpeeds.ContainsKey(zdo.m_uid)) { originalBlastFurnaceSpeeds[zdo.m_uid] = blastFurnace.m_secPerProduct; } if (blastFurnaceInfusions.TryGetValue(zdo.m_uid, out var value)) { float num = Time.time - value.timestamp; if (!(num < 1f) && (value.IsExpired || blastFurnace.GetQueueSize() == 0 || blastFurnace.GetFuel() <= 0f)) { blastFurnace.m_secPerProduct = originalBlastFurnaceSpeeds[zdo.m_uid]; blastFurnaceInfusions.Remove(zdo.m_uid); ManageInfusionGlow(((Component)blastFurnace).transform, zdo.m_uid, enable: false); } else { blastFurnace.m_secPerProduct = value.bonusSpeed; value.wasActive = true; } } else { blastFurnace.m_secPerProduct = originalBlastFurnaceSpeeds[zdo.m_uid]; } } private static void HandleKilnInfusion(Smelter kiln, ZDO zdo) { //IL_0007: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!originalKilnSpeeds.ContainsKey(zdo.m_uid)) { originalKilnSpeeds[zdo.m_uid] = kiln.m_secPerProduct; } if (kilnInfusions.TryGetValue(zdo.m_uid, out var value)) { bool flag = kiln.GetFuel() > 0f || kiln.GetBakeTimer() > 0f; if (value.IsExpired || !flag) { kiln.m_secPerProduct = originalKilnSpeeds[zdo.m_uid]; kilnInfusions.Remove(zdo.m_uid); ManageInfusionGlow(((Component)kiln).transform, zdo.m_uid, enable: false); } else { kiln.m_secPerProduct = value.bonusSpeed; } } else { kiln.m_secPerProduct = originalKilnSpeeds[zdo.m_uid]; } } private static void HandleSmelterInfusion(Smelter smelter, ZDO zdo) { //IL_0007: 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_001f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if (!originalSmelterSpeeds.ContainsKey(zdo.m_uid)) { originalSmelterSpeeds[zdo.m_uid] = smelter.m_secPerProduct; } if (smelterInfusions.TryGetValue(zdo.m_uid, out var value)) { float num = Time.time - value.timestamp; if (!(num < 1f) && (value.IsExpired || smelter.GetQueueSize() == 0 || smelter.GetFuel() <= 0f)) { smelter.m_secPerProduct = originalSmelterSpeeds[zdo.m_uid]; smelterInfusions.Remove(zdo.m_uid); ManageInfusionGlow(((Component)smelter).transform, zdo.m_uid, enable: false); } else { smelter.m_secPerProduct = value.bonusSpeed; value.wasActive = true; } } else { smelter.m_secPerProduct = originalSmelterSpeeds[zdo.m_uid]; } } } public class FlickerLight : MonoBehaviour { private Light lightSource; private float baseIntensity; private void Start() { lightSource = ((Component)this).GetComponent<Light>(); baseIntensity = lightSource.intensity; } private void Update() { if ((Object)(object)lightSource != (Object)null) { lightSource.intensity = baseIntensity + Random.Range(-0.2f, 0.2f); } } } [HarmonyPatch(typeof(Attack), "Start")] public static class Patch_AttackStart { private static void Prefix(Attack __instance, ItemData weapon, Humanoid character) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 if (weapon == null || !weapon.IsWeapon()) { return; } Player val = (Player)(object)((character is Player) ? character : null); if (val == null || !weapon.m_shared.m_name.ToLower().Contains("spear") || (int)__instance.m_attackType != 2) { return; } BlacksmithingItemData blacksmithingItemData = weapon.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData != null && blacksmithingItemData.level > 0) { string key = GenerateSpearKey(weapon, val); BlacksmithingItemData blacksmithingItemData2 = new BlacksmithingItemData(); CopyBlacksmithingData(blacksmithingItemData, blacksmithingItemData2); if (tempSpearDataStorage.Count >= 50) { CleanupOldSpearData(); } tempSpearDataStorage[key] = blacksmithingItemData2; } } } [HarmonyPatch(typeof(ItemDrop), "Start")] public static class Patch_ItemDropStart { private static void Postfix(ItemDrop __instance) { if (__instance == null) { return; } ItemData itemData = __instance.m_itemData; if (!((itemData != null) ? new bool?(itemData.IsWeapon()) : null).GetValueOrDefault() || !__instance.m_itemData.m_shared.m_name.ToLower().Contains("spear")) { return; } ItemData itemData2 = __instance.m_itemData; BlacksmithingItemData blacksmithingItemData = itemData2.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData == null || blacksmithingItemData.level <= 0) { KeyValuePair<string, BlacksmithingItemData> keyValuePair = FindBestSpearMatch(itemData2); if (keyValuePair.Key != null && keyValuePair.Value != null) { BlacksmithingItemData orCreate = itemData2.Data().GetOrCreate<BlacksmithingItemData>(); CopyBlacksmithingData(keyValuePair.Value, orCreate); orCreate.Save(); ApplyStoredBlacksmithingStats(itemData2, orCreate); tempSpearDataStorage.Remove(keyValuePair.Key); } } } } [HarmonyPatch(typeof(ItemData), "Clone")] public static class Patch_ItemDataClone { private static void Postfix(ItemData __result, ItemData __instance) { if (__instance != null && __result != null) { BlacksmithingItemData blacksmithingItemData = __instance.Data().Get<BlacksmithingItemData>(); if (blacksmithingItemData != null && blacksmithingItemData.level > 0) { BlacksmithingItemData orCreate = __result.Data().GetOrCreate<BlacksmithingItemData>(); CopyBlacksmithingData(blacksmithingItemData, orCreate); orCreate.Save(); orCreate.Load(); } } } } [CompilerGenerated] private sealed class <>c__DisplayClass85_0 { public HashSet<long> connectedPlayerIds; internal bool <PerformanceMaintenance>b__0(long id) { return !connectedPlayerIds.Contains(id); } } [CompilerGenerated] private sealed class <PerformanceMaintenance>d__85 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public BlacksmithingExpanded <>4__this; private <>c__DisplayClass85_0 <>8__1; private List<long> <playersToRemove>5__2; private List<Player>.Enumerator <>s__3; private Player <player>5__4; private List<long>.Enumerator <>s__5; private long <playerId>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PerformanceMaintenance>d__85(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <playersToRemove>5__2 = null; <>s__3 = default(List<Player>.Enumerator); <player>5__4 = null; <>s__5 = default(List<long>.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; ItemEligibilityCache.ClearCache(); if (tempSpearDataStorage.Count > 25) { CleanupOldSpearData(); } <>8__1.connectedPlayerIds = new HashSet<long>(); <>s__3 = Player.GetAllPlayers().GetEnumerator(); try { while (<>s__3.MoveNext()) { <player>5__4 = <>s__3.Current; <>8__1.connectedPlayerIds.Add(<player>5__4.GetPlayerID()); <player>5__4 = null; } } finally { ((IDisposable)<>s__3).Dispose(); } <>s__3 = default(List<Player>.Enumerator); <playersToRemove>5__2 = Patch_UpgradeDetection.playerItemQualities.Keys.Where((long id) => !<>8__1.connectedPlayerIds.Contains(id)).ToList(); <>s__5 = <playersToRemove>5__2.GetEnumerator(); try { while (<>s__5.MoveNext()) { <playerId>5__6 = <>s__5.Current; Patch_UpgradeDetection.playerItemQualities.Remove(<playerId>5__6); initializedPlayers.Remove(<playerId>5__6); } } finally { ((IDisposable)<>s__5).Dispose(); } <>s__5 = default(List<long>.Enumerator); <>8__1 = null; <playersToRemove>5__2 = null; break; } <>8__1 = new <>c__DisplayClass85_0(); <>2__current = (object)new WaitForSeconds(60f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpearDataCleanupRoutine>d__84 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public BlacksmithingExpanded <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpearDataCleanupRoutine>d__84(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; CleanupOldSpearData(); break; } <>2__current = (object)new WaitForSeconds(30f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal const string ModName = "Blacksmithing Expanded"; internal const string ModVersion = "1.1.2"; internal const string ModGUID = "org.bepinex.plugins.blacksmithingexpanded"; private Harmony harmony; private static readonly ConfigSync configSync = new ConfigSync("org.bepinex.plugins.blacksmithingexpanded") { DisplayName = "Blacksmithing Expanded", CurrentVersion = "1.1.2", MinimumRequiredVersion = "1.1.2", ModRequired = true }; internal static Skill blacksmithSkill; private static readonly Dictionary<string, ItemBaseStats> baseStatsCache = new Dictionary<string, ItemBaseStats>(); private static readonly object cacheLocker = new object(); private static readonly HashSet<long> initializedPlayers = new HashSet<long>(); private static ItemFilterConfig itemFilterConfig; private static readonly HashSet<string> whitelistedItems = new HashSet<string>(); private static readonly HashSet<string> blacklistedItems = new HashSet<string>(); private static string configPath; public static readonly CustomSyncedValue<List<string>> syncedWhitelistItems = new CustomSyncedValue<List<string>>(configSync, "whitelist items", new List<string>()); public static readonly CustomSyncedValue<List<string>> syncedBlacklistItems = new CustomSyncedValue<List<string>>(configSync, "blacklist items", new List<string>()); internal static Dictionary<ZDOID, WorkstationInfusion> smelterInfusions = new Dictionary<ZDOID, WorkstationInfusion>(); internal static Dictionary<ZDOID, WorkstationInfusion> kilnInfusions = new Dictionary<ZDOID, WorkstationInfusion>(); internal static Dictionary<ZDOID, WorkstationInfusion> blastFurnaceInfusions = new Dictionary<ZDOID, WorkstationInfusion>(); private static readonly Dictionary<ZDOID, float> originalBlastFurnaceSpeeds = new Dictionary<ZDOID, float>(); private static readonly Dictionary<ZDOID, float> originalSmelterSpeeds = new Dictionary<ZDOID, float>(); private static readonly Dictionary<ZDOID, float> originalKilnSpeeds = new Dictionary<ZDOID, float>(); private static readonly Dictionary<ZDOID, GameObject> activeGlowEffects = new Dictionary<ZDOID, GameObject>(); private static readonly Dictionary<string, BlacksmithingItemData> tempSpearDataStorage = new Dictionary<string, BlacksmithingItemData>(); private const int MAX_SPEAR_DATA_ENTRIES = 50; private const float SPEAR_DATA_CLEANUP_INTERVAL = 30f; private static float lastSpearCleanup = 0f; internal static ConfigEntry<float> cfg_SkillGainFactor; internal static ConfigEntry<float> cfg_SkillEffectFactor; internal static ConfigEntry<int> cfg_InfusionTierInterval; internal static ConfigEntry<float> cfg_ChanceExtraItemAt100; internal static ConfigEntry<float> cfg_SmelterSaveOreChanceAt100; internal static ConfigEntry<float> cfg_SmeltingSpeedBonusPerTier; internal static ConfigEntry<float> cfg_KilnSpeedBonusPerTier; internal static ConfigEntry<float> cfg_InfusionExpireTime; internal static ConfigEntry<bool> cfg_ShowInfusionVisualEffect; internal static ConfigEntry<bool> cfg_ShowBlacksmithLevelInTooltip; internal static ConfigEntry<bool> cfg_ShowInfusionInTooltip; internal static ConfigEntry<float> cfg_FirstCraftBonusXP; internal static ConfigEntry<float> UpgradeBonus; internal static ConfigEntry<bool> cfg_UseYamlFiltering; internal static ConfigEntry<bool> cfg_LogFilteredItems; internal static ConfigEntry<int> cfg_DurabilityTierInterval; internal static ConfigEntry<float> cfg_DurabilityBonusPerTier; internal static ConfigEntry<float> cfg_DurabilityBonusPerUpgrade; internal static ConfigEntry<bool> cfg_RespectOriginalDurability; internal static ConfigEntry<float> cfg_MaxDurabilityCap; internal static ConfigEntry<bool> cfg_AllowNonRepairableItems; internal static ConfigEntry<int> cfg_StatTierInterval; internal static ConfigEntry<float> cfg_ArmorBonusPerTier; internal static ConfigEntry<float> cfg_ArmorBonusPerUpgrade; internal static ConfigEntry<float> cfg_ArmorCap; internal static ConfigEntry<int> cfg_DamageBonusPerTier; internal static ConfigEntry<float> cfg_StatBonusPerUpgrade; internal static ConfigEntry<bool> cfg_UsePercentageDamageBonus; internal static ConfigEntry<float> cfg_DamagePercentageBonusPerTier; internal static ConfigEntry<bool> cfg_UsePercentageUpgradeBonus; internal static ConfigEntry<float> cfg_StatPercentageBonusPerUpgrade; internal static ConfigEntry<bool> cfg_AlwaysAddElementalAtMax; internal static ConfigEntry<int> cfg_ElementalUnlockLevel; internal static ConfigEntry<float> cfg_FireBonusPerTier; internal static ConfigEntry<float> cfg_FrostBonusPerTier; internal static ConfigEntry<float> cfg_LightningBonusPerTier; internal static ConfigEntry<float> cfg_PoisonBonusPerTier; internal static ConfigEntry<float> cfg_SpiritBonusPerTier; internal static ConfigEntry<bool> cfg_BoostElementalWeapons; internal static ConfigEntry<float> cfg_ElementalWeaponBoostChance; internal static ConfigEntry<bool> cfg_UsePercentageElementalBonus; internal static ConfigEntry<float> cfg_ElementalPercentageBonusPerTier; internal static ConfigEntry<float> cfg_TimedBlockBonusPerTier; internal static ConfigEntry<float> cfg_TimedBlockBonusPerUpgrade; internal static ConfigEntry<float> cfg_BlockPowerBonusPerTier; internal static ConfigEntry<float> cfg_BlockPowerBonusPerUpgrade; internal static ConfigEntry<float> cfg_XPPerCraft; internal static ConfigEntry<float> cfg_XPPerSmelt; internal static ConfigEntry<float> cfg_XPPerRepair; internal static ConfigEntry<float> cfg_XPPerUpgrade; private static Sprite s_skillIcon; private ConfigEntry<T> AddConfig<T>(string group, string name, T value, string description, bool sync = true) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = sync; return val; } private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("org.bepinex.plugins.blacksmithingexpanded"); configPath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), "BlacksmithExpItemList.yml"); try { s_skillIcon = LoadEmbeddedSprite("smithing.png", 64, 64); if ((Object)(object)s_skillIcon == (Object)null) { throw new Exception("Failed to load embedded sprite: smithing.png"); } blacksmithSkill = new Skill("Blacksmithing", s_skillIcon) { Configurable = true }; blacksmithSkill.Name.English("Blacksmithing"); blacksmithSkill.Description.English("Craft better, last longer. Improves durability, damage, and armor of crafted items."); } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Skill setup failed: {arg}"); } SetupConfigs(); InitializeYamlFiltering(); syncedWhitelistItems.ValueChanged += delegate { whitelistedItems.Clear(); foreach (string item in syncedWhitelistItems.Value) { whitelistedItems.Add(item); } ((BaseUnityPlugin)this).Logger.LogDebug((object)$"[BlacksmithingExpanded] Received synced whitelist: {whitelistedItems.Count} items"); }; syncedBlacklistItems.ValueChanged += delegate { blacklistedItems.Clear(); foreach (string item2 in syncedBlacklistItems.Value) { blacklistedItems.Add(item2); } ((BaseUnityPlugin)this).Logger.LogDebug((object)$"[BlacksmithingExpanded] Received synced blacklist: {blacklistedItems.Count} items"); }; if (blacksmithSkill != null) { blacksmithSkill.SkillGainFactor = cfg_SkillGainFactor.Value; blacksmithSkill.SkillEffectFactor = cfg_SkillEffectFactor.Value; cfg_SkillGainFactor.SettingChanged += delegate { blacksmithSkill.SkillGainFactor = cfg_SkillGainFactor.Value; }; cfg_SkillEffectFactor.SettingChanged += delegate { blacksmithSkill.SkillEffectFactor = cfg_SkillEffectFactor.Value; }; } cfg_UseYamlFiltering.SettingChanged += delegate { if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer()) { ReloadYamlConfiguration(); } }; ItemInfo.ForceLoadTypes.Add(typeof(BlacksmithingItemData)); ((MonoBehaviour)this).StartCoroutine(SpearDataCleanupRoutine()); ((MonoBehaviour)this).StartCoroutine(PerformanceMaintenance()); harmony.PatchAll(); } private void Update() { if (Time.time - lastSpearCleanup > 30f) { CleanupOldSpearData(); lastSpearCleanup = Time.time; } } [IteratorStateMachine(typeof(<SpearDataCleanupRoutine>d__84))] private IEnumerator SpearDataCleanupRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpearDataCleanupRoutine>d__84(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<PerformanceMaintenance>d__85))] private IEnumerator PerformanceMaintenance() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PerformanceMaintenance>d__85(0) { <>4__this = this }; } private static void CacheBaseStats(ItemData item) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (item?.m_shared == null) { return; } string name = item.m_shared.m_name; lock (cacheLocker) { if (!baseStatsCache.ContainsKey(name)) { baseStatsCache[name] = new ItemBaseStats { armor = item.m_shared.m_armor, damages = ((DamageTypes)(ref item.m_shared.m_damages)).Clone(), durability = item.m_shared.m_maxDurability, resistances = new List<DamageModPair>(item.m_shared.m_damageModifiers), isCached = true }; } } } private static ItemBaseStats GetBaseStats(ItemData item) { if (item?.m_shared == null) { ItemBaseStats result = default(ItemBaseStats); result.isCached = false; return result; } string name = item.m_shared.m_name; lock (cacheLocker) { if (!baseStatsCache.ContainsKey(name)) { CacheBaseStats(item); } return baseStatsCache[name]; } } private static void CleanupOldSpearData() { float time = Time.time; List<string> list = new List<string>(); foreach (KeyValuePair<string, BlacksmithingItemData> item in tempSpearDataStorage.ToList()) { string[] array = item.Key.Split(new char[1] { '_' }); if (array.Length >= 5 && float.TryParse(array[4], out var result)) { if (time - result > 120f) { list.Add(item.Key); } } else { list.Add(item.Key); } } if (tempSpearDataStorage.Count > 50) { List<string> collection = (from kvp in tempSpearDataStorage.OrderBy(delegate(KeyValuePair<string, BlacksmithingItemData> kvp) { string[] array2 = kvp.Key.Split(new char[1] { '_' }); float result2; return (array2.Length >= 5 && float.TryParse(array2[4], out result2)) ? result2 : 0f; }).Take(tempSpearDataStorage.Count - 50) select kvp.Key).ToList(); list.AddRange(collection); } foreach (string item2 in list) { tempSpearDataStorage.Remove(item2); } if (list.Count > 0) { Debug.Log((object)$"[BlacksmithingExpanded] Cleaned up {list.Count} old spear data entries"); } } private void SetupConfigs() { cfg_SkillGainFactor = AddConfig("General", "Skill gain factor", 1f, "Multiplier for blacksmithing XP gain rate (1.5 = 50% faster leveling)"); cfg_SkillEffectFactor = AddConfig("General", "Skill effect factor", 1f, "Global multiplier for all blacksmithing bonuses (damage, armor, durability, etc). Higher = stronger effects"); cfg_InfusionTierInterval = AddConfig("General", "Workstation infusion milestone interval", 10, "Every X blacksmithing levels unlocks a new tier of smelter/kiln speed bonus"); cfg_SmeltingSpeedBonusPerTier = AddConfig("General", "Smelting speed bonus per tier", 0.15f, "Speed bonus per tier - 0.15 = 15% faster smelting. Stacks with each tier"); cfg_KilnSpeedBonusPerTier = AddConfig("General", "Kiln speed bonus per tier", 0.15f, "Speed bonus per tier - 0.15 = 15% faster charcoal production. Stacks with each tier"); cfg_InfusionExpireTime = AddConfig("General", "Infusion expire time", 300f, "Seconds that speed bonuses last after adding fuel/ore to smelters/kilns (300 = 5 minutes)"); cfg_ShowInfusionVisualEffect = AddConfig("General", "Show infusion visual effect", value: true, "Show orange glowing light effect when smelters/kilns have speed bonuses active"); cfg_SmelterSaveOreChanceAt100 = AddConfig("General", "Ore save chance at 100", 0.2f, "At level 100: chance to not consume ore when smelting (0.2 = 20% ore savings)"); cfg_ChanceExtraItemAt100 = AddConfig("General", "Extra item chance at 100", 0.05f, "At level 100: chance to get bonus item when crafting (0.05 = 5% chance for double output)"); cfg_UsePercentageUpgradeBonus = AddConfig("PercentageSystem", "Use percentage upgrade bonus", value: true, "If enabled, upgrade bonuses are percentage-based instead of flat. When disabled, uses flat bonuses"); cfg_StatPercentageBonusPerUpgrade = AddConfig("PercentageSystem", "Stat percentage bonus per upgrade", 5f, "Percentage bonus per upgrade level when using percentage upgrade system (5 = 5% per upgrade level)"); cfg_UseYamlFiltering = AddConfig("Item Filtering", "Use YAML item filtering", value: true, "Enable custom whitelist/blacklist system via BlacksmithExpItemList.yml file"); cfg_LogFilteredItems = AddConfig("Item Filtering", "Log filtered items", value: false, "Write to console when items are blocked by whitelist/blacklist filters"); cfg_XPPerCraft = AddConfig("XP", "XP per craft", 1f, "Base blacksmithing XP gained when crafting any item"); cfg_XPPerSmelt = AddConfig("XP", "XP per smelt", 0.75f, "Base blacksmithing XP gained when adding ore to smelters/kilns"); cfg_XPPerRepair = AddConfig("XP", "XP per repair", 0.1f, "Base blacksmithing XP gained when repairing items"); cfg_XPPerUpgrade = AddConfig("XP", "XP per upgrade", 3f, "Base blacksmithing XP gained when upgrading items at workbenches"); cfg_FirstCraftBonusXP = AddConfig("XP", "First craft bonus XP", 10f, "One-time bonus XP when crafting each item type for the first time"); cfg_ShowBlacksmithLevelInTooltip = AddConfig("Tooltip", "Show level in tooltip", value: true, "Display blacksmithing level used to craft item in item tooltips"); cfg_ShowInfusionInTooltip = AddConfig("Tooltip", "Show infusion in tooltip", value: false, "Display elemental infusion type in item tooltips (Fire, Frost, etc.)"); cfg_DurabilityTierInterval = AddConfig("Durability", "Durability tier interval", 10, "Every X blacksmithing levels unlocks next tier of durability bonuses"); cfg_DurabilityBonusPerTier = AddConfig("Durability", "Durability bonus per tier", 25f, "Flat durability points added per tier when crafting items"); cfg_DurabilityBonusPerUpgrade = AddConfig("Durability", "Durability bonus per upgrade", 50f, "Extra durability points per item quality level (star rating)"); cfg_RespectOriginalDurability = AddConfig("Durability", "Respect original durability", value: true, "Only boost durability on items that already have durability (prevents boosting consumables/arrows)"); cfg_MaxDurabilityCap = AddConfig("Durability", "Max durability cap", 2000f, "Maximum durability any item can reach (0 = no limit)"); cfg_AllowNonRepairableItems = AddConfig("Durability", "Allow non-repairable items", value: false, "Allow blacksmithing bonuses on items with no durability (torches, consumables, etc.)"); cfg_BoostElementalWeapons = AddConfig("Stats", "Boost elemental weapons", value: true, "Allow boosting weapons that already have elemental damage (like Frostner)"); cfg_ElementalWeaponBoostChance = AddConfig("Stats", "Elemental weapon boost chance", 0.25f, "For weapons with both physical and elemental damage: chance to boost elemental instead of physical (0.25 = 25% chance)"); cfg_StatTierInterval = AddConfig("Stats", "Stat tier interval", 5, "Every X blacksmithing levels unlocks next tier of damage/armor bonuses"); cfg_ArmorBonusPerTier = AddConfig("Stats", "Armor bonus per tier", 0.5f, "Flat armor points added per tier when crafting armor pieces"); cfg_ArmorBonusPerUpgrade = AddConfig("Stats", "Armor bonus per upgrade", 2f, "Extra armor points per item quality level (star rating)"); cfg_ArmorCap = AddConfig("Stats", "Armor cap", 150f, "Maximum armor value any piece can reach (0 = no limit)"); cfg_UsePercentageDamageBonus = AddConfig("PercentageSystem", "Use percentage damage bonus", value: true, "If enabled, damage bonuses are percentage-based instead of flat. Much more balanced for all weapon types"); cfg_DamagePercentageBonusPerTier = AddConfig("PercentageSystem", "Damage percentage bonus per tier", 1f, "Percentage damage bonus per tier when using percentage system (1 = 1% per tier)"); cfg_DamageBonusPerTier = AddConfig("Stats", "Damage bonus per tier", 5, "Flat damage bonus added per stat tier. Applied to one random damage type (slash/pierce/blunt). Only used if percentage system is disabled"); cfg_StatBonusPerUpgrade = AddConfig("Stats", "Stat bonus per upgrade", 4f, "Extra damage/armor bonus per item quality level (star rating). Only used if percentage upgrade system is disabled"); cfg_AlwaysAddElementalAtMax = AddConfig("Elemental", "Add elemental at milestone", value: true, "Automatically add random elemental damage when reaching elemental unlock level"); cfg_ElementalUnlockLevel = AddConfig("Elemental", "Elemental unlock level", 75, "Blacksmithing level required to add elemental damage bonuses to weapons"); cfg_FireBonusPerTier = AddConfig("Elemental", "Fire bonus per tier", 3f, "Fire damage points per tier (causes burning damage over time)"); cfg_FrostBonusPerTier = AddConfig("Elemental", "Frost bonus per tier", 6f, "Frost damage points per tier (causes instant cold damage)"); cfg_LightningBonusPerTier = AddConfig("Elemental", "Lightning bonus per tier", 5f, "Lightning damage points per tier (good vs wet enemies)"); cfg_PoisonBonusPerTier = AddConfig("Elemental", "Poison bonus per tier", 2.5f, "Poison damage points per tier (causes poison damage over time)"); cfg_SpiritBonusPerTier = AddConfig("Elemental", "Spirit bonus per tier", 4f, "Spirit damage points per tier (extra effective vs undead enemies)"); cfg_UsePercentageElementalBonus = AddConfig("PercentageSystem", "Use percentage elemental bonus", value: true, "If enabled, elemental bonuses are percentage-based instead of flat. Much more balanced for all weapon types"); cfg_ElementalPercentageBonusPerTier = AddConfig("PercentageSystem", "Elemental percentage bonus per tier", 0.75f, "Percentage elemental bonus per tier when using percentage system (0.75 = 0.75% per tier)"); cfg_TimedBlockBonusPerTier = AddConfig("Shields", "Timed block bonus per tier", 0.01f, "Parry/perfect block bonus per tier (0.01 = 1% better parry window/damage)"); cfg_TimedBlockBonusPerUpgrade = AddConfig("Shields", "Timed block bonus per upgrade", 0.05f, "Extra parry bonus per shield quality level (star rating)"); cfg_BlockPowerBonusPerTier = AddConfig("Shields", "Block power bonus per tier", 1f, "Block strength points per tier (reduces stamina cost when blocking)"); cfg_BlockPowerBonusPerUpgrade = AddConfig("Shields", "Block power bonus per upgrade", 1f, "Extra block power per shield quality level (star rating)"); } private void InitializeYamlFiltering() { try { if (!File.Exists(configPath)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[BlacksmithingExpanded] YAML not found at " + configPath + ". Generating default YAML...")); GenerateDefaultYaml(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BlacksmithingExpanded] Default YAML created. Please restart the client."); } else { ReloadYamlConfiguration(); ((BaseUnityPlugin)this).Logger.LogDebug((object)("[BlacksmithingExpanded] YAML filtering system initialized. File: " + configPath)); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"[BlacksmithingExpanded] Failed to initialize YAML filtering: {arg}"); } } private void ReloadYamlConfiguration() { whitelistedItems.Clear(); blacklistedItems.Clear(); if (!cfg_UseYamlFiltering.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BlacksmithingExpanded] YAML filtering disabled"); return; } try { IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(PascalCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build(); string input = File.ReadAllText(configPath); itemFilterConfig = deserializer.Deserialize<ItemFilterConfig>(input) ?? new ItemFilterConfig(); if (itemFilterConfig.Whitelist != null) { foreach (string item in itemFilterConfig.Whitelist.Where((string x) => !string.IsNullOrWhiteSpace(x))) { whitelistedItems.Add(item.Trim()); } } if (itemFilterConfig.Blacklist != null) { foreach (string item2 in itemFilterConfig.Blacklist.Where((string x) => !string.IsNullOrWhiteSpace(x))) { blacklistedItems.Add(item2.Trim()); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[BlacksmithingExpanded] Loaded YAML config - Whitelist: {whitelistedItems.Count} items, Blacklist: {blacklistedItems.Count} items"); if (whitelistedItems.Count > 0) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("[BlacksmithingExpanded] Whitelisted items: " + string.Join(", ", whitelistedItems))); } if (blacklistedItems.Count > 0) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("[BlacksmithingExpanded] Blacklisted items: " + string.Join(", ", blacklistedItems))); } } catch (YamlException ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[BlacksmithingExpanded] YAML parsing error: " + ex.Message)); ((BaseUnityPlugin)this).Logger.LogError((object)("[BlacksmithingExpanded] Check your YAML syntax in: " + configPath)); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"[BlacksmithingExpanded] Failed to load YAML config: {arg}"); } } private void GenerateDefaultYaml() { try { string contents = "# If whitelist is empty:\r\n# Items not on blacklist → Enhanced (normal mod behavior)\r\n# Items on blacklist → Not enhanced\r\n\r\n# If whitelist has items:\r\n# Items on whitelist → Enhanced\r\n# Items NOT on whitelist → Not enhanced (regardless of blacklist)\r\n\r\nWhitelist:\r\n\r\nBlacklist:\r\n - Club\r\n - AxeStone\r\n - Torch\r\n - Tankard\r\n - TankardAnniversary\r\n - TrinketBronzeHealth\r\n - TrinketBronzeStamina\r\n - TrinketCarapaceEitr\r\n - TrinketBlackDamageHealth\r\n - TrinketFlametalEitr\r\n - TrinketChitinSwim\r\n - TrinketFlametalStaminaHealth\r\n - TrinketIronHealth\r\n - TrinketIronStamina\r\n - TrinketScaleStaminaDamage\r\n - TrinketSilverDamage\r\n - TrinketSilverResist\r\n - Demister\r\n - DvergrKey\r\n - SaddleAsksvin\r\n - SaddleLox\r\n"; File.WriteAllText(configPath, contents); ((BaseUnityPlugin)this).Logger.LogDebug((object)("[BlacksmithingExpanded] Created default YAML file at " + configPath)); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"[BlacksmithingExpanded] Failed to create default YAML: {arg}"); } } internal static bool IsItemAllowed(ItemData item) { if (!cfg_UseYamlFiltering.Value) { return true; } if (item?.m_shared == null) { return false; } string itemPrefabName = GetItemPrefabName(item); if (string.IsNullOrEmpty(itemPrefabName)) { if (cfg_LogFilteredItems.Value) { Debug.Log((object)"[BlacksmithingExpanded] Could not determine prefab name for item - allowing by default"); } return true; } if (whitelistedItems.Count > 0) { bool flag = whitelistedItems.Contains(itemPrefabName); if (cfg_LogFilteredItems.Value) { if (flag) { Debug.Log((object)("[BlacksmithingExpanded] Item prefab '" + itemPrefabName + "' found in whitelist - allowing bonuses")); } else { Debug.Log((object)("[BlacksmithingExpanded] Item prefab '" + itemPrefabName + "' not in whitelist - filtering out")); } } return flag; } if (blacklistedItems.Contains(itemPrefabName)) { if (cfg_LogFilteredItems.Value) { Debug.Log((object)("[BlacksmithingExpanded] Item prefab '" + itemPrefabName + "' is blacklisted - filtering out")); } return false; } if (cfg_LogFilteredItems.Value) { Debug.Log((object)("[BlacksmithingExpanded] Item prefab '" + itemPrefabName + "' allowed (not blacklisted)")); } return true; } private static string GetItemPrefabName(ItemData item) { try { if ((Object)(object)item.m_dropPrefab != (Object)null) { return ((Object)item.m_dropPrefab).name; } ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(item.m_shared.m_name) : null); if ((Object)(object)val != (Object)null) { return ((Object)val).name; } string name = item.m_shared.m_name; if (name.StartsWith("$item_")) { string text = name.Substring(6); return char.ToUpper(text[0]) + text.Substring(1); } return name; } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Error getting prefab name: {arg}"); return item.m_shared?.m_name ?? "Unknown"; } } internal static int GetPlayerBlacksmithingLevel(Player player) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((player != null) ? ((Component)player).GetComponent<Skills>() : null) == (Object)null) { return 0; } try { SkillType val = Skill.fromName("Blacksmithing"); bool flag = false; float skillLevel = ((Component)player).GetComponent<Skills>().GetSkillLevel(val); return Mathf.FloorToInt(skillLevel); } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Error getting blacksmithing level: {arg}"); return 0; } } internal static void GiveBlacksmithingXP(Player player, float amount) { if ((Object)(object)player == (Object)null || amount <= 0f) { return; } try { float value = amount * cfg_SkillGainFactor.Value; ((Character)(object)player).RaiseSkill("Blacksmithing", value); } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] XP grant failed: {arg}"); } } internal static void ApplyCraftingBonuses(ItemData item, int level) { //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Invalid comparison between Unknown and I4 if (item?.m_shared == null || level <= 0 || item.m_shared.m_maxStackSize > 1) { return; } if (!IsItemAllowed(item)) { if (cfg_LogFilteredItems.Value) { Debug.Log((object)("[BlacksmithingExpanded] Item '" + item.m_shared.m_name + "' filtered out by YAML configuration")); } return; } ItemBaseStats baseStats = GetBaseStats(item); if (!baseStats.isCached) { Debug.LogError((object)("[BlacksmithingExpanded] Failed to get base stats for " + item.m_shared.m_name)); return; } bool flag = baseStats.durability > 0f; if (!flag && !cfg_AllowNonRepairableItems.Value) { if (cfg_LogFilteredItems.Value) { Debug.Log((object)("[BlacksmithingExpanded] Item '" + item.m_shared.m_name + "' has no durability and non-repairable items are disabled - skipping")); } return; } BlacksmithingItemData orCreate = item.Data().GetOrCreate<BlacksmithingItemData>(); string text = orCreate.infusion ?? ""; bool flag2 = false; if (orCreate.level != level || orCreate.level == 0) { flag2 = true; } else if (orCreate.lastKnownQuality > 0 && orCreate.lastKnownQuality != item.m_quality) { flag2 = true; } else if (orCreate.lastKnownQuality == 0 && orCreate.level > 0) { orCreate.lastKnownQuality = item.m_quality; orCreate.Save(); return; } if (!flag2) { return; } orCreate.level = level; orCreate.lastKnownQuality = item.m_quality; orCreate.baseDurability = baseStats.durability; orCreate.armorBonus = 0f; orCreate.damageBlunt = 0f; orCreate.damageSlash = 0f; orCreate.damagePierce = 0f; orCreate.damageFire = 0f; orCreate.damageFrost = 0f; orCreate.damageLightning = 0f; orCreate.damagePoison = 0f; orCreate.damageSpirit = 0f; orCreate.blockPowerBonus = 0f; orCreate.timedBlockBonus = 0f; orCreate.statsApplied = false; int num = level / cfg_StatTierInterval.Value; int num2 = level / cfg_DurabilityTierInterval.Value; if ((flag || cfg_AllowNonRepairableItems.Value) && ((cfg_RespectOriginalDurability.Value && flag) || !cfg_RespectOriginalDurability.Value || cfg_AllowNonRepairableItems.Value)) { float num3 = (float)num2 * cfg_DurabilityBonusPerTier.Value + (float)item.m_quality * cfg_DurabilityBonusPerUpgrade.Value; orCreate.maxDurability = baseStats.durability + num3; if (cfg_MaxDurabilityCap.Value > 0f) { orCreate.maxDurability = Mathf.Min(orCreate.maxDurability, cfg_MaxDurabilityCap.Value); } } ApplyDamageBonuses(item, baseStats, num, orCreate); if (baseStats.armor > 0f) { float num4 = (float)num * cfg_ArmorBonusPerTier.Value; float num6; if (cfg_UsePercentageUpgradeBonus.Value) { float num5 = (float)item.m_quality * cfg_StatPercentageBonusPerUpgrade.Value / 100f; num6 = baseStats.armor * num5; } else { num6 = (float)item.m_quality * cfg_ArmorBonusPerUpgrade.Value; } orCreate.armorBonus = num4 + num6; if (cfg_ArmorCap.Value > 0f && baseStats.armor + orCreate.armorBonus > cfg_ArmorCap.Value) { orCreate.armorBonus = cfg_ArmorCap.Value - baseStats.armor; } Debug.Log((object)("[BlacksmithingExpanded] Armor calculation for " + item.m_shared.m_name + ": " + $"Base={baseStats.armor}, Quality={item.m_quality}, " + $"TierBonus={num4}, UpgradeBonus={num6}, " + $"TotalBonus={orCreate.armorBonus}")); } if ((int)item.m_shared.m_itemType == 5) { if (item.m_shared.m_blockPower > 0f) { orCreate.blockPowerBonus = (float)num * cfg_BlockPowerBonusPerTier.Value + (float)item.m_quality * cfg_BlockPowerBonusPerUpgrade.Value; } if (item.m_shared.m_timedBlockBonus > 0f) { orCreate.timedBlockBonus = (float)num * cfg_TimedBlockBonusPerTier.Value + (float)item.m_quality * cfg_TimedBlockBonusPerUpgrade.Value; } } if (level >= cfg_ElementalUnlockLevel.Value && cfg_AlwaysAddElementalAtMax.Value && item.IsWeapon()) { if (!string.IsNullOrEmpty(text)) { float effectiveTiers = CalculateElementalEffectiveTier(num, item.m_quality); ApplySpecificInfusion(text, baseStats, effectiveTiers, orCreate); } else if (!HasElementalDamageBonus(orCreate)) { float effectiveTiers2 = CalculateElementalEffectiveTier(num, item.m_quality); ApplyElementalInfusion(item, baseStats, effectiveTiers2, orCreate); } } orCreate.Save(); orCreate.Load(); Debug.Log((object)$"[BlacksmithingExpanded] Applied bonuses to {item.m_shared.m_name} (level {level}, quality {item.m_quality})"); } private static void ApplyDamageBonuses(ItemData item, ItemBaseStats baseStats, int statTier, BlacksmithingItemData data) { float tierBonus = ((!cfg_UsePercentageDamageBonus.Value) ? ((float)(statTier * cfg_DamageBonusPerTier.Value)) : ((float)statTier * cfg_DamagePercentageBonusPerTier.Value / 100f)); float upgradeBonus = 0f; if (item.m_quality > 0) { if (cfg_UsePercentageUpgradeBonus.Value) { upgradeBonus = (float)item.m_quality * cfg_StatPercentageBonusPerUpgrade.Value / 100f; } else if (cfg_UsePercentageDamageBonus.Value) { float totalPhysicalDamage = GetTotalPhysicalDamage(baseStats); if (totalPhysicalDamage > 0f) { upgradeBonus = (float)item.m_quality * cfg_StatBonusPerUpgrade.Value / totalPhysicalDamage; } } else { upgradeBonus = (float)item.m_quality * cfg_StatBonusPerUpgrade.Value; } } ApplyRandomDamageBonus(item, baseStats, tierBonus, upgradeBonus, data); } private static float CalculateElementalEffectiveTier(int statTier, int quality) { float num = statTier; if (cfg_UsePercentageUpgradeBonus.Value) { return num + (float)quality * cfg_StatPercentageBonusPerUpgrade.Value / cfg_ElementalPercentageBonusPerTier.Value; } return num + (float)quality * cfg_StatBonusPerUpgrade.Value / cfg_ElementalPercentageBonusPerTier.Value; } private static bool HasElementalDamageBonus(BlacksmithingItemData data) { return data.damageFire > 0f || data.damageFrost > 0f || data.damageLightning > 0f || data.damagePoison > 0f || data.damageSpirit > 0f; } private static void ApplySpecificInfusion(string infusionType, ItemBaseStats baseStats, float effectiveTiers, BlacksmithingItemData data) { if (cfg_UsePercentageElementalBonus.Value) { float num = effectiveTiers * cfg_ElementalPercentageBonusPerTier.Value / 100f; float totalPhysicalDamage = GetTotalPhysicalDamage(baseStats); switch (infusionType) { case "Fire": data.damageFire = totalPhysicalDamage * num; break; case "Frost": data.damageFrost = totalPhysicalDamage * num; break; case "Lightning": data.damageLightning = totalPhysicalDamage * num; break; case "Poison": data.damagePoison = totalPhysicalDamage * num; break; case "Spirit": data.damageSpirit = totalPhysicalDamage * num; break; } } else { switch (infusionType) { case "Fire": data.damageFire = effectiveTiers * cfg_FireBonusPerTier.Value; break; case "Frost": data.damageFrost = effectiveTiers * cfg_FrostBonusPerTier.Value; break; case "Lightning": data.damageLightning = effectiveTiers * cfg_LightningBonusPerTier.Value; break; case "Poison": data.damagePoison = effectiveTiers * cfg_PoisonBonusPerTier.Value; break; case "Spirit": data.damageSpirit = effectiveTiers * cfg_SpiritBonusPerTier.Value; break; } } data.infusion = infusionType; } private static float GetTotalPhysicalDamage(ItemBaseStats baseStats) { //IL_0002: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return baseStats.damages.m_blunt + baseStats.damages.m_slash + baseStats.damages.m_pierce; } private static void ApplyRandomDamageBonus(ItemData item, ItemBaseStats baseStats, float tierBonus, float upgradeBonus, BlacksmithingItemData data) { //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_026f: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) List<Action> list = new List<Action>(); if (cfg_UsePercentageDamageBonus.Value) { float totalPercentageBonus = tierBonus + upgradeBonus; float totalBaseDamage = GetTotalPhysicalDamage(baseStats); if (baseStats.damages.m_blunt > 0f) { list.Add(delegate { data.damageBlunt = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_slash > 0f) { list.Add(delegate { data.damageSlash = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_pierce > 0f) { list.Add(delegate { data.damagePierce = totalBaseDamage * totalPercentageBonus; }); } if (cfg_BoostElementalWeapons.Value) { if (baseStats.damages.m_fire > 0f) { list.Add(delegate { data.damageFire = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_frost > 0f) { list.Add(delegate { data.damageFrost = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_lightning > 0f) { list.Add(delegate { data.damageLightning = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_poison > 0f) { list.Add(delegate { data.damagePoison = totalBaseDamage * totalPercentageBonus; }); } if (baseStats.damages.m_spirit > 0f) { list.Add(delegate { data.damageSpirit = totalBaseDamage * totalPercentageBonus; }); } } } else { float totalFlatBonus = tierBonus + upgradeBonus; if (baseStats.damages.m_blunt > 0f) { list.Add(delegate { data.damageBlunt = totalFlatBonus; }); } if (baseStats.damages.m_slash > 0f) { list.Add(delegate { data.damageSlash = totalFlatBonus; }); } if (baseStats.damages.m_pierce > 0f) { list.Add(delegate { data.damagePierce = totalFlatBonus; }); } if (cfg_BoostElementalWeapons.Value) { if (baseStats.damages.m_fire > 0f) { list.Add(delegate { data.damageFire = totalFlatBonus; }); } if (baseStats.damages.m_frost > 0f) { list.Add(delegate { data.damageFrost = totalFlatBonus; }); } if (baseStats.damages.m_lightning > 0f) { list.Add(delegate { data.damageLightning = totalFlatBonus; }); } if (baseStats.damages.m_poison > 0f) { list.Add(delegate { data.damagePoison = totalFlatBonus; }); } if (baseStats.damages.m_spirit > 0f) { list.Add(delegate { data.damageSpirit = totalFlatBonus; }); } } } if (list.Count > 0) { list[Random.Range(0, list.Count)](); } } private static void ApplyElementalInfusion(ItemData item, ItemBaseStats baseStats, float effectiveTiers, BlacksmithingItemData data) { //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_027a: 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) List<(string, Action)> list = new List<(string, Action)>(); if (cfg_UsePercentageElementalBonus.Value) { float percentageBonus = effectiveTiers * cfg_ElementalPercentageBonusPerTier.Value / 100f; float totalBaseDamage = GetTotalPhysicalDamage(baseStats); if (baseStats.damages.m_fire <= 0f) { list.Add(("Fire", delegate { data.damageFire = totalBaseDamage * percentageBonus; data.infusion = "Fire"; })); } if (baseStats.damages.m_frost <= 0f) { list.Add(("Frost", delegate { data.damageFrost = totalBaseDamage * percentageBonus; data.infusion = "Frost"; })); } if (baseStats.damages.m_lightning <= 0f) { list.Add(("Lightning", delegate { data.damageLightning = totalBaseDamage * percentageBonus; data.infusion = "Lightning"; })); } if (baseStats.damages.m_poison <= 0f) { list.Add(("Poison", delegate { data.damagePoison = totalBaseDamage * percentageBonus; data.infusion = "Poison"; })); } if (baseStats.damages.m_spirit <= 0f) { list.Add(("Spirit", delegate { data.damageSpirit = totalBaseDamage * percentageBonus; data.infusion = "Spirit"; })); } } else { if (baseStats.damages.m_fire <= 0f) { list.Add(("Fire", delegate { data.damageFire = effectiveTiers * cfg_FireBonusPerTier.Value; data.infusion = "Fire"; })); } if (baseStats.damages.m_frost <= 0f) { list.Add(("Frost", delegate { data.damageFrost = effectiveTiers * cfg_FrostBonusPerTier.Value; data.infusion = "Frost"; })); } if (baseStats.damages.m_lightning <= 0f) { list.Add(("Lightning", delegate { data.damageLightning = effectiveTiers * cfg_LightningBonusPerTier.Value; data.infusion = "Lightning"; })); } if (baseStats.damages.m_poison <= 0f) { list.Add(("Poison", delegate { data.damagePoison = effectiveTiers * cfg_PoisonBonusPerTier.Value; data.infusion = "Poison"; })); } if (baseStats.damages.m_spirit <= 0f) { list.Add(("Spirit", delegate { data.damageSpirit = effectiveTiers * cfg_SpiritBonusPerTier.Value; data.infusion = "Spirit"; })); } } if (list.Count > 0) { list[Random.Range(0, list.Count)].Item2(); } } private static void EnsureSkillInitialized(Player player) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) try { long playerID = player.GetPlayerID(); if (!initializedPlayers.Contains(playerID)) { Skills component = ((Component)player).GetComponent<Skills>(); if (!((Object)(object)component == (Object)null)) { SkillType val = Skill.fromName("Blacksmithing"); bool flag = false; initializedPlayers.Add(playerID); } } } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Failed to initialize skill: {arg}"); } } private static bool IsEligibleForCraftingXP(ItemData item) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 if (item.IsWeapon()) { return true; } if ((int)item.m_shared.m_itemType == 5) { return true; } if ((int)item.m_shared.m_itemType == 6 || (int)item.m_shared.m_itemType == 7 || (int)item.m_shared.m_itemType == 11 || (int)item.m_shared.m_itemType == 17) { return true; } return false; } private static bool IsEligibleForBlacksmithingBonuses(ItemData item) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 if (item == null || item.m_shared == null) { return false; } if (!item.IsWeapon() && (int)item.m_shared.m_itemType != 5 && (int)item.m_shared.m_itemType != 6 && (int)item.m_shared.m_itemType != 7 && (int)item.m_shared.m_itemType != 11 && (int)item.m_shared.m_itemType != 17) { return false; } if (item.m_shared.m_maxStackSize > 1) { return false; } if (!IsItemAllowed(item)) { return false; } return true; } private static float HandleCraftingXP(Player player, ItemData item) { if (!ItemEligibilityCache.IsEligibleForBlacksmithingBonuses(item)) { return 0f; } float num = 0f; string text = StringExtensionMethods.GetStableHashCode(item.m_shared.m_name).ToString(); string key = "crafted_" + text; if (!player.m_customData.ContainsKey(key)) { player.m_customData[key] = "1"; float value = cfg_FirstCraftBonusXP.Value; GiveBlacksmithingXP(player, value); num += value; } float value2 = cfg_XPPerCraft.Value; GiveBlacksmithingXP(player, value2); return num + value2; } private static void ManageInfusionGlow(Transform workstation, ZDOID zdoid, bool enable) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0075: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (!cfg_ShowInfusionVisualEffect.Value) { if (activeGlowEffects.TryGetValue(zdoid, out var value)) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } activeGlowEffects.Remove(zdoid); } return; } try { GameObject value2; if (enable && !activeGlowEffects.ContainsKey(zdoid)) { GameObject val = new GameObject("InfusionGlow_Light"); val.transform.position = workstation.position + Vector3.up * 0.5f; val.transform.SetParent(workstation); Light val2 = val.AddComponent<Light>(); val2.color = new Color(1f, 0.5f, 0.1f); val2.intensity = 4f; val2.range = 8f; val2.type = (LightType)2; val.AddComponent<FlickerLight>(); activeGlowEffects[zdoid] = val; } else if (!enable && activeGlowEffects.TryGetValue(zdoid, out value2)) { if ((Object)(object)value2 != (Object)null) { Object.Destroy((Object)(object)value2); } activeGlowEffects.Remove(zdoid); } } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Light management failed: {arg}"); } } private static string GenerateSpearKey(ItemData weapon, Player player) { return $"{weapon.m_shared.m_name}_{weapon.m_quality}_{weapon.m_durability:F1}_{player.GetPlayerID()}_{Time.time:F2}"; } private static KeyValuePair<string, BlacksmithingItemData> FindBestSpearMatch(ItemData item) { string key = null; BlacksmithingItemData value = null; float num = 0f; float time = Time.time; foreach (KeyValuePair<string, BlacksmithingItemData> item2 in tempSpearDataStorage.ToList()) { string[] array = item2.Key.Split(new char[1] { '_' }); if (array.Length < 5) { continue; } string text = array[0]; if (!int.TryParse(array[1], out var result) || !float.TryParse(array[2], out var result2) || !long.TryParse(array[3], out var _) || !float.TryParse(array[4], out var result4) || text != item.m_shared.m_name || result != item.m_quality) { continue; } float num2 = time - result4; if (!(num2 > 60f)) { float num3 = Mathf.Abs(item.m_durability - result2); float num4 = 1000f - num3 * 10f - num2 * 5f; if (num4 > num) { num = num4; key = item2.Key; value = item2.Value; } } } return new KeyValuePair<string, BlacksmithingItemData>(key, value); } private static void ApplyStoredBlacksmithingStats(ItemData item, BlacksmithingItemData data) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0102: 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_0146: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Invalid comparison between Unknown and I4 ItemBaseStats baseStats = GetBaseStats(item); if (data.maxDurability > 0f) { item.m_shared.m_maxDurability = data.maxDurability; item.m_durability = Mathf.Min(item.m_durability, data.maxDurability); } if (data.armorBonus > 0f) { item.m_shared.m_armor = baseStats.armor + data.armorBonus; } item.m_shared.m_damages.m_blunt = baseStats.damages.m_blunt + data.damageBlunt; item.m_shared.m_damages.m_slash = baseStats.damages.m_slash + data.damageSlash; item.m_shared.m_damages.m_pierce = baseStats.damages.m_pierce + data.damagePierce; item.m_shared.m_damages.m_fire = baseStats.damages.m_fire + data.damageFire; item.m_shared.m_damages.m_frost = baseStats.damages.m_frost + data.damageFrost; item.m_shared.m_damages.m_lightning = baseStats.damages.m_lightning + data.damageLightning; item.m_shared.m_damages.m_poison = baseStats.damages.m_poison + data.damagePoison; item.m_shared.m_damages.m_spirit = baseStats.damages.m_spirit + data.damageSpirit; if ((int)item.m_shared.m_itemType == 5) { if (data.blockPowerBonus > 0f) { SharedData shared = item.m_shared; shared.m_blockPower += data.blockPowerBonus; } if (data.timedBlockBonus > 0f) { SharedData shared2 = item.m_shared; shared2.m_timedBlockBonus += data.timedBlockBonus; } } } private static void CopyBlacksmithingData(BlacksmithingItemData source, BlacksmithingItemData target) { target.level = source.level; target.lastKnownQuality = source.lastKnownQuality; target.infusion = source.infusion; target.baseDurability = source.baseDurability; target.maxDurability = source.maxDurability; target.armorBonus = source.armorBonus; target.damageBlunt = source.damageBlunt; target.damageSlash = source.damageSlash; target.damagePierce = source.damagePierce; target.damageFire = source.damageFire; target.damageFrost = source.damageFrost; target.damageLightning = source.damageLightning; target.damagePoison = source.damagePoison; target.damageSpirit = source.damageSpirit; target.blockPowerBonus = source.blockPowerBonus; target.timedBlockBonus = source.timedBlockBonus; target.statsApplied = source.statsApplied; } private static Sprite LoadEmbeddedSprite(string resourceName, int width, int height) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BlacksmithingExpanded.icons." + resourceName); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); Texture2D val = new Texture2D(width, height); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), Vector2.zero); } } catch (Exception arg) { Debug.LogError((object)$"[BlacksmithingExpanded] Failed to load sprite {resourceName}: {arg}"); } return null; } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<9b651806-9622-47b4-820d-b6ff4c81977d>Embedded] internal sealed class <9b651806-9622-47b4-820d-b6ff4c81977d>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<9b651806-9622-47b4-820d-b6ff4c81977d>Embedded] [CompilerGenerated] internal sealed class <d081303b-7360-4590-b6be-66ee31bca316>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <d081303b-7360-4590-b6be-66ee31bca316>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <d081303b-7360-4590-b6be-66ee31bca316>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<9b651806-9622-47b4-820d-b6ff4c81977d>Embedded] internal sealed class <ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContextAttribute : Attribute { public readonly byte Flag; public <ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [<9b651806-9622-47b4-820d-b6ff4c81977d>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <4fdb2555-1f22-45ae-9161-e931bc7b47aa>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <4fdb2555-1f22-45ae-9161-e931bc7b47aa>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] [PublicAPI] internal abstract class OwnConfigEntryBase { [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] [PublicAPI] internal class SyncedConfigEntry<[<d081303b-7360-4590-b6be-66ee31bca316>Nullable(2)] T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; base..ctor(); } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(2)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(1)] public readonly string Identifier; [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(1)] public readonly Type Type; private object boxedValue; protected bool localIsOwner; public readonly int Priority; public object BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action ValueChanged; [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [PublicAPI] [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] internal sealed class CustomSyncedValue<[<d081303b-7360-4590-b6be-66ee31bca316>Nullable(2)] T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] [PublicAPI] internal class ConfigSync { [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(0)] [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(2)] public static ZRpc currentRpc; [HarmonyPrefix] [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] static IEnumerator WatchAdminListChanges() { MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p) { string hostName = p.m_rpc.GetSocket().GetHostName(); return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })); }).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(0)] private static class RegisterClientRPCPatch { [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(1)] [HarmonyPostfix] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(0)] private class ParsedConfigs { [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [<ae22cf51-9e3e-4dee-8373-1c6d5a803e89>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] private class SendConfigsAfterLogin { [<d081303b-7360-4590-b6be-66ee31bca316>Nullable(0)] private class BufferingSocket : ZPlayFabSocket, ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; ((ZPlayFabSocket)this)..ctor(); } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix([<d081303b-7360-4590-b6be-66ee31bca316>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (!__instance.IsServer()) { return; } B