From 2e87277b9a4401a9e65d1919094f2133564e2e13 Mon Sep 17 00:00:00 2001 From: Matsay <142046219+MrMatsay@users.noreply.github.com> Date: Thu, 11 Jul 2024 03:50:34 +0200 Subject: [PATCH] Update HarmonyPatches_Misc.cs Fix and addition to the recipe gene locking --- Source/AthenaFramework/Harmony/HarmonyPatches_Misc.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/AthenaFramework/Harmony/HarmonyPatches_Misc.cs b/Source/AthenaFramework/Harmony/HarmonyPatches_Misc.cs index ac32da8..5d41c63 100644 --- a/Source/AthenaFramework/Harmony/HarmonyPatches_Misc.cs +++ b/Source/AthenaFramework/Harmony/HarmonyPatches_Misc.cs @@ -331,7 +331,10 @@ public static void Postfix(Thing t, Pawn p, ref bool __result) return; } - GeneLockedRecipeExtension extension = t.def.GetModExtension(); + //GeneLockedRecipeExtension extension = t.def.GetModExtension(); + //At that point the building doesn't exists yet, the def you're pointing to is either the blueprint or the frame. + //The mod extension will likely be added to the buildingdef though, hence : + GeneLockedRecipeExtension extension = t.def.entityDefToBuild.GetModExtension(); if (extension != null && !extension.CanCreate(p)) { @@ -350,7 +353,8 @@ public static void Postfix(Bill __instance, Pawn p, ref bool __result) return; } - GeneLockedRecipeExtension extension = __instance.recipe.GetModExtension(); + //This will allow you to reach recipes hidden in recipeMakers by adding the modExtension to the parent thingDef instead + GeneLockedRecipeExtension extension = __instance.recipe.GetModExtension() ?? __instance.recipe.ProducedThingDef?.GetModExtension(); if (extension != null && !extension.CanCreate(p)) {