Exemplo n.º 1
0
        private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition)
        {
            if (__instance == null)
            {
                return(true);
            }
            var lov = __instance as JobDriver_Lovin;

            //Edited by nizhuan-jjr: The PostFix method cannot do this.
            if ((lov != null) && (condition == JobCondition.Succeeded))
            {
                //--Log.Message("[RJW]patches_lovin::on_cleanup_driver is called0");
                var par = find_partner(lov);
                xxx.aftersex(lov.pawn, par, false, true);                 // note that JobDriver_Lovin will be called for both pawns
                //lov.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(lov.pawn);
                //if (par != null)
                //    par.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(par);
            }
            else if (xxx.RomanceDiversifiedIsActive && condition == JobCondition.Succeeded && __instance.GetType() == JobDriverDoLovinCasual)
            {
                //--Log.Message("[RJW]patches_lovin::on_cleanup_driver is called1");
                var any_ins         = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
                var casuallovin_par = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
                if (casuallovin_par != null)
                {
                    xxx.aftersex(__instance.pawn, casuallovin_par, false, true);                     // note that JobDriver_DoLovinCasual will be called for both pawns
                    //lov.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(lov.pawn);
                    //casuallovin_par.mindState.canLovinTick = Find.TickManager.TicksGame + xxx.generate_min_ticks_to_next_lovin(casuallovin_par);
                }
            }
            return(true);
        }
        public static string GetName(JobDriver __instance)
        {
            var str = $"{__instance.GetType().Name}";

            return(ByPawn
                ? $"{__instance.pawn.KindLabel} - {str}"
                : str);
        }
Exemplo n.º 3
0
 public static bool Prefix(JobDriver __instance)
 {
     if (TimeControlBase.partialTick < 1.0 &&
         (
             (TimeControlSettings.scalePawns && TimeControlSettings.slowWork &&
              !(__instance is JobDriver_TendPatient
                //|| (__instance is JobDriver_Wait || __instance is JobDriver_WaitDowned || __instance is JobDriver_WaitMaintainPosture)
                || (__instance is JobDriver_Lovin || __instance is JobDriver_Mate)
                // A RimWorld of Magic
                || __instance.GetType().Name == "TMJobDriver_CastAbilityVerb" ||
                __instance.GetType().Name == "TMJobDriver_CastAbilitySelf" ||
                __instance.GetType().Name == "JobDriver_GotoAndCast")
             ) ||
             (__instance is JobDriver_ChatWithPrisoner || __instance is JobDriver_Tame)
         ))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
        public static IEnumerable <Toil> PickToils(JobDriver toilMaker)
        {
            var method = toilMaker.GetType().GetMethod("MakeNewToils", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IEnumerable <Toil>)method.Invoke(toilMaker, new object[] { }));
        }
Exemplo n.º 5
0
        private static bool on_cleanup_driver(JobDriver __instance, JobCondition condition)
        {
            if (__instance == null)
            {
                return(true);
            }

            if (condition == JobCondition.Succeeded)
            {
                Pawn pawn    = __instance.pawn;
                Pawn partner = null;

                //Log.Message("[RJW]patches_lovin::on_cleanup_driver" + xxx.get_pawnname(pawn));

                //[RF] Rational Romance [1.0] loving
                if (xxx.RomanceDiversifiedIsActive && __instance.GetType() == JobDriverDoLovinCasual)
                {
                    // not sure RR can even cause pregnancies but w/e
                    var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
                    partner = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
                    Log.Message("[RJW]patches_lovin::on_cleanup_driver RomanceDiversified/RationalRomance:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
                }
                //Vanilla loving
                else if (__instance.GetType() == JobDriverLovin)
                {
                    var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
                    partner = (Pawn)(__instance.GetType().GetProperty("Partner", any_ins).GetValue(__instance, null));
                    //CnP loving
                    if (xxx.RimWorldChildrenIsActive && RJWPregnancySettings.humanlike_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_human(partner))
                    {
                        Log.Message("[RJW]patches_lovin:: RimWorldChildren/ChildrenAndPregnancy pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
                        PregnancyHelper.cleanup_CnP(pawn);
                        PregnancyHelper.cleanup_CnP(partner);
                    }
                    else
                    {
                        Log.Message("[RJW]patches_lovin:: JobDriverLovin pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
                    }
                }
                //Vanilla mating
                else if (__instance.GetType() == JobDriverMate)
                {
                    var any_ins = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
                    partner = (Pawn)(__instance.GetType().GetProperty("Female", any_ins).GetValue(__instance, null));
                    Log.Message("[RJW]patches_lovin:: JobDriverMate pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
                }
                else
                {
                    return(true);
                }

                // TODO: Doing TryUseCondom here is a bit weird... it should happen before.
                var usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(partner);

                //vanilla will probably be f****d up for non humanlikes... but only humanlikes do loving, right?
                //if rjw pregnancy enabled, remove vanilla for:
                //human-human
                //animal-animal
                //bestiality
                //always remove when someone is insect or mech
                if (RJWPregnancySettings.humanlike_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_human(partner) ||
                    RJWPregnancySettings.animal_pregnancy_enabled && xxx.is_animal(pawn) && xxx.is_animal(partner) ||
                    (RJWPregnancySettings.bestial_pregnancy_enabled && xxx.is_human(pawn) && xxx.is_animal(partner) ||
                     RJWPregnancySettings.bestial_pregnancy_enabled && xxx.is_animal(pawn) && xxx.is_human(partner)) ||
                    xxx.is_insect(pawn) || xxx.is_insect(partner) || xxx.is_mechanoid(pawn) || xxx.is_mechanoid(partner)
                    )
                {
                    Log.Message("[RJW]patches_lovin::on_cleanup_driver vanilla pregnancy:" + xxx.get_pawnname(pawn) + "+" + xxx.get_pawnname(partner));
                    PregnancyHelper.cleanup_vanilla(pawn);
                    PregnancyHelper.cleanup_vanilla(partner);
                }

                SexUtility.ProcessSex(pawn, partner, usedCondom, false, true);
            }
            return(true);
        }