Hardened Extra-Genitalia addition to check for existing items, should fix #19

This commit is contained in:
Vegapnk 2023-02-21 09:41:26 +01:00
parent c187765400
commit 87c7bad919
4 changed files with 103 additions and 0 deletions

View file

@ -1,6 +1,7 @@
using Verse;
using rjw;
using RimWorld;
using System.Linq;
namespace RJW_Genes
{
@ -18,6 +19,13 @@ namespace RJW_Genes
{
base.PostMake();
// Some sources add Genes before they fire, e.g. Character Editor
// This should harden the gene, to solve #19
if (HasAlreadyTwoVaginas())
{
return;
}
// Vaginas are only added for female pawns!
if (GenderUtility.IsFemale(pawn) && additional_vagina == null)
{
@ -29,6 +37,13 @@ namespace RJW_Genes
{
base.PostAdd();
// Some sources add Genes before they fire, e.g. Character Editor
// This should harden the gene, to solve #19
if (HasAlreadyTwoVaginas())
{
return;
}
// Vaginas are only added for female pawns!
if (GenderUtility.IsFemale(pawn) && additional_vagina == null)
{
@ -60,5 +75,15 @@ namespace RJW_Genes
pawn.health.AddHediff(additional_vagina, partBPR);
}
internal bool HasAlreadyTwoVaginas()
{
if (pawn == null)
return false;
var possible_breasts =
Genital_Helper.get_AllPartsHediffList(pawn).Where(t => Genital_Helper.is_vagina(t));
return possible_breasts.Count() >= 2;
}
}
}