Compare commits

...

3 commits

Author SHA1 Message Date
Usagirei
421770be3a Merge branch 'nre-partner' into 'master'
Fix NRE when jobdriver partner is null

See merge request c0ffeeeeeeee/rimworld-animations!5
2023-04-09 19:30:26 +00:00
Tory
a9acb2bd62 Added conditionals to race patches 2023-04-08 11:03:29 +00:00
Reisen Usagi
8888f76708
Fix NRE when jobdriver partner is null 2022-03-22 20:15:38 -03:00
3 changed files with 40 additions and 21 deletions

View file

@ -504,14 +504,29 @@ namespace Rimworld_Animations {
public bool LoopNeverending() public bool LoopNeverending()
{ {
if(pawn?.jobs?.curDriver != null && return IsNeverEndingSex(pawn) || IsNeverEndingSexPartner(pawn);
(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;
} }
public static bool IsNeverEndingSex(Pawn pawn)
{
bool hasDriver = pawn?.jobs?.curDriver != null;
if (!hasDriver)
return false; 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() public void ResetOnLoop()

View file

@ -6,14 +6,16 @@
</mods> </mods>
<match Class="PatchOperationSequence"> <match Class="PatchOperationSequence">
<operations> <operations>
<li Class="PatchOperationReplace"> <li Class="PatchOperationConditional">
<xpath>/Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Epona"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[hediffGraphics/Epona_OHPG_female="Things/Pawn/Addons/Breasts/Breasts"]/drawnInBed</xpath> <xpath>Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Epona"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[hediffGraphics/Epona_OHPG_female="Things/Pawn/Addons/Breasts/Breasts"]/drawnInBed</xpath>
<match Class="PatchOperationReplace">
<xpath>Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Epona"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[hediffGraphics/Epona_OHPG_female="Things/Pawn/Addons/Breasts/Breasts"]/drawnInBed</xpath>
<value> <value>
<drawnInBed>false</drawnInBed> <drawnInBed>false</drawnInBed>
</value> </value>
</match>
</li> </li>
</operations> </operations>
</match> </match>
</Operation> </Operation>
</Patch> </Patch>

View file

@ -6,14 +6,16 @@
</mods> </mods>
<match Class="PatchOperationSequence"> <match Class="PatchOperationSequence">
<operations> <operations>
<li Class="PatchOperationAdd"> <li Class="PatchOperationConditional">
<xpath>Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Nyaron"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[bodyPart="tail"]</xpath>
<match Class="PatchOperationAdd">
<xpath>/Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Nyaron"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[bodyPart="tail"]</xpath> <xpath>/Defs/AlienRace.ThingDef_AlienRace[defName = "Alien_Nyaron"]/alienRace/generalSettings/alienPartGenerator/bodyAddons/li[bodyPart="tail"]</xpath>
<value> <value>
<drawnInBed>false</drawnInBed> <drawnInBed>false</drawnInBed>
</value> </value>
</match>
</li> </li>
</operations> </operations>
</match> </match>
</Operation> </Operation>
</Patch> </Patch>