Merge breastadjuster branch

This commit is contained in:
lutepickle 2022-03-16 09:22:42 -07:00
commit 4677db4e93
63 changed files with 111 additions and 11 deletions

2
.gitignore vendored
View file

@ -9,6 +9,7 @@
*.user *.user
*.userosscache *.userosscache
*.sln.docstates *.sln.docstates
#.pdn
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
@ -341,3 +342,4 @@ healthchecksdb
*.psd *.psd
*.dds *.dds
*.pdn

View file

@ -87,6 +87,17 @@
</value> </value>
</Operation> </Operation>
<Operation Class="PatchOperationAdd">
<xpath>Defs/rjw.HediffDef_PartBase[defName="UdderBreasts"]</xpath>
<value>
<comps>
<li Class="RJW_Menstruation.CompProperties_Breast">
<BreastTex>Breasts_Udder/Breast</BreastTex>
<BlacknippleColor>(55,20,0)</BlacknippleColor>
</li>
</comps>
</value>
</Operation>
</Patch> </Patch>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -52,7 +52,9 @@ namespace RJW_Menstruation
protected float nippleSizePermanent = -1f; protected float nippleSizePermanent = -1f;
protected float nippleSizeCurrent = -1f; protected float nippleSizeCurrent = -1f;
protected float nippleSize = -1f; protected float nippleSize = -1f;
protected long ageOfLastBirth = 0;
protected float breastSizeIncreased = 0f; protected float breastSizeIncreased = 0f;
protected string debugGrowthStatus = "(Growth/shrink not yet calculated; run for 1.5h to update)";
protected float originalpha = -1f; protected float originalpha = -1f;
protected float originareola = -1f; protected float originareola = -1f;
protected float originnipple = -1f; protected float originnipple = -1f;
@ -61,6 +63,31 @@ namespace RJW_Menstruation
protected bool pregnant = false; protected bool pregnant = false;
public Action action; public Action action;
protected float BabyHalfAge
{
get
{
float res = parent.pawn.RaceProps.lifeStageAges.ElementAtOrDefault(1).minAge / 2;
if (res == default)
{
if (Configurations.Debug) Log.Warning($"Could not find end age of baby lifestage for {parent.pawn}'s race");
res = 1.2f / 2; // Default to human
}
if (RJWPregnancySettings.phantasy_pregnancy)
res /= GenDate.DaysPerYear;
return res;
}
}
protected void ShrinkBreasts()
{
// The natural rate will take them from full to empty during the second half of their child's babyhood
float shrinkRate = TICKINTERVAL * MAX_BREAST_INCREMENT / (BabyHalfAge * GenDate.TicksPerYear);
float shrinkAmount = Mathf.Min(shrinkRate, breastSizeIncreased);
breastSizeIncreased -= shrinkAmount;
parent.Severity -= shrinkAmount;
}
public float MaxAlpha public float MaxAlpha
{ {
get get
@ -137,6 +164,7 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref nippleSizePermanent, "nippleSizePermanent", DEFAULTNIPPLE, true); Scribe_Values.Look(ref nippleSizePermanent, "nippleSizePermanent", DEFAULTNIPPLE, true);
Scribe_Values.Look(ref nippleSizeCurrent, "nippleSizeCurrent", DEFAULTNIPPLE, true); Scribe_Values.Look(ref nippleSizeCurrent, "nippleSizeCurrent", DEFAULTNIPPLE, true);
Scribe_Values.Look(ref nippleSize, "nippleSize", DEFAULTNIPPLE, true); Scribe_Values.Look(ref nippleSize, "nippleSize", DEFAULTNIPPLE, true);
Scribe_Values.Look(ref ageOfLastBirth, "ageOfLastBirth", ageOfLastBirth, true);
Scribe_Values.Look(ref breastSizeIncreased, "breastSizeIncreased", breastSizeIncreased, true); Scribe_Values.Look(ref breastSizeIncreased, "breastSizeIncreased", breastSizeIncreased, true);
Scribe_Values.Look(ref originalpha, "originalpha", originalpha, true); Scribe_Values.Look(ref originalpha, "originalpha", originalpha, true);
Scribe_Values.Look(ref originareola, "originareola", originareola, true); Scribe_Values.Look(ref originareola, "originareola", originareola, true);
@ -150,6 +178,7 @@ namespace RJW_Menstruation
public override void CompPostPostAdd(DamageInfo? dinfo) public override void CompPostPostAdd(DamageInfo? dinfo)
{ {
if (!loaded) Initialize(); if (!loaded) Initialize();
if (ageOfLastBirth > parent.pawn.ageTracker.AgeChronologicalTicks) ageOfLastBirth = CalculateLastBirth(); // catch transplant issues
} }
public override void CompPostPostRemoved() public override void CompPostPostRemoved()
@ -167,10 +196,41 @@ namespace RJW_Menstruation
} }
} }
protected long CalculateLastBirth()
{
long youngestAge = (long)(BabyHalfAge * GenDate.TicksPerYear) * -2; // So a newborn isn't considered a new mother, either
if ((parent.pawn.relations?.ChildrenCount ?? 0) > 0)
{
foreach (Pawn child in parent.pawn.relations.Children)
{
bool isFetus;
if (PregnancyHelper.GetPregnancy(parent.pawn) is Hediff_BasePregnancy preg)
{
isFetus = preg.babies.Contains(child);
}
else isFetus = false;
if (
parent.pawn.ageTracker.BirthAbsTicks - child.ageTracker.BirthAbsTicks > ageOfLastBirth &&
!isFetus &&
child.GetMother() == parent.pawn // Don't do Dad's boobs
)
youngestAge = parent.pawn.ageTracker.BirthAbsTicks - child.ageTracker.BirthAbsTicks;
}
}
return youngestAge;
}
public void Initialize() public void Initialize()
{ {
Props = (CompProperties_Breast)props; Props = (CompProperties_Breast)props;
action = Transition; action = Transition;
if (ageOfLastBirth == 0)
{
ageOfLastBirth = CalculateLastBirth();
}
if (alphaPermanent < 0f) if (alphaPermanent < 0f)
{ {
alphaPermanent = (Utility.RandGaussianLike(0.0f, 0.3f) + Rand.Range(0.0f,0.5f))/2; alphaPermanent = (Utility.RandGaussianLike(0.0f, 0.3f) + Rand.Range(0.0f,0.5f))/2;
@ -206,23 +266,47 @@ namespace RJW_Menstruation
nippleSizeCurrent = Mathf.Lerp(nippleSizeCurrent, nippleSize, Configurations.NippleTransitionRatio); nippleSizeCurrent = Mathf.Lerp(nippleSizeCurrent, nippleSize, Configurations.NippleTransitionRatio);
UpdateColor(); UpdateColor();
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, TICKINTERVAL, parent.pawn); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, TICKINTERVAL, parent.pawn);
if (pregnant)
// Scenario A: the youngest child is less than halfway into babyhood: Full size
if (ageOfLastBirth + BabyHalfAge * GenDate.TicksPerYear > parent.pawn.ageTracker.AgeBiologicalTicks)
{ {
debugGrowthStatus = "Full size due to young child";
if (breastSizeIncreased < MAX_BREAST_INCREMENT) if (breastSizeIncreased < MAX_BREAST_INCREMENT)
{ {
breastSizeIncreased += 0.02f; parent.Severity += (MAX_BREAST_INCREMENT - breastSizeIncreased);
parent.Severity += 0.02f; breastSizeIncreased = MAX_BREAST_INCREMENT;
} }
} }
// Scenario B: Pregnant, grow in the second half of first trimester
else if (parent.pawn.IsPregnant())
{
float pregnancySize = Mathf.InverseLerp(1f / 6f, 1f / 3f, parent.pawn.GetPregnancyProgress()) * MAX_BREAST_INCREMENT;
if (breastSizeIncreased > pregnancySize)
{
debugGrowthStatus = "Shrinking due to being oversize for pregnancy";
// Breasts still large from the last kid
ShrinkBreasts();
}
else if (breastSizeIncreased < MAX_BREAST_INCREMENT)
{
// Time to grow
float growAmount = pregnancySize - breastSizeIncreased;
if (growAmount != 0)
debugGrowthStatus = "Growing due to pregnancy";
else else
{ debugGrowthStatus = "Pregnant, but not time to grow";
if (breastSizeIncreased > 0) breastSizeIncreased += growAmount;
{ parent.Severity += growAmount;
breastSizeIncreased -= 0.02f;
parent.Severity -= 0.02f;
} }
else debugGrowthStatus = "Pregnant and full size";
} }
// Scenario C: Not (or very early) pregnant and youngest child nonexistent or more than halfway into babyhood, time to shrink
else if (breastSizeIncreased > 0)
{
debugGrowthStatus = "Shrinking due to no pregnancy nor young child";
ShrinkBreasts();
}
else debugGrowthStatus = "Base size";
} }
public void ChangeColorFermanant(float alpha) public void ChangeColorFermanant(float alpha)
@ -252,6 +336,7 @@ namespace RJW_Menstruation
areolaSize = areolaSizePermanent; areolaSize = areolaSizePermanent;
nippleSize = nippleSizePermanent; nippleSize = nippleSizePermanent;
pregnant = false; pregnant = false;
ageOfLastBirth = parent.pawn.ageTracker.AgeBiologicalTicks;
} }
@ -305,7 +390,9 @@ namespace RJW_Menstruation
public string DebugInfo() public string DebugInfo()
{ {
return "Alpha: " + alpha + return "Increase: " + breastSizeIncreased +
"\n" + debugGrowthStatus +
"\nAlpha: " + alpha +
"\nNippleSize: " + nippleSize + "\nNippleSize: " + nippleSize +
"\nAreolaSize: " + areolaSize + "\nAreolaSize: " + areolaSize +
"\nAlphaCurrent: " + alphaCurrent + "\nAlphaCurrent: " + alphaCurrent +