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

4
.gitignore vendored
View File

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

View File

@ -86,7 +86,18 @@
</comps>
</value>
</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 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.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 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.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 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.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 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.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 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.0 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.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -52,7 +52,9 @@ namespace RJW_Menstruation
protected float nippleSizePermanent = -1f;
protected float nippleSizeCurrent = -1f;
protected float nippleSize = -1f;
protected long ageOfLastBirth = 0;
protected float breastSizeIncreased = 0f;
protected string debugGrowthStatus = "(Growth/shrink not yet calculated; run for 1.5h to update)";
protected float originalpha = -1f;
protected float originareola = -1f;
protected float originnipple = -1f;
@ -61,6 +63,31 @@ namespace RJW_Menstruation
protected bool pregnant = false;
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
{
get
@ -137,6 +164,7 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref nippleSizePermanent, "nippleSizePermanent", DEFAULTNIPPLE, true);
Scribe_Values.Look(ref nippleSizeCurrent, "nippleSizeCurrent", 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 originalpha, "originalpha", originalpha, true);
Scribe_Values.Look(ref originareola, "originareola", originareola, true);
@ -150,6 +178,7 @@ namespace RJW_Menstruation
public override void CompPostPostAdd(DamageInfo? dinfo)
{
if (!loaded) Initialize();
if (ageOfLastBirth > parent.pawn.ageTracker.AgeChronologicalTicks) ageOfLastBirth = CalculateLastBirth(); // catch transplant issues
}
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()
{
Props = (CompProperties_Breast)props;
action = Transition;
if (ageOfLastBirth == 0)
{
ageOfLastBirth = CalculateLastBirth();
}
if (alphaPermanent < 0f)
{
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);
UpdateColor();
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)
{
breastSizeIncreased += 0.02f;
parent.Severity += 0.02f;
parent.Severity += (MAX_BREAST_INCREMENT - breastSizeIncreased);
breastSizeIncreased = MAX_BREAST_INCREMENT;
}
}
else
// Scenario B: Pregnant, grow in the second half of first trimester
else if (parent.pawn.IsPregnant())
{
if (breastSizeIncreased > 0)
float pregnancySize = Mathf.InverseLerp(1f / 6f, 1f / 3f, parent.pawn.GetPregnancyProgress()) * MAX_BREAST_INCREMENT;
if (breastSizeIncreased > pregnancySize)
{
breastSizeIncreased -= 0.02f;
parent.Severity -= 0.02f;
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
debugGrowthStatus = "Pregnant, but not time to grow";
breastSizeIncreased += growAmount;
parent.Severity += growAmount;
}
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)
@ -252,6 +336,7 @@ namespace RJW_Menstruation
areolaSize = areolaSizePermanent;
nippleSize = nippleSizePermanent;
pregnant = false;
ageOfLastBirth = parent.pawn.ageTracker.AgeBiologicalTicks;
}
@ -305,7 +390,9 @@ namespace RJW_Menstruation
public string DebugInfo()
{
return "Alpha: " + alpha +
return "Increase: " + breastSizeIncreased +
"\n" + debugGrowthStatus +
"\nAlpha: " + alpha +
"\nNippleSize: " + nippleSize +
"\nAreolaSize: " + areolaSize +
"\nAlphaCurrent: " + alphaCurrent +