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

namespace SCE
{
    public class JobDriver_SexBaseInitiatorSimple : JobDriver_SexBaseInitiator
    {
        protected virtual JobDef PartnerJob => SCEJobDefOf.GetLoved;

        protected override IEnumerable<Toil> MakeNewToils()
        {
            setup_ticks();
            
            JobUtility.SetSexFailConditions(this);

            Toil goToPartner = Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell);
            goToPartner.tickAction = delegate
            {
                if (pawn.Position.InHorDistOf(Partner.Position, 0f))
                {
                    ReadyForNextToil();
                }
            };
            yield return goToPartner;

            yield return Toils_Sex.StartPartnerJob(pawn, Partner, PartnerJob);

            InitSexProps();            
            yield return Toils_Sex.SexToil(this, PartnerJob);
            
            yield return Toils_Sex.ProcessSex(this);
        }

        protected virtual void InitSexProps()
        {
            Sexprops = InteractionUtility.MakeSexProps(pawn, Partner);
        }
    }
}