using System.Collections.Generic;
using Verse;
using RimWorld;
using rjw;
using Verse.AI;

namespace SCE
{
    public class JobDriver_LewdTrainSex : JobDriver_SexBaseInitiatorSimple
    {
        private Pawn originalPartner;

        protected override IEnumerable<Toil> MakeNewToils()
        {
            originalPartner = Partner;
            if (SexAppraiser.would_fuck(pawn, Partner) > 0f)
            {
                foreach (var baseToil in base.MakeNewToils())
                {
                    yield return baseToil;
                }
            }

            if (originalPartner != Partner)
            {
                // Pawn got interrupted by another partner, then the original partner finished before them.
                yield break;
            }

            yield return Toils_Interpersonal.SetLastInteractTime(iTarget);

            yield return Toils_Interpersonal.TryTrain(iTarget);
        }
    }
}