Merge branch 'panicWhileDownedFix' into 'master'

fix #6 "Beginning to panic tries to path even if incapacitated"

Closes #6

See merge request AbstractConcept/privacy-please!4
This commit is contained in:
Zsar 2023-04-20 20:52:39 +00:00
commit 629cfde51e
1 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,6 @@
using System.Linq;
using Verse;
using Verse.AI;
using Verse.AI.Group;
using RimWorld;
using rjw;
using UnityEngine;
@ -107,7 +106,7 @@ namespace Privacy_Please
if (witness?.Drafted == true || witness?.mindState?.duty?.def.alwaysShowWeapon == true) return;
// Panic reaction
if (reactionOfWitness == ReactionToSexAct.Panic)
if (reactionOfWitness == ReactionToSexAct.Panic && !witness.Downed)
{
Job job = JobMaker.MakeJob(JobDefOf.FleeAndCower, CellFinderLoose.GetFleeDest(witness, new List<Thing>() { pawn }, 24f), pawn);
@ -115,24 +114,31 @@ namespace Privacy_Please
witness.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false);
witness.jobs.StartJob(job);
}
// Vomit reaction
else if (reactionOfWitness == ReactionToSexAct.Nausea)
{
Job jobVomit = JobMaker.MakeJob(JobDefOf.Vomit);
Job jobFlee = JobMaker.MakeJob(JobDefOf.FleeAndCower, CellFinderLoose.GetFleeDest(witness, new List<Thing>() { pawn }, 24f), pawn);
bool vomit = Random.value <= 0.25f;
bool flee = !witness.Downed;
if (!(flee || vomit)) return;
witness.jobs.ClearQueuedJobs();
witness.jobs.EndCurrentJob(JobCondition.InterruptForced, false, false);
if (Random.value <= 0.25f)
System.Action<Job> doFleeJob;
if (vomit)
{
Job jobVomit = JobMaker.MakeJob(JobDefOf.Vomit);
witness.jobs.StartJob(jobVomit);
witness.jobs.jobQueue.EnqueueFirst(jobFlee);
doFleeJob = job => witness.jobs.jobQueue.EnqueueFirst(job);
}
else
{ witness.jobs.StartJob(jobFlee); }
{ doFleeJob = job => witness.jobs.StartJob(job); }
if (flee)
{
Job jobFlee = JobMaker.MakeJob(JobDefOf.FleeAndCower, CellFinderLoose.GetFleeDest(witness, new List<Thing>() { pawn }, 24f), pawn);
doFleeJob(jobFlee);
}
}
}