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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest> <Manifest>
<identifier>RJW-Events</identifier> <identifier>RJW-Events</identifier>
<version>0.1.0</version> <version>0.1.1</version>
</Manifest> </Manifest>

BIN
Assemblies/RJW-Events.dll Normal file

Binary file not shown.

View file

@ -32,7 +32,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="0Harmony"> <Reference Include="0Harmony">
<HintPath>..\..\Modpacks\Mods\836308268\1.2\Assemblies\0Harmony.dll</HintPath> <HintPath>..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
@ -40,7 +40,7 @@
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="RJW"> <Reference Include="RJW">
<HintPath>..\RJW\1.2\Assemblies\RJW.dll</HintPath> <HintPath>..\rjw-master\1.2\Assemblies\RJW.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />

View file

@ -24,6 +24,7 @@ namespace RJW_Events
base.setup_ticks(); base.setup_ticks();
JobDef PartnerJob = DefDatabase<JobDef>.GetNamed("GettinOrgySex", true); JobDef PartnerJob = DefDatabase<JobDef>.GetNamed("GettinOrgySex", true);
this.FailOnDespawnedOrNull(this.iTarget); this.FailOnDespawnedOrNull(this.iTarget);
this.FailOn(() => this.Partner == null);
this.FailOn(() => !this.Partner.health.capacities.CanBeAwake); this.FailOn(() => !this.Partner.health.capacities.CanBeAwake);
this.FailOn(() => this.pawn.IsFighting()); this.FailOn(() => this.pawn.IsFighting());
this.FailOn(() => this.Partner.IsFighting()); this.FailOn(() => this.Partner.IsFighting());
@ -53,7 +54,7 @@ namespace RJW_Events
initAction = delegate () 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); Job newJob = JobMaker.MakeJob(PartnerJob, this.pawn, this.Partner);
this.Partner.jobs.StartJob(newJob, JobCondition.InterruptForced, null, false, true, null, null, false, false); 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.ticks_between_hearts -= 25;
} }
this.FailOnDespawnedOrNull(this.iTarget); this.FailOnDespawnedOrNull(this.iTarget);
this.FailOn(() => this.Partner == null);
this.FailOn(() => !(Partner.jobs.curDriver is JobDriver_Sex)); this.FailOn(() => !(Partner.jobs.curDriver is JobDriver_Sex));
this.FailOn(() => !base.Partner.health.capacities.CanBeAwake); this.FailOn(() => !base.Partner.health.capacities.CanBeAwake);
this.FailOn(() => this.pawn.Drafted); this.FailOn(() => this.pawn.Drafted);