mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Babies inherit parent traits
This commit is contained in:
		
							parent
							
								
									84c1d12cff
								
							
						
					
					
						commit
						680af9d3af
					
				
					 2 changed files with 92 additions and 18 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -314,7 +314,6 @@ namespace RJW_Menstruation
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (xxx.is_human(baby))
 | 
					                if (xxx.is_human(baby))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    List<Trait> traitpool = new List<Trait>();
 | 
					 | 
				
			||||||
                    baby.SetMother(mother);
 | 
					                    baby.SetMother(mother);
 | 
				
			||||||
                    if (mother != father)
 | 
					                    if (mother != father)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
| 
						 | 
					@ -325,22 +324,97 @@ namespace RJW_Menstruation
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
 | 
					                    // re-use the trait code from base RJW's rjw.Hediff_BasePregnancy.GenerateBabies()
 | 
				
			||||||
                    //{
 | 
					                    List<Trait> traitpool = new List<Trait>();
 | 
				
			||||||
                    //    foreach (Trait momtrait in pawn.story.traits.allTraits)
 | 
					                    List<Trait> momtraits = new List<Trait>();
 | 
				
			||||||
                    //    {
 | 
					                    List<Trait> poptraits = new List<Trait>();
 | 
				
			||||||
                    //        if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName))
 | 
					                    List<Trait> traits_to_inherit = new List<Trait>();
 | 
				
			||||||
                    //            traitpool.Add(momtrait);
 | 
					                    System.Random rd = new System.Random();
 | 
				
			||||||
                    //    }
 | 
					                    int rand_trait_index = 0;
 | 
				
			||||||
                    //}
 | 
					                    float max_num_momtraits_inherited = RJWPregnancySettings.max_num_momtraits_inherited;
 | 
				
			||||||
                    //if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
 | 
					                    float max_num_poptraits_inherited = RJWPregnancySettings.max_num_poptraits_inherited;
 | 
				
			||||||
                    //{
 | 
					                    float max_num_traits_inherited = max_num_momtraits_inherited + max_num_poptraits_inherited;
 | 
				
			||||||
                    //    foreach (Trait poptrait in father.story.traits.allTraits)
 | 
					                    int i = 1;
 | 
				
			||||||
                    //    {
 | 
					                    int j = 1;
 | 
				
			||||||
                    //        if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName))
 | 
					                    if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
 | 
				
			||||||
                    //            traitpool.Add(poptrait);
 | 
					                    {
 | 
				
			||||||
                    //    }
 | 
					                        foreach (Trait momtrait in pawn.story.traits.allTraits)
 | 
				
			||||||
                    //}
 | 
					                        {
 | 
				
			||||||
 | 
					                            if(!non_genetic_traits.Contains(momtrait.def.defName) && !momtrait.ScenForced)
 | 
				
			||||||
 | 
					                                momtraits.Add(momtrait);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        foreach (Trait poptrait in father.story.traits.allTraits)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if(!non_genetic_traits.Contains(poptrait.def.defName) && !poptrait.ScenForced)
 | 
				
			||||||
 | 
					                                poptraits.Add(poptrait);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if(!momtraits.NullOrEmpty())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        i = 1;
 | 
				
			||||||
 | 
					                        while (momtraits.Count > 0 && i <= max_num_momtraits_inherited)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            rand_trait_index = rd.Next(0, momtraits.Count);
 | 
				
			||||||
 | 
					                            traits_to_inherit.Add(momtraits[rand_trait_index]);
 | 
				
			||||||
 | 
					                            momtraits.RemoveAt(rand_trait_index);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if(!poptraits.NullOrEmpty())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        j = 1;
 | 
				
			||||||
 | 
					                        while (poptraits.Count > 0 && j <= max_num_poptraits_inherited)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            rand_trait_index = rd.Next(0, poptraits.Count);
 | 
				
			||||||
 | 
					                            traits_to_inherit.Add(poptraits[rand_trait_index]);
 | 
				
			||||||
 | 
					                            poptraits.RemoveAt(rand_trait_index);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if(poptraits.NullOrEmpty() || momtraits.NullOrEmpty())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        foreach(Trait traits in traits_to_inherit)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            traitpool.Add(traits);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (traits_to_inherit.Count() != max_num_traits_inherited)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (momtraits.Count != 0 && i != max_num_momtraits_inherited)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                while (poptraits != null && momtraits.Count() > 0 && i <= max_num_momtraits_inherited)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    rand_trait_index = rd.Next(0, momtraits.Count);
 | 
				
			||||||
 | 
					                                    if (!traits_to_inherit.Contains(momtraits[rand_trait_index]))
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        traits_to_inherit.Add(momtraits[rand_trait_index]);
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                    momtraits.RemoveAt(rand_trait_index);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (poptraits != null && poptraits.Count != 0 && j != max_num_poptraits_inherited)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                while (poptraits.Count > 0 && i < max_num_poptraits_inherited)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    rand_trait_index = rd.Next(0, poptraits.Count);
 | 
				
			||||||
 | 
					                                    if (!traits_to_inherit.Contains(poptraits[rand_trait_index]))
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        traits_to_inherit.Add(poptraits[rand_trait_index]);
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                    poptraits.RemoveAt(rand_trait_index);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        foreach (Trait traits in traits_to_inherit)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            traitpool.Add(traits);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    updateTraits(baby, traitpool);
 | 
					                    updateTraits(baby, traitpool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue