mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Copy RJW parts across enzygotic siblings at birth
This commit is contained in:
		
							parent
							
								
									ff7a06af99
								
							
						
					
					
						commit
						aab02f07fb
					
				
					 5 changed files with 113 additions and 19 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -389,6 +389,23 @@ namespace RJW_Menstruation
 | 
				
			||||||
            cachedcolor = Colors.CMYKLerp(parent?.pawn?.story?.SkinColor ?? Color.white, Props.BlackNippleColor, Alpha);
 | 
					            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()
 | 
					        public string DebugInfo()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return "Increase: " + breastSizeIncreased +
 | 
					            return "Increase: " + breastSizeIncreased +
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 class Egg : IExposable
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            public bool fertilized;
 | 
					            public bool fertilized;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,9 @@ namespace RJW_Menstruation
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class Hediff_MultiplePregnancy : Hediff_BasePregnancy
 | 
					    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()
 | 
					        public override void DiscoverPregnancy()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            PregnancyThought();
 | 
					            PregnancyThought();
 | 
				
			||||||
| 
						 | 
					@ -185,6 +188,68 @@ namespace RJW_Menstruation
 | 
				
			||||||
            //baby.story.birthLastName = last_name;
 | 
					            //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
 | 
					        // From RJW's trait code
 | 
				
			||||||
        protected List<Trait> GetInheritableTraits(Pawn mother, Pawn father)
 | 
					        protected List<Trait> GetInheritableTraits(Pawn mother, Pawn father)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -279,13 +344,17 @@ namespace RJW_Menstruation
 | 
				
			||||||
            return traitpool;
 | 
					            return traitpool;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void ExposeData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.ExposeData();
 | 
				
			||||||
 | 
					            Scribe_Collections.Look(ref zygotes, "zygotes", keyLookMode: LookMode.Reference, valueLookMode: LookMode.Reference);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override void GenerateBabies()
 | 
					        protected override void GenerateBabies()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            AddNewBaby(pawn, father);
 | 
					            AddNewBaby(pawn, father);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        protected void Train(Pawn baby, Pawn mother)
 | 
					        protected void Train(Pawn baby, Pawn mother)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (xxx.is_human(baby) || baby.Faction != Faction.OfPlayer) return;
 | 
					            if (xxx.is_human(baby) || baby.Faction != Faction.OfPlayer) return;
 | 
				
			||||||
| 
						 | 
					@ -348,10 +417,7 @@ namespace RJW_Menstruation
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int division = 1;
 | 
					            int division = 1;
 | 
				
			||||||
            HairDef firsthair = null;
 | 
					            Pawn firstbaby = null;
 | 
				
			||||||
            Color firsthaircolor = Color.white;
 | 
					 | 
				
			||||||
            BodyTypeDef firstbody = null;
 | 
					 | 
				
			||||||
            CrownType firstcrown = CrownType.Undefined;
 | 
					 | 
				
			||||||
            string firstheadpath = null;
 | 
					            string firstheadpath = null;
 | 
				
			||||||
            string firstHARcrown = null;
 | 
					            string firstHARcrown = null;
 | 
				
			||||||
            int traitSeed = Rand.Int;
 | 
					            int traitSeed = Rand.Int;
 | 
				
			||||||
| 
						 | 
					@ -364,11 +430,8 @@ namespace RJW_Menstruation
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (i == 0 && baby.story != null)
 | 
					                    if (i == 0 && baby.story != null)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        firsthair = baby.story.hairDef;
 | 
					                        firstbaby = baby;
 | 
				
			||||||
                        firsthaircolor = baby.story.hairColor;
 | 
					 | 
				
			||||||
                        request.FixedGender = baby.gender;
 | 
					                        request.FixedGender = baby.gender;
 | 
				
			||||||
                        firstbody = baby.story.bodyType;
 | 
					 | 
				
			||||||
                        firstcrown = baby.story.crownType;
 | 
					 | 
				
			||||||
                        firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
 | 
					                        firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
 | 
				
			||||||
                        if (firstheadpath == null)
 | 
					                        if (firstheadpath == null)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
| 
						 | 
					@ -386,26 +449,25 @@ namespace RJW_Menstruation
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (baby.story != null)
 | 
					                        if (baby.story != null)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            baby.story.hairDef = firsthair;
 | 
					                            baby.story.hairDef = firstbaby.story.hairDef;
 | 
				
			||||||
                            baby.story.hairColor = firsthaircolor;
 | 
					                            baby.story.hairColor = firstbaby.story.hairColor;
 | 
				
			||||||
                            baby.story.bodyType = firstbody;
 | 
					                            baby.story.bodyType = firstbaby.story.bodyType;
 | 
				
			||||||
                            baby.story.crownType = firstcrown;
 | 
					                            baby.story.crownType = firstbaby.story.crownType;
 | 
				
			||||||
                            baby.story.SetMemberValue("headGraphicPath", firstheadpath);
 | 
					                            baby.story.SetMemberValue("headGraphicPath", firstheadpath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (Configurations.HARActivated && baby.IsHAR())
 | 
					                            if (Configurations.HARActivated && baby.IsHAR())
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                baby.SetHARCrown(firstHARcrown);
 | 
					                                baby.SetHARCrown(firstHARcrown);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (firstbaby != null) zygotes?.Add(baby, firstbaby);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (baby != null) babies.Add(baby);
 | 
					                if (baby != null) babies.Add(baby);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -665,8 +727,11 @@ namespace RJW_Menstruation
 | 
				
			||||||
            pawn.story.traits.allTraits = selectedTraits;
 | 
					            pawn.story.traits.allTraits = selectedTraits;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override void Initialize(Pawn mother, Pawn dad)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.Initialize(mother, dad);
 | 
				
			||||||
 | 
					            zygotes = new Dictionary<Pawn, Pawn>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					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.
 | 
					 - 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.
 | 
					 - Designed for RJW 5.0.0, but should work with previous versions.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue