2021-04-12 07:48:48 +00:00
|
|
|
|
using RimWorld;
|
|
|
|
|
using rjw;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Verse;
|
|
|
|
|
using Verse.AI;
|
|
|
|
|
using Verse.AI.Group;
|
|
|
|
|
|
|
|
|
|
namespace RJW_Events
|
|
|
|
|
{
|
|
|
|
|
class JobDriver_OrgySex : JobDriver_SexQuick
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<Toil> MakeNewToils()
|
|
|
|
|
{
|
|
|
|
|
base.setup_ticks();
|
|
|
|
|
JobDef PartnerJob = DefDatabase<JobDef>.GetNamed("GettinOrgySex", true);
|
2021-04-12 17:43:58 +00:00
|
|
|
|
this.FailOnDespawnedOrNull(this.iTarget);
|
2021-04-12 07:48:48 +00:00
|
|
|
|
this.FailOn(() => !this.Partner.health.capacities.CanBeAwake);
|
|
|
|
|
this.FailOn(() => this.pawn.IsFighting());
|
|
|
|
|
this.FailOn(() => this.Partner.IsFighting());
|
|
|
|
|
this.FailOn(() => this.pawn.Drafted);
|
2021-04-12 17:43:58 +00:00
|
|
|
|
this.FailOn(() => this.Partner.Drafted);
|
|
|
|
|
yield return Toils_Goto.GotoThing(this.iTarget, PathEndMode.ClosestTouch);
|
2021-04-12 07:48:48 +00:00
|
|
|
|
yield return new Toil
|
|
|
|
|
{
|
|
|
|
|
defaultCompleteMode = ToilCompleteMode.Delay,
|
|
|
|
|
initAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
this.ticksLeftThisToil = 5000;
|
|
|
|
|
},
|
|
|
|
|
tickAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
this.pawn.GainComfortFromCellIfPossible(false);
|
2021-04-12 17:43:58 +00:00
|
|
|
|
if (this.pawn.Position.DistanceTo(this.Partner.Position) <= 3f)
|
2021-04-12 07:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
this.ReadyForNextToil();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new Toil
|
|
|
|
|
{
|
|
|
|
|
defaultCompleteMode = ToilCompleteMode.Instant,
|
|
|
|
|
socialMode = RandomSocialMode.Off,
|
|
|
|
|
initAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Toil toil = new Toil();
|
|
|
|
|
toil.defaultCompleteMode = ToilCompleteMode.Never;
|
2021-04-13 19:40:37 +00:00
|
|
|
|
toil.socialMode = RandomSocialMode.Normal;
|
2021-04-12 07:48:48 +00:00
|
|
|
|
toil.defaultDuration = this.duration;
|
|
|
|
|
toil.handlingFacing = true;
|
|
|
|
|
toil.FailOn(() => this.Partner.CurJob.def != PartnerJob);
|
|
|
|
|
toil.initAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
this.Partner.pather.StopDead();
|
|
|
|
|
this.Partner.jobs.curDriver.asleep = false;
|
|
|
|
|
this.usedCondom = (CondomUtility.TryUseCondom(this.pawn) || CondomUtility.TryUseCondom(this.Partner));
|
|
|
|
|
this.Start();
|
|
|
|
|
};
|
|
|
|
|
toil.AddPreTickAction(delegate
|
|
|
|
|
{
|
|
|
|
|
if (this.pawn.IsHashIntervalTick(this.ticks_between_hearts))
|
|
|
|
|
{
|
|
|
|
|
this.ThrowMetaIcon(this.pawn.Position, this.pawn.Map, ThingDefOf.Mote_Heart);
|
|
|
|
|
}
|
|
|
|
|
this.SexTick(this.pawn, this.Partner, true, true);
|
|
|
|
|
SexUtility.reduce_rest(this.Partner, 1f);
|
|
|
|
|
SexUtility.reduce_rest(this.pawn, 1f);
|
|
|
|
|
if (this.ticks_left <= 0)
|
|
|
|
|
{
|
|
|
|
|
this.ReadyForNextToil();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
toil.AddFinishAction(delegate
|
|
|
|
|
{
|
|
|
|
|
this.End();
|
2021-04-12 17:43:58 +00:00
|
|
|
|
if(LordUtility.GetLord(pawn)?.LordJob != null && LordUtility.GetLord(pawn).LordJob is LordJob_Joinable_Orgy && !(LordUtility.GetLord(pawn).CurLordToil is LordToil_End))
|
2021-04-12 20:01:36 +00:00
|
|
|
|
{
|
2021-04-12 07:48:48 +00:00
|
|
|
|
SexUtility.DrawNude(pawn);
|
2021-04-12 20:01:36 +00:00
|
|
|
|
SexUtility.DrawNude(Partner);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 07:48:48 +00:00
|
|
|
|
});
|
|
|
|
|
yield return toil;
|
|
|
|
|
yield return new Toil
|
|
|
|
|
{
|
|
|
|
|
initAction = delegate ()
|
|
|
|
|
{
|
|
|
|
|
SexUtility.ProcessSex(this.pawn, this.Partner, this.usedCondom, this.isRape, false, false, this.sexType);
|
|
|
|
|
},
|
|
|
|
|
defaultCompleteMode = ToilCompleteMode.Instant
|
|
|
|
|
};
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|