Skip to content

Commit

Permalink
A proper way to unlock recipes and items
Browse files Browse the repository at this point in the history
  • Loading branch information
glcoder committed Oct 16, 2023
1 parent bf36371 commit 14554e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dependencies/Foundry/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Place Foundry dependencies here

* `0Harmony.dll` (unstripped)
* `Main.dll` (publicized)
* `UnityEngine.CoreModule.dll`
22 changes: 15 additions & 7 deletions ScienceUnlock/Main.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
using System.Reflection;
using HarmonyLib;

namespace ScienceUnlock
{
internal static class Main
[HarmonyPatch(typeof(ItemTemplate), nameof(ItemTemplate.onLoad))]
internal static class ItemTemplate_OnLoad
{
[OnGameAssemblyLoad]
public static void OnGameAssemblyLoad(Assembly assembly)
static void Postfix(ItemTemplate __instance, bool isCalledFromEditor)
{
if (!BuildInfo.isDemo)
return;
__instance.includeInBuild = true;
__instance.includeInDemo = true;
}
}

BuildInfo.isDemo = false;
[HarmonyPatch(typeof(ResearchTemplate), nameof(ResearchTemplate.onLoad))]
internal static class ResearchTemplate_OnLoad
{
static void Postfix(ResearchTemplate __instance)
{
__instance.includeInBuild = true;
__instance.includeInDemo = true;
}
}
}
3 changes: 3 additions & 0 deletions ScienceUnlock/ScienceUnlock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
</PropertyGroup>

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>../Dependencies/Foundry/0Harmony.dll</HintPath>
</Reference>
<Reference Include="Main">
<HintPath>../Dependencies/Foundry/Main.dll</HintPath>
</Reference>
Expand Down

0 comments on commit 14554e5

Please sign in to comment.