Added check for rare null ref exception of partner in large orgies

This commit is contained in:
c0ffee 2021-05-14 09:57:20 -07:00
parent 8b13a27272
commit d165e0487b
5 changed files with 6 additions and 4 deletions

View file

@ -24,6 +24,7 @@ namespace RJW_Events
base.setup_ticks();
JobDef PartnerJob = DefDatabase<JobDef>.GetNamed("GettinOrgySex", true);
this.FailOnDespawnedOrNull(this.iTarget);
this.FailOn(() => this.Partner == null);
this.FailOn(() => !this.Partner.health.capacities.CanBeAwake);
this.FailOn(() => this.pawn.IsFighting());
this.FailOn(() => this.Partner.IsFighting());
@ -53,7 +54,7 @@ namespace RJW_Events
initAction = delegate ()
{
if(Partner.CurJob.def != PartnerJob)
if(Partner?.jobs != null && Partner?.CurJob?.def != null && Partner.CurJob.def != PartnerJob)
{
Job newJob = JobMaker.MakeJob(PartnerJob, this.pawn, this.Partner);
this.Partner.jobs.StartJob(newJob, JobCondition.InterruptForced, null, false, true, null, null, false, false);

View file

@ -35,6 +35,7 @@ namespace RJW_Events
this.ticks_between_hearts -= 25;
}
this.FailOnDespawnedOrNull(this.iTarget);
this.FailOn(() => this.Partner == null);
this.FailOn(() => !(Partner.jobs.curDriver is JobDriver_Sex));
this.FailOn(() => !base.Partner.health.capacities.CanBeAwake);
this.FailOn(() => this.pawn.Drafted);