public static void Postfix(ref Job __result, Pawn pawn)
        {
            //Log.Message("[RJW]patches_lovin::JobGiver_Mate fail, try rjw for " + xxx.get_pawnname(pawn));
            var partBPR = Genital_Helper.get_genitalsBPR(pawn);
            var parts   = Genital_Helper.get_PartsHediffList(pawn, partBPR);

            if (!(Genital_Helper.has_penis_fertile(pawn, parts) || Genital_Helper.has_penis_infertile(pawn, parts)) || !pawn.ageTracker.CurLifeStage.reproductive)
            {
                //Log.Message("[RJW]patches_lovin::JobGiver_Mate " + xxx.get_pawnname(pawn) + ", has no penis " + (Genital_Helper.has_penis(pawn) || Genital_Helper.has_penis_infertile(pawn)));
                //Log.Message("[RJW]patches_lovin::JobGiver_Mate " + xxx.get_pawnname(pawn) + ", not reproductive " + !pawn.ageTracker.CurLifeStage.reproductive);
                return;
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn3 = t as Pawn;
                var  valid = !pawn3.Downed &&
                             pawn3 != pawn &&
                             pawn3.CanCasuallyInteractNow() &&
                             !pawn3.IsForbidden(pawn) &&
                             !pawn3.HostileTo(pawn) &&
                             PawnUtility.FertileMateTarget(pawn, pawn3);
                if (!valid && pawn3 != pawn)
                {
                    //Log.Message("[RJW]patches_lovin::JobGiver_Mate " + xxx.get_pawnname(pawn3) + ", not valid");
                    //Log.Message("[RJW]patches_lovin::JobGiver_Mate Downed " + pawn3.Downed);
                    //Log.Message("[RJW]patches_lovin::JobGiver_Mate CanCasuallyInteractNow " + pawn3.CanCasuallyInteractNow());
                    //Log.Message("[RJW]patches_lovin::JobGiver_Mate IsForbidden " + pawn3.IsForbidden(pawn));
                    //Log.Message("[RJW]patches_lovin::JobGiver_Mate FertileMateTarget " + PawnUtility.FertileMateTarget(pawn, pawn3));
                }
                return(valid);
            };

            ThingRequest request = ThingRequest.ForDef(pawn.def);                               // mate sames species

            if (RJWSettings.WildMode)                                                           // go wild xD
            {
                request = ThingRequest.ForGroup(ThingRequestGroup.Pawn);                        // mate everyone
            }
            //add animal check?

            Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, request, PathEndMode.Touch, TraverseParms.For(pawn), 30f, validator);

            if (pawn2 == null)
            {
                //Log.Message("[RJW]patches_lovin::JobGiver_Mate " + xxx.get_pawnname(pawn) + ", no valid partner found");
                return;
            }
            //__result = JobMaker.MakeJob(xxx.animalBreed, pawn2);
            __result = JobMaker.MakeJob(JobDefOf.Mate, pawn2);
            //Log.Message("[RJW]patches_lovin::JobGiver_Mate " + xxx.get_pawnname(pawn) + ", female " + xxx.get_pawnname(pawn2) + ", job " + __result);
        }
    private static bool IsValidFemale(Thing femaleThing, Pawn malePawn,
                                      IReadOnlyDictionary <PawnKindDef, IReadOnlyCollection <HybridDef> > specialDict)
    {
        if (!(femaleThing is Pawn femalePawn))
        {
            return(false);
        }

        if (malePawn == femalePawn)
        {
            return(false);
        }

        if (!specialDict.ContainsKey(femalePawn.kindDef))
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "not a valid mate"
                );
            return(false);
        }

        if (femalePawn.Downed)
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "female downed"
                );
            return(false);
        }

        if (!femalePawn.CanCasuallyInteractNow())
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "cannot interact casually with female"
                );
            return(false);
        }

        if (femalePawn.IsForbidden(malePawn))
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "female is forbidden"
                );
            return(false);
        }

        if (femalePawn.Faction != malePawn.Faction)
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "not same faction"
                );
            return(false);
        }

        if (!PawnUtility.FertileMateTarget(malePawn, femalePawn))
        {
            DogsMateMod.Debug(
                $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
                $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
                "female is not fertile"
                );
            return(false);
        }

        DogsMateMod.Debug(
            $"male=<{malePawn.ToStringSafe()}={malePawn.kindDef.ToStringSafe()}> " +
            $"female=<{femalePawn.ToStringSafe()}={femalePawn.kindDef.ToStringSafe()}> " +
            "is valid pair"
            );
        return(true);
    }
Example #3
0
 public static void Postfix(Job __result, Pawn pawn)
 {
     if (__result == null)
     {
         if (!(Genital_Helper.has_penis(pawn) || Genital_Helper.has_penis_infertile(pawn)) || !pawn.ageTracker.CurLifeStage.reproductive)
         {
             __result = null;
         }
         Predicate <Thing> validator = delegate(Thing t)
         {
             Pawn pawn3 = t as Pawn;
             return(!pawn3.Downed && pawn3.CanCasuallyInteractNow(false) && !pawn3.IsForbidden(pawn) && pawn3.Faction == pawn.Faction && PawnUtility.FertileMateTarget(pawn, pawn3));
         };
         Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(pawn.def), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 30f, validator, null, 0, -1, false, RegionType.Set_Passable, false);
         if (pawn2 == null)
         {
             __result = null;
         }
         __result = new Job(JobDefOf.Mate, pawn2);
     }
 }