-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrafting.cs
More file actions
26 lines (23 loc) · 759 Bytes
/
Crafting.cs
File metadata and controls
26 lines (23 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using HarmonyLib;
namespace DarkwoodCustomizer;
internal static class CraftingPatch
{
// Prevents the game from consuming items when crafting
[HarmonyPatch(typeof(CraftingRecipes.Recipe), nameof(CraftingRecipes.Recipe.removeIngredients))]
[HarmonyPrefix]
private static bool Prefix_RemoveIngredients()
{
return !Plugin.FreeCrafting.Value;
}
[HarmonyPatch(typeof(CraftingRequirement), "refresh")]
[HarmonyPostfix]
// ReSharper disable once InconsistentNaming
private static void Postfix_CraftingRequirement_Refresh(CraftingRequirement __instance)
{
if (Plugin.FreeCrafting.Value)
{
// Force the requirement to always be met
__instance.met = true;
}
}
}