mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Refactor the impregnation patch postfix to use MaxByWithFallback, too
This commit is contained in:
		
							parent
							
								
									e023938a41
								
							
						
					
					
						commit
						4fc1d6b4ab
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		| 
						 | 
					@ -57,11 +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;
 | 
				
			||||||
            IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
 | 
					            Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxByWithFallback(hediff => hediff.loadID);
 | 
				
			||||||
            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 (newestPregnancy == null || pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
 | 
				
			||||||
            else __state.Pregnancy = newestPregnancy;
 | 
					            else __state.Pregnancy = newestPregnancy;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue