2022-11-13 17:37:40 +00:00
|
|
|
|
using rjw;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
|
|
|
|
using System.Collections.Generic;
|
2024-06-04 11:08:37 +00:00
|
|
|
|
using rjw.Modules.Interactions.DefModExtensions;
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
|
|
|
|
internal class GenitaliaChanger
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This method changes the pawns genitalia to the given types of genitalia.
|
|
|
|
|
/// All genitals will be changed, e.g. pawns with 2 penises (for whatever reason) or is a futa, all genitals will be changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pawn">the pawn who's genitals will be changed</param>
|
|
|
|
|
/// <param name="penisReplacement">the new type of penis</param>
|
|
|
|
|
/// <param name="vaginaReplacement">the new type of vagina</param>
|
2022-11-14 14:55:52 +00:00
|
|
|
|
/// <param name="anusReplacement">the new type of anus</param>
|
2024-06-04 11:08:37 +00:00
|
|
|
|
public static void ChangeGenitalia(Pawn pawn, HediffDef penisReplacement = null, HediffDef vaginaReplacement = null, HediffDef anusReplacement = null , HediffDef breastsReplacement = null)
|
2022-11-13 17:37:40 +00:00
|
|
|
|
{
|
2022-11-14 14:55:52 +00:00
|
|
|
|
var oldParts = Genital_Helper.get_AllPartsHediffList(pawn);
|
|
|
|
|
BodyPartRecord correctBPR;
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
|
|
|
|
if (!oldParts.NullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
Hediff replacementGenital;
|
|
|
|
|
CompHediffBodyPart CompHediff;
|
|
|
|
|
|
|
|
|
|
foreach (Hediff existingGenital in oldParts)
|
|
|
|
|
{
|
|
|
|
|
if (IsArtificial(existingGenital))
|
|
|
|
|
continue;
|
2022-11-14 14:55:52 +00:00
|
|
|
|
correctBPR = Genital_Helper.get_genitalsBPR(pawn);
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
|
|
|
|
replacementGenital = null;
|
|
|
|
|
CompHediff = null;
|
2024-05-26 23:13:01 +00:00
|
|
|
|
if (Genital_Helper.is_penis(existingGenital) && penisReplacement != null && existingGenital.def != penisReplacement)
|
2022-11-14 14:55:52 +00:00
|
|
|
|
replacementGenital = HediffMaker.MakeHediff(penisReplacement, pawn, correctBPR);
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
2024-05-26 23:13:01 +00:00
|
|
|
|
if (Genital_Helper.is_vagina(existingGenital) && vaginaReplacement != null && existingGenital.def != vaginaReplacement)
|
2022-11-14 14:55:52 +00:00
|
|
|
|
replacementGenital = HediffMaker.MakeHediff(vaginaReplacement, pawn, correctBPR);
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
2024-06-04 11:08:37 +00:00
|
|
|
|
if (is_breast(existingGenital) && breastsReplacement != null && existingGenital.def != breastsReplacement)
|
|
|
|
|
{
|
|
|
|
|
correctBPR = Genital_Helper.get_breastsBPR(pawn);
|
|
|
|
|
replacementGenital = HediffMaker.MakeHediff(breastsReplacement, pawn, correctBPR);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 23:13:01 +00:00
|
|
|
|
if (IsAnus(existingGenital) && anusReplacement != null && existingGenital.def != anusReplacement)
|
2022-11-14 14:55:52 +00:00
|
|
|
|
{
|
|
|
|
|
correctBPR = Genital_Helper.get_anusBPR(pawn);
|
|
|
|
|
replacementGenital = HediffMaker.MakeHediff(anusReplacement, pawn, correctBPR);
|
|
|
|
|
}
|
2022-11-13 17:37:40 +00:00
|
|
|
|
|
|
|
|
|
if (replacementGenital != null)
|
|
|
|
|
{
|
|
|
|
|
CompHediff = replacementGenital.TryGetComp<rjw.CompHediffBodyPart>();
|
|
|
|
|
if (CompHediff != null)
|
|
|
|
|
{
|
|
|
|
|
CompHediff.initComp(pawn);
|
|
|
|
|
CompHediff.updatesize();
|
|
|
|
|
}
|
|
|
|
|
GenderHelper.ChangeSex(pawn, () =>
|
|
|
|
|
{
|
|
|
|
|
pawn.health.RemoveHediff(existingGenital);
|
2022-11-14 14:55:52 +00:00
|
|
|
|
pawn.health.AddHediff(replacementGenital, correctBPR);
|
2022-11-13 17:37:40 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Messages.Message("RJW_Genes_GenitalsNotAlterable".Translate(pawn), pawn, MessageTypeDefOf.SilentInput);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 16:47:43 +00:00
|
|
|
|
public static bool IsAnus(Hediff candidate)
|
2022-11-13 17:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
return candidate.def.defName.ToLower().Contains("anus"); }
|
|
|
|
|
|
2024-06-04 11:08:37 +00:00
|
|
|
|
|
|
|
|
|
public static bool is_breast(Hediff hed)
|
|
|
|
|
{
|
|
|
|
|
if (!GenitalPartExtension.TryGet(hed, out var ext))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ext.family == rjw.Modules.Interactions.Enums.GenitalFamily.Breasts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsArtificial(Hediff candidate)
|
2022-11-13 17:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
return candidate.def.defName.ToLower().Contains("bionic") || candidate.def.defName.ToLower().Contains("archo");
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 16:33:50 +00:00
|
|
|
|
public static void RemoveAllGenitalia(Pawn pawn)
|
|
|
|
|
{
|
|
|
|
|
var parts = Genital_Helper.get_AllPartsHediffList(pawn);
|
|
|
|
|
foreach (var part in parts)
|
|
|
|
|
{
|
|
|
|
|
pawn.health.RemoveHediff(part);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-04 11:08:37 +00:00
|
|
|
|
|
|
|
|
|
|
2022-11-13 17:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|