using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HZ_WoodPolish")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HZ_WoodPolish")] [assembly: AssemblyTitle("HZ_WoodPolish")] [assembly: AssemblyVersion("1.0.0.0")] [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 HZ_Polish { [BepInPlugin("hz.valheim.polish", "HZ_WoodPolish", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class HZPolishPlugin : BaseUnityPlugin { public const string PluginGUID = "hz.valheim.polish"; public const string PluginName = "HZ_WoodPolish"; public const string PluginVersion = "1.0.0"; public const string PieceGameObjectName = "HZPolish_Piece"; public const string ResinPrefabName = "Resin"; public const string ResinSharedName = "$item_resin"; internal static readonly int PolishedHash = StringExtensionMethods.GetStableHashCode("HZPolish_polished"); private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable += RegisterPiece; new Harmony("hz.valheim.polish").PatchAll(); } private void RegisterPiece() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; GameObject prefab = PrefabManager.Instance.GetPrefab("piece_repair"); if ((Object)(object)prefab == (Object)null) { Logger.LogError((object)"HZ_Polish: prefab 'piece_repair' não encontrado. Verifique o nome no dnSpy."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("HZPolish_Piece", prefab); Sprite icon = null; GameObject prefab2 = PrefabManager.Instance.GetPrefab("Resin"); if ((Object)(object)prefab2 != (Object)null) { ItemDrop component = prefab2.GetComponent(); if ((Object)(object)component != (Object)null) { icon = component.m_itemData.GetIcon(); } } else { Logger.LogWarning((object)"HZ_Polish: prefab 'Resin' não encontrado, ícone ficará vazio."); } PieceConfig val2 = new PieceConfig(); val2.Name = "Polir"; val2.Description = "Polir e reparar totalmente uma peça de madeira, protegendo-a do desgaste da chuva. Custo: 1 Resina por aplicação."; val2.PieceTable = "Hammer"; val2.Category = "Misc"; val2.Icon = icon; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Resin", Amount = 1, Recover = false } }; PieceConfig val3 = val2; CustomPiece val4 = new CustomPiece(val, false, val3); PieceManager.Instance.AddPiece(val4); } } [HarmonyPatch(typeof(Player), "Repair")] public static class Player_Repair_PolishPatch { private static bool Prefix(Player __instance, ItemData toolItem, Piece repairPiece) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)repairPiece == (Object)null || ((Object)((Component)repairPiece).gameObject).name != "HZPolish_Piece") { return true; } Piece hoveringPiece = __instance.GetHoveringPiece(); if ((Object)(object)hoveringPiece == (Object)null) { return false; } if (!PrivateArea.CheckAccess(((Component)hoveringPiece).transform.position, 0f, true, false)) { return false; } WearNTear component = ((Component)hoveringPiece).GetComponent(); if ((Object)(object)component == (Object)null || (int)component.m_materialType != 0) { ((Character)__instance).Message((MessageType)1, hoveringPiece.m_name + " só funciona em madeira.", 0, (Sprite)null); return false; } ZNetView component2 = ((Component)hoveringPiece).GetComponent(); if ((Object)(object)component2 == (Object)null || !component2.IsValid()) { return false; } if (component2.GetZDO().GetBool(HZPolishPlugin.PolishedHash, false)) { ((Character)__instance).Message((MessageType)1, hoveringPiece.m_name + " já está polido.", 0, (Sprite)null); return false; } Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory.CountItems("$item_resin", -1, true) < 1) { ((Character)__instance).Message((MessageType)2, "$msg_missingrequirement", 0, (Sprite)null); return false; } component2.ClaimOwnership(); inventory.RemoveItem("$item_resin", 1, -1, true); component.Repair(); component2.GetZDO().Set(HZPolishPlugin.PolishedHash, true); component.m_noRoofWear = false; __instance.FaceLookDirection(); ZSyncAnimation value = Traverse.Create((object)__instance).Field("m_zanim").GetValue(); if (value != null) { value.SetTrigger(toolItem.m_shared.m_attack.m_attackAnimation); } hoveringPiece.m_placeEffect.Create(((Component)hoveringPiece).transform.position, ((Component)hoveringPiece).transform.rotation, (Transform)null, 1f, -1); ((Character)__instance).Message((MessageType)1, hoveringPiece.m_name + " polido e reparado!", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(WearNTear), "Awake")] public static class WearNTear_Awake_PolishPatch { private static void Postfix(WearNTear __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.m_materialType == 0) { ZNetView component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO().GetBool(HZPolishPlugin.PolishedHash, false)) { __instance.m_noRoofWear = false; } } } } }