Skip to content
Snippets Groups Projects
Commit e3b926d3 authored by a flock of birds's avatar a flock of birds
Browse files

Fixed error when babies become children with ideology installed but not biotech

parent 16dbe779
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,11 @@ namespace rjw
// Fixes an error caused by trying to spawn a biotech-only effector when a child starts a new lifestage
[HarmonyTranspiler]
static IEnumerable<CodeInstruction> FixLifeStageStartError(IEnumerable<CodeInstruction> instructions)
static IEnumerable<CodeInstruction> FixLifeStageStartError(IEnumerable<CodeInstruction> instructions, MethodBase original)
{
PropertyInfo thingSpawned = AccessTools.DeclaredProperty(typeof(Thing), nameof(Thing.Spawned));
bool finished = false;
MethodInfo shouldSendNotificationsAbout = AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.ShouldSendNotificationAbout));
bool foundAny = false;
foreach (var instruction in instructions)
{
......@@ -33,17 +34,17 @@ namespace rjw
// if (pawn.Spawned) SpawnBiotechOnlyEffector()
// => if (pawn.Spawned && ModsConfig.IsBiotechActive) SpawnBiotechOnlyEffector()
if (!finished && instruction.Calls(thingSpawned.GetMethod))
if (instruction.Calls(thingSpawned.GetMethod) || instruction.Calls(shouldSendNotificationsAbout))
{
yield return CodeInstruction.Call(typeof(ModsConfig), "get_BiotechActive");
yield return new CodeInstruction(OpCodes.And);
finished = true;
foundAny = true;
}
}
if (!finished)
if (!foundAny)
{
ModLog.Error("Failed to patch LifeStageWorker_HumanlikeChild.Notify_LifeStageStarted");
ModLog.Error("Failed to patch " + original.Name);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment