Actually changed animal genes selection.

This commit is contained in:
Shabakur 2022-11-30 14:26:47 +01:00
parent 3d6c84f66f
commit 2cdde450a4
7 changed files with 24 additions and 39 deletions

Binary file not shown.

View file

@ -11,7 +11,7 @@
<raceNames> <raceNames>
<li> </li> <li> </li>
</raceNames> </raceNames>
For more direct control you can use raceNames directly. For more direct control you can use raceNames directly. Use the defName of the animal. Can also use modded animals.
<pawnKindNames> <pawnKindNames>
<li> </li> <li> </li>
@ -25,7 +25,7 @@
<genes> <genes>
<li>Ears_Floppy</li> <li>Ears_Floppy</li>
</genes> </genes>
The genes which may be inherited. The genes which may be inherited. Use the defName of the gene, you can also add modded genes.
<genechances> <genechances>
<li>0.9</li> <li>0.9</li>

Binary file not shown.

View file

@ -12,51 +12,36 @@ namespace RJW_BGS
{ {
public static List<GeneDef> AnimalInheritedGenes(Pawn father, Pawn mother) 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>(); List<GeneDef> genelist = new List<GeneDef>();
if (father != null && !father.RaceProps.Humanlike) if (father != null && !father.RaceProps.Humanlike)
{ {
PawnKindDef pawnKindDef = father.kindDef; return SelectGenes(father);
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);
}
}
} }
if (mother != null && !mother.RaceProps.Humanlike) if (mother != null && !mother.RaceProps.Humanlike)
{ {
PawnKindDef pawnKindDef = mother.kindDef; return SelectGenes(mother);
RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef); //PawnKindDef pawnKindDef = mother.kindDef;
if (raceGeneDef != null) //RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef);
{ //if (raceGeneDef != null)
GeneDef gene = null; //{
// GeneDef gene = null;
//In case you hit a modded gene not currently active try again. //In case you hit a modded gene not currently active try again.
for (int i = 0; i < 50 || gene == null; i++) // for (int i = 0; i < 50 || gene == null; i++)
{ // {
if (raceGeneDef.genes.Any()) // if (raceGeneDef.genes.Any())
{ // {
gene = DefDatabase<GeneDef>.GetNamed(raceGeneDef.genes.RandomElement()); // gene = DefDatabase<GeneDef>.GetNamed(raceGeneDef.genes.RandomElement());
} // }
} // }
if (gene != null) // if (gene != null)
{ // {
genelist.Add(gene); // genelist.Add(gene);
//
} // }
//
} // }
} }
return genelist; return genelist;
} }

Binary file not shown.