mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Catch pawns that are pregnant but not with BasePregnancy (e.g. vanilla animal pregnancy)
This commit is contained in:
		
							parent
							
								
									177f941d93
								
							
						
					
					
						commit
						d98a102d44
					
				
					 3 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -306,6 +306,8 @@ namespace RJW_Menstruation
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
                newNippleProgress = 0f;
 | 
					                newNippleProgress = 0f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (newNippleProgress < 0) newNippleProgress = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (newNippleProgress == nippleProgress) return;    // Nothing to change
 | 
					            if (newNippleProgress == nippleProgress) return;    // Nothing to change
 | 
				
			||||||
            else if (newNippleProgress > nippleProgress)
 | 
					            else if (newNippleProgress > nippleProgress)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,8 +57,9 @@ namespace RJW_Menstruation
 | 
				
			||||||
            if (__state == null || __state.Pregnancy != null) return;
 | 
					            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
 | 
					            // It was pregnant, but not anymore. This probably means the pregnancy was destroyed by e.g. a mech implant
 | 
				
			||||||
            Pawn pawn = props.partner;
 | 
					            Pawn pawn = props.partner;
 | 
				
			||||||
            Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.loadID);
 | 
					            IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
 | 
				
			||||||
            if (newestPregnancy == null) return;
 | 
					            if (!pregnancies.Any()) return;
 | 
				
			||||||
 | 
					            Hediff_BasePregnancy newestPregnancy = pregnancies.MaxBy(hediff => hediff.loadID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
 | 
					            if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
 | 
				
			||||||
            else __state.Pregnancy = newestPregnancy;
 | 
					            else __state.Pregnancy = newestPregnancy;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,9 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static float GetFarthestPregnancyProgress(this Pawn pawn)
 | 
					        public static float GetFarthestPregnancyProgress(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.GestationProgress)?.GestationProgress ?? -1;
 | 
					            IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
 | 
				
			||||||
 | 
					            if (!pregnancies.Any()) return -1;
 | 
				
			||||||
 | 
					            else return pregnancies.MaxBy(hediff => hediff.GestationProgress)?.GestationProgress ?? -1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static float GetPregnancyProgress(this HediffComp_Menstruation comp)
 | 
					        public static float GetPregnancyProgress(this HediffComp_Menstruation comp)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue