mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using AnimalGenetics;
|
|
using RimWorld;
|
|
using System.Collections.Generic;
|
|
using Verse;
|
|
|
|
namespace RJW_Menstruation
|
|
{
|
|
public static class AnimalGeneticsCompatibility
|
|
{
|
|
public static void PreConception(Pawn mother, Pawn father)
|
|
{
|
|
GeneticInformation motherGeneticInformation = mother?.AnimalGenetics();
|
|
GeneticInformation fatherGeneticInformation = father?.AnimalGenetics();
|
|
|
|
ParentReferences.Push(new ParentReferences.Record { Mother = motherGeneticInformation, Father = fatherGeneticInformation });
|
|
}
|
|
|
|
public static void PostConception()
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|