2022-11-14 16:47:43 +00:00
|
|
|
|
using Verse;
|
|
|
|
|
using rjw;
|
|
|
|
|
using RimWorld;
|
2023-02-21 08:41:26 +00:00
|
|
|
|
using System.Linq;
|
2022-11-14 16:47:43 +00:00
|
|
|
|
|
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
2022-11-20 16:33:50 +00:00
|
|
|
|
public class Gene_ExtraVagina : RJW_Gene
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
internal Hediff additional_vagina;
|
|
|
|
|
|
|
|
|
|
//TODO: This works ingame when genes are added, but if there is
|
|
|
|
|
//a gene (e.g. ovipositor) in creation it does not work as expected (only has one genital)
|
|
|
|
|
//Penis works as expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void PostMake()
|
|
|
|
|
{
|
|
|
|
|
base.PostMake();
|
|
|
|
|
|
2023-02-21 08:41:26 +00:00
|
|
|
|
// Some sources add Genes before they fire, e.g. Character Editor
|
|
|
|
|
// This should harden the gene, to solve #19
|
|
|
|
|
if (HasAlreadyTwoVaginas())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 16:47:43 +00:00
|
|
|
|
// Vaginas are only added for female pawns!
|
2022-11-20 16:33:50 +00:00
|
|
|
|
if (GenderUtility.IsFemale(pawn) && additional_vagina == null)
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
CreateAndAddVagina();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostAdd()
|
|
|
|
|
{
|
|
|
|
|
base.PostAdd();
|
|
|
|
|
|
2023-02-21 08:41:26 +00:00
|
|
|
|
// Some sources add Genes before they fire, e.g. Character Editor
|
|
|
|
|
// This should harden the gene, to solve #19
|
|
|
|
|
if (HasAlreadyTwoVaginas())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 16:47:43 +00:00
|
|
|
|
// Vaginas are only added for female pawns!
|
2022-11-20 16:33:50 +00:00
|
|
|
|
if (GenderUtility.IsFemale(pawn) && additional_vagina == null)
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
CreateAndAddVagina();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostRemove()
|
|
|
|
|
{
|
|
|
|
|
base.PostRemove();
|
|
|
|
|
if(additional_vagina != null)
|
|
|
|
|
pawn.health.RemoveHediff(additional_vagina);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void CreateAndAddVagina()
|
|
|
|
|
{
|
|
|
|
|
var correctGene = GenitaliaUtility.GetGenitaliaTypeGeneForPawn(pawn);
|
|
|
|
|
HediffDef vaginaDef = GenitaliaUtility.GetVaginaForGene(correctGene);
|
|
|
|
|
var partBPR = Genital_Helper.get_genitalsBPR(pawn);
|
|
|
|
|
additional_vagina = HediffMaker.MakeHediff(vaginaDef, pawn);
|
|
|
|
|
|
|
|
|
|
var CompHediff = additional_vagina.TryGetComp<rjw.CompHediffBodyPart>();
|
|
|
|
|
if (CompHediff != null)
|
|
|
|
|
{
|
|
|
|
|
CompHediff.initComp(pawn);
|
|
|
|
|
CompHediff.updatesize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pawn.health.AddHediff(additional_vagina, partBPR);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 08:41:26 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2022-11-14 16:47:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|