mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Copy Animal Genetics properties for enzygotic siblings
This commit is contained in:
parent
9e8dcc0540
commit
511e5286dc
2 changed files with 21 additions and 8 deletions
|
@ -1,4 +1,6 @@
|
|||
using AnimalGenetics;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Menstruation
|
||||
|
@ -10,12 +12,6 @@ namespace RJW_Menstruation
|
|||
GeneticInformation motherGeneticInformation = mother?.AnimalGenetics();
|
||||
GeneticInformation fatherGeneticInformation = father?.AnimalGenetics();
|
||||
|
||||
if (fatherGeneticInformation == null && motherGeneticInformation != null)
|
||||
{
|
||||
FatherGeneticInformation fatherGeneticInformationComp = pregnancy.TryGetComp<FatherGeneticInformation>();
|
||||
fatherGeneticInformation = fatherGeneticInformationComp?.GeneticInformation;
|
||||
}
|
||||
|
||||
ParentReferences.Push(new ParentReferences.Record { Mother = motherGeneticInformation, Father = fatherGeneticInformation });
|
||||
}
|
||||
|
||||
|
@ -23,5 +19,22 @@ namespace RJW_Menstruation
|
|||
{
|
||||
ParentReferences.Pop();
|
||||
}
|
||||
|
||||
public static void CopyGenes(Pawn baby, Pawn original)
|
||||
{
|
||||
Dictionary<StatDef, GeneRecord> babyRecords = baby.AnimalGenetics()?.GeneRecords;
|
||||
Dictionary<StatDef, GeneRecord> originalRecords = original.AnimalGenetics()?.GeneRecords;
|
||||
|
||||
if (babyRecords == null || originalRecords == null) return;
|
||||
|
||||
foreach(KeyValuePair<StatDef, GeneRecord> record in originalRecords)
|
||||
{
|
||||
GeneRecord originalRecord = record.Value;
|
||||
if (!babyRecords.TryGetValue(record.Key, out GeneRecord babyRecord)) continue; // Shouldn't fail, but best to be safe
|
||||
|
||||
babyRecord.Parent = originalRecord.Parent;
|
||||
babyRecord.Value = originalRecord.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -455,9 +455,9 @@ namespace RJW_Menstruation
|
|||
baby.story.SetMemberValue("headGraphicPath", firstheadpath);
|
||||
|
||||
if (baby.IsHAR())
|
||||
{
|
||||
HARCompatibility.CopyHARProperties(baby, firstbaby);
|
||||
}
|
||||
if (Configurations.AnimalGeneticsActivated)
|
||||
AnimalGeneticsCompatibility.CopyGenes(baby, firstbaby);
|
||||
}
|
||||
}
|
||||
babies.Add(baby);
|
||||
|
|
Loading…
Reference in a new issue