rimworld-animations/Source/JobDrivers/JobDriver_SexCasualForAnimation.cs

94 lines
3.5 KiB
C#
Raw Normal View History

2020-04-09 00:43:01 +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;
namespace Rimworld_Animations {
class JobDriver_SexCasualForAnimation : JobDriver_SexBaseInitiator {
public readonly TargetIndex ipartner = TargetIndex.A;
public readonly TargetIndex ibed = TargetIndex.B;
public override bool TryMakePreToilReservations(bool errorOnFailed) {
2020-04-26 15:03:57 +00:00
return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed);
2020-04-09 00:43:01 +00:00
}
protected override IEnumerable<Toil> MakeNewToils() {
setup_ticks();
this.FailOnDespawnedOrNull(ipartner);
this.FailOnDespawnedOrNull(ibed);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
yield return Toils_Reserve.Reserve(ipartner, xxx.max_rapists_per_prisoner, 0, null);
Toil goToPawnInBed = Toils_Goto.GotoThing(ipartner, PathEndMode.OnCell);
goToPawnInBed.FailOn(() => !RestUtility.InBed(Partner) && Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation") && !xxx.in_same_bed(Partner, pawn));
2020-04-09 00:43:01 +00:00
yield return goToPawnInBed;
Toil startPartnerSex = new Toil();
startPartnerSex.initAction = delegate {
if(Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation")) // allows threesomes
{
Job gettinLovedJob = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("GettinLovedAnimation"), pawn, Bed); // new gettin loved toil that wakes up the pawn goes here
Partner.jobs.jobQueue.EnqueueFirst(gettinLovedJob);
Partner.jobs.EndCurrentJob(JobCondition.InterruptForced);
}
2020-04-09 00:43:01 +00:00
};
yield return startPartnerSex;
Toil sexToil = new Toil();
sexToil.FailOn(() => (Partner.CurJobDef == null) || Partner.CurJobDef != DefDatabase<JobDef>.GetNamed("GettinLovedAnimation", true)); //partner jobdriver is not sexbaserecieverlovedforanim
sexToil.socialMode = RandomSocialMode.Off;
sexToil.defaultCompleteMode = ToilCompleteMode.Never;
2020-04-26 15:03:57 +00:00
sexToil.handlingFacing = true;
2020-04-09 00:43:01 +00:00
sexToil.initAction = delegate {
usedCondom = (CondomUtility.TryUseCondom(base.pawn) || CondomUtility.TryUseCondom(Partner));
Start();
};
sexToil.AddPreTickAction(delegate {
if(!Partner.TryGetComp<CompBodyAnimator>().isAnimating)
{
pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
}
2020-04-09 00:43:01 +00:00
if(Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) {
MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
}
2020-04-26 15:03:57 +00:00
SexTick(pawn, Partner);
SexUtility.reduce_rest(Partner);
SexUtility.reduce_rest(pawn, 2);
2020-04-09 00:43:01 +00:00
if (ticks_left <= 0)
ReadyForNextToil();
});
sexToil.AddFinishAction(delegate {
End();
});
yield return sexToil;
Toil finish = new Toil();
finish.initAction = delegate {
2020-04-26 15:03:57 +00:00
SexUtility.ProcessSex(pawn, Partner, usedCondom, isRape, isCoreLovin: false, isWhoring, sexType);
2020-04-09 00:43:01 +00:00
};
finish.defaultCompleteMode = ToilCompleteMode.Instant;
yield return finish;
}
}
}