Don't allow adding genes to pawns without wombs

This commit is contained in:
lutepickle 2023-01-22 09:44:28 -08:00
parent 9f20f78aab
commit aba80efe58
4 changed files with 24 additions and 0 deletions

Binary file not shown.

View File

@ -192,6 +192,20 @@ namespace RJW_Menstruation
}
}
[HarmonyPatch(typeof(Pawn_GeneTracker), "AddGene", new Type[] {typeof(Gene), typeof(bool)})]
public class AddGene_Patch
{
public static bool Prefix(ref Gene __result, Gene gene, Pawn ___pawn)
{
if(VariousDefOf.WombGenes.Contains(gene.def) && !___pawn.GetMenstruationComps().Any())
{
__result = null;
return false;
}
else return true;
}
}
[HarmonyPatch(typeof(Pawn_GeneTracker), "Notify_GenesChanged")]
public class Notify_GenesChanged_Patch
{

View File

@ -53,6 +53,16 @@ namespace RJW_Menstruation
public static readonly GeneDef QuadOvulation = DefDatabase<GeneDef>.GetNamed("Menstruation_QuadOvulation");
public static readonly GeneDef NoBleeding = DefDatabase<GeneDef>.GetNamed("Menstruation_NoBleeding");
public static readonly HashSet<GeneDef> WombGenes = new HashSet<GeneDef>() {
ShortEggLifetime,
DoubleEggLifetime,
QuadEggLifetime,
NeverEstrus,
FullEstrus,
DoubleOvulation,
QuadOvulation,
NoBleeding };
private static List<ThingDef> allraces = null;
private static List<PawnKindDef> allkinds = null;
private static HashSet<HediffDef> allvaginas = null;