using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HarmonyLib; using Verse; using Verse.AI; using RimWorld; using RJWSexperience; namespace RJW_Menstruation.Sexperience { public class JobDriver_VaginaWashingWithBucket : JobDriver { const int excretingTime = 300;//ticks - 120 = 2 real seconds, 3 in-game minutes protected Building_CumBucket Bucket => TargetB.Thing as Building_CumBucket; public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(pawn, job, 1, -1, null, errorOnFailed); } protected override IEnumerable MakeNewToils() { HediffComp_Menstruation Comp = pawn.GetMenstruationComp(); this.FailOn(delegate { return !(Comp.TotalCumPercent > 0.001); }); yield return Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch); Toil excreting = Toils_General.Wait(excretingTime, TargetIndex.None);//duration of excreting.WithProgressBarToilDelay(TargetIndex.A); yield return excreting; yield return new Toil() { initAction = delegate () { CumMixture mixture = Comp.MixtureOut(RJWSexperience.VariousDefOf.GatheredCum, 0.5f); float amount = mixture.Volume; if (mixture.ispurecum) { Bucket.AddCum(amount); } else { GatheredCumMixture cummixture = (GatheredCumMixture)ThingMaker.MakeThing(VariousDefOf.GatheredCumMixture); cummixture.InitwithCum(mixture); Bucket.AddCum(amount, cummixture); } if (Comp.TotalCumPercent > 0.001) JumpToToil(excreting); } }; //yield return excreting; yield break; } } }