using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: AssemblyCompany("NotSoNeedyCraftingStation")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4ba2e6477b675e18b11376887621290b24ef9b27")] [assembly: AssemblyProduct("NotSoNeedyCraftingStation")] [assembly: AssemblyTitle("NotSoNeedyCraftingStation")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace NotSoNeedyCraftingStation; [BepInPlugin("uk.co.oliapps.valheim.notsoneedycraftingstation", "Not So Needy Crafting Station", "1.3.0")] public class NotSoNeedyCraftingStation : BaseUnityPlugin { private static ConfigEntry modEnabled; private static ConfigEntry disableWeatherDamageForCraftingStation; private static readonly FieldRef HaveFireRef = AccessTools.FieldRefAccess("m_haveFire"); public void Awake() { modEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Mod enabled", true, "Sets whether this mod is enabled"); disableWeatherDamageForCraftingStation = ((BaseUnityPlugin)this).Config.Bind("General", "Disable Rain Damage", false, "Disables rain damage for the crafting station"); ((BaseUnityPlugin)this).Config.Save(); if (modEnabled.Value) { Harmony.CreateAndPatchAll(typeof(NotSoNeedyCraftingStation), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Not So Needy Crafting Station v1.3.0 loaded successfully!"); } } [HarmonyPatch(typeof(CraftingStation), "Start")] [HarmonyPostfix] public static void CraftingStation_Start(CraftingStation __instance) { if (disableWeatherDamageForCraftingStation.Value && (Object)(object)__instance != (Object)null) { WearNTear component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.m_noRoofWear = false; } } } [HarmonyPatch(typeof(CraftingStation), "CheckUsable")] [HarmonyPrefix] [HarmonyPriority(0)] public static bool CheckUsable(CraftingStation __instance, Player player, bool showMessage, ref bool __result) { if (!modEnabled.Value) { return true; } bool flag = HaveFireRef.Invoke(__instance); if (!__instance.m_craftRequireFire || flag) { __result = true; return false; } if (showMessage) { ((Character)player).Message((MessageType)2, "$msg_needfire", 0, (Sprite)null, false); } __result = false; return false; } }