protected override IEnumerable <Toil> MakeNewToils()
        {
            //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - making toils");
            this.FailOnDespawnedOrNull(PartnerInd);
            this.FailOnDespawnedNullOrForbidden(BedInd);
            //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() fail conditions check " + (Actor is null) + " " + !xxx.CanUse(Actor, Bed) + " " + !Actor.CanReserve(Partner));
            this.FailOn(() => Actor is null || !xxx.CanUse(Actor, Bed) || !Actor.CanReserve(Partner));
            this.FailOn(() => pawn.Drafted);
            int price = WhoringHelper.PriceOfWhore(Actor);

            yield return(Toils_Reserve.Reserve(PartnerInd, 1, 0));

            //yield return Toils_Reserve.Reserve(BedInd, Bed.SleepingSlotsCount, 0);
            bool partnerHasPenis = Genital_Helper.has_penis(Partner) || Genital_Helper.has_penis_infertile(Partner);

            Toil gotoWhoreBed = new Toil
            {
                initAction = delegate
                {
                    //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - gotoWhoreBed initAction is called");
                    Actor.pather.StartPath(WhoreSleepSpot, PathEndMode.OnCell);
                    Partner.jobs.StopAll();
                    Partner.pather.StartPath(WhoreSleepSpot, PathEndMode.Touch);
                },
                tickAction = delegate
                {
                    if (Partner.IsHashIntervalTick(150))
                    {
                        Partner.pather.StartPath(Actor, PathEndMode.Touch);
                        //Log.Message(xxx.get_pawnname(Partner) + ": I'm following the w***e");
                    }
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            gotoWhoreBed.FailOnWhorebedNoLongerUsable(BedInd, Bed);
            yield return(gotoWhoreBed);

            Toil waitInBed = new Toil
            {
                initAction = delegate
                {
                    //Rand.PopState();
                    //Rand.PushState(RJW_Multiplayer.PredictableSeed());
                    //Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - waitInBed, initAction is called");
                    ticksLeftThisToil = 5000;
                    ticks_left        = (int)(2000.0f * Rand.Range(0.30f, 1.30f));
                    //Actor.pather.StopDead();  //Let's just make w****s standing at the bed
                    //JobDriver curDriver = Actor.jobs.curDriver;
                    //curDriver.layingDown = LayingDownState.LayingInBed;
                    //curDriver.asleep = false;
                    var gettin_loved = new Job(xxx.gettin_loved, Actor, Bed);
                    Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced);
                },
                tickAction = delegate
                {
                    Actor.GainComfortFromCellIfPossible();
                    if (IsInOrByBed(Bed, Partner))
                    {
                        //Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - waitInBed, tickAction pass");
                        ticksLeftThisToil = 0;
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Delay,
            };

            waitInBed.FailOn(() => pawn.GetRoom() == null);
            yield return(waitInBed);

            bool canAfford = WhoringHelper.CanAfford(Partner, Actor, price);

            if (canAfford)
            {
                Toil loveToil = new Toil
                {
                    initAction = delegate
                    {
                        //Actor.jobs.curDriver.ticksLeftThisToil = 1200;
                        //Using ticks_left to control the time of sex
                        //--Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - loveToil, setting initAction");

                        /*
                         * //Hoge: W***e is just work. no feel cheatedOnMe.
                         * if (xxx.HasNonPolyPartner(Actor))
                         * {
                         *      Pawn pawn = LovePartnerRelationUtility.ExistingLovePartner(Actor);
                         *      if (((Partner != pawn) && !pawn.Dead) && ((pawn.Map == Actor.Map) || (Rand.Value < 0.15)))
                         *      {
                         *              pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, Actor);
                         *      }
                         * }
                         */
                        if (xxx.HasNonPolyPartnerOnCurrentMap(Partner))
                        {
                            Pawn lover = LovePartnerRelationUtility.ExistingLovePartner(Partner);
                            //Rand.PopState();
                            //Rand.PushState(RJW_Multiplayer.PredictableSeed());
                            // We have to do a few other checks because the pawn might have multiple lovers and ExistingLovePartner() might return the wrong one
                            if (lover != null && Actor != lover && !lover.Dead && (lover.Map == Partner.Map || Rand.Value < 0.25))
                            {
                                lover.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, Partner);
                            }
                        }
                        if (!partnerHasPenis)
                        {
                            Actor.rotationTracker.Face(Partner.DrawPos);
                        }
                    },
                    defaultCompleteMode = ToilCompleteMode.Never,                     //Changed from Delay
                };
                loveToil.AddPreTickAction(delegate
                {
                    //Actor.Reserve(Partner, 1, 0);
                    --ticks_left;
                    xxx.reduce_rest(Partner);
                    xxx.reduce_rest(Actor, 2);

                    if (ticks_left <= 0)
                    {
                        ReadyForNextToil();
                    }
                    else if (pawn.IsHashIntervalTick(ticks_between_hearts))
                    {
                        MoteMaker.ThrowMetaIcon(Actor.Position, Actor.Map, ThingDefOf.Mote_Heart);
                    }
                    Actor.GainComfortFromCellIfPossible();
                    Partner.GainComfortFromCellIfPossible();
                });
                loveToil.AddFinishAction(delegate
                {
                    //Log.Message("[RJW] JobDriver_WhoreIsServingVisitors::MakeNewToils() - finished loveToil");
                    //// Trying to add some interactions and social logs
                    //xxx.processAnalSex(Partner, Actor, ref isAnalSex, partnerHasPenis);
                });
                loveToil.AddFailCondition(() => Partner.Dead || !IsInOrByBed(Bed, Partner));
                loveToil.socialMode = RandomSocialMode.Off;
                yield return(loveToil);

                Toil afterSex = new Toil
                {
                    initAction = delegate
                    {
                        // Adding interactions, social logs, etc
                        SexUtility.ProcessSex(Actor, Partner, false, false, true);

                        //--Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Partner should pay the price now in afterSex.initAction");
                        int remainPrice = WhoringHelper.PayPriceToWhore(Partner, price, Actor);

                        /*if (remainPrice <= 0)
                         * {
                         *      --Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Paying price is success");
                         * }
                         * else
                         * {
                         *      --Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Paying price failed");
                         * }*/
                        xxx.UpdateRecords(Actor, price - remainPrice);
                        var thought = (Actor.IsPrisoner) ? thought_captive : thought_free;
                        pawn.needs.mood.thoughts.memories.TryGainMemory(thought);
                        if (SexUtility.ConsiderCleaning(pawn))
                        {
                            LocalTargetInfo cum = pawn.PositionHeld.GetFirstThing <Filth>(pawn.Map);

                            Job clean = new Job(JobDefOf.Clean);
                            clean.AddQueuedTarget(TargetIndex.A, cum);

                            pawn.jobs.jobQueue.EnqueueFirst(clean);
                        }
                    },
                    defaultCompleteMode = ToilCompleteMode.Instant
                };
                yield return(afterSex);
            }
        }
        public static Pawn FindAttractivePawn(Pawn w***e, out int price)
        {
            price = 0;
            if (w***e == null || xxx.is_asexual(w***e))
            {
                if (RJWSettings.DebugWhoring)
                {
                    Log.Message($" {xxx.get_pawnname(w***e)} is asexual, abort");
                }
                return(null);
            }
            //Rand.PopState();
            //Rand.PushState(RJW_Multiplayer.PredictableSeed());

            FindAttractivePawnHelper client = new FindAttractivePawnHelper
            {
                w***e = w***e
            };

            price = WhoringHelper.PriceOfWhore(w***e);
            int priceOfWhore = price;

            IntVec3 pos = w***e.Position;

            IEnumerable <Pawn> potentialClients = w***e.Map.mapPawns.AllPawnsSpawned;

            potentialClients = potentialClients.Where(x
                                                      => x != w***e &&
                                                      !x.IsForbidden(w***e) &&
                                                      !x.HostileTo(w***e) &&
                                                      !x.IsPrisoner &&
                                                      x.Position.DistanceTo(pos) < 100 &&
                                                      w***e.CanReserveAndReach(x, PathEndMode.ClosestTouch, Danger.Some, 1) &&
                                                      xxx.is_healthy_enough(x));

            potentialClients = potentialClients.Except(potentialClients.Where(client.TraitCheckFail));

            if (!potentialClients.Any())
            {
                return(null);
            }

            if (RJWSettings.DebugWhoring)
            {
                Log.Message($" FindAttractivePawn number of all potential clients {potentialClients.Count()}");
            }

            List <Pawn> valid_targets = new List <Pawn>();

            foreach (Pawn target in potentialClients)
            {
                if (xxx.can_path_to_target(w***e, target.Position))
                {
                    valid_targets.Add(target);
                }
            }

            IEnumerable <Pawn> guestsSpawned = valid_targets.Where(x => x.Faction != w***e.Faction &&
                                                                   WhoringHelper.CanAfford(x, w***e, priceOfWhore) &&
                                                                   !MemoryChecker(x, ThoughtDef.Named("RJWFailedSolicitation")) &&
                                                                   x != LovePartnerRelationUtility.ExistingLovePartner(w***e));

            if (guestsSpawned.Any())
            {
                if (RJWSettings.DebugWhoring)
                {
                    Log.Message($" FindAttractivePawn number of all acceptable Guests {guestsSpawned.Count()}");
                }
                return(guestsSpawned.RandomElement());
            }

            return(null);

            //use casual sex for colonist hooking
            if (RJWSettings.DebugWhoring)
            {
                Log.Message($" FindAttractivePawn found no guests, trying colonists");
            }

            if (!WhoringHelper.WillPawnTryHookup(w***e))            // will hookup colonists?
            {
                return(null);
            }
            IEnumerable <Pawn> freeColonists = valid_targets.Where(x => x.Faction == w***e.Faction &&
                                                                   Roll_to_skip(x, w***e));

            if (RJWSettings.DebugWhoring)
            {
                Log.Message($" FindAttractivePawn number of free colonists {freeColonists.Count()}");
            }

            freeColonists = freeColonists.Where(x => client.RelationCheckPass(x) && !MemoryChecker(x, ThoughtDef.Named("RJWTurnedDownWhore")));

            if (freeColonists.Any())
            {
                if (RJWSettings.DebugWhoring)
                {
                    Log.Message($" FindAttractivePawn number of all acceptable Colonists {freeColonists.Count()}");
                }
                return(freeColonists.RandomElement());
            }

            return(null);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - making toils");
            setup_ticks();

            this.FailOnDespawnedOrNull(iTarget);
            this.FailOnDespawnedNullOrForbidden(iBed);
            //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() fail conditions check " + !xxx.CanUse(pawn, Bed) + " " + !pawn.CanReserve(Partner));
            this.FailOn(() => !xxx.CanUse(pawn, Bed) || !pawn.CanReserve(Partner));
            this.FailOn(() => pawn.Drafted);
            this.FailOn(() => Partner.IsFighting());
            this.FailOn(() => !Partner.CanReach(pawn, PathEndMode.Touch, Danger.Deadly));

            yield return(Toils_Reserve.Reserve(iTarget, 1, 0));

            //yield return Toils_Reserve.Reserve(BedInd, Bed.SleepingSlotsCount, 0);

            //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - generate toils");
            Toil gotoBed = new Toil();

            gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            gotoBed.FailOnWhorebedNoLongerUsable(iBed, Bed);
            gotoBed.AddFailCondition(() => Partner.Downed);
            gotoBed.FailOn(() => !Partner.CanReach(Bed, PathEndMode.Touch, Danger.Deadly));
            gotoBed.initAction = delegate
            {
                //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - gotoWhoreBed initAction is called");
                pawn.pather.StartPath(SleepSpot, PathEndMode.OnCell);
                Partner.jobs.StopAll();
                Job job = JobMaker.MakeJob(JobDefOf.GotoMindControlled, SleepSpot);
                Partner.jobs.StartJob(job, JobCondition.InterruptForced);
            };
            yield return(gotoBed);

            ticks_left = (int)(2000.0f * Rand.Range(0.30f, 1.30f));

            Toil waitInBed = new Toil();

            waitInBed.initAction = delegate
            {
                ticksLeftThisToil = 5000;
            };
            waitInBed.tickAction = delegate
            {
                pawn.GainComfortFromCellIfPossible();
                if (IsInOrByBed(Bed, Partner) && pawn.PositionHeld == Partner.PositionHeld)
                {
                    ReadyForNextToil();
                }
            };
            waitInBed.defaultCompleteMode = ToilCompleteMode.Delay;
            yield return(waitInBed);

            Toil StartPartnerJob = new Toil();

            StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant;
            StartPartnerJob.socialMode          = RandomSocialMode.Off;
            StartPartnerJob.initAction          = delegate
            {
                //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - StartPartnerJob");
                var gettin_loved = JobMaker.MakeJob(xxx.gettin_loved, pawn, Bed);
                Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced);
            };
            yield return(StartPartnerJob);

            Toil loveToil = new Toil();

            loveToil.AddFailCondition(() => Partner.Dead || Partner.CurJobDef != xxx.gettin_loved);
            loveToil.defaultCompleteMode = ToilCompleteMode.Never;
            loveToil.socialMode          = RandomSocialMode.Off;
            loveToil.handlingFacing      = true;
            loveToil.initAction          = delegate
            {
                //Log.Message("[RJW]JobDriver_WhoreIsServingVisitors::MakeNewToils() - loveToil");
                // TODO: replace this quick n dirty way
                CondomUtility.GetCondomFromRoom(pawn);

                // Try to use w***e's condom first, then client's
                usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner);

                Start();

                if (xxx.HasNonPolyPartnerOnCurrentMap(Partner))
                {
                    Pawn lover = LovePartnerRelationUtility.ExistingLovePartner(Partner);
                    // We have to do a few other checks because the pawn might have multiple lovers and ExistingLovePartner() might return the wrong one
                    if (lover != null && pawn != lover && !lover.Dead && (lover.Map == Partner.Map || Rand.Value < 0.25))
                    {
                        lover.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, Partner);
                    }
                }
            };
            loveToil.AddPreTickAction(delegate
            {
                --ticks_left;
                if (pawn.IsHashIntervalTick(ticks_between_hearts))
                {
                    if (xxx.is_nympho(pawn))
                    {
                        ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
                    }
                    else
                    {
                        ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart);
                    }
                }
                SexUtility.reduce_rest(Partner, 1);
                SexUtility.reduce_rest(pawn, 2);
                if (ticks_left <= 0)
                {
                    ReadyForNextToil();
                }
            });
            loveToil.AddFinishAction(delegate
            {
                End();
            });
            yield return(loveToil);

            Toil afterSex = new Toil
            {
                initAction = delegate
                {
                    // Adding interactions, social logs, etc
                    SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, whoring: isWhoring, sextype: sexType);

                    if (!(Partner.IsColonist && (pawn.IsPrisonerOfColony || pawn.IsColonist)))
                    {
                        int price = WhoringHelper.PriceOfWhore(pawn);
                        //--Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Partner should pay the price now in afterSex.initAction");
                        int remainPrice = WhoringHelper.PayPriceToWhore(Partner, price, pawn);

                        /*if (remainPrice <= 0)
                         * {
                         *      --Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Paying price is success");
                         * }
                         * else
                         * {
                         *      --Log.Message("JobDriver_WhoreIsServingVisitors::MakeNewToils() - Paying price failed");
                         * }*/
                        xxx.UpdateRecords(pawn, price - remainPrice);
                    }
                    var thought = (pawn.IsPrisoner || xxx.is_slave(pawn)) ? thought_captive : thought_free;
                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought);
                    if (SexUtility.ConsiderCleaning(pawn))
                    {
                        LocalTargetInfo cum = pawn.PositionHeld.GetFirstThing <Filth>(pawn.Map);

                        Job clean = JobMaker.MakeJob(JobDefOf.Clean);
                        clean.AddQueuedTarget(TargetIndex.A, cum);

                        pawn.jobs.jobQueue.EnqueueFirst(clean);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(afterSex);
        }