mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	After impregnation, re-check womb pregnancies in case RJW did something to them
This commit is contained in:
		
							parent
							
								
									acfee52dd8
								
							
						
					
					
						commit
						57df60d62c
					
				
					 3 changed files with 27 additions and 25 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -982,21 +982,7 @@ namespace RJW_Menstruation
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
            InitOvary();
 | 
			
		||||
 | 
			
		||||
            if (pregnancy == null)
 | 
			
		||||
            {
 | 
			
		||||
                // If this womb isn't marked pregnant, search for pregnancies that have no womb and claim one
 | 
			
		||||
                foreach (Hediff_BasePregnancy preg in Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>())
 | 
			
		||||
                {
 | 
			
		||||
                    if (preg.GetMenstruationComp() == null)
 | 
			
		||||
                    {
 | 
			
		||||
                        currentIntervalHours = (int)preg.GestationHours();
 | 
			
		||||
                        curStage = Stage.Pregnant;
 | 
			
		||||
                        pregnancy = preg;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            TakeLoosePregnancy();
 | 
			
		||||
 | 
			
		||||
            //Log.Message(Pawn.Label + " - Initialized menstruation comp");
 | 
			
		||||
            loaded = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -1764,6 +1750,23 @@ namespace RJW_Menstruation
 | 
			
		|||
            return stage;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Searches for an RJW pregnancy unclaimed by any womb and put it in this one
 | 
			
		||||
        public void TakeLoosePregnancy()
 | 
			
		||||
        {
 | 
			
		||||
            if (pregnancy != null) return;
 | 
			
		||||
 | 
			
		||||
            pregnancy =
 | 
			
		||||
                Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Except(
 | 
			
		||||
                    Pawn.GetMenstruationComps().Select(comp => comp.pregnancy).Where(preg => preg != null)
 | 
			
		||||
                    ).FirstOrDefault();
 | 
			
		||||
            if (pregnancy != null)
 | 
			
		||||
            {
 | 
			
		||||
                currentIntervalHours = (int)pregnancy.GestationHours();
 | 
			
		||||
                curStage = Stage.Pregnant;
 | 
			
		||||
                curStageHrs = 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CopyCycleProperties(HediffComp_Menstruation original)
 | 
			
		||||
        {
 | 
			
		||||
            cycleSpeed = original.cycleSpeed;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ using System.Reflection;
 | 
			
		|||
using System.Reflection.Emit;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using Verse;
 | 
			
		||||
using static RJW_Menstruation.HediffComp_Menstruation;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Menstruation
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -15,15 +16,12 @@ namespace RJW_Menstruation
 | 
			
		|||
    [HarmonyPatch(typeof(PregnancyHelper), nameof(PregnancyHelper.impregnate))]
 | 
			
		||||
    public static class Impregnate_Patch
 | 
			
		||||
    {
 | 
			
		||||
        public static bool Prefix(SexProps props, out HediffComp_Menstruation __state)
 | 
			
		||||
        public static bool Prefix(SexProps props)
 | 
			
		||||
        {
 | 
			
		||||
            xxx.rjwSextype sextype = props.sexType;
 | 
			
		||||
            Pawn pawn = props.pawn;
 | 
			
		||||
            Pawn partner = props.partner;
 | 
			
		||||
 | 
			
		||||
            if (PregnancyHelper.GetPregnancy(partner) is Hediff_BasePregnancy oldestPregnancy) __state = oldestPregnancy.GetMenstruationComp();
 | 
			
		||||
            else __state = null;
 | 
			
		||||
 | 
			
		||||
            if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return true;
 | 
			
		||||
 | 
			
		||||
            if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -52,15 +50,16 @@ namespace RJW_Menstruation
 | 
			
		|||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void Postfix(SexProps props, HediffComp_Menstruation __state)
 | 
			
		||||
        public static void Postfix(SexProps props)
 | 
			
		||||
        {
 | 
			
		||||
            if (__state == null || __state.Pregnancy != null) return;
 | 
			
		||||
            // It was pregnant, but not anymore. This probably means the pregnancy was destroyed by e.g. a mech implant
 | 
			
		||||
            Pawn pawn = props.partner;
 | 
			
		||||
            Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxByWithFallback(hediff => hediff.loadID);
 | 
			
		||||
 | 
			
		||||
            if (newestPregnancy == null || pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
 | 
			
		||||
            else __state.Pregnancy = newestPregnancy;
 | 
			
		||||
            // A pregnancy might have been destroyed by a mech or insect implantation, so double-check them all
 | 
			
		||||
            foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
 | 
			
		||||
            {
 | 
			
		||||
                _ = comp.Pregnancy; // get_Pregnancy will do any removals
 | 
			
		||||
                comp.TakeLoosePregnancy();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue