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_ExtraBreasts : RJW_Gene
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
internal Hediff additional_breasts;
|
|
|
|
|
|
|
|
|
|
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 (HasAlreadyTwoBreasts())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 16:33:50 +00:00
|
|
|
|
// Tits are only added for female pawns!
|
|
|
|
|
if (GenderUtility.IsFemale(pawn) && additional_breasts == null)
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
2022-11-20 16:33:50 +00:00
|
|
|
|
CreateAndAddBreasts();
|
2022-11-14 16:47:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (HasAlreadyTwoBreasts())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 16:33:50 +00:00
|
|
|
|
// Tits are only added for female pawns!
|
|
|
|
|
if (GenderUtility.IsFemale(pawn) && additional_breasts == null)
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
2022-11-20 16:33:50 +00:00
|
|
|
|
CreateAndAddBreasts();
|
2022-11-14 16:47:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostRemove()
|
|
|
|
|
{
|
|
|
|
|
base.PostRemove();
|
|
|
|
|
if(additional_breasts != null)
|
|
|
|
|
pawn.health.RemoveHediff(additional_breasts);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 16:33:50 +00:00
|
|
|
|
internal void CreateAndAddBreasts()
|
2022-11-14 16:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
var correctGene = GenitaliaUtility.GetGenitaliaTypeGeneForPawn(pawn);
|
|
|
|
|
var breastDef = GenitaliaUtility.GetBreastsForGene(correctGene);
|
|
|
|
|
var partBPR = Genital_Helper.get_breastsBPR(pawn);
|
|
|
|
|
additional_breasts = HediffMaker.MakeHediff(breastDef, pawn);
|
|
|
|
|
|
|
|
|
|
var CompHediff = additional_breasts.TryGetComp<rjw.CompHediffBodyPart>();
|
|
|
|
|
if (CompHediff != null)
|
|
|
|
|
{
|
|
|
|
|
CompHediff.initComp(pawn);
|
|
|
|
|
CompHediff.updatesize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pawn.health.AddHediff(additional_breasts, partBPR);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 08:41:26 +00:00
|
|
|
|
internal bool HasAlreadyTwoBreasts()
|
|
|
|
|
{
|
|
|
|
|
if (pawn == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
var possible_breasts =
|
|
|
|
|
Genital_Helper.get_AllPartsHediffList(pawn).Where(t => t.def.defName.Contains("breast"));
|
|
|
|
|
|
|
|
|
|
return possible_breasts.Count() >= 2;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 16:47:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|