using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Testing2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Testing2")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("55CC6F29-0D48-4124-93BF-F657DE656B82")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace YourModName
{
public static class FixItemCommand
{
private class FixItemCmd : ConsoleCommand
{
public override string Name => "naz_fixitem";
public override string Help => "Corrige rareza y herrería del item equipado. Uso: naz_fixitem [all]";
public override bool IsCheat => true;
public override void Run(string[] args)
{
Player localPlayer = Player.m_localPlayer;
if ((Object)(object)localPlayer == (Object)null)
{
Logger.LogWarning((object)"[naz_fixitem] No hay jugador local.");
}
else if (args.Length != 0 && args[0].ToLower() == "all")
{
FixAllEquipped(localPlayer);
}
else
{
FixRightHandItem(localPlayer);
}
}
}
private struct FixResult
{
public bool Fixed;
public bool FixedRarity;
public bool FixedSmith;
public bool Error;
}
private const string SMITH_LVL_KEY = "nazhi_blacksmith_lvl";
private const string SMITH_DUR_KEY = "nazhi_blacksmith_durability";
private const string SMITH_NAME_KEY = "nazhi_blacksmith_crafter";
private const float SMITH_DMG_MAX = 0.5f;
private const float SMITH_ARM_MAX = 0.5f;
private const float SMITH_DUR_MAX = 0.6f;
public static void Register()
{
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FixItemCmd());
}
private static void FixRightHandItem(Player player)
{
ItemData rightItem = ((Humanoid)player).GetRightItem();
if (rightItem == null)
{
((Character)player).Message((MessageType)2, "No tienes ningún item en mano derecha.", 0, (Sprite)null);
return;
}
FixResult result = TryFixItem(rightItem, player);
ReportSingle(player, rightItem.m_shared.m_name, result);
}
private static void FixAllEquipped(Player player)
{
ItemData[] array = (ItemData[])(object)new ItemData[7]
{
((Humanoid)player).m_rightItem,
((Humanoid)player).m_leftItem,
((Humanoid)player).m_chestItem,
((Humanoid)player).m_legItem,
((Humanoid)player).m_helmetItem,
((Humanoid)player).m_shoulderItem,
((Humanoid)player).m_utilityItem
};
int num = 0;
int num2 = 0;
ItemData[] array2 = array;
foreach (ItemData val in array2)
{
if (val != null && RarityPatches.IsWeaponOrArmor(val))
{
if (TryFixItem(val, player).Fixed)
{
num++;
}
else
{
num2++;
}
}
}
string text = ((num > 0) ? $"Se corrigieron {num} item(s). {num2} sin cambios." : "Todos los items ya tenían sus stats correctos.");
((Character)player).Message((MessageType)2, text, 0, (Sprite)null);
}
private static FixResult TryFixItem(ItemData item, Player player)
{
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Invalid comparison between Unknown and I4
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Invalid comparison between Unknown and I4
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Invalid comparison between Unknown and I4
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Invalid comparison between Unknown and I4
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Invalid comparison between Unknown and I4
FixResult result = default(FixResult);
if (item == null)
{
result.Error = true;
return result;
}
RarityItemData rarityItemData = RarityTooltip.Get(item);
if (rarityItemData == null)
{
rarityItemData = new RarityItemData(ItemRarity.Common);
rarityItemData.SaveBaseDamages(item);
RarityTooltip.Save(item, rarityItemData);
Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " sin RarityData — inicializado como Common"));
}
else if (rarityItemData.Rarity != ItemRarity.Common)
{
bool flag = false;
bool flag2 = false;
float num = 1f + RarityData.Info[rarityItemData.Rarity].StatBonus;
if (!rarityItemData.HasBaseDamages)
{
rarityItemData.SaveBaseDamages(item);
RarityTooltip.Save(item, rarityItemData);
flag = rarityItemData.HasBaseDamages;
Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " BaseDamages recuperados del prefab"));
}
else
{
DamageTypes damages = item.m_shared.m_damages;
flag = (rarityItemData.BasePierce > 0f && (ApproxEqual(damages.m_pierce, rarityItemData.BasePierce) || damages.m_pierce < rarityItemData.BasePierce * num - 0.2f)) || (rarityItemData.BaseBlunt > 0f && (ApproxEqual(damages.m_blunt, rarityItemData.BaseBlunt) || damages.m_blunt < rarityItemData.BaseBlunt * num - 0.2f)) || (rarityItemData.BaseSlash > 0f && (ApproxEqual(damages.m_slash, rarityItemData.BaseSlash) || damages.m_slash < rarityItemData.BaseSlash * num - 0.2f));
}
ItemType itemType = item.m_shared.m_itemType;
bool flag3 = (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17;
bool flag4 = (int)itemType == 5;
if (flag3 && rarityItemData.BaseArmor > 0f)
{
float num2 = rarityItemData.BaseArmor * num - item.m_shared.m_armorPerLevel * (float)(item.m_quality - 1);
flag2 = item.m_shared.m_armor < num2 - 0.2f;
}
if (flag4 && rarityItemData.BaseBlockPower > 0f)
{
float num3 = rarityItemData.BaseBlockPower * num - item.m_shared.m_blockPowerPerLevel * (float)(item.m_quality - 1);
flag2 |= item.m_shared.m_blockPower < num3 - 0.2f;
}
if (flag || flag2)
{
if (flag)
{
rarityItemData.RestoreBaseDamages(item);
RarityPatches.ApplyStatBonusToDamages(item, rarityItemData);
}
if (flag2)
{
RarityPatches.ApplyStatBonusToArmor(item, rarityItemData);
}
EnchantBonusManager.RefreshSingleItem(item);
RarityTooltip.Save(item, rarityItemData);
result.FixedRarity = true;
Logger.LogInfo((object)($"[naz_fixitem] rareza corregida — {item.m_shared.m_name} [{rarityItemData.Rarity}] " + $"mult={num:0.##} fixDmg={flag} fixArm={flag2}"));
}
}
bool flag5 = SmithHasSignature(item);
if (!flag5 && RarityPatches.IsWeaponOrArmor(item))
{
int currentSmithLevel = GetCurrentSmithLevel(player);
float num4 = 1f + 0.6f * Mathf.Clamp01((float)currentSmithLevel / 100f);
item.m_customData["nazhi_blacksmith_lvl"] = currentSmithLevel.ToString(CultureInfo.InvariantCulture);
item.m_customData["nazhi_blacksmith_durability"] = num4.ToString(CultureInfo.InvariantCulture);
item.m_customData["nazhi_blacksmith_crafter"] = player.GetPlayerName();
float num5 = SmithGetDamageFactor(currentSmithLevel);
Logger.LogInfo((object)("[naz_fixitem] herrería restaurada — " + item.m_shared.m_name + " " + $"smithLvl={currentSmithLevel} dmgFactor={num5:0.##} " + $"(GetDamage() aplicará ×{num5:0.##} en runtime)"));
result.FixedSmith = true;
}
else if (flag5)
{
int num6 = SmithGetSavedLevel(item);
Logger.LogInfo((object)$"[naz_fixitem] herrería ok — {item.m_shared.m_name} smithLvl={num6}");
}
if (result.FixedRarity || result.FixedSmith)
{
EnchantBonusManager.Refresh(player);
result.Fixed = true;
RarityItemData rarityItemData2 = RarityTooltip.Get(item);
int level = SmithGetSavedLevel(item);
Logger.LogInfo((object)("[naz_fixitem] ✓ " + item.m_shared.m_name + " " + $"Rarity={rarityItemData2?.Rarity} " + $"blunt={item.m_shared.m_damages.m_blunt:0.#} " + $"(×{SmithGetDamageFactor(level):0.##} smith en runtime) " + $"armor={item.m_shared.m_armor:0.#} " + $"fixRarity={result.FixedRarity} fixSmith={result.FixedSmith}"));
}
else
{
Logger.LogInfo((object)("[naz_fixitem] " + item.m_shared.m_name + " — sin cambios necesarios"));
}
return result;
}
private static bool SmithHasSignature(ItemData item)
{
if (item?.m_customData == null)
{
return false;
}
return item.m_customData.ContainsKey("nazhi_blacksmith_lvl") || item.m_customData.ContainsKey("nazhi_blacksmith_durability") || item.m_customData.ContainsKey("nazhi_blacksmith_crafter");
}
private static int SmithGetSavedLevel(ItemData item)
{
if (item?.m_customData == null)
{
return 0;
}
if (!item.m_customData.TryGetValue("nazhi_blacksmith_lvl", out var value))
{
return 0;
}
int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result);
return result;
}
private static float SmithGetDamageFactor(int level)
{
if (level <= 0)
{
return 1f;
}
return 1f + 0.5f * Mathf.Clamp01((float)level / 100f);
}
private static int GetCurrentSmithLevel(Player player)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player == (Object)null)
{
return 0;
}
SkillType val = (SkillType)StringExtensionMethods.GetStableHashCode("nazhi.blacksmithing.skill");
return Mathf.RoundToInt(Mathf.Clamp(((Character)player).GetSkillLevel(val), 0f, 100f));
}
private static void ReportSingle(Player player, string itemName, FixResult result)
{
if (result.Error)
{
((Character)player).Message((MessageType)2, "Error al procesar " + itemName + ".", 0, (Sprite)null);
return;
}
if (!result.Fixed)
{
((Character)player).Message((MessageType)2, "" + itemName + ": sin cambios necesarios.", 0, (Sprite)null);
return;
}
bool fixedRarity = result.FixedRarity;
bool fixedSmith = result.FixedSmith;
if (1 == 0)
{
}
string text = (fixedRarity ? ((!fixedSmith) ? "rareza corregida" : "rareza + herrería corregidas") : ((!fixedSmith) ? "corregido" : "herrería restaurada"));
if (1 == 0)
{
}
string text2 = text;
((Character)player).Message((MessageType)2, "✓ " + itemName + ": " + text2 + ".", 0, (Sprite)null);
}
private static bool ApproxEqual(float a, float b, float tolerance = 0.15f)
{
return Mathf.Abs(a - b) < tolerance;
}
}
public enum ItemRarity
{
Common,
Uncommon,
Rare,
Epic,
Legendary
}
public static class RarityData
{
public static readonly Dictionary Info = new Dictionary
{
{
ItemRarity.Common,
new RarityInfo
{
Name = "Common",
Color = new Color(1f, 1f, 1f),
StatBonus = 0f,
SlotCount = 0,
Weight = 20f
}
},
{
ItemRarity.Uncommon,
new RarityInfo
{
Name = "Uncommon",
Color = new Color(0.3f, 0.85f, 0.3f),
StatBonus = 0.05f,
SlotCount = 1,
Weight = 40f
}
},
{
ItemRarity.Rare,
new RarityInfo
{
Name = "Rare",
Color = new Color(0.3f, 0.5f, 1f),
StatBonus = 0.1f,
SlotCount = 2,
Weight = 25f
}
},
{
ItemRarity.Epic,
new RarityInfo
{
Name = "Epic",
Color = new Color(0.7f, 0.3f, 1f),
StatBonus = 0.15f,
SlotCount = 3,
Weight = 15f
}
},
{
ItemRarity.Legendary,
new RarityInfo
{
Name = "Legendary",
Color = new Color(1f, 0.85f, 0.1f),
StatBonus = 0.2f,
SlotCount = 4,
Weight = 0f
}
}
};
private static readonly Dictionary MasterWeights = new Dictionary
{
{
ItemRarity.Common,
0f
},
{
ItemRarity.Uncommon,
0f
},
{
ItemRarity.Rare,
45f
},
{
ItemRarity.Epic,
35f
},
{
ItemRarity.Legendary,
20f
}
};
public const float MASTER_ROLL_THRESHOLD = 100f;
public static ItemRarity RollRarity(float smithingLevel = 0f)
{
Dictionary dictionary = ((smithingLevel >= 100f) ? MasterWeights : null);
float num = 0f;
foreach (KeyValuePair item in Info)
{
num += dictionary?[item.Key] ?? item.Value.Weight;
}
float num2 = Random.Range(0f, num);
float num3 = 0f;
foreach (KeyValuePair item2 in Info)
{
num3 += dictionary?[item2.Key] ?? item2.Value.Weight;
if (num2 < num3)
{
return item2.Key;
}
}
return ItemRarity.Common;
}
}
public class RarityInfo
{
public string Name;
public Color Color;
public float StatBonus;
public int SlotCount;
public float Weight;
}
public class RarityItemData
{
public ItemRarity Rarity;
public int SlotCount;
public List InsertedScrollIds;
public float BasePierce;
public float BaseBlunt;
public float BaseSlash;
public float BaseFire;
public float BaseFrost;
public float BaseLightning;
public float BaseSpirit;
public float BasePoison;
public float BaseArmor;
public float BaseBlockPower;
private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;
public int FilledSlots => InsertedScrollIds.FindAll((string s) => !string.IsNullOrEmpty(s)).Count;
public int EmptySlots => SlotCount - FilledSlots;
public bool HasFreeSlot => EmptySlots > 0;
public bool HasBaseDamages => BasePierce > 0f || BaseBlunt > 0f || BaseSlash > 0f || BaseFire > 0f || BaseFrost > 0f || BaseLightning > 0f || BaseSpirit > 0f || BasePoison > 0f;
public RarityItemData()
{
}
public RarityItemData(ItemRarity rarity)
{
Rarity = rarity;
SlotCount = RarityData.Info[rarity].SlotCount;
InsertedScrollIds = new List();
for (int i = 0; i < SlotCount; i++)
{
InsertedScrollIds.Add(string.Empty);
}
}
public void SaveBaseDamages(ItemData item)
{
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: 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_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Invalid comparison between Unknown and I4
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Invalid comparison between Unknown and I4
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Invalid comparison between Unknown and I4
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Invalid comparison between Unknown and I4
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Invalid comparison between Unknown and I4
ObjectDB instance = ObjectDB.instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
GameObject dropPrefab = item.m_dropPrefab;
obj = instance.GetItemPrefab(((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? "");
}
GameObject val = (GameObject)obj;
ItemData val2 = ((val == null) ? null : val.GetComponent()?.m_itemData);
if (val2 != null)
{
DamageTypes damages = val2.m_shared.m_damages;
DamageTypes damagesPerLevel = val2.m_shared.m_damagesPerLevel;
int num = item.m_quality - 1;
BasePierce = damages.m_pierce + damagesPerLevel.m_pierce * (float)num;
BaseBlunt = damages.m_blunt + damagesPerLevel.m_blunt * (float)num;
BaseSlash = damages.m_slash + damagesPerLevel.m_slash * (float)num;
BaseFire = damages.m_fire + damagesPerLevel.m_fire * (float)num;
BaseFrost = damages.m_frost + damagesPerLevel.m_frost * (float)num;
BaseLightning = damages.m_lightning + damagesPerLevel.m_lightning * (float)num;
BaseSpirit = damages.m_spirit + damagesPerLevel.m_spirit * (float)num;
BasePoison = damages.m_poison + damagesPerLevel.m_poison * (float)num;
ItemType itemType = item.m_shared.m_itemType;
bool flag = (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17;
bool flag2 = (int)itemType == 5;
BaseArmor = (flag ? (val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)num) : 0f);
BaseBlockPower = (flag2 ? (val2.m_shared.m_blockPower + val2.m_shared.m_blockPowerPerLevel * (float)num) : 0f);
Logger.LogInfo((object)($"[SaveBase] {item.m_shared.m_name} q={item.m_quality} FROM_PREFAB " + $"pierce={BasePierce:0.##} slash={BaseSlash:0.##} blunt={BaseBlunt:0.##} " + $"armor={BaseArmor:0.##} block={BaseBlockPower:0.##}"));
}
else
{
Logger.LogWarning((object)("[SaveBase] " + item.m_shared.m_name + " prefab no encontrado, usando item actual"));
DamageTypes damages2 = item.m_shared.m_damages;
BasePierce = damages2.m_pierce;
BaseBlunt = damages2.m_blunt;
BaseSlash = damages2.m_slash;
BaseFire = damages2.m_fire;
BaseFrost = damages2.m_frost;
BaseLightning = damages2.m_lightning;
BaseSpirit = damages2.m_spirit;
BasePoison = damages2.m_poison;
BaseArmor = item.m_shared.m_armor;
BaseBlockPower = item.m_shared.m_blockPower;
}
}
public void RestoreBaseDamages(ItemData item)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
DamageTypes damages = item.m_shared.m_damages;
damages.m_pierce = BasePierce;
damages.m_blunt = BaseBlunt;
damages.m_slash = BaseSlash;
damages.m_fire = BaseFire;
damages.m_frost = BaseFrost;
damages.m_lightning = BaseLightning;
damages.m_spirit = BaseSpirit;
damages.m_poison = BasePoison;
item.m_shared.m_damages = damages;
}
public bool InsertScroll(string scrollPerkId)
{
for (int i = 0; i < InsertedScrollIds.Count; i++)
{
if (string.IsNullOrEmpty(InsertedScrollIds[i]))
{
InsertedScrollIds[i] = scrollPerkId;
return true;
}
}
return false;
}
public string RemoveScroll(int slotIndex)
{
if (slotIndex < 0 || slotIndex >= InsertedScrollIds.Count)
{
return string.Empty;
}
string result = InsertedScrollIds[slotIndex];
InsertedScrollIds[slotIndex] = string.Empty;
return result;
}
public string Serialize()
{
string text = string.Join(",", InsertedScrollIds);
string text2 = string.Join(";", BasePierce.ToString("F4", Inv), BaseBlunt.ToString("F4", Inv), BaseSlash.ToString("F4", Inv), BaseFire.ToString("F4", Inv), BaseFrost.ToString("F4", Inv), BaseLightning.ToString("F4", Inv), BaseSpirit.ToString("F4", Inv), BasePoison.ToString("F4", Inv), BaseArmor.ToString("F4", Inv), BaseBlockPower.ToString("F4", Inv));
return $"{(int)Rarity}|{SlotCount}|{text}|{text2}";
}
public static RarityItemData Deserialize(string raw)
{
if (string.IsNullOrEmpty(raw))
{
return null;
}
string[] array = raw.Split(new char[1] { '|' });
if (array.Length < 1)
{
return null;
}
RarityItemData rarityItemData = new RarityItemData();
if (int.TryParse(array[0], out var result))
{
rarityItemData.Rarity = (ItemRarity)result;
}
if (array.Length > 1 && int.TryParse(array[1], out var result2))
{
rarityItemData.SlotCount = result2;
}
else
{
rarityItemData.SlotCount = RarityData.Info[rarityItemData.Rarity].SlotCount;
}
rarityItemData.InsertedScrollIds = new List();
if (array.Length > 2 && !string.IsNullOrEmpty(array[2]))
{
string[] array2 = array[2].Split(new char[1] { ',' });
foreach (string item in array2)
{
rarityItemData.InsertedScrollIds.Add(item);
}
}
while (rarityItemData.InsertedScrollIds.Count < rarityItemData.SlotCount)
{
rarityItemData.InsertedScrollIds.Add(string.Empty);
}
string[] d;
if (array.Length > 3 && !string.IsNullOrEmpty(array[3]))
{
d = array[3].Split(new char[1] { ';' });
rarityItemData.BasePierce = F(0);
rarityItemData.BaseBlunt = F(1);
rarityItemData.BaseSlash = F(2);
rarityItemData.BaseFire = F(3);
rarityItemData.BaseFrost = F(4);
rarityItemData.BaseLightning = F(5);
rarityItemData.BaseSpirit = F(6);
rarityItemData.BasePoison = F(7);
rarityItemData.BaseArmor = F(8);
rarityItemData.BaseBlockPower = F(9);
}
return rarityItemData;
float F(int num)
{
float result3;
return (d.Length > num && float.TryParse(d[num], NumberStyles.Float, Inv, out result3)) ? result3 : 0f;
}
}
}
[HarmonyPatch(typeof(ZNetScene), "RemoveObjects")]
public static class ZNetScene_RemoveObjects_NullSafePatch
{
[HarmonyPrefix]
public static void Prefix(ZNetScene __instance)
{
List list = new List();
foreach (KeyValuePair instance in __instance.m_instances)
{
if ((Object)(object)instance.Value == (Object)null || (Object)(object)((Component)instance.Value).gameObject == (Object)null)
{
list.Add(instance.Key);
}
}
foreach (ZDO item in list)
{
__instance.m_instances.Remove(item);
}
}
}
[HarmonyPatch(typeof(ZNetScene), "Shutdown")]
public static class ZNetScene_Shutdown_NullSafePatch
{
[HarmonyPrefix]
public static void Prefix(ZNetScene __instance)
{
List list = new List();
foreach (KeyValuePair instance in __instance.m_instances)
{
if ((Object)(object)instance.Value == (Object)null || (Object)(object)((Component)instance.Value).gameObject == (Object)null)
{
list.Add(instance.Key);
}
}
foreach (ZDO item in list)
{
__instance.m_instances.Remove(item);
}
}
}
[HarmonyPatch]
public static class RarityItemVFX
{
private const string VFX_CHILD_NAME = "RarityVFX";
[HarmonyPatch(typeof(ItemDrop), "Start")]
[HarmonyPostfix]
public static void ItemDrop_Start_Postfix(ItemDrop __instance)
{
((MonoBehaviour)__instance).StartCoroutine(ApplyVFXNextFrame(__instance));
}
private static IEnumerator ApplyVFXNextFrame(ItemDrop drop)
{
yield return null;
if (!((Object)(object)drop == (Object)null) && !((Object)(object)((Component)drop).gameObject == (Object)null))
{
float timeout = 5f;
while (timeout > 0f && ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsTeleporting()))
{
yield return (object)new WaitForSeconds(0.2f);
timeout -= 0.2f;
}
yield return null;
if (!((Object)(object)drop == (Object)null) && !((Object)(object)((Component)drop).gameObject == (Object)null))
{
ApplyVFX(drop);
}
}
}
public static void ApplyVFX(ItemDrop drop)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Expected O, but got Unknown
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)drop == (Object)null)
{
return;
}
ItemData itemData = drop.m_itemData;
if (itemData == null)
{
return;
}
Color color;
if (ScrollItem.IsEnchantScroll(itemData))
{
ScrollItem.TryGetScrollTier(itemData, out var rarity);
if (rarity == ItemRarity.Common)
{
return;
}
color = RarityData.Info[rarity].Color;
}
else
{
if (!RarityPatches.IsWeaponOrArmor(itemData))
{
return;
}
RarityItemData rarityItemData = RarityTooltip.Get(itemData);
if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
{
return;
}
color = RarityData.Info[rarityItemData.Rarity].Color;
}
Transform val = FindDeep(((Component)drop).transform, "fx_ItemSparkles");
if ((Object)(object)val == (Object)null)
{
Logger.LogWarning((object)("[Rarity VFX] No se encontró fx_ItemSparkles en " + ((Object)drop).name));
return;
}
ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren(true);
foreach (ParticleSystem val2 in componentsInChildren)
{
MainModule main = val2.main;
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(color.r, color.g, color.b, 1f), new Color(color.r, color.g, color.b, 0.4f));
((MainModule)(ref main)).maxParticles = 100;
((MainModule)(ref main)).simulationSpeed = 1f;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(50f);
ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
{
Gradient val3 = new Gradient();
val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(color, 0f),
new GradientColorKey(color, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
}
ParticleSystemRenderer component = ((Component)val2).GetComponent();
if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
{
Material val4 = new Material(((Renderer)component).material);
if (val4.HasProperty("_Color"))
{
val4.SetColor("_Color", color);
}
if (val4.HasProperty("_TintColor"))
{
val4.SetColor("_TintColor", color);
}
if (val4.HasProperty("_EmissionColor"))
{
val4.SetColor("_EmissionColor", color * 2f);
}
((Renderer)component).material = val4;
}
}
val.localScale = new Vector3(1f, 4f, 1f);
Logger.LogInfo((object)("[Rarity VFX] " + ((Object)drop).name + " recoloreado | color #" + ColorUtility.ToHtmlStringRGB(color)));
}
private static Transform FindDeep(Transform parent, string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (((Object)val).name == name)
{
return val;
}
Transform val2 = FindDeep(val, name);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
}
[HarmonyPatch]
public static class RarityPatches
{
private static bool _addItemProcessing;
private const string BORDER_CHILD_NAME = "RarityBorder";
private const float BORDER_THICKNESS = 2f;
private const float LINE_HEIGHT = 3f;
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
[HarmonyPostfix]
public static void DoCrafting_Postfix(InventoryGui __instance, Player player)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Inventory inventory = ((Humanoid)player).GetInventory();
float num = 0f;
bool flag = false;
bool flag2 = false;
if ((Object)(object)player == (Object)(object)Player.m_localPlayer)
{
SkillType val = (SkillType)StringExtensionMethods.GetStableHashCode("nazhi.blacksmithing.skill");
num = Mathf.Clamp(((Character)player).GetSkillLevel(val), 0f, 100f);
if (player.m_customData.TryGetValue("nazhi_specialization", out var value) && int.TryParse(value, out var result))
{
flag2 = result == 2;
flag = flag2 && num >= 50f;
}
}
float smithingLevel = (flag ? 100f : num);
foreach (ItemData allItem in inventory.GetAllItems())
{
if (!allItem.m_customData.ContainsKey("RarityData") && IsWeaponOrArmor(allItem))
{
RarityItemData orCreate = RarityTooltip.GetOrCreate(allItem, smithingLevel);
orCreate.SaveBaseDamages(allItem);
ApplyStatBonusToDamages(allItem, orCreate);
ApplyStatBonusToArmor(allItem, orCreate);
RarityTooltip.Save(allItem, orCreate);
string arg = (flag ? " [Maestro Herrero ✓]" : (flag2 ? " [Maestro Herrero — nivel insuficiente]" : ""));
Logger.LogInfo((object)("[Rarity] Crafteado: " + allItem.m_shared.m_name + " " + $"-> {orCreate.Rarity} ({orCreate.SlotCount} slots) " + $"| StatBonus +{RarityData.Info[orCreate.Rarity].StatBonus * 100f:0}%" + $"| Herrería lv{num:0}{arg}"));
}
}
}
[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
{
typeof(string),
typeof(int),
typeof(int),
typeof(int),
typeof(long),
typeof(string),
typeof(Vector2i),
typeof(bool)
})]
[HarmonyPostfix]
public static void AddItem_Postfix(ref ItemData __result)
{
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
if (__result == null || !IsWeaponOrArmor(__result))
{
return;
}
RarityItemData rarityItemData = RarityTooltip.Get(__result);
if (rarityItemData == null || __result.m_quality <= 1 || _addItemProcessing)
{
return;
}
_addItemProcessing = true;
try
{
Logger.LogInfo((object)($"[Upgrade:START] {__result.m_shared.m_name} q={__result.m_quality} " + $"| m_armor={__result.m_shared.m_armor:0.##} " + $"| BaseArmor_guardado={rarityItemData.BaseArmor:0.##} " + $"| Rarity={rarityItemData.Rarity} mult={1f + RarityData.Info[rarityItemData.Rarity].StatBonus:0.##}"));
ObjectDB instance = ObjectDB.instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
GameObject dropPrefab = __result.m_dropPrefab;
obj = instance.GetItemPrefab(((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? "");
}
GameObject val = (GameObject)obj;
ItemData val2 = ((val == null) ? null : val.GetComponent()?.m_itemData);
if (val2 == null && (Object)(object)ObjectDB.instance != (Object)null)
{
foreach (GameObject item in ObjectDB.instance.m_items)
{
ItemDrop val3 = ((item != null) ? item.GetComponent() : null);
if (val3?.m_itemData?.m_shared?.m_name == __result.m_shared.m_name)
{
val2 = val3.m_itemData;
break;
}
}
}
string text = $"[Upgrade:PREFAB] encontrado={val2 != null} ";
string text2;
if (val2 == null)
{
GameObject dropPrefab2 = __result.m_dropPrefab;
text2 = "| m_dropPrefab.name='" + (((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) ?? "NULL") + "'";
}
else
{
text2 = $"| prefab.m_armor={val2.m_shared.m_armor:0.##} " + $"| prefab.m_armorPerLevel={val2.m_shared.m_armorPerLevel:0.##} " + $"| vanillaArmor_calculado={val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)(__result.m_quality - 1):0.##}";
}
Logger.LogInfo((object)(text + text2));
if (val2 != null)
{
float num = val2.m_shared.m_armor + val2.m_shared.m_armorPerLevel * (float)(__result.m_quality - 1);
float num2 = val2.m_shared.m_blockPower + val2.m_shared.m_blockPowerPerLevel * (float)(__result.m_quality - 1);
Logger.LogInfo((object)($"[Upgrade:BASE] via prefab — BaseArmor anterior={rarityItemData.BaseArmor:0.##} → nuevo={num:0.##} " + $"| BaseBlockPower anterior={rarityItemData.BaseBlockPower:0.##} → nuevo={num2:0.##}"));
rarityItemData.BaseArmor = num;
rarityItemData.BaseBlockPower = num2;
if (!rarityItemData.HasBaseDamages)
{
DamageTypes damages = val2.m_shared.m_damages;
rarityItemData.BasePierce = damages.m_pierce;
rarityItemData.BaseBlunt = damages.m_blunt;
rarityItemData.BaseSlash = damages.m_slash;
rarityItemData.BaseFire = damages.m_fire;
rarityItemData.BaseFrost = damages.m_frost;
rarityItemData.BaseLightning = damages.m_lightning;
rarityItemData.BaseSpirit = damages.m_spirit;
rarityItemData.BasePoison = damages.m_poison;
Logger.LogInfo((object)"[Upgrade:BASE] BaseDamages inicializados desde prefab");
}
}
else
{
float num3 = 1f + RarityData.Info[rarityItemData.Rarity].StatBonus;
float num4 = rarityItemData.BaseArmor * num3;
bool flag = Mathf.Abs(__result.m_shared.m_armor - num4) < 0.2f;
Logger.LogInfo((object)($"[Upgrade:BASE] sin prefab — rarityMult={num3:0.##} " + $"expectedWithRarity={num4:0.##} " + $"m_armor={__result.m_shared.m_armor:0.##} " + $"alreadyApplied={flag}"));
if (rarityItemData.BaseArmor > 0f && flag)
{
float num5 = __result.m_shared.m_armor / num3;
Logger.LogInfo((object)$"[Upgrade:BASE] rarity ya aplicada — BaseArmor inferido={num5:0.##} (anterior={rarityItemData.BaseArmor:0.##})");
rarityItemData.BaseArmor = num5;
}
else if (rarityItemData.BaseArmor <= 0f)
{
Logger.LogWarning((object)"[Upgrade:BASE] sin BaseArmor previo — forzando SaveBaseDamages (último recurso)");
rarityItemData.SaveBaseDamages(__result);
}
else
{
Logger.LogInfo((object)$"[Upgrade:BASE] BaseArmor={rarityItemData.BaseArmor:0.##} parece correcto, no se toca");
}
}
Logger.LogInfo((object)($"[Upgrade:APPLY] BaseArmor={rarityItemData.BaseArmor:0.##} " + $"mult={1f + RarityData.Info[rarityItemData.Rarity].StatBonus:0.##} " + $"→ m_armor esperado={rarityItemData.BaseArmor * (1f + RarityData.Info[rarityItemData.Rarity].StatBonus):0.##}"));
ApplyStatBonusToDamages(__result, rarityItemData);
ApplyStatBonusToArmor(__result, rarityItemData);
EnchantBonusManager.RefreshSingleItem(__result);
RarityTooltip.Save(__result, rarityItemData);
Logger.LogInfo((object)($"[Upgrade:END] {__result.m_shared.m_name} q={__result.m_quality} " + $"BaseArmor={rarityItemData.BaseArmor:0.##} m_armor_final={__result.m_shared.m_armor:0.##}"));
}
finally
{
_addItemProcessing = false;
}
}
[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
[HarmonyPostfix]
public static void UpdateGui_Postfix(InventoryGrid __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
Inventory inventory = __instance.m_inventory;
if (inventory == null)
{
return;
}
foreach (Element element in __instance.m_elements)
{
if (!element.m_used)
{
SetBorderColor(element.m_go, Color.clear);
continue;
}
ItemData itemAt = inventory.GetItemAt(element.m_pos.x, element.m_pos.y);
if (itemAt == null)
{
SetBorderColor(element.m_go, Color.clear);
continue;
}
if (ScrollItem.IsEnchantScroll(itemAt))
{
ScrollItem.TryGetScrollTier(itemAt, out var rarity);
Color color = RarityData.Info[rarity].Color;
string text = ColorUtility.ToHtmlStringRGB(color);
element.m_tooltip.m_topic = "" + itemAt.m_shared.m_name + "";
SetBorderColor(element.m_go, color, rarity);
continue;
}
RarityItemData rarityItemData = RarityTooltip.Get(itemAt);
if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
{
element.m_tooltip.m_topic = itemAt.m_shared.m_name;
SetBorderColor(element.m_go, Color.clear);
continue;
}
Color color2 = RarityData.Info[rarityItemData.Rarity].Color;
string text2 = ColorUtility.ToHtmlStringRGB(color2);
element.m_tooltip.m_topic = "" + itemAt.m_shared.m_name + "";
SetBorderColor(element.m_go, color2, rarityItemData.Rarity);
}
}
[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
[HarmonyPostfix]
public static void UpdateIcons_Postfix(HotkeyBar __instance, Player player)
{
//IL_0059: 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_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player == (Object)null)
{
return;
}
Inventory inventory = ((Humanoid)player).GetInventory();
if (inventory == null)
{
return;
}
foreach (ElementData element in __instance.m_elements)
{
if (!element.m_used)
{
SetBorderColor(element.m_go, Color.clear);
continue;
}
ItemData val = null;
foreach (ItemData item in __instance.m_items)
{
if (item.m_gridPos.x == __instance.m_elements.IndexOf(element))
{
val = item;
break;
}
}
if (val == null)
{
SetBorderColor(element.m_go, Color.clear);
continue;
}
if (ScrollItem.IsEnchantScroll(val))
{
ScrollItem.TryGetScrollTier(val, out var rarity);
SetBorderColor(element.m_go, RarityData.Info[rarity].Color, rarity);
continue;
}
RarityItemData rarityItemData = RarityTooltip.Get(val);
if (rarityItemData == null || rarityItemData.Rarity == ItemRarity.Common)
{
SetBorderColor(element.m_go, Color.clear);
}
else
{
SetBorderColor(element.m_go, RarityData.Info[rarityItemData.Rarity].Color, rarityItemData.Rarity);
}
}
}
private static void SetBorderColor(GameObject slotGo, Color color, ItemRarity rarity = ItemRarity.Common)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Expected O, but got Unknown
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: 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_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Expected O, but got Unknown
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_0473: Unknown result type (might be due to invalid IL or missing references)
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_058f: Unknown result type (might be due to invalid IL or missing references)
//IL_0596: Expected O, but got Unknown
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0522: Expected O, but got Unknown
//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0602: Unknown result type (might be due to invalid IL or missing references)
//IL_0615: Unknown result type (might be due to invalid IL or missing references)
//IL_0617: Unknown result type (might be due to invalid IL or missing references)
//IL_053c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)slotGo == (Object)null)
{
return;
}
Transform obj = slotGo.transform.Find("icon");
RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Rect rect = val.rect;
Vector2 size = ((Rect)(ref rect)).size;
if (size.x <= 0f)
{
((Vector2)(ref size))..ctor(64f, 64f);
}
bool flag = color.a > 0f;
Transform val2 = slotGo.transform.Find("RarityLetter");
if ((Object)(object)val2 == (Object)null)
{
GameObject val3 = new GameObject("RarityLetter", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val3.transform.SetParent(slotGo.transform, false);
Transform obj2 = slotGo.transform.Find("icon");
int num = ((obj2 != null) ? obj2.GetSiblingIndex() : 0);
val3.transform.SetSiblingIndex(Mathf.Max(0, num));
RectTransform component = val3.GetComponent();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = new Vector2(size.x * 0.15f, size.y * 0.15f);
component.offsetMax = new Vector2((0f - size.x) * 0.15f, (0f - size.y) * 0.15f);
((Transform)component).localScale = Vector3.one;
Image component2 = val3.GetComponent();
((Graphic)component2).raycastTarget = false;
((Graphic)component2).color = Color.clear;
val2 = val3.transform;
}
Image component3 = ((Component)val2).GetComponent();
if ((Object)(object)component3 != (Object)null)
{
if (!flag)
{
((Graphic)component3).color = Color.clear;
component3.sprite = null;
}
else
{
component3.sprite = VegvisirSprites.GetForRarity(rarity);
((Graphic)component3).color = new Color(1f, 1f, 1f, 0.2f);
}
}
Transform val4 = slotGo.transform.Find("RarityBg");
if ((Object)(object)val4 == (Object)null)
{
GameObject val5 = new GameObject("RarityBg", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val5.transform.SetParent(slotGo.transform, false);
val5.transform.SetAsFirstSibling();
RectTransform component4 = val5.GetComponent();
component4.anchorMin = Vector2.zero;
component4.anchorMax = Vector2.one;
component4.offsetMin = Vector2.zero;
component4.offsetMax = Vector2.zero;
((Transform)component4).localScale = Vector3.one;
Image component5 = val5.GetComponent();
((Graphic)component5).raycastTarget = false;
val5.AddComponent();
val4 = val5.transform;
}
Transform val6 = slotGo.transform.Find("RarityBorder");
GameObject val7;
if ((Object)(object)val6 == (Object)null)
{
val7 = new GameObject("RarityBorder", new Type[1] { typeof(RectTransform) });
val7.transform.SetParent(slotGo.transform, false);
val7.transform.SetAsLastSibling();
RectTransform component6 = val7.GetComponent();
component6.anchorMin = new Vector2(0.5f, 0.5f);
component6.anchorMax = new Vector2(0.5f, 0.5f);
component6.pivot = new Vector2(0.5f, 0.5f);
component6.sizeDelta = size;
((Transform)component6).localScale = Vector3.one;
CreateRect(val7, "Top", new Vector2(0f, size.y * 0.5f - 1f), new Vector2(size.x, 2f), 1f);
CreateRect(val7, "Bottom", new Vector2(0f, (0f - size.y) * 0.5f + 1f), new Vector2(size.x, 2f), 1f);
CreateRect(val7, "Left", new Vector2((0f - size.x) * 0.5f + 1f, 0f), new Vector2(2f, size.y), 1f);
CreateRect(val7, "Right", new Vector2(size.x * 0.5f - 1f, 0f), new Vector2(2f, size.y), 1f);
}
else
{
val7 = ((Component)val6).gameObject;
}
RarityBgPulse component7 = ((Component)val4).GetComponent();
if (!((Object)(object)component7 != (Object)null))
{
return;
}
if (!flag)
{
component7.Hide();
{
foreach (Transform item in val7.transform)
{
Transform val8 = item;
Image component8 = ((Component)val8).GetComponent();
if ((Object)(object)component8 != (Object)null)
{
((Graphic)component8).color = Color.clear;
}
}
return;
}
}
List list = new List();
foreach (Transform item2 in val7.transform)
{
Transform val9 = item2;
Image component9 = ((Component)val9).GetComponent();
if ((Object)(object)component9 != (Object)null)
{
list.Add(component9);
}
}
component7.BorderImages = list.ToArray();
Color darkColor = default(Color);
((Color)(ref darkColor))..ctor(color.r * 0.3f, color.g * 0.3f, color.b * 0.3f);
component7.SetRarity(darkColor, color, rarity);
}
private static void CreateRect(GameObject parent, string name, Vector2 anchoredPos, Vector2 size, float alpha)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name, new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val.transform.SetParent(parent.transform, false);
RectTransform component = val.GetComponent();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
component.anchoredPosition = anchoredPos;
component.sizeDelta = size;
((Transform)component).localScale = Vector3.one;
Image component2 = val.GetComponent();
((Graphic)component2).raycastTarget = false;
((Graphic)component2).color = new Color(1f, 1f, 1f, alpha);
}
public static bool IsWeaponOrArmor(ItemData item)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
ItemType itemType = item.m_shared.m_itemType;
return (int)itemType == 3 || (int)itemType == 14 || (int)itemType == 4 || (int)itemType == 5 || (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17 || (int)itemType == 18;
}
public static void ApplyStatBonusToDamages(ItemData item, RarityItemData data)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
if (data.Rarity != ItemRarity.Common && data.HasBaseDamages)
{
float num = 1f + RarityData.Info[data.Rarity].StatBonus;
DamageTypes damages = item.m_shared.m_damages;
if (data.BasePierce > 0f)
{
damages.m_pierce = data.BasePierce * num;
}
if (data.BaseBlunt > 0f)
{
damages.m_blunt = data.BaseBlunt * num;
}
if (data.BaseSlash > 0f)
{
damages.m_slash = data.BaseSlash * num;
}
if (data.BaseFire > 0f)
{
damages.m_fire = data.BaseFire * num;
}
if (data.BaseFrost > 0f)
{
damages.m_frost = data.BaseFrost * num;
}
if (data.BaseLightning > 0f)
{
damages.m_lightning = data.BaseLightning * num;
}
if (data.BaseSpirit > 0f)
{
damages.m_spirit = data.BaseSpirit * num;
}
if (data.BasePoison > 0f)
{
damages.m_poison = data.BasePoison * num;
}
item.m_shared.m_damages = damages;
}
}
public static void ApplyStatBonusToArmor(ItemData item, RarityItemData data)
{
//IL_0037: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Invalid comparison between Unknown and I4
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Invalid comparison between Unknown and I4
if (data.Rarity != ItemRarity.Common)
{
float num = 1f + RarityData.Info[data.Rarity].StatBonus;
ItemType itemType = item.m_shared.m_itemType;
if (((int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17) && data.BaseArmor > 0f)
{
float num2 = item.m_shared.m_armorPerLevel * (float)(item.m_quality - 1);
item.m_shared.m_armor = data.BaseArmor * num - num2;
Logger.LogInfo((object)($"[ApplyArmor] {item.m_shared.m_name} q={item.m_quality} " + $"base={data.BaseArmor:0.##} mult={num:0.##} " + $"qualityBonus={num2:0.##} " + $"m_armor_escrito={item.m_shared.m_armor:0.##} " + $"GetArmor_esperado={data.BaseArmor * num:0.##}"));
}
if ((int)itemType == 5 && data.BaseBlockPower > 0f)
{
float num3 = item.m_shared.m_blockPowerPerLevel * (float)(item.m_quality - 1);
item.m_shared.m_blockPower = data.BaseBlockPower * num - num3;
Logger.LogInfo((object)($"[ApplyBlock] {item.m_shared.m_name} q={item.m_quality} " + $"baseBlock={data.BaseBlockPower:0.##} mult={num:0.##} " + $"qualityBonus={num3:0.##} " + $"m_blockPower_escrito={item.m_shared.m_blockPower:0.##} " + $"GetBlockPower_esperado={data.BaseBlockPower * num:0.##}"));
}
}
}
}
[HarmonyPatch]
public static class GetTooltip_Patch
{
private static MethodBase TargetMethod()
{
MethodInfo[] methods = typeof(ItemData).GetMethods(BindingFlags.Static | BindingFlags.Public);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name == "GetTooltip")
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length != 0 && parameters[0].ParameterType == typeof(ItemData))
{
return methodInfo;
}
}
}
return null;
}
[HarmonyPostfix]
public static void Postfix(ItemData item, ref string __result)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (item == null)
{
return;
}
if (ScrollItem.IsEnchantScroll(item))
{
ScrollItem.TryGetScrollTier(item, out var rarity);
RarityInfo rarityInfo = RarityData.Info[rarity];
string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
string text2 = "";
if (item.m_customData.TryGetValue("ScrollPerk", out var value) && !string.IsNullOrEmpty(value))
{
string[] array = value.Split(new char[1] { ':' });
ScrollPerkDef byName = ScrollPerkRegistry.GetByName(array[0]);
if (byName != null)
{
string text3 = ((array.Length == 2) ? (byName.GetDisplayText(rarity) + " vs " + array[1]) : byName.GetDisplayText(rarity));
text2 = "\n" + text3 + "";
}
}
__result = "Pergamino " + rarityInfo.Name + "" + text2 + "\nClick derecho para encantar.\n\nRareza: " + rarityInfo.Name + "";
return;
}
RarityItemData rarityItemData = RarityTooltip.Get(item);
if (rarityItemData != null && rarityItemData.Rarity != ItemRarity.Common && (__result == null || !__result.Contains("Tier: " + RarityData.Info[rarityItemData.Rarity].Name)))
{
__result = RarityTooltip.ColorizeHeader(__result, rarityItemData);
__result = RarityTooltip.StripExistingPerkLines(__result, rarityItemData);
__result = RarityTooltip.ReplaceDamageLines(__result, rarityItemData, item);
__result = RarityTooltip.ReplaceArmorLine(__result, rarityItemData, item);
__result = RarityTooltip.ReplaceBlockLine(__result, rarityItemData, item);
string text4 = RarityTooltip.BuildTooltipAddition(rarityItemData, item);
if (!string.IsNullOrEmpty(text4))
{
__result = __result + "\n" + text4;
}
}
}
}
public class RarityBgPulse : MonoBehaviour
{
private Image _bgImg;
public float BgAlphaMin = 0.35f;
public float BgAlphaMax = 0.7f;
public float BorderAlphaMin = 0.6f;
public float BorderAlphaMax = 1f;
public float Speed = 0.9f;
public Color BaseColor = Color.white;
private Color _borderColor = Color.white;
public Image[] BorderImages;
private float _t = 0f;
private const float BG_DARK_MIX_INV = 0.35f;
private void Awake()
{
_bgImg = ((Component)this).GetComponent();
}
private void Update()
{
//IL_008e: 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)
if ((Object)(object)_bgImg == (Object)null)
{
return;
}
_t += Time.deltaTime * Speed;
float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
float num2 = Mathf.Lerp(BgAlphaMin, BgAlphaMax, num);
((Graphic)_bgImg).color = new Color(BaseColor.r, BaseColor.g, BaseColor.b, num2);
if (BorderImages == null)
{
return;
}
float num3 = Mathf.Lerp(BorderAlphaMin, BorderAlphaMax, num);
Color color = default(Color);
((Color)(ref color))..ctor(_borderColor.r, _borderColor.g, _borderColor.b, num3);
Image[] borderImages = BorderImages;
foreach (Image val in borderImages)
{
if ((Object)(object)val != (Object)null)
{
((Graphic)val).color = color;
}
}
}
public void SetRarity(Color darkColor, Color borderColor, ItemRarity rarity)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
BaseColor = darkColor;
_borderColor = borderColor;
Speed = 0.8f;
((Behaviour)this).enabled = true;
}
public void Hide()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_bgImg != (Object)null)
{
((Graphic)_bgImg).color = Color.clear;
}
if (BorderImages != null)
{
Image[] borderImages = BorderImages;
foreach (Image val in borderImages)
{
if ((Object)(object)val != (Object)null)
{
((Graphic)val).color = Color.clear;
}
}
}
((Behaviour)this).enabled = false;
}
}
public class RarityIconPulse : MonoBehaviour
{
private Shadow _shadow;
public float AlphaMin = 0.5f;
public float AlphaMax = 1f;
public float Speed = 0.8f;
public Color BaseColor = Color.white;
private float _t = 0f;
private void Awake()
{
_shadow = ((Component)this).GetComponent();
}
private void Update()
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_shadow == (Object)null) && ((Behaviour)_shadow).enabled)
{
_t += Time.deltaTime * Speed;
float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
float num2 = Mathf.Lerp(AlphaMin, AlphaMax, num);
_shadow.effectColor = new Color(BaseColor.r, BaseColor.g, BaseColor.b, num2);
}
}
public void SetColor(Color color)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
BaseColor = color;
_t = 0f;
((Behaviour)this).enabled = true;
}
public void Hide()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_shadow != (Object)null)
{
_shadow.effectColor = Color.clear;
}
((Behaviour)this).enabled = false;
}
}
public class RarityDesignBPulse : MonoBehaviour
{
private GameObject _container;
private Color _color;
private float _t = 0f;
private const float SPEED = 0.8f;
private const float ALPHA_MIN = 0.3f;
private const float ALPHA_MAX = 1f;
private void Update()
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_container == (Object)null)
{
return;
}
_t += Time.deltaTime * 0.8f;
float num = (Mathf.Sin(_t * (float)Math.PI * 2f) + 1f) * 0.5f;
float num2 = Mathf.Lerp(0.3f, 1f, num);
foreach (Transform item in _container.transform)
{
Transform val = item;
Image component = ((Component)val).GetComponent();
if ((Object)(object)component != (Object)null)
{
((Graphic)component).color = new Color(_color.r, _color.g, _color.b, num2);
}
}
}
public void Activate(Color borderColor, Color bgColor, GameObject container)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
_color = borderColor;
_container = container;
_t = 0f;
((Behaviour)this).enabled = true;
}
public void Hide(GameObject container)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
_container = container;
if ((Object)(object)container != (Object)null)
{
foreach (Transform item in container.transform)
{
Transform val = item;
Image component = ((Component)val).GetComponent();
if ((Object)(object)component != (Object)null)
{
((Graphic)component).color = Color.clear;
}
}
}
((Behaviour)this).enabled = false;
}
}
public static class VegvisirSprites
{
public static Sprite Uncommon;
public static Sprite Rare;
public static Sprite Epic;
public static Sprite Legendary;
public static void Load()
{
string path = Path.Combine(Paths.PluginPath, "Rarity", "Assets");
Uncommon = LoadSprite(Path.Combine(path, "logoverde.png"));
Rare = LoadSprite(Path.Combine(path, "logoazul.png"));
Epic = LoadSprite(Path.Combine(path, "logomorado.png"));
Legendary = LoadSprite(Path.Combine(path, "logoamarillo.png"));
}
private static Sprite LoadSprite(string fullPath)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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)
if (!File.Exists(fullPath))
{
Logger.LogWarning((object)("[Vegvisir] PNG no encontrado: " + fullPath));
return null;
}
byte[] array = File.ReadAllBytes(fullPath);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
try
{
MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3]
{
typeof(Texture2D),
typeof(byte[]),
typeof(bool)
});
if (methodInfo != null && !(bool)methodInfo.Invoke(null, new object[3] { val, array, false }))
{
Logger.LogWarning((object)("[Vegvisir] LoadImage falló: " + fullPath));
return null;
}
}
catch (Exception ex)
{
Logger.LogWarning((object)("[Vegvisir] Excepción cargando " + fullPath + ": " + ex.Message));
return null;
}
((Texture)val).filterMode = (FilterMode)1;
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one * 0.5f);
}
public static Sprite GetForRarity(ItemRarity rarity)
{
if (1 == 0)
{
}
Sprite result = (Sprite)(rarity switch
{
ItemRarity.Uncommon => Uncommon,
ItemRarity.Rare => Rare,
ItemRarity.Epic => Epic,
ItemRarity.Legendary => Legendary,
_ => null,
});
if (1 == 0)
{
}
return result;
}
}
[BepInPlugin("com.tuusuario.valheim.rarity", "ItemRaritySystem", "0.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class RarityPlugin : BaseUnityPlugin
{
public const string ModGUID = "com.tuusuario.valheim.rarity";
public const string ModName = "ItemRaritySystem";
public const string ModVersion = "0.2.0";
private Harmony _harmony;
public static RarityPlugin Instance { get; private set; }
private void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
Instance = this;
Logger.LogInfo((object)"[ItemRaritySystem] Cargando sistema de rareza v0.2.0...");
_harmony = new Harmony("com.tuusuario.valheim.rarity");
_harmony.PatchAll();
VegvisirSprites.Load();
ScrollItem.Register();
FixItemCommand.Register();
GUIManager.OnCustomGUIAvailable += CreateScrollUI;
Logger.LogInfo((object)"[ItemRaritySystem] ¡Listo! Patches aplicados.");
}
private void CreateScrollUI()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (!((Object)(object)ScrollEnchantUI.Instance != (Object)null))
{
GameObject val = new GameObject("ScrollEnchantUI");
Object.DontDestroyOnLoad((Object)(object)val);
val.AddComponent();
}
}
private void OnDestroy()
{
Instance = null;
GUIManager.OnCustomGUIAvailable -= CreateScrollUI;
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public static class RarityTooltip
{
private const string CUSTOM_DATA_KEY = "RarityData";
private const string SMITH_LEVEL_KEY = "nazhi_blacksmith_lvl";
private const float SMITH_WEAPON_MAX = 0.5f;
private const float SMITH_ARMOR_MAX = 0.5f;
private static readonly Dictionary SlotFilledChar = new Dictionary
{
{
ItemRarity.Common,
"\ud83d\udc8e"
},
{
ItemRarity.Uncommon,
"\ud83d\udc8e"
},
{
ItemRarity.Rare,
"\ud83d\udc8e"
},
{
ItemRarity.Epic,
"\ud83d\udc8e"
},
{
ItemRarity.Legendary,
"\ud83d\udc8e"
}
};
private const string SLOT_EMPTY = "\ud83d\udd28";
private const string SEP = "━━━━━━━━━━━━━━━━";
private static readonly string[] ItemTypeKeys = new string[14]
{
"$item_onehanded", "$item_twohanded", "$item_bow", "$item_shield", "$item_helmet", "$item_chest", "$item_legs", "$item_shoulder", "$item_utility", "$item_tool",
"$item_ammo", "$item_trophy", "$item_consumable", "$item_material"
};
public static string ColorizeHeader(string tooltip, RarityItemData data)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(tooltip) || data == null || data.Rarity == ItemRarity.Common)
{
return tooltip;
}
RarityInfo rarityInfo = RarityData.Info[data.Rarity];
string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
string text2 = null;
string[] itemTypeKeys = ItemTypeKeys;
foreach (string text3 in itemTypeKeys)
{
if (tooltip.Contains(text3))
{
text2 = text3;
break;
}
}
if (text2 == null)
{
return tooltip;
}
int num = tooltip.IndexOf(text2, StringComparison.OrdinalIgnoreCase);
if (num < 0)
{
return tooltip;
}
string text4 = tooltip.Substring(0, num).TrimEnd('\n', '\r');
string text5 = tooltip.Substring(num);
string[] array = text4.Split(new char[1] { '\n' });
StringBuilder stringBuilder = new StringBuilder();
string[] array2 = array;
foreach (string text6 in array2)
{
string text7 = text6.TrimEnd(new char[1] { '\r' });
if (string.IsNullOrWhiteSpace(text7))
{
stringBuilder.AppendLine();
continue;
}
stringBuilder.AppendLine("" + text7 + "");
}
stringBuilder.AppendLine("Tier: " + rarityInfo.Name + "");
stringBuilder.AppendLine("━━━━━━━━━━━━━━━━");
return stringBuilder.ToString() + text5;
}
public static string ReplaceDamageLines(string tooltip, RarityItemData data, ItemData item)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(tooltip) || item == null)
{
return tooltip;
}
RarityInfo rarityInfo = RarityData.Info[data.Rarity];
string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
float smithWeaponFactor = GetSmithWeaponFactor(GetSmithLevel(item));
DamageTypes damages = item.m_shared.m_damages;
DamageTypes damagesPerLevel = item.m_shared.m_damagesPerLevel;
int num = item.m_quality - 1;
Dictionary dictionary = new Dictionary
{
{
"pierce",
(damages.m_pierce + damagesPerLevel.m_pierce * (float)num, data.BasePierce, "Perforante")
},
{
"blunt",
(damages.m_blunt + damagesPerLevel.m_blunt * (float)num, data.BaseBlunt, "Contundente")
},
{
"slash",
(damages.m_slash + damagesPerLevel.m_slash * (float)num, data.BaseSlash, "Cortante")
},
{
"fire",
(damages.m_fire + damagesPerLevel.m_fire * (float)num, data.BaseFire, "Fuego")
},
{
"frost",
(damages.m_frost + damagesPerLevel.m_frost * (float)num, data.BaseFrost, "Escarcha")
},
{
"lightning",
(damages.m_lightning + damagesPerLevel.m_lightning * (float)num, data.BaseLightning, "Rayo")
},
{
"spirit",
(damages.m_spirit + damagesPerLevel.m_spirit * (float)num, data.BaseSpirit, "Espíritu")
},
{
"poison",
(damages.m_poison + damagesPerLevel.m_poison * (float)num, data.BasePoison, "Veneno")
}
};
foreach (KeyValuePair item2 in dictionary)
{
string pattern = "^\\$inventory_" + item2.Key + "\\s*:.*$";
var (num2, num3, arg2) = item2.Value;
if (num2 <= 0f)
{
tooltip = Regex.Replace(tooltip, pattern, string.Empty, RegexOptions.IgnoreCase | RegexOptions.Multiline);
continue;
}
float num4 = num2 * smithWeaponFactor;
string text = ((num3 > 0f) ? FormatStatDiff(num4, num3) : string.Empty);
string replacement = $"{arg2}: {num4:0.#}" + ((text.Length > 0) ? (" " + text) : string.Empty) + "";
tooltip = Regex.Replace(tooltip, pattern, replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
}
return tooltip;
}
public static string ReplaceArmorLine(string tooltip, RarityItemData data, ItemData item)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Invalid comparison between Unknown and I4
if (string.IsNullOrEmpty(tooltip) || item == null)
{
return tooltip;
}
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 tooltip;
}
RarityInfo rarityInfo = RarityData.Info[data.Rarity];
string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
float smithArmorFactor = GetSmithArmorFactor(GetSmithLevel(item));
float num = 0f;
foreach (string insertedScrollId in data.InsertedScrollIds)
{
if (!string.IsNullOrEmpty(insertedScrollId))
{
ScrollPerkDef byName = ScrollPerkRegistry.GetByName(insertedScrollId.Split(new char[1] { ':' })[0]);
if (byName != null && byName.Type == ScrollPerkType.Armadura)
{
num += byName.GetValue(data.Rarity);
}
}
}
float num2 = data.BaseArmor * (1f + rarityInfo.StatBonus);
float num3 = num2 * smithArmorFactor;
float num4 = num3 + num;
string text = ((data.BaseArmor > 0f) ? FormatStatDiff(num4, data.BaseArmor) : string.Empty);
Logger.LogInfo((object)($"[ArmorDebug] base={data.BaseArmor:0.##} " + $"afterRarity={num2:0.##} " + $"afterSmith={num3:0.##} " + $"perk={num:0.##} " + $"total={num4:0.##}"));
string replacement = $"Armadura: {num4:0.#}" + ((text.Length > 0) ? (" " + text) : string.Empty) + "";
tooltip = Regex.Replace(tooltip, "^\\$item_armor\\s*:.*$", replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
return tooltip;
}
public static string ReplaceBlockLine(string tooltip, RarityItemData data, ItemData item)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(tooltip) || item == null)
{
return tooltip;
}
if ((int)item.m_shared.m_itemType != 5)
{
return tooltip;
}
RarityInfo rarityInfo = RarityData.Info[data.Rarity];
string arg = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
float num = 0f;
foreach (string insertedScrollId in data.InsertedScrollIds)
{
if (!string.IsNullOrEmpty(insertedScrollId))
{
ScrollPerkDef byName = ScrollPerkRegistry.GetByName(insertedScrollId.Split(new char[1] { ':' })[0]);
if (byName != null && byName.Type == ScrollPerkType.Bloqueo)
{
num += byName.GetValue(data.Rarity);
}
}
}
float num2 = data.BaseBlockPower * (1f + rarityInfo.StatBonus);
float num3 = num2 + num;
string text = ((data.BaseBlockPower > 0f) ? FormatStatDiff(num3, data.BaseBlockPower) : string.Empty);
string replacement = $"Bloqueo: {num3:0.#}" + ((text.Length > 0) ? (" " + text) : string.Empty) + "";
tooltip = Regex.Replace(tooltip, "^\\$item_blockarmor\\s*:.*$", replacement, RegexOptions.IgnoreCase | RegexOptions.Multiline);
return tooltip;
}
public static string StripExistingPerkLines(string tooltip, RarityItemData data)
{
if (string.IsNullOrEmpty(tooltip) || data == null)
{
return tooltip;
}
if (data.InsertedScrollIds == null || data.InsertedScrollIds.Count == 0)
{
return tooltip;
}
List list = new List();
foreach (string insertedScrollId in data.InsertedScrollIds)
{
if (!string.IsNullOrEmpty(insertedScrollId))
{
list.Add(insertedScrollId.Split(new char[1] { ':' })[0]);
}
}
if (list.Count == 0)
{
return tooltip;
}
string[] array = tooltip.Split(new char[1] { '\n' });
StringBuilder stringBuilder = new StringBuilder();
string[] array2 = array;
foreach (string text in array2)
{
bool flag = text.Contains("━━━━━━━━━━━━━━━━");
if (!flag)
{
foreach (string item in list)
{
if (text.Contains(item))
{
flag = true;
break;
}
}
}
if (!flag && (text.Contains("\ud83d\udd28") || text.Contains("\ud83d\udc8e")))
{
flag = true;
}
if (!flag)
{
stringBuilder.AppendLine(text.TrimEnd(new char[1] { '\r' }));
}
}
return stringBuilder.ToString().TrimEnd('\n', '\r');
}
public static string BuildTooltipAddition(RarityItemData data, ItemData item = null)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (data == null || data.Rarity == ItemRarity.Common)
{
return string.Empty;
}
RarityInfo rarityInfo = RarityData.Info[data.Rarity];
string text = ColorUtility.ToHtmlStringRGB(rarityInfo.Color);
string filledChar = SlotFilledChar[data.Rarity];
StringBuilder stringBuilder = new StringBuilder();
if (data.SlotCount > 0)
{
stringBuilder.AppendLine();
for (int i = 0; i < data.SlotCount; i++)
{
string text2 = ((i < data.InsertedScrollIds.Count) ? data.InsertedScrollIds[i] : string.Empty);
if (string.IsNullOrEmpty(text2))
{
stringBuilder.AppendLine("\ud83d\udd28 Slot vacío");
}
else
{
stringBuilder.AppendLine(BuildPerkDescription(text2, data.Rarity, text, filledChar));
}
}
}
stringBuilder.AppendLine();
stringBuilder.Append("━━━━━━━━━━━━━━━━");
return stringBuilder.ToString();
}
public static RarityItemData GetOrCreate(ItemData itemData, float smithingLevel = 0f)
{
if (itemData.m_customData.TryGetValue("RarityData", out var value))
{
RarityItemData rarityItemData = RarityItemData.Deserialize(value);
if (rarityItemData != null)
{
return rarityItemData;
}
}
ItemRarity rarity = RarityData.RollRarity(smithingLevel);
RarityItemData rarityItemData2 = new RarityItemData(rarity);
itemData.m_customData["RarityData"] = rarityItemData2.Serialize();
return rarityItemData2;
}
public static RarityItemData Get(ItemData itemData)
{
if (itemData.m_customData.TryGetValue("RarityData", out var value))
{
return RarityItemData.Deserialize(value);
}
return null;
}
public static void Save(ItemData itemData, RarityItemData data)
{
itemData.m_customData["RarityData"] = data.Serialize();
}
public static string GetRarityHex(RarityItemData data)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (data == null)
{
return "ffffff";
}
return ColorUtility.ToHtmlStringRGB(RarityData.Info[data.Rarity].Color);
}
private static int GetSmithLevel(ItemData item)
{
if (item?.m_customData == null)
{
return 0;
}
if (!item.m_customData.TryGetValue("nazhi_blacksmith_lvl", out var value))
{
return 0;
}
int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result);
return result;
}
private static float GetSmithWeaponFactor(int smithLvl)
{
if (smithLvl <= 0)
{
return 1f;
}
return 1f + 0.5f * Mathf.Clamp01((float)smithLvl / 100f);
}
private static float GetSmithArmorFactor(int smithLvl)
{
if (smithLvl <= 0)
{
return 1f;
}
return 1f + 0.5f * Mathf.Clamp01((float)smithLvl / 100f);
}
private static string FormatStatDiff(float current, float vanillaBase)
{
if (vanillaBase <= 0f)
{
return string.Empty;
}
float num = current - vanillaBase;
float num2 = num / vanillaBase * 100f;
if (Mathf.Abs(num) < 0.05f)
{
return string.Empty;
}
bool flag = num >= 0f;
string text = (flag ? "00e676" : "ff5252");
string arg = (flag ? "+" : "");
string text2 = $"{arg}{num:0.#}";
string text3 = $"{arg}{num2:0.#}%";
return "↑" + text2 + " (" + text3 + ")";
}
private static string BuildPerkDescription(string scrollId, ItemRarity rarity, string hex, string filledChar)
{
string[] array = scrollId.Split(new char[1] { ':' });
string displayName = array[0];
string text = ((array.Length == 2) ? array[1] : null);
ScrollPerkDef byName = ScrollPerkRegistry.GetByName(displayName);
if (byName == null)
{
return filledChar + " " + scrollId + "";
}
float value = byName.GetValue(rarity);
bool flag = byName.Type == ScrollPerkType.Vida || byName.Type == ScrollPerkType.Armadura || byName.Type == ScrollPerkType.Durabilidad;
string text2 = ((byName.Type == ScrollPerkType.NoMovPen) ? "Activado" : (flag ? $"{value:0}" : $"{value:0.##}%"));
ScrollPerkType type = byName.Type;
if (1 == 0)
{
}
string text3 = type switch
{
ScrollPerkType.Pierce => "Perforante: Aumenta en " + text2 + " el daño perforante",
ScrollPerkType.Blunt => "Contundente: Aumenta en " + text2 + " el daño contundente",
ScrollPerkType.Slash => "Cortante: Aumenta en " + text2 + " el daño cortante",
ScrollPerkType.DmgMagico => "Dominio Elemental: Aumenta en " + text2 + " el daño mágico",
ScrollPerkType.VelocidadAtk => "Frenesí: Aumenta en " + text2 + " la velocidad de ataque",
ScrollPerkType.DmgFaccion => "Oportunista: Aumenta en " + text2 + " el daño vs " + TranslateFaction(text ?? "enemigos"),
ScrollPerkType.ReduccionDmg => "Piel de Hierro: Reduce en " + text2 + " el daño recibido",
ScrollPerkType.Armadura => "Bastión: Aumenta en " + text2 + " la armadura",
ScrollPerkType.Vida => "Vitalidad: Aumenta en " + text2 + " el HP máximo",
ScrollPerkType.RegHP => "Vitalis: Aumenta en " + text2 + " la regeneración de HP",
ScrollPerkType.RegStamina => "Segundo Aliento: Aumenta en " + text2 + " la regen. de Stamina",
ScrollPerkType.RegEitr => "Eco de Eitr: Aumenta en " + text2 + " la regeneración de Eitr",
ScrollPerkType.Durabilidad => "Temple Reforjado: Aumenta en " + text2 + " la durabilidad",
ScrollPerkType.Healing => "Sagrado: Aumenta en " + text2 + " el poder de curación",
ScrollPerkType.ResistPierce => "Escudo Perforante: Reduce en " + text2 + " el daño perforante recibido",
ScrollPerkType.ResistBlunt => "Escudo Contundente: Reduce en " + text2 + " el daño contundente recibido",
ScrollPerkType.ResistSlash => "Escudo Cortante: Reduce en " + text2 + " el daño cortante recibido",
ScrollPerkType.Bloqueo => "Aegis: Aumenta en " + text2 + " el valor de bloqueo",
ScrollPerkType.Parry => "Contraataque: Aumenta en " + text2 + " el multiplicador de parry",
ScrollPerkType.NoMovPen => "Sin Límites: Elimina la penalización de movimiento",
ScrollPerkType.WeapSkill => "Destreza: Aumenta en " + text2 + " puntos la skill del arma",
ScrollPerkType.Weight => "Sobrecarga: Aumenta en " + text2 + " puntos el peso máximo",
_ => byName.DisplayName + ": +" + text2,
};
if (1 == 0)
{
}
string text4 = text3;
return filledChar + " " + text4 + "";
}
private static string TranslateFaction(string faction)
{
if (1 == 0)
{
}
string result = faction switch
{
"ForestMonsters" => "Monstruos del Bosque",
"Undead" => "No Muertos",
"Demon" => "Demonios",
"MountainMonsters" => "Monstruos de Montaña",
"SeaMonsters" => "Monstruos del Mar",
"PlainsMonsters" => "Monstruos de Llanos",
"Boss" => "Jefes",
"MistlandsMonsters" => "Monstruos de Niebla",
"Dverger" => "Dverger",
_ => faction,
};
if (1 == 0)
{
}
return result;
}
}
[HarmonyPatch]
public static class ScrollDropPatch
{
[HarmonyPatch(typeof(Humanoid), "UseItem")]
[HarmonyPrefix]
public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui)
{
if (item == null)
{
return true;
}
if (!ScrollItem.IsEnchantScroll(item))
{
return true;
}
return false;
}
}
public class ScrollEnchantUI : MonoBehaviour
{
private ItemData _scrollItem;
private ItemData _targetItem;
private bool _isOpen;
private GameObject _titlePanel;
private GameObject _leftPanel;
private GameObject _rightPanel;
private GameObject _bottomPanel;
private Image _weaponIcon;
private Text _weaponHint;
private Text _weaponLabelText;
private Image _scrollIcon;
private Text _scrollPerkText;
private Text _statusText;
private Text _itemNameText;
private Text _slotsAvailText;
private Text _perksCurrentText;
private Text _perksNewText;
private Text _smithLevelText;
private Button _acceptBtn;
private Image _coinIcon;
private Text _coinCostText;
private const float LeftW = 300f;
private const float RightW = 460f;
private const float BodyH = 540f;
private const float Gap = 10f;
private const float TotalW = 770f;
private const float BottomH = 80f;
private const string COIN_PREFAB_NAME = "Coins";
private Text _titleText;
public static ScrollEnchantUI Instance { get; private set; }
private static int GetSmithLevelRequired(ItemRarity rarity)
{
if (1 == 0)
{
}
int result = rarity switch
{
ItemRarity.Common => 0,
ItemRarity.Uncommon => 5,
ItemRarity.Rare => 10,
ItemRarity.Epic => 15,
ItemRarity.Legendary => 50,
_ => 0,
};
if (1 == 0)
{
}
return result;
}
private static int GetCoinCost(ItemRarity rarity)
{
if (1 == 0)
{
}
int result = rarity switch
{
ItemRarity.Common => 0,
ItemRarity.Uncommon => 200,
ItemRarity.Rare => 300,
ItemRarity.Epic => 600,
ItemRarity.Legendary => 1500,
_ => 0,
};
if (1 == 0)
{
}
return result;
}
private void Awake()
{
Instance = this;
GUIManager.OnCustomGUIAvailable += OnGUIAvailable;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
GUIManager.OnCustomGUIAvailable -= OnGUIAvailable;
}
private void OnGUIAvailable()
{
Object.Destroy((Object)(object)_titlePanel);
_titlePanel = null;
Object.Destroy((Object)(object)_leftPanel);
_leftPanel = null;
Object.Destroy((Object)(object)_rightPanel);
_rightPanel = null;
Object.Destroy((Object)(object)_bottomPanel);
_bottomPanel = null;
EnsurePanel();
}
private void Update()
{
}
public void Open(ItemData scrollItem)
{
if (scrollItem != null)
{
_scrollItem = scrollItem;
_targetItem = null;
EnsurePanel();
if (!((Object)(object)_titlePanel == (Object)null))
{
RefreshUI();
_titlePanel.SetActive(true);
_leftPanel.SetActive(true);
_rightPanel.SetActive(true);
_bottomPanel.SetActive(true);
_isOpen = true;
}
}
}
public void Close()
{
((MonoBehaviour)this).CancelInvoke("Close");
_isOpen = false;
GameObject titlePanel = _titlePanel;
if (titlePanel != null)
{
titlePanel.SetActive(false);
}
GameObject leftPanel = _leftPanel;
if (leftPanel != null)
{
leftPanel.SetActive(false);
}
GameObject rightPanel = _rightPanel;
if (rightPanel != null)
{
rightPanel.SetActive(false);
}
GameObject bottomPanel = _bottomPanel;
if (bottomPanel != null)
{
bottomPanel.SetActive(false);
}
_scrollItem = null;
_targetItem = null;
}
public void TrySetTarget(ItemData item)
{
if (_isOpen && item != null && RarityPatches.IsWeaponOrArmor(item))
{
_targetItem = item;
RefreshUI();
}
}
private void EnsurePanel()
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0505: Unknown result type (might be due to invalid IL or missing references)
//IL_0527: Unknown result type (might be due to invalid IL or missing references)
//IL_0566: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
//IL_0658: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Unknown result type (might be due to invalid IL or missing references)
//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
//IL_06de: Unknown result type (might be due to invalid IL or missing references)
//IL_070b: Unknown result type (might be due to invalid IL or missing references)
//IL_0718: Unknown result type (might be due to invalid IL or missing references)
//IL_071f: Expected O, but got Unknown
//IL_0756: Unknown result type (might be due to invalid IL or missing references)
//IL_075e: Unknown result type (might be due to invalid IL or missing references)
//IL_0772: Unknown result type (might be due to invalid IL or missing references)
//IL_0789: Unknown result type (might be due to invalid IL or missing references)
//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
//IL_07fe: Expected O, but got Unknown
//IL_0828: Unknown result type (might be due to invalid IL or missing references)
//IL_083f: Unknown result type (might be due to invalid IL or missing references)
//IL_084e: Unknown result type (might be due to invalid IL or missing references)
//IL_0853: Unknown result type (might be due to invalid IL or missing references)
//IL_0854: Unknown result type (might be due to invalid IL or missing references)
//IL_085c: Unknown result type (might be due to invalid IL or missing references)
//IL_08a2: Unknown result type (might be due to invalid IL or missing references)
//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0907: Unknown result type (might be due to invalid IL or missing references)
//IL_093c: Unknown result type (might be due to invalid IL or missing references)
//IL_0946: Expected O, but got Unknown
//IL_0966: Unknown result type (might be due to invalid IL or missing references)
//IL_0975: Unknown result type (might be due to invalid IL or missing references)
//IL_0984: Unknown result type (might be due to invalid IL or missing references)
//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
//IL_09b7: Expected O, but got Unknown
if (!((Object)(object)_titlePanel != (Object)null) && GUIManager.Instance != null && !((Object)(object)GUIManager.CustomGUIFront == (Object)null))
{
float num = -235f;
float num2 = 155f;
float num3 = 302f;
float num4 = -316f;
Color color = default(Color);
((Color)(ref color))..ctor(0.08f, 0.06f, 0.06f, 0.97f);
_titlePanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, num3), 770f, 58f, true);
_titlePanel.SetActive(false);
DarkenPanel(_titlePanel, color);
GameObject val = GUIManager.Instance.CreateText("Encantamiento", _titlePanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, GUIManager.Instance.AveriaSerifBold, 27, GUIManager.Instance.ValheimOrange, true, Color.black, 750f, 35f, false);
_titleText = val.GetComponent();
_titleText.alignment = (TextAnchor)4;
_leftPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(num, 0f), 300f, 540f, false);
_leftPanel.SetActive(false);
DarkenPanel(_leftPanel, color);
float num5 = 170f;
float num6 = -60f;
GameObject val2 = GUIManager.Instance.CreateText("Arma / Armadura", _leftPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, num5 + 68f), GUIManager.Instance.AveriaSerifBold, 17, GUIManager.Instance.ValheimOrange, true, Color.black, 260f, 25f, false);
_weaponLabelText = val2.GetComponent();
_weaponLabelText.alignment = (TextAnchor)4;
GameObject val3 = CreateSlot(_leftPanel.transform, new Vector2(0f, num5));
_weaponIcon = ((Component)val3.transform.Find("Icon")).GetComponent();
_weaponHint = MakeText(_leftPanel.transform, new Vector2(0f, num5), 105f, 105f, 14);
_weaponHint.text = "Click\nizquierdo";
((Graphic)_weaponHint).color = new Color(0.5f, 0.5f, 0.5f);
_weaponHint.alignment = (TextAnchor)4;
MakeSep(_leftPanel.transform, new Vector2(0f, num5 - 78f));
MakeLabel(_leftPanel.transform, "Pergamino", new Vector2(0f, num6 + 68f), 260f, 17, orange: true);
GameObject val4 = CreateSlot(_leftPanel.transform, new Vector2(0f, num6));
_scrollIcon = ((Component)val4.transform.Find("Icon")).GetComponent();
_scrollPerkText = MakeText(_leftPanel.transform, new Vector2(0f, num6 - 68f), 270f, 27f, 14);
_scrollPerkText.alignment = (TextAnchor)4;
_rightPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(num2, 0f), 460f, 540f, false);
_rightPanel.SetActive(false);
DarkenPanel(_rightPanel, color);
_itemNameText = MakeText(_rightPanel.transform, new Vector2(0f, 228f), 420f, 30f, 25);
_itemNameText.alignment = (TextAnchor)4;
((Graphic)_itemNameText).color = GUIManager.Instance.ValheimOrange;
_slotsAvailText = MakeText(_rightPanel.transform, new Vector2(0f, 198f), 420f, 22f, 19);
_slotsAvailText.alignment = (TextAnchor)4;
((Graphic)_slotsAvailText).color = new Color(0.75f, 0.75f, 0.75f);
MakeSep(_rightPanel.transform, new Vector2(0f, 172f));
_statusText = MakeText(_rightPanel.transform, new Vector2(0f, 138f), 420f, 28f, 20);
_statusText.alignment = (TextAnchor)4;
_smithLevelText = MakeText(_rightPanel.transform, new Vector2(0f, 110f), 420f, 24f, 17);
_smithLevelText.alignment = (TextAnchor)4;
MakeSep(_rightPanel.transform, new Vector2(0f, 86f));
MakeLabel(_rightPanel.transform, "Perks actuales:", new Vector2(0f, 64f), 420f, 21);
_perksCurrentText = MakeText(_rightPanel.transform, new Vector2(0f, -2f), 420f, 80f, 22);
_perksCurrentText.alignment = (TextAnchor)1;
MakeSep(_rightPanel.transform, new Vector2(0f, -50f));
MakeLabel(_rightPanel.transform, "Con este encanto:", new Vector2(0f, -72f), 420f, 21);
_perksNewText = MakeText(_rightPanel.transform, new Vector2(0f, -138f), 420f, 80f, 22);
_perksNewText.alignment = (TextAnchor)1;
_bottomPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, num4), 770f, 80f, false);
_bottomPanel.SetActive(false);
DarkenPanel(_bottomPanel, color);
GameObject val5 = new GameObject("CoinSlot");
val5.transform.SetParent(_bottomPanel.transform, false);
RectTransform val6 = val5.AddComponent();
Vector2 val7 = default(Vector2);
((Vector2)(ref val7))..ctor(0.5f, 0.5f);
val6.anchorMax = val7;
val6.anchorMin = val7;
val6.anchoredPosition = new Vector2(-345f, 0f);
val6.sizeDelta = new Vector2(40f, 40f);
Image val8 = val5.AddComponent();
Sprite sprite = GUIManager.Instance.GetSprite("item_background");
if ((Object)(object)sprite != (Object)null)
{
val8.sprite = sprite;
val8.type = (Type)1;
}
((Graphic)val8).color = new Color(0.1f, 0.1f, 0.1f, 0.6f);
GameObject val9 = new GameObject("CoinIcon");
val9.transform.SetParent(val5.transform, false);
RectTransform val10 = val9.AddComponent();
val10.anchorMin = new Vector2(0.1f, 0.1f);
val10.anchorMax = new Vector2(0.9f, 0.9f);
val7 = (val10.offsetMin = (val10.offsetMax = Vector2.zero));
_coinIcon = val9.AddComponent();
((Behaviour)_coinIcon).enabled = false;
((Graphic)_coinIcon).raycastTarget = false;
_coinCostText = MakeText(_bottomPanel.transform, new Vector2(-270f, 0f), 100f, 36f, 17);
_coinCostText.alignment = (TextAnchor)3;
GameObject val12 = GUIManager.Instance.CreateButton("ENCANTAR", _bottomPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-110f, 0f), 180f, 50f);
_acceptBtn = val12.GetComponent