using Verse;
using RimWorld;
using rjw;

namespace SCE
{
    public class PreceptComp_Taboo_Rape : PreceptComp_Taboo
    {
        public bool permitDesignatedRape = true;

        public bool exceptSlaves;

        public bool exceptPrisoners;

        public Gender? exceptGender;

        protected override bool BrokeTabooInt(Pawn pawn, HistoryEvent ev, Precept precept)
        {
            if (!base.BrokeTabooInt(pawn, ev, precept))
            {
                return false;
            }

            var props = ev.args.GetArg<SexProps>(SCEHistoryEventArgNames.SexProps);

            if (!props.canBeGuilty)
            {
                return false;
            }

            Pawn partner = props.partner;

            if (exceptGender.HasValue && partner.gender == exceptGender)
            {
                return false;
            }

            if ((exceptSlaves && partner.IsSlave) || (exceptPrisoners && partner.IsPrisoner))
            {
                return false;
            }

            if (xxx.is_animal(partner) && !precept.ideo.HasMeme(SCEMemeDefOf.AnimalPersonhood))
            {
                return false;
            }

            return !(permitDesignatedRape && partner.IsDesignatedComfort());
        }
    }
}