rjw-events/Source/JobDrivers/JobDriver_OrgySex.cs

119 lines
3.3 KiB
C#
Raw Normal View History

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);
this.FailOn(() => this.Partner == null);
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);
2021-08-02 02:43:25 +00:00
2022-01-23 20:51:58 +00:00
yield return Toils_Goto.GotoThing(this.iTarget, PathEndMode.OnCell);
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?.jobs != null && Partner?.CurJob?.def != null && Partner.CurJob.def != PartnerJob)
2021-04-12 07:48:48 +00:00
{
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.Start();
2021-09-10 17:32:12 +00:00
this.Sexprops.usedCondom = (CondomUtility.TryUseCondom(this.pawn) || CondomUtility.TryUseCondom(this.Partner));
2021-04-12 07:48:48 +00:00
};
toil.AddPreTickAction(delegate
{
if (this.pawn.IsHashIntervalTick(this.ticks_between_hearts))
{
2021-07-23 22:49:39 +00:00
FleckMaker.ThrowMetaIcon(this.pawn.Position, this.pawn.Map, FleckDefOf.Heart);
2021-04-12 07:48:48 +00:00
}
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 07:48:48 +00:00
SexUtility.DrawNude(pawn);
SexUtility.DrawNude(Partner);
}
2021-04-12 07:48:48 +00:00
});
yield return toil;
yield return new Toil
{
initAction = delegate ()
{
2021-09-09 15:14:42 +00:00
SexUtility.ProcessSex(this.Sexprops);
2021-04-12 07:48:48 +00:00
},
defaultCompleteMode = ToilCompleteMode.Instant
};
yield break;
}
}
}