Copy RJW parts across enzygotic siblings at birth

This commit is contained in:
lutepickle 2022-07-27 11:49:57 -07:00
parent ff7a06af99
commit aab02f07fb
5 changed files with 113 additions and 19 deletions

Binary file not shown.

View File

@ -389,6 +389,23 @@ namespace RJW_Menstruation
cachedcolor = Colors.CMYKLerp(parent?.pawn?.story?.SkinColor ?? Color.white, Props.BlackNippleColor, Alpha);
}
public void CopyBreastProperties(HediffComp_Breast original)
{
alphaPermanent = original.alphaPermanent;
alphaCurrent = original.alphaCurrent;
alpha = original.alpha;
areolaSizePermanent = original.areolaSizePermanent;
areolaSizeCurrent = original.areolaSizeCurrent;
areolaSize = original.areolaSize;
nippleSizePermanent = original.nippleSizePermanent;
nippleSizeCurrent = original.nippleSizeCurrent;
nippleSize = original.nippleSize;
originalpha = original.originalpha;
originareola = original.originareola;
originnipple = original.originnipple;
cachedcolor = original.cachedcolor;
}
public string DebugInfo()
{
return "Increase: " + breastSizeIncreased +

View File

@ -1792,6 +1792,14 @@ namespace RJW_Menstruation
}
}
public void CopyCycleProperties(HediffComp_Menstruation original)
{
cycleSpeed = original.cycleSpeed;
cycleVariability = original.cycleVariability;
ovarypower = original.ovarypower;
crampPain = original.crampPain;
}
public class Egg : IExposable
{
public bool fertilized;

View File

@ -9,6 +9,9 @@ namespace RJW_Menstruation
{
public class Hediff_MultiplePregnancy : Hediff_BasePregnancy
{
//public List<Pawn> zygotes;
public Dictionary<Pawn, Pawn> zygotes; // Each pawn and who they split from
public override void DiscoverPregnancy()
{
PregnancyThought();
@ -185,6 +188,68 @@ namespace RJW_Menstruation
//baby.story.birthLastName = last_name;
}
protected void CopyBodyPartProperties(Hediff part, Hediff originalPart)
{
CompHediffBodyPart comp = part.TryGetComp<CompHediffBodyPart>();
CompHediffBodyPart originalComp = originalPart.TryGetComp<CompHediffBodyPart>();
if (comp != null && originalPart != null)
{
// the string properties should be the same between both pawns anyways, besides the name of the owner
part.Severity = originalPart.Severity;
comp.SizeBase = originalComp.SizeBase;
comp.SizeOwner = originalComp.SizeOwner;
// comp.EffSize seems to be unused
comp.FluidAmmount = originalComp.FluidAmmount;
comp.FluidModifier = originalComp.FluidModifier;
}
HediffComp_Menstruation menstruationComp = part.GetMenstruationComp();
HediffComp_Menstruation originalMenstruationComp = originalPart.GetMenstruationComp();
if (menstruationComp != null && originalMenstruationComp != null)
{
menstruationComp.CopyCycleProperties(originalMenstruationComp);
}
HediffComp_Breast breastComp = part.GetBreastComp();
HediffComp_Breast originalBreastComp = originalPart.GetBreastComp();
if (breastComp != null && originalBreastComp != null)
{
breastComp.CopyBreastProperties(originalBreastComp);
}
}
protected void CopyBodyPartRecord(Pawn baby, Pawn original, BodyPartRecord babyBPR, BodyPartRecord originalBPR)
{
if (babyBPR == null || originalBPR == null) return;
RemoveBabyParts(baby, Genital_Helper.get_PartsHediffList(baby, babyBPR));
foreach (Hediff originalPart in Genital_Helper.get_PartsHediffList(original, originalBPR))
{
Hediff part = SexPartAdder.MakePart(originalPart.def, baby, babyBPR);
CopyBodyPartProperties(part, originalPart);
baby.health.AddHediff(part, babyBPR);
}
}
// Baby is the sibling to be changed, original is the first of the set and the one to copy to the rest.
public virtual void ProcessIdenticalZygote(Pawn baby, Pawn original)
{
// They'll be the same pawnkind, which lets us make a lot of useful assumptions
// However, some RNG might still be involved in genital generation (e.g. futas), so the easiest method is to clear out and re-generate
// A bit wasteful since Hediff_BasePregnancy.PostBirth already redid the genitals
CopyBodyPartRecord(baby, original, Genital_Helper.get_genitalsBPR(baby), Genital_Helper.get_genitalsBPR(original));
CopyBodyPartRecord(baby, original, Genital_Helper.get_breastsBPR(baby), Genital_Helper.get_breastsBPR(original));
CopyBodyPartRecord(baby, original, Genital_Helper.get_anusBPR(baby), Genital_Helper.get_anusBPR(original));
}
public override void PostBirth(Pawn mother, Pawn father, Pawn baby)
{
base.PostBirth(mother, father, baby);
if (zygotes.NullOrEmpty() || !zygotes.TryGetValue(baby, out Pawn original) || baby == original) return;
// Has to happen on birth since RJW redoes the genitals at birth
ProcessIdenticalZygote(baby, original);
}
// From RJW's trait code
protected List<Trait> GetInheritableTraits(Pawn mother, Pawn father)
{
@ -279,13 +344,17 @@ namespace RJW_Menstruation
return traitpool;
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Collections.Look(ref zygotes, "zygotes", keyLookMode: LookMode.Reference, valueLookMode: LookMode.Reference);
}
protected override void GenerateBabies()
{
AddNewBaby(pawn, father);
}
protected void Train(Pawn baby, Pawn mother)
{
if (xxx.is_human(baby) || baby.Faction != Faction.OfPlayer) return;
@ -348,10 +417,7 @@ namespace RJW_Menstruation
);
int division = 1;
HairDef firsthair = null;
Color firsthaircolor = Color.white;
BodyTypeDef firstbody = null;
CrownType firstcrown = CrownType.Undefined;
Pawn firstbaby = null;
string firstheadpath = null;
string firstHARcrown = null;
int traitSeed = Rand.Int;
@ -364,11 +430,8 @@ namespace RJW_Menstruation
{
if (i == 0 && baby.story != null)
{
firsthair = baby.story.hairDef;
firsthaircolor = baby.story.hairColor;
firstbaby = baby;
request.FixedGender = baby.gender;
firstbody = baby.story.bodyType;
firstcrown = baby.story.crownType;
firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
if (firstheadpath == null)
{
@ -386,26 +449,25 @@ namespace RJW_Menstruation
{
if (baby.story != null)
{
baby.story.hairDef = firsthair;
baby.story.hairColor = firsthaircolor;
baby.story.bodyType = firstbody;
baby.story.crownType = firstcrown;
baby.story.hairDef = firstbaby.story.hairDef;
baby.story.hairColor = firstbaby.story.hairColor;
baby.story.bodyType = firstbaby.story.bodyType;
baby.story.crownType = firstbaby.story.crownType;
baby.story.SetMemberValue("headGraphicPath", firstheadpath);
if (Configurations.HARActivated && baby.IsHAR())
{
baby.SetHARCrown(firstHARcrown);
}
}
if (firstbaby != null) zygotes?.Add(baby, firstbaby);
}
}
if (baby != null) babies.Add(baby);
}
return true;
}
@ -665,8 +727,11 @@ namespace RJW_Menstruation
pawn.story.traits.allTraits = selectedTraits;
}
public override void Initialize(Pawn mother, Pawn dad)
{
base.Initialize(mother, dad);
zygotes = new Dictionary<Pawn, Pawn>();
}
}
/// <summary>

View File

@ -1,3 +1,7 @@
Version 1.0.7.1
- Identical twins conceived after this update will have identical sex part sizes, properties, etc. upon being born.
- Race modders: The function Hediff_MultiplePregnancy.ProcessIdenticalZygote is called on every identical sibling when born except the first. Feel free to patch race-specific things into it.
Version 1.0.7.0
- Not save compatible with previous versions. Expect glitches and many red errors if you try. However, things should stabilize eventually.
- Designed for RJW 5.0.0, but should work with previous versions.