From 8888f76708ebc5defa5dc2bdb7b6f5108d8b9fc7 Mon Sep 17 00:00:00 2001 From: Reisen Usagi Date: Tue, 22 Mar 2022 20:15:38 -0300 Subject: [PATCH 1/2] Fix NRE when jobdriver partner is null --- 1.3/Source/Comps/CompBodyAnimator.cs | 29 +++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/1.3/Source/Comps/CompBodyAnimator.cs b/1.3/Source/Comps/CompBodyAnimator.cs index 9f5f95c..0d9c966 100644 --- a/1.3/Source/Comps/CompBodyAnimator.cs +++ b/1.3/Source/Comps/CompBodyAnimator.cs @@ -501,14 +501,29 @@ namespace Rimworld_Animations { public bool LoopNeverending() { - if(pawn?.jobs?.curDriver != null && - (pawn.jobs.curDriver is JobDriver_Sex) && (pawn.jobs.curDriver as JobDriver_Sex).neverendingsex || - (pawn.jobs.curDriver is JobDriver_SexBaseReciever) && (pawn.jobs.curDriver as JobDriver_Sex).Partner?.jobs?.curDriver != null && ((pawn.jobs.curDriver as JobDriver_Sex).Partner.jobs.curDriver as JobDriver_Sex).neverendingsex) - { - return true; - } + return IsNeverEndingSex(pawn) || IsNeverEndingSexPartner(pawn); + } - return false; + public static bool IsNeverEndingSex(Pawn pawn) + { + bool hasDriver = pawn?.jobs?.curDriver != null; + if (!hasDriver) + return false; + + return (pawn.jobs.curDriver is JobDriver_Sex jds) && jds.neverendingsex; + } + + public static bool IsNeverEndingSexPartner(Pawn pawn) + { + bool hasDriver = pawn?.jobs?.curDriver != null; + if (!hasDriver) + return false; + + var partner = (pawn.jobs.curDriver is JobDriver_SexBaseReciever jds) ? jds.Partner : null; + if (partner == null) + return false; + + return IsNeverEndingSex(partner); } public void ResetOnLoop() From 8204a5698b9031d22a48b213129af08910818d94 Mon Sep 17 00:00:00 2001 From: Tory <22203-Tory@users.noreply.gitgud.io> Date: Mon, 6 Feb 2023 23:36:21 +0000 Subject: [PATCH 2/2] Updated Version number --- About/Manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/About/Manifest.xml b/About/Manifest.xml index cce0048..99a4330 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,5 +1,5 @@ Rimworld-Animations - 1.3.2 + 1.3.3