mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Merge branch 'main' of https://github.com/vegapnk/RJW-Genes
This commit is contained in:
		
						commit
						a6b82080ec
					
				
					 17 changed files with 778 additions and 9 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										30
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_Base.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_Base.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Defs>
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef Name="Insect_base" Abstract="True">
 | 
				
			||||||
 | 
							<defName>Insect_base</defName> 
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>AG_InsectBlood</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>rjw_genes_ovipositor_genitalia</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef Name="Slime_base" Abstract="True">
 | 
				
			||||||
 | 
							<defName>Slime_base</defName>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>AG_SlimeBlood</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>rjw_genes_slime_genitalia</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>		 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										116
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_Vanilla_Racegroups.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_Vanilla_Racegroups.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,116 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Defs>
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef Name = "Canine">
 | 
				
			||||||
 | 
							<defName>Canine</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Canine_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Ears_Floppy</defName>
 | 
				
			||||||
 | 
									<chance>0.9</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes> 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Insect</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Insect_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Beauty_Ugly</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Feline</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Feline_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Ears_Cat</defName>
 | 
				
			||||||
 | 
									<chance>0.9</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Sleepy</defName>
 | 
				
			||||||
 | 
									<chance>0.25</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>DarkVision</defName>
 | 
				
			||||||
 | 
									<chance>0.25</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					<!--	
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Equine</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Equine_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>StrongStomach</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					-->	
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Dragon</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Dragon_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Unstoppable</defName>
 | 
				
			||||||
 | 
									<chance>0.25</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Headbone_CenterHorn</defName>
 | 
				
			||||||
 | 
									<chance>0.9</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes> 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Rodent</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Rodent_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Fertile</defName>
 | 
				
			||||||
 | 
									<chance>0.25</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes> 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Racoon</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Raccon_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>StrongStomach</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					<!--	
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Needle</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Needle_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>StrongStomach</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes> 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Hemi</defName> 
 | 
				
			||||||
 | 
							<raceGroup>Hemi_Group</raceGroup>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>StrongStomach</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes> 
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										55
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_template.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								Common/Defs/RaceGeneDefs/RaceGeneDefs_template.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Defs>
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
							<defName>Canine</defName>
 | 
				
			||||||
 | 
							defName can be anything you want, as long as it is unique
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<raceGroup>Canine_Group</raceGroup>
 | 
				
			||||||
 | 
							RJW.Racegroupdef, all animals in the raceGroup will be part of this group, RJW race support uses this so those can be used to quickly add a group
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<raceNames>
 | 
				
			||||||
 | 
								<li> </li>
 | 
				
			||||||
 | 
							</raceNames>
 | 
				
			||||||
 | 
							For more direct control you can use raceNames directly. Use the defName of the animal. Can also use modded animals.
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<pawnKindNames>
 | 
				
			||||||
 | 
								<li> </li>
 | 
				
			||||||
 | 
							</pawnKindNames>
 | 
				
			||||||
 | 
							For even more direct control you can use pawnKindNames. 
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							The RaceGeneDef for an animal will first be decided by if it is in the pawnkindNames, after that racenames and lastly racegroup,
 | 
				
			||||||
 | 
							so if there is for a wolf a RaceGeneDef with the canine group and a second which has wolf under raceNames it will always use the second one to determine
 | 
				
			||||||
 | 
							which genes can be inherited
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>Ears_Floppy</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>rjw_genes_slime_genitalia</defName> You can add modded genes which will be ignored if the mod is inactive.
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>		 
 | 
				
			||||||
 | 
							For each gene you need to find the defname and give it a chance to appear. Each gene is rolled independently.
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<!-- You can use parents to have animals get specific genes in addition to the group. So warg children will have a chance for Ears_Floppy, rjw_genes_slime_genitalia and StrongStomach
 | 
				
			||||||
 | 
						<RJW_BGS.RaceGeneDef ParentName = "Canine">
 | 
				
			||||||
 | 
							<defName>Warg</defName>
 | 
				
			||||||
 | 
							<raceNames>
 | 
				
			||||||
 | 
								<li>Warg</li>
 | 
				
			||||||
 | 
							</raceNames>
 | 
				
			||||||
 | 
							<genes>
 | 
				
			||||||
 | 
								<li>
 | 
				
			||||||
 | 
									<defName>StrongStomach</defName>
 | 
				
			||||||
 | 
									<chance>0.5</chance>
 | 
				
			||||||
 | 
								</li>			
 | 
				
			||||||
 | 
							</genes>
 | 
				
			||||||
 | 
						</RJW_BGS.RaceGeneDef>
 | 
				
			||||||
 | 
					--> 
 | 
				
			||||||
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										31
									
								
								Source/Animal_Inheritance/First.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Source/Animal_Inheritance/First.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [StaticConstructorOnStartup]
 | 
				
			||||||
 | 
					    internal static class First
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        static First()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RJWcopy.Racegroupdictbuilder();
 | 
				
			||||||
 | 
					            //foreach (RaceGroupDef raceGroupDef2  in DefDatabase<RaceGroupDef>.AllDefs)      
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                //Log.Message("defName = " + raceGroupDef2.defName);
 | 
				
			||||||
 | 
					            //    if (raceGroupDef2.raceNames != null)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        foreach (string race in raceGroupDef2.raceNames)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					                        //Log.Message(race);
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					           //}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										14
									
								
								Source/Animal_Inheritance/GeneChance.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Source/Animal_Inheritance/GeneChance.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class GeneChance
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string defName;
 | 
				
			||||||
 | 
					        public float chance = 1f;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								Source/Animal_Inheritance/Harmony_Init.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Source/Animal_Inheritance/Harmony_Init.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						[StaticConstructorOnStartup]
 | 
				
			||||||
 | 
						internal static class HarmonyInit
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Token: 0x0600001F RID: 31 RVA: 0x000029A4 File Offset: 0x00000BA4
 | 
				
			||||||
 | 
							static HarmonyInit()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								Harmony harmony = new Harmony("RJW_BGS");
 | 
				
			||||||
 | 
								harmony.PatchAll();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										127
									
								
								Source/Animal_Inheritance/InheritanceUtility.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								Source/Animal_Inheritance/InheritanceUtility.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,127 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class InheritanceUtility
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static List<GeneDef> AnimalInheritedGenes(Pawn father, Pawn mother)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //One parent must be an animal and the other must be human, so only one needs to return
 | 
				
			||||||
 | 
					            List<GeneDef> genelist = new List<GeneDef>();
 | 
				
			||||||
 | 
					            if (father != null && !father.RaceProps.Humanlike)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return SelectGenes(father);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (mother != null && !mother.RaceProps.Humanlike)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return SelectGenes(mother);
 | 
				
			||||||
 | 
					                //PawnKindDef pawnKindDef = mother.kindDef;
 | 
				
			||||||
 | 
					                //RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef);
 | 
				
			||||||
 | 
					                //if (raceGeneDef != null)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    GeneDef gene = null;
 | 
				
			||||||
 | 
					                    //In case you hit a modded gene not currently active try again.
 | 
				
			||||||
 | 
					                //    for (int i = 0; i < 50 || gene == null; i++)
 | 
				
			||||||
 | 
					                //    {
 | 
				
			||||||
 | 
					                //        if (raceGeneDef.genes.Any())
 | 
				
			||||||
 | 
					                //        {
 | 
				
			||||||
 | 
					                //            gene = DefDatabase<GeneDef>.GetNamed(raceGeneDef.genes.RandomElement());
 | 
				
			||||||
 | 
					                //        }
 | 
				
			||||||
 | 
					                //    }
 | 
				
			||||||
 | 
					                //    if (gene != null)
 | 
				
			||||||
 | 
					                //    {
 | 
				
			||||||
 | 
					                //        genelist.Add(gene);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					  //                  }
 | 
				
			||||||
 | 
					    //                
 | 
				
			||||||
 | 
					      //          }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return genelist;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<GeneDef> SelectGenes(Pawn pawn)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<GeneDef> genelist = new List<GeneDef>();
 | 
				
			||||||
 | 
					            PawnKindDef pawnKindDef = pawn.kindDef;
 | 
				
			||||||
 | 
					            RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef);
 | 
				
			||||||
 | 
					            if (raceGeneDef != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                foreach (GeneChance gene in raceGeneDef.genes)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (gene.chance >= Rand.Range(0.01f,1f))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        genelist.Add(DefDatabase<GeneDef>.GetNamed(gene.defName));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return genelist;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void AddGenes(Pawn pawn, List<GeneDef> genes)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            foreach (GeneDef gene in genes)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                pawn.genes.AddGene(gene, false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void NewGenes(Pawn mother, Pawn dad, Pawn baby)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (baby.RaceProps.Humanlike)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (baby.genes == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    baby.genes = new Pawn_GeneTracker(baby);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //Remove the hair and skin genes pawns always start with, should get correct ones from human parent anyway.
 | 
				
			||||||
 | 
					                for (int i = baby.genes.Endogenes.Count - 1; i >= 0; i--)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    baby.genes.RemoveGene(baby.genes.Endogenes[i]);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                List<GeneDef> genes = PregnancyUtility.GetInheritedGenes(dad, mother);
 | 
				
			||||||
 | 
					                List<GeneDef> beastgenes = InheritanceUtility.AnimalInheritedGenes(dad, mother);
 | 
				
			||||||
 | 
					                InheritanceUtility.AddGenes(baby, beastgenes);
 | 
				
			||||||
 | 
					                InheritanceUtility.AddGenes(baby, genes);
 | 
				
			||||||
 | 
					                if(baby.genes.GetFirstEndogeneByCategory(EndogeneCategory.Melanin) == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AddSkinColor(mother, dad, baby);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void AddSkinColor(Pawn mother, Pawn father, Pawn baby)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (mother != null && mother.genes != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                GeneDef gene = mother.genes.GetFirstEndogeneByCategory(EndogeneCategory.Melanin);
 | 
				
			||||||
 | 
					                if (gene != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    baby.genes.AddGene(gene, false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (father != null && father.genes != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                GeneDef gene = father.genes.GetFirstEndogeneByCategory(EndogeneCategory.Melanin);
 | 
				
			||||||
 | 
					                if (gene != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    baby.genes.AddGene(gene, false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Log.Message("Could not find skincolor of " + baby.Name + "'s parents, giving random skincolor.");
 | 
				
			||||||
 | 
					                baby.genes.AddGene(PawnSkinColors.RandomSkinColorGene(baby), false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,46 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [HarmonyPatch(typeof(Hediff_BasePregnancy), "Initialize")]
 | 
				
			||||||
 | 
					    public static class PatchRJWBestialityPregnancyUtility
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [HarmonyPostfix]
 | 
				
			||||||
 | 
					        public static void AddGenes(Pawn mother, Pawn dad, ref Hediff_BasePregnancy __instance)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            foreach (Pawn baby in __instance.babies)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (baby.RaceProps.Humanlike)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (baby.genes == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        baby.genes = new Pawn_GeneTracker(baby);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //Remove the hair and skin genes pawns always start with, should get correct ones from human parent anyway.
 | 
				
			||||||
 | 
					                    for (int i = baby.genes.Endogenes.Count - 1; i >= 0; i--)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        baby.genes.RemoveGene(baby.genes.Endogenes[i]);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    List<GeneDef> genes = PregnancyUtility.GetInheritedGenes(dad, mother);
 | 
				
			||||||
 | 
					                    List<GeneDef> beastgenes = InheritanceUtility.AnimalInheritedGenes(dad, mother);
 | 
				
			||||||
 | 
					                    InheritanceUtility.AddGenes(baby, beastgenes);
 | 
				
			||||||
 | 
					                    InheritanceUtility.AddGenes(baby, genes);
 | 
				
			||||||
 | 
					                    //foreach (GeneDef gene in genes)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    baby.genes.AddGene(gene, false);
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Source/Animal_Inheritance/PatchRJWHediffInsect_Egg.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,41 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					using System.Reflection.Emit;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [HarmonyPatch(typeof(Hediff_InsectEgg), "GiveBirth")]
 | 
				
			||||||
 | 
					    public static class PatchRJWHediffInsect_Egg
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [HarmonyTranspiler]
 | 
				
			||||||
 | 
					        public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            MethodInfo newgenes = AccessTools.Method(typeof(InheritanceUtility), "NewGenes", null, null);
 | 
				
			||||||
 | 
					            FieldInfo implanter = AccessTools.Field(typeof(Hediff_InsectEgg), "implanter");
 | 
				
			||||||
 | 
					            FieldInfo father = AccessTools.Field(typeof(Hediff_InsectEgg), "father");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (CodeInstruction instruction in instructions)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                yield return instruction;
 | 
				
			||||||
 | 
					                if (instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "Void BabyPostBirth(Verse.Pawn, Verse.Pawn, Verse.Pawn)")
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Ldloc_0, null);
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Ldfld, implanter);
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Ldarg_0, null);
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Ldfld, father);
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Ldloc_1, null);
 | 
				
			||||||
 | 
					                    yield return new CodeInstruction(OpCodes.Call, newgenes);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Source/Animal_Inheritance/PatchVanillaPregnancyUtility.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [HarmonyPatch(typeof(PregnancyUtility), "GetInheritedGeneSet", new Type[] 
 | 
				
			||||||
 | 
					    { 
 | 
				
			||||||
 | 
					        typeof(Pawn), 
 | 
				
			||||||
 | 
					        typeof(Pawn),
 | 
				
			||||||
 | 
					        //typeof(bool)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    )]
 | 
				
			||||||
 | 
					    public static class PatchVanillaPregnancyUtility
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [HarmonyPostfix]
 | 
				
			||||||
 | 
					        public static void AnimalInheritedGenes(Pawn father, Pawn mother, ref GeneSet __result)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<GeneDef> genes = InheritanceUtility.AnimalInheritedGenes(father, mother);
 | 
				
			||||||
 | 
					            if (genes.Any())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                foreach (GeneDef gene in genes)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    __result.AddGene(gene);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }        
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										36
									
								
								Source/Animal_Inheritance/RJW_BGSSettings.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Source/Animal_Inheritance/RJW_BGSSettings.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using UnityEngine;
 | 
				
			||||||
 | 
					namespace RJW_Genes.Animal_Inheritance
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class RJW_BGSSettings : ModSettings
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static void DoWindowContents(Rect inRect)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //Copied from RJW settings mostly
 | 
				
			||||||
 | 
					            Rect outRect = new Rect(0f, 30f, inRect.width, inRect.height - 30f);
 | 
				
			||||||
 | 
					            Rect rect = new Rect(0f, 0f, inRect.width - 16f, inRect.height + 300f);
 | 
				
			||||||
 | 
					            //Widgets.BeginScrollView(outRect, ref RJWSettings.scrollPosition, rect, true);
 | 
				
			||||||
 | 
					            Listing_Standard listing_Standard = new Listing_Standard();
 | 
				
			||||||
 | 
					            listing_Standard.maxOneColumn = true;
 | 
				
			||||||
 | 
					            listing_Standard.ColumnWidth = rect.width / 2.05f;
 | 
				
			||||||
 | 
					            listing_Standard.Begin(rect);
 | 
				
			||||||
 | 
					            listing_Standard.Gap(24f);
 | 
				
			||||||
 | 
					            listing_Standard.CheckboxLabeled("enabled", ref enabled, "no function yet", 0f, 1f);
 | 
				
			||||||
 | 
					            //listing_Standard.CheckboxLabeled("sexfrenzy", ref sexfrenzy, "disable the effects", 0f, 1f);
 | 
				
			||||||
 | 
					            listing_Standard.End();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void ExposeData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.ExposeData();
 | 
				
			||||||
 | 
					            Scribe_Values.Look<bool>(ref RJW_BGSSettings.enabled, "enabled", RJW_BGSSettings.enabled, true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static bool enabled;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										27
									
								
								Source/Animal_Inheritance/RJW_BGSSettingsController.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Source/Animal_Inheritance/RJW_BGSSettingsController.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using UnityEngine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_Genes.Animal_Inheritance
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class RJW_BGSSettingsController : Mod
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public RJW_BGSSettingsController(ModContentPack content) : base(content)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.GetSettings<RJW_BGSSettings>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override string SettingsCategory()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return "RJW Genes Animal Gene Inheritance";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public override void DoSettingsWindowContents(Rect inRect)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RJW_BGSSettings.DoWindowContents(inRect);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										151
									
								
								Source/Animal_Inheritance/RJWcopies.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								Source/Animal_Inheritance/RJWcopies.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,151 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class RJWcopy
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //Code copied from rjw, as their code was internal and I need the dictionary to know which genes to add to the pawn
 | 
				
			||||||
 | 
					        public static void Racegroupdictbuilder()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            foreach (PawnKindDef pawnKindDef2 in from pawnKindDef in DefDatabase<PawnKindDef>.AllDefs
 | 
				
			||||||
 | 
					                                                 where pawnKindDef.race.race != null
 | 
				
			||||||
 | 
					                                                 select pawnKindDef)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RaceGroupDef raceGroupDef = null;
 | 
				
			||||||
 | 
									bool temp = TryGetRaceGroupDef(pawnKindDef2, out raceGroupDef);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public static bool TryGetRaceGroupDef(PawnKindDef pawnKindDef, out RaceGroupDef raceGroupDef)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if (RaceGroupByPawnKind.TryGetValue(pawnKindDef, out raceGroupDef))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									return raceGroupDef != null;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								raceGroupDef = GetRaceGroupDefInternal(pawnKindDef);
 | 
				
			||||||
 | 
								RaceGroupByPawnKind.Add(pawnKindDef, raceGroupDef);
 | 
				
			||||||
 | 
								return raceGroupDef != null;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static RaceGroupDef GetRaceGroupDefInternal(PawnKindDef kindDef)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								string raceName = kindDef.race.defName;
 | 
				
			||||||
 | 
								string pawnKindName = kindDef.defName;
 | 
				
			||||||
 | 
								IEnumerable<RaceGroupDef> allDefs = DefDatabase<RaceGroupDef>.AllDefs;
 | 
				
			||||||
 | 
								List<RaceGroupDef> list = allDefs.Where(delegate (RaceGroupDef group)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									List<string> pawnKindNames = group.pawnKindNames;
 | 
				
			||||||
 | 
									return pawnKindNames != null && pawnKindNames.Contains(pawnKindName);
 | 
				
			||||||
 | 
								}).ToList<RaceGroupDef>();
 | 
				
			||||||
 | 
								List<RaceGroupDef> list2 = allDefs.Where(delegate (RaceGroupDef group)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									List<string> raceNames = group.raceNames;
 | 
				
			||||||
 | 
									return raceNames != null && raceNames.Contains(raceName);
 | 
				
			||||||
 | 
								}).ToList<RaceGroupDef>();
 | 
				
			||||||
 | 
								int num = list.Count<RaceGroupDef>() + list2.Count<RaceGroupDef>();
 | 
				
			||||||
 | 
								if (num == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									return null;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if (num == 1)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									return list.Concat(list2).Single<RaceGroupDef>();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								RaceGroupDef result;
 | 
				
			||||||
 | 
								if ((result = list.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if ((result = list2.FirstOrDefault((RaceGroupDef match) => !IsThisMod(match))) == null)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										result = (list.FirstOrDefault<RaceGroupDef>() ?? list2.FirstOrDefault<RaceGroupDef>());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return result;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//slightly modified copy of code above so it also works for racegenedefs
 | 
				
			||||||
 | 
							public static RaceGeneDef GetRaceGenDefInternal(PawnKindDef kindDef)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
								if (kindDef == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
									return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
								string raceName = kindDef.race.defName;
 | 
				
			||||||
 | 
								string pawnKindName = kindDef.defName;
 | 
				
			||||||
 | 
								RaceGroupDef raceGroupDef = GetRaceGroupDef(kindDef);
 | 
				
			||||||
 | 
								//string raceGroupName = GetRaceGroupDef(kindDef).defName;
 | 
				
			||||||
 | 
								IEnumerable<RaceGeneDef> allDefs = DefDatabase<RaceGeneDef>.AllDefs;
 | 
				
			||||||
 | 
								Log.Message(allDefs.Count<RaceGeneDef>().ToString());
 | 
				
			||||||
 | 
								List<RaceGeneDef> list = allDefs.Where(delegate (RaceGeneDef group)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									List<string> pawnKindNames = group.pawnKindNames;
 | 
				
			||||||
 | 
									return pawnKindNames != null && pawnKindNames.Contains(pawnKindName);
 | 
				
			||||||
 | 
								}).ToList<RaceGeneDef>();
 | 
				
			||||||
 | 
								List<RaceGeneDef> list2 = allDefs.Where(delegate (RaceGeneDef group)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									List<string> raceNames = group.raceNames;
 | 
				
			||||||
 | 
									return raceNames != null && raceNames.Contains(raceName);
 | 
				
			||||||
 | 
								}).ToList<RaceGeneDef>();
 | 
				
			||||||
 | 
								List<RaceGeneDef> list3 = new List<RaceGeneDef>();
 | 
				
			||||||
 | 
								if (raceGroupDef != null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Log.Message("found a raceGroupDef");
 | 
				
			||||||
 | 
									Log.Message(raceGroupDef.defName);
 | 
				
			||||||
 | 
									foreach (RaceGeneDef rgd in allDefs)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
										Log.Message(rgd.defName);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
									list3 = allDefs.Where(delegate (RaceGeneDef group)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										String raceGroupDefName = group.raceGroup;
 | 
				
			||||||
 | 
										return raceGroupDefName != null && raceGroupDefName == raceGroupDef.defName;
 | 
				
			||||||
 | 
									}).ToList<RaceGeneDef>();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								RaceGeneDef result = null;
 | 
				
			||||||
 | 
								//First check if there is a matching pawnkinddef then race, then racegroup
 | 
				
			||||||
 | 
								if (list.Any())
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									result = list.RandomElement();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else if (list2.Any() && result == null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									result = list2.RandomElement();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else if (list3.Any() && result == null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									result = list3.RandomElement();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
									result = null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
								return result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							private static RaceGroupDef GetRaceGroupDef(PawnKindDef kindDef)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
								RaceGroupDef raceGroupDef = null;
 | 
				
			||||||
 | 
								bool temp = TryGetRaceGroupDef(kindDef, out raceGroupDef);
 | 
				
			||||||
 | 
								return raceGroupDef;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							private static bool IsThisMod(Def def)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return LoadedModManager.RunningMods.Single((ModContentPack pack) => pack.Name == "RimJobWorld").AllDefs.Contains(def);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							private static readonly IDictionary<PawnKindDef, RaceGroupDef> RaceGroupByPawnKind = new Dictionary<PawnKindDef, RaceGroupDef>();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								Source/Animal_Inheritance/RaceGeneDef.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Source/Animal_Inheritance/RaceGeneDef.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_BGS
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class RaceGeneDef : Def
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public String raceGroup;
 | 
				
			||||||
 | 
					        public List<string> raceNames;
 | 
				
			||||||
 | 
					        public List<string> pawnKindNames;
 | 
				
			||||||
 | 
					        public List<GeneChance> genes;
 | 
				
			||||||
 | 
					        //public List<float> genechances;
 | 
				
			||||||
 | 
					        public String hybridName;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@
 | 
				
			||||||
    <ProjectGuid>{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}</ProjectGuid>
 | 
					    <ProjectGuid>{D7D21B4A-1DA7-41D8-B202-C58CA8FA62AA}</ProjectGuid>
 | 
				
			||||||
    <OutputType>Library</OutputType>
 | 
					    <OutputType>Library</OutputType>
 | 
				
			||||||
    <AppDesignerFolder>Properties</AppDesignerFolder>
 | 
					    <AppDesignerFolder>Properties</AppDesignerFolder>
 | 
				
			||||||
    <RootNamespace>Rjw-Genes</RootNamespace>
 | 
					    <RootNamespace>RJW_Genes</RootNamespace>
 | 
				
			||||||
    <AssemblyName>Rjw-Genes</AssemblyName>
 | 
					    <AssemblyName>Rjw-Genes</AssemblyName>
 | 
				
			||||||
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
 | 
					    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
 | 
				
			||||||
    <FileAlignment>512</FileAlignment>
 | 
					    <FileAlignment>512</FileAlignment>
 | 
				
			||||||
| 
						 | 
					@ -23,18 +23,19 @@
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <Reference Include="0Harmony">
 | 
					    <Reference Include="0Harmony">
 | 
				
			||||||
      <HintPath>..\..\..\..\..\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll</HintPath>
 | 
				
			||||||
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="Assembly-CSharp">
 | 
					    <Reference Include="Assembly-CSharp">
 | 
				
			||||||
      <HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="LicentiaLabs">
 | 
					    <Reference Include="LicentiaLabs">
 | 
				
			||||||
      <HintPath>..\..\licentia-labs\Assemblies\LicentiaLabs.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\licentia-labs-master\Assemblies\LicentiaLabs.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="RJW">
 | 
					    <Reference Include="RJW">
 | 
				
			||||||
      <HintPath>..\..\rjw\1.4\Assemblies\RJW.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\RJW\1.4\Assemblies\RJW.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="System" />
 | 
					    <Reference Include="System" />
 | 
				
			||||||
| 
						 | 
					@ -43,18 +44,28 @@
 | 
				
			||||||
    <Reference Include="System.Data.DataSetExtensions" />
 | 
					    <Reference Include="System.Data.DataSetExtensions" />
 | 
				
			||||||
    <Reference Include="System.Data" />
 | 
					    <Reference Include="System.Data" />
 | 
				
			||||||
    <Reference Include="System.Xml" />
 | 
					    <Reference Include="System.Xml" />
 | 
				
			||||||
    <Reference Include="UnityEngine">
 | 
					 | 
				
			||||||
      <HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
 | 
					 | 
				
			||||||
      <Private>False</Private>
 | 
					 | 
				
			||||||
    </Reference>
 | 
					 | 
				
			||||||
    <None Include="..\About\**" />
 | 
					    <None Include="..\About\**" />
 | 
				
			||||||
    <None Include="..\Common\Defs\Genes\GeneCategories.xml" />
 | 
					    <None Include="..\Common\Defs\Genes\GeneCategories.xml" />
 | 
				
			||||||
    <None Include="..\Common\Defs\Genes\GeneDefs_ExtraGenitaliaEndogenes.xml" />
 | 
					    <None Include="..\Common\Defs\Genes\GeneDefs_ExtraGenitaliaEndogenes.xml" />
 | 
				
			||||||
    <None Include="..\Common\Defs\Genes\GeneDefs_GenitaliaTypeEndogenes.xml" />
 | 
					    <None Include="..\Common\Defs\Genes\GeneDefs_GenitaliaTypeEndogenes.xml" />
 | 
				
			||||||
    <None Include="..\Common\Languages\**" />
 | 
					    <None Include="..\Common\Languages\**" />
 | 
				
			||||||
    <None Include="..\Common\Patches\**" />
 | 
					    <None Include="..\Common\Patches\**" />
 | 
				
			||||||
 | 
					    <Reference Include="UnityEngine.CoreModule">
 | 
				
			||||||
 | 
					      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
 | 
				
			||||||
 | 
					    </Reference>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\First.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\Harmony_Init.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\InheritanceUtility.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\PatchRJWBestialityPregnancyUtility.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\PatchRJWHediffInsect_Egg.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\PatchVanillaPregnancyUtility.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\RaceGeneDef.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\RJWcopies.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\RJW_BGSSettings.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\RJW_BGSSettingsController.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Animal_Inheritance\GeneChance.cs" />
 | 
				
			||||||
    <Compile Include="GeneDefOf.cs" />
 | 
					    <Compile Include="GeneDefOf.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
 | 
					    <Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Breeding\PatchMechBirth.cs" />
 | 
					    <Compile Include="Genes\Breeding\PatchMechBirth.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								Source/Rjw-Genes.csproj.user
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Source/Rjw-Genes.csproj.user
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <ReferencePath>
 | 
				
			||||||
 | 
					    </ReferencePath>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue