Skip to content

Commit 14554e5

Browse files
committed
A proper way to unlock recipes and items
1 parent bf36371 commit 14554e5

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Dependencies/Foundry/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Place Foundry dependencies here
22

3+
* `0Harmony.dll` (unstripped)
34
* `Main.dll` (publicized)
45
* `UnityEngine.CoreModule.dll`

ScienceUnlock/Main.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
using System.Reflection;
1+
using HarmonyLib;
22

33
namespace ScienceUnlock
44
{
5-
internal static class Main
5+
[HarmonyPatch(typeof(ItemTemplate), nameof(ItemTemplate.onLoad))]
6+
internal static class ItemTemplate_OnLoad
67
{
7-
[OnGameAssemblyLoad]
8-
public static void OnGameAssemblyLoad(Assembly assembly)
8+
static void Postfix(ItemTemplate __instance, bool isCalledFromEditor)
99
{
10-
if (!BuildInfo.isDemo)
11-
return;
10+
__instance.includeInBuild = true;
11+
__instance.includeInDemo = true;
12+
}
13+
}
1214

13-
BuildInfo.isDemo = false;
15+
[HarmonyPatch(typeof(ResearchTemplate), nameof(ResearchTemplate.onLoad))]
16+
internal static class ResearchTemplate_OnLoad
17+
{
18+
static void Postfix(ResearchTemplate __instance)
19+
{
20+
__instance.includeInBuild = true;
21+
__instance.includeInDemo = true;
1422
}
1523
}
1624
}

ScienceUnlock/ScienceUnlock.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<Reference Include="0Harmony">
10+
<HintPath>../Dependencies/Foundry/0Harmony.dll</HintPath>
11+
</Reference>
912
<Reference Include="Main">
1013
<HintPath>../Dependencies/Foundry/Main.dll</HintPath>
1114
</Reference>

0 commit comments

Comments
 (0)