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 babyRecords = baby.AnimalGenetics()?.GeneRecords; Dictionary originalRecords = original.AnimalGenetics()?.GeneRecords; if (babyRecords == null || originalRecords == null) return; foreach(KeyValuePair 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; } } } }