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

namespace SCE
{
    public class JobDriver_ConsummateMarriage : JobDriver_SexBaseInitiatorSimple
    {
        protected override JobDef PartnerJob => SCEJobDefOf.BeLewdlyMarried;

        protected override void InitSexProps()
        {
            // Make pawns of an ideo's supreme gender refuse to perform selfless acts on a non-supreme partner.
            // The new interaction system decides that either initiator is in a dominant role or it's reversed.
            // I'm not going to try to figure out how to swap in my own reversal code when the clusterfuck of 
            // services probably aren't even designed to allow that, so let's just swap participants here and
            // hope for the best.
            Sexprops = new SexProps();
            if (pawn.gender != pawn.Ideo.SupremeGender && pawn.gender != Partner.gender && Partner.gender == Partner.Ideo.SupremeGender)
            {
                Sexprops.pawn = Partner;
                Sexprops.partner = pawn;
            }
            else
            {
                Sexprops.pawn = pawn;
                Sexprops.partner = Partner;
            }

            // Unfortunately, we still need to tell the services whether to account for the "submissive" partner's
            // preferences, and that's apparently too much customisation for us to just use LewdInteractionService.
            InteractionUtility.JustPickADamnSexType(Sexprops, submissivePreferenceWeight: Sexprops.pawn.Ideo.SupremeGender == Gender.None ? 1f : 0f);

            // And now swap back. Contemplate life choices.
            Sexprops.pawn = pawn;
            Sexprops.partner = Partner;
        }
    }
}