Rewrite nipple system to a simpler version

This commit is contained in:
lutepickle 2022-07-28 21:06:51 -07:00
parent df1455ece2
commit 105c4df01f
12 changed files with 196 additions and 284 deletions

Binary file not shown.

View file

@ -37,7 +37,7 @@
<Dialog_DoCleanWomb_Tooltip>Gather cum into bucket</Dialog_DoCleanWomb_Tooltip> <Dialog_DoCleanWomb_Tooltip>Gather cum into bucket</Dialog_DoCleanWomb_Tooltip>
<Dialog_DontCleanWomb_Tooltip>Store cum in womb</Dialog_DontCleanWomb_Tooltip> <Dialog_DontCleanWomb_Tooltip>Store cum in womb</Dialog_DontCleanWomb_Tooltip>
<Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown> <Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown>
<Option1_Label_1>Enable womb icon</Option1_Label_1> <Option1_Label_1>Enable womb icon</Option1_Label_1>
@ -94,14 +94,12 @@
<Option23_Label>Dominant hybrid extension</Option23_Label> <Option23_Label>Dominant hybrid extension</Option23_Label>
<Option23_Label_1>Mother</Option23_Label_1> <Option23_Label_1>Mother</Option23_Label_1>
<Option23_Label_2>Father</Option23_Label_2> <Option23_Label_2>Father</Option23_Label_2>
<Option24_Label>Transition variance of nipples after pregnancy</Option24_Label> <Option_MaxBreastIncrementFactor_Label>Breast growth during pregnancy</Option_MaxBreastIncrementFactor_Label>
<Option24_Desc>Set how much nipples/areolas should darken/widen on every pregnancy.</Option24_Desc> <Option_MaxBreastIncrementFactor_Desc>Change how much a pregnant pawn's breasts will grow when pregnant. Some pawns will grow more than others.</Option_MaxBreastIncrementFactor_Desc>
<Option25_Label>Permanent transition variance of nipples</Option25_Label> <Option_MaxNippleIncrementFactor_Label>Nipple change during pregnancy</Option_MaxNippleIncrementFactor_Label>
<Option25_Desc>Set how much nipples/areolas should darken/widen permanently on every pregnancy.</Option25_Desc> <Option_MaxNippleIncrementFactor_Desc>Change how much a pregnant pawn's nipples will change during pregnancy.</Option_MaxNippleIncrementFactor_Desc>
<Option26_Label>Maximum transition</Option26_Label> <Option_PermanentNippleChange_Label>Permanent nipple change after pregnancy</Option_PermanentNippleChange_Label>
<Option26_Desc>Nipples/areolas won't be darker/wider than this value.</Option26_Desc> <Option_PermanentNippleChange_Desc>Adjusts approximately how much of a pregnant pawn's nipples will remain changed after the pregnancy ends.</Option_PermanentNippleChange_Desc>
<Option27_Label>Transition speed of nipples</Option27_Label>
<Option27_Desc>Set speed of transition of nipples/areolas.&#10;1 = instant transition</Option27_Desc>
<Option28_Label>Customize Hybrids</Option28_Label> <Option28_Label>Customize Hybrids</Option28_Label>
<Option28_Tooltip>Open custom hybrid editor.&#10;This will overrides hybrid definitions of XML files.</Option28_Tooltip> <Option28_Tooltip>Open custom hybrid editor.&#10;This will overrides hybrid definitions of XML files.</Option28_Tooltip>
<Option29_Label>Allow shrink icon</Option29_Label> <Option29_Label>Allow shrink icon</Option29_Label>

View file

@ -32,8 +32,7 @@ namespace MilkModule
{ {
if (breastcomp != null) if (breastcomp != null)
{ {
breastcomp.AdjustAreolaSize(Rand.Range(0.0f, 0.0001f * Configurations.NipplePermanentTransitionVariance)); breastcomp.AdjustNippleProgress(Rand.Range(0.0f, 0.01f));
breastcomp.AdjustNippleSize(Rand.Range(0.0f, 0.0001f * Configurations.NipplePermanentTransitionVariance));
} }
} }

View file

@ -24,8 +24,7 @@ namespace MilkModule
if (__instance.parent is Pawn pawn) comp = pawn.GetBreastComp(); if (__instance.parent is Pawn pawn) comp = pawn.GetBreastComp();
if (comp != null) if (comp != null)
{ {
comp.AdjustAreolaSize(Rand.Range(0.0f, 0.01f * Configurations.NipplePermanentTransitionVariance)); comp.AdjustNippleProgress(Rand.Range(0.0f, 0.01f));
comp.AdjustNippleSize(Rand.Range(0.0f, 0.01f * Configurations.NipplePermanentTransitionVariance));
} }
} }

View file

@ -21,10 +21,9 @@ namespace RJW_Menstruation
public const int EnzygoticTwinsChanceAdjustDefault = 2; public const int EnzygoticTwinsChanceAdjustDefault = 2;
public const int MaxEnzygoticTwinsDefault = 9; public const int MaxEnzygoticTwinsDefault = 9;
public const int BleedingAmountDefault = 50; public const int BleedingAmountDefault = 50;
public const float NippleTransitionVarianceDefault = 0.2f; public const float MaxBreastIncrementFactorDefault = 1.0f;
public const float NipplePermanentTransitionVarianceDefault = 0.02f; public const float MaxNippleIncrementFactorDefault = 1.0f;
public const float NippleMaximumTransitionDefault = 0.4f; public const float PermanentNippleChangeDefault = 0.1f;
public const float NippleTransitionSpeedDefault = 0.035f;
public const float EggLifespanMultiplierDefault = 1.0f; public const float EggLifespanMultiplierDefault = 1.0f;
public const float VaginaMorphPowerDefault = 0.2f; public const float VaginaMorphPowerDefault = 0.2f;
@ -67,19 +66,9 @@ namespace RJW_Menstruation
public static float EggLifespanMultiplier = EggLifespanMultiplierDefault; public static float EggLifespanMultiplier = EggLifespanMultiplierDefault;
public static bool EnableBirthVaginaMorph = false; public static bool EnableBirthVaginaMorph = false;
public static float VaginaMorphPower = VaginaMorphPowerDefault; public static float VaginaMorphPower = VaginaMorphPowerDefault;
public static float MaxBreastIncrementFactor = MaxBreastIncrementFactorDefault;
public static float NippleTransitionVariance = NippleTransitionVarianceDefault; public static float MaxNippleIncrementFactor = MaxNippleIncrementFactorDefault;
public static float NipplePermanentTransitionVariance = NipplePermanentTransitionVarianceDefault; public static float PermanentNippleChange = PermanentNippleChangeDefault;
public static float NippleMaximumTransition = NippleMaximumTransitionDefault;
public static float NippleTransitionSpeed = NippleTransitionSpeedDefault;
public static float NippleTransitionRatio
{
get
{
return NippleTransitionVariance * NippleTransitionSpeed;
}
}
public static void SettoDefault() public static void SettoDefault()
{ {
ImplantationChanceAdjust = ImplantationChanceAdjustDefault; ImplantationChanceAdjust = ImplantationChanceAdjustDefault;
@ -101,10 +90,9 @@ namespace RJW_Menstruation
MaxEnzygoticTwins = MaxEnzygoticTwinsDefault; MaxEnzygoticTwins = MaxEnzygoticTwinsDefault;
BleedingAmount = BleedingAmountDefault; BleedingAmount = BleedingAmountDefault;
MotherFirst = false; MotherFirst = false;
NippleTransitionVariance = NippleTransitionVarianceDefault; MaxBreastIncrementFactor = MaxBreastIncrementFactorDefault;
NipplePermanentTransitionVariance = NipplePermanentTransitionVarianceDefault; MaxNippleIncrementFactor= MaxNippleIncrementFactorDefault;
NippleMaximumTransition = NippleMaximumTransitionDefault; PermanentNippleChange = PermanentNippleChangeDefault;
NippleTransitionSpeed = NippleTransitionSpeedDefault;
EggLifespanMultiplier = EggLifespanMultiplierDefault; EggLifespanMultiplier = EggLifespanMultiplierDefault;
VaginaMorphPower = VaginaMorphPowerDefault; VaginaMorphPower = VaginaMorphPowerDefault;
} }
@ -214,10 +202,9 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref ShowFlag, "ShowFlag", ShowFlag, true); Scribe_Values.Look(ref ShowFlag, "ShowFlag", ShowFlag, true);
Scribe_Values.Look(ref UseHybridExtention, "UseHybridExtention", UseHybridExtention, true); Scribe_Values.Look(ref UseHybridExtention, "UseHybridExtention", UseHybridExtention, true);
Scribe_Values.Look(ref MotherFirst, "MotherFirst", MotherFirst, true); Scribe_Values.Look(ref MotherFirst, "MotherFirst", MotherFirst, true);
Scribe_Values.Look(ref NippleTransitionVariance, "NippleTransitionVariance", NippleTransitionVariance, true); Scribe_Values.Look(ref MaxBreastIncrementFactor, "MaxBreastIncrementFactor", MaxBreastIncrementFactor, true);
Scribe_Values.Look(ref NipplePermanentTransitionVariance, "NipplePermanentTransitionVariance", NipplePermanentTransitionVariance, true); Scribe_Values.Look(ref MaxNippleIncrementFactor, "MaxNippleImcrementFactor", MaxNippleIncrementFactor, true);
Scribe_Values.Look(ref NippleMaximumTransition, "NippleMaximumTransition", NippleMaximumTransition, true); Scribe_Values.Look(ref PermanentNippleChange, "PermanentNippleChange", PermanentNippleChange, true);
Scribe_Values.Look(ref NippleTransitionSpeed, "NippleTransitionSpeed", NippleTransitionSpeed, true);
Scribe_Values.Look(ref AllowShrinkIcon, "AllowShrinkIcon", AllowShrinkIcon, true); Scribe_Values.Look(ref AllowShrinkIcon, "AllowShrinkIcon", AllowShrinkIcon, true);
Scribe_Values.Look(ref EggLifespanMultiplier, "EggLifespanMultiplier", EggLifespanMultiplier, true); Scribe_Values.Look(ref EggLifespanMultiplier, "EggLifespanMultiplier", EggLifespanMultiplier, true);
Scribe_Values.Look(ref EnableBirthVaginaMorph, "EnableBirthVaginaMorph", EnableBirthVaginaMorph, true); Scribe_Values.Look(ref EnableBirthVaginaMorph, "EnableBirthVaginaMorph", EnableBirthVaginaMorph, true);
@ -352,25 +339,20 @@ namespace RJW_Menstruation
Configurations.ShowFlag ^= Configurations.PawnFlags.Hostile; Configurations.ShowFlag ^= Configurations.PawnFlags.Hostile;
} }
Adjust = (int)(Configurations.NippleTransitionVariance * 1000); Adjust = (int)(Configurations.MaxBreastIncrementFactor * 1000);
wombsection.Label(Translations.Option24_Label + " " + Configurations.NippleTransitionVariance * 100 + " / 100", -1, Translations.Option24_Desc); wombsection.Label(Translations.Option_MaxBreastIncrementFactor_Label + " " + Configurations.MaxBreastIncrementFactor * 100 + "%", -1, Translations.Option_MaxBreastIncrementFactor_Desc);
Adjust = (int)wombsection.Slider(Adjust, 0, 1000); Adjust = (int)wombsection.Slider(Adjust, 0, 1000);
Configurations.NippleTransitionVariance = (float)Adjust / 1000; Configurations.MaxBreastIncrementFactor = (float)Adjust / 100;
Adjust = (int)(Configurations.NipplePermanentTransitionVariance * 1000); Adjust = (int)(Configurations.MaxNippleIncrementFactor * 1000);
wombsection.Label(Translations.Option25_Label + " " + Configurations.NipplePermanentTransitionVariance * 100 + " / 100", -1, Translations.Option25_Desc); wombsection.Label(Translations.Option_MaxNippleIncrementFactor_Label + " " + Configurations.MaxNippleIncrementFactor * 100 + "%", -1, Translations.Option_MaxNippleIncrementFactor_Desc);
Adjust = (int)wombsection.Slider(Adjust, 0, 1000); Adjust = (int)wombsection.Slider(Adjust, 0, 1000);
Configurations.NipplePermanentTransitionVariance = (float)Adjust / 1000; Configurations.MaxNippleIncrementFactor = (float)Adjust / 100;
Adjust = (int)(Configurations.NippleMaximumTransition * 1000); Adjust = (int)(Configurations.PermanentNippleChange * 1000);
wombsection.Label(Translations.Option26_Label + " " + Configurations.NippleMaximumTransition * 100 + " / 100", -1, Translations.Option26_Desc); wombsection.Label(Translations.Option_PermanentNippleChange_Label + " " + Configurations.PermanentNippleChange, -1, Translations.Option_PermanentNippleChange_Desc);
Adjust = (int)wombsection.Slider(Adjust, 0, 1000); Adjust = (int)wombsection.Slider(Adjust, 0, 1000);
Configurations.NippleMaximumTransition = (float)Adjust / 1000; Configurations.PermanentNippleChange = (float)Adjust / 2500;
Adjust = (int)(Configurations.NippleTransitionSpeed * 1000);
wombsection.Label(Translations.Option27_Label + " " + Configurations.NippleTransitionSpeed, -1, Translations.Option27_Desc);
Adjust = (int)wombsection.Slider(Adjust, 0, 1000);
Configurations.NippleTransitionSpeed = (float)Adjust / 1000;
listmain.EndSection(wombsection); listmain.EndSection(wombsection);
} }

View file

@ -31,117 +31,101 @@ namespace RJW_Menstruation
public class HediffComp_Breast : HediffComp public class HediffComp_Breast : HediffComp
{ {
public const float DEFAULTALPHA = -1; public const int tickInterval = GenDate.TicksPerHour * 3 / 2;
public const float DEFAULTAREOLA = -1; public const float breastGrowthStart = 1f / 6f;
public const float DEFAULTNIPPLE = -1; public const float breastGrowthEnd = 1f / 3f;
public const float VARIANT = 0.2f; public static readonly SimpleCurve nippleTransitions = new SimpleCurve()
public const int TICKINTERVAL = 3750; {
public const float MAX_BREAST_INCREMENT = 0.10f; new CurvePoint(0f,0f),
public const float BREAST_GROWTH_START = 1f / 6f; new CurvePoint(0.1f,0f),
public const float BREAST_GROWTH_END = 1f / 3f; new CurvePoint(0.333f,0.167f),
new CurvePoint(0.667f,0.833f),
new CurvePoint(1.0f,1.0f)
};
public const float nippleChange = 0.2f;
public CompProperties_Breast Props; public CompProperties_Breast Props;
protected float alphaPermanent = -1;
protected float alphaCurrent = -1;
protected float alpha = -1;
protected float areolaSizePermanent = -1f;
protected float areolaSizeCurrent = -1f;
protected float areolaSize = -1f;
protected float nippleSizePermanent = -1f;
protected float nippleSizeCurrent = -1f;
protected float nippleSize = -1f;
protected long ageOfLastBirth = 0; protected long ageOfLastBirth = 0;
protected float maxBreastIncrement = -1f;
protected float maxAreolaIncrement = -1f;
protected float breastSizeIncreased = 0f; protected float breastSizeIncreased = 0f;
protected string debugGrowthStatus = "(Growth/shrink not yet calculated; run for 1.5h to update)"; protected string debugGrowthStatus = "(Growth/shrink not yet calculated; run for 1.5h to update)";
protected float originalpha = -1f; protected float nippleProgress = 0f;
protected float originareola = -1f; protected float baseAlpha = -1f; // Will grow in response to pregnancy
protected float originnipple = -1f; protected float baseAreola = -1f;
protected Color cachedcolor; protected float baseNipple = -1f;
protected float cachedAlpha = -1f; // Calculated dynamically instead of saved
protected float cachedAreola = -1f; // Actual size = these * breast size
protected float cachedNipple = -1f;
protected float babyHalfAge = -1f;
protected Color cachedColor;
protected bool loaded = false; protected bool loaded = false;
protected bool pregnant = false;
public Action action; public Action action;
protected float BabyHalfAge protected float BabyHalfAge
{ {
get get
{ {
float res = 0; if (babyHalfAge >= 0f) return babyHalfAge;
List<LifeStageAge> ages = parent.pawn.RaceProps.lifeStageAges; List<LifeStageAge> ages = parent.pawn.def.race.lifeStageAges;
if (ages?.Count > 1) if (ages?.Count > 1)
res = ages[1].minAge / 2; babyHalfAge = ages[1].minAge / 2;
if (res <= 0) res = 1.2f / 2; // Default to human if (babyHalfAge <= 0) babyHalfAge = 1.2f / 2; // Default to human
if (RJWPregnancySettings.phantasy_pregnancy) if (RJWPregnancySettings.phantasy_pregnancy)
res /= GenDate.DaysPerYear; babyHalfAge /= GenDate.DaysPerYear;
return res; return babyHalfAge;
} }
} }
protected void ShrinkBreasts() protected void ShrinkBreasts()
{ {
// The natural rate will take them from full to empty during the second half of their child's babyhood // 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 shrinkRate = tickInterval * MaxBreastIncrement / (BabyHalfAge * GenDate.TicksPerYear);
float shrinkAmount = Mathf.Min(shrinkRate, breastSizeIncreased); float shrinkAmount = Mathf.Min(shrinkRate, breastSizeIncreased);
breastSizeIncreased -= shrinkAmount; breastSizeIncreased -= shrinkAmount;
parent.Severity -= shrinkAmount; parent.Severity -= shrinkAmount;
} }
public float MaxAlpha protected float MaxBreastIncrement
{ {
get get
{ {
return originalpha + Configurations.NippleMaximumTransition; return maxBreastIncrement * Configurations.MaxBreastIncrementFactor;
} }
} }
public float MaxAreola
{
get
{
return originareola + Configurations.NippleMaximumTransition;
}
}
public float MaxNipple
{
get
{
return originnipple + Configurations.NippleMaximumTransition;
}
}
public float OriginAlpha => originalpha;
public float OriginNipple => originnipple;
public float OriginAreola => originareola;
public Color OriginColor => Colors.CMYKLerp(parent?.pawn?.story?.SkinColor ?? Color.white, Props.BlackNippleColor, originalpha);
public Color NippleColor public Color NippleColor
{ {
get get
{ {
return cachedcolor; return cachedColor;
} }
} }
public float Alpha public float Alpha
{ {
get get
{ {
return alphaCurrent; return cachedAlpha;
} }
} }
public float NippleSize public float NippleSize
{ {
get get
{ {
return nippleSizeCurrent; return cachedNipple * parent.Severity;
} }
} }
public float AreolaSize public float AreolaSize
{ {
get get
{ {
return areolaSizeCurrent; return cachedAreola * parent.Severity;
} }
} }
@ -156,22 +140,25 @@ namespace RJW_Menstruation
public override void CompExposeData() public override void CompExposeData()
{ {
base.CompExposeData(); base.CompExposeData();
Scribe_Values.Look(ref alphaPermanent, "alphaPermanent", DEFAULTALPHA, true);
Scribe_Values.Look(ref alphaCurrent, "alphaCurrent", DEFAULTALPHA, true);
Scribe_Values.Look(ref alpha, "alpha", DEFAULTALPHA, true);
Scribe_Values.Look(ref areolaSizePermanent, "areolaSizePermanent", DEFAULTAREOLA, true);
Scribe_Values.Look(ref areolaSizeCurrent, "areolaSizeCurrent", DEFAULTAREOLA, true);
Scribe_Values.Look(ref areolaSize, "areolaSize", DEFAULTAREOLA, true);
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);
Scribe_Values.Look(ref originnipple, "originnipple", originnipple, true);
Scribe_Values.Look(ref pregnant, "pregnant", pregnant, true);
if (Scribe.mode == LoadSaveMode.LoadingVars)
{ // For compatibility
Scribe_Values.Look(ref baseAlpha, "alphaPermanent", -1, false);
Scribe_Values.Look(ref baseAreola, "areolaSizePermanent", -1, false);
Scribe_Values.Look(ref baseNipple, "nippleSizePermanent", -1, false);
baseAlpha *= 2;
baseAreola *= 2;
baseNipple *= 2;
}
Scribe_Values.Look(ref ageOfLastBirth, "ageOfLastBirth", ageOfLastBirth, true);
Scribe_Values.Look(ref maxBreastIncrement, "maxBreastIncrement", maxBreastIncrement, true);
Scribe_Values.Look(ref maxAreolaIncrement, "maxAreolaIncrement", maxAreolaIncrement, true);
Scribe_Values.Look(ref breastSizeIncreased, "breastSizeIncreased", breastSizeIncreased, true);
Scribe_Values.Look(ref nippleProgress, "nippleProgress", nippleProgress, true);
Scribe_Values.Look(ref baseAlpha, "baseAlpha", baseAlpha, true);
Scribe_Values.Look(ref baseAreola, "baseAreola", baseAreola, true);
Scribe_Values.Look(ref baseNipple, "baseNipple", baseNipple, true);
} }
public override void CompPostTick(ref float severityAdjustment) { } public override void CompPostTick(ref float severityAdjustment) { }
@ -225,70 +212,69 @@ namespace RJW_Menstruation
public void Initialize() public void Initialize()
{ {
Props = (CompProperties_Breast)props; Props = (CompProperties_Breast)props;
action = Transition; action = Update;
if (maxBreastIncrement <= 0f)
{
maxBreastIncrement = Utility.RandGaussianLike(0.088f, 0.202f);
}
if (maxAreolaIncrement <= 0f)
{
maxAreolaIncrement = Utility.RandGaussianLike(0.0375f, 0.1125f);
}
if (ageOfLastBirth == 0) if (ageOfLastBirth == 0)
{ {
ageOfLastBirth = CalculateLastBirth(); ageOfLastBirth = CalculateLastBirth();
} }
if (baseAlpha <= 0f)
if (alphaPermanent < 0f)
{ {
alphaPermanent = (Utility.RandGaussianLike(0.0f, 0.3f) + Rand.Range(0.0f, 0.5f)) / 2; baseAlpha = Utility.RandGaussianLike(0.0f, 0.3f) + Rand.Range(0.0f, 0.5f);
originalpha = alphaPermanent;
alpha = alphaPermanent;
alphaCurrent = alphaPermanent;
} }
if (areolaSizePermanent < 0f) if (baseAreola <= 0f)
{ {
areolaSizePermanent = Utility.RandGaussianLike(0f, parent.Severity); baseAreola = Utility.RandGaussianLike(0.0f, 1.0f);
originareola = areolaSizePermanent;
areolaSize = areolaSizePermanent;
areolaSizeCurrent = areolaSizePermanent;
} }
if (nippleSizePermanent < 0f) if (baseNipple <= 0f)
{ {
nippleSizePermanent = Utility.RandGaussianLike(0f, parent.Severity); baseNipple = Utility.RandGaussianLike(0.0f, 1.0f);
originnipple = nippleSizePermanent;
nippleSize = nippleSizePermanent;
nippleSizeCurrent = nippleSizePermanent;
} }
UpdateColor(); CalculateNipples();
UpdateNipples();
loaded = true; loaded = true;
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, TICKINTERVAL, parent.pawn); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, GetNextUpdate(), parent.pawn);
} }
public void Update()
public void Transition()
{ {
alphaCurrent = Mathf.Lerp(alphaCurrent, alpha, Configurations.NippleTransitionRatio); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, GetNextUpdate(), parent.pawn);
areolaSizeCurrent = Mathf.Lerp(areolaSizeCurrent, areolaSize, Configurations.NippleTransitionRatio); CalculateBreastSize();
nippleSizeCurrent = Mathf.Lerp(nippleSizeCurrent, nippleSize, Configurations.NippleTransitionRatio); CalculateNipples();
UpdateColor(); UpdateNipples();
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, TICKINTERVAL, parent.pawn); }
protected void CalculateBreastSize()
{
// Scenario A: the youngest child is less than halfway into babyhood: Full size // Scenario A: the youngest child is less than halfway into babyhood: Full size
if (ageOfLastBirth + BabyHalfAge * GenDate.TicksPerYear > parent.pawn.ageTracker.AgeBiologicalTicks) if (ageOfLastBirth + BabyHalfAge * GenDate.TicksPerYear > parent.pawn.ageTracker.AgeBiologicalTicks)
{ {
debugGrowthStatus = "Full size due to young child"; debugGrowthStatus = "Full size due to young child";
if (breastSizeIncreased < MAX_BREAST_INCREMENT) if (breastSizeIncreased < MaxBreastIncrement)
{ {
parent.Severity += (MAX_BREAST_INCREMENT - breastSizeIncreased); parent.Severity += (MaxBreastIncrement - breastSizeIncreased);
breastSizeIncreased = MAX_BREAST_INCREMENT; breastSizeIncreased = MaxBreastIncrement;
} }
} }
// Scenario B: Pregnant, grow in the second half of first trimester // Scenario B: Pregnant, grow in the second half of first trimester
else if (parent.pawn.IsPregnant()) else if (parent.pawn.IsPregnant())
{ {
float pregnancySize = Mathf.InverseLerp(BREAST_GROWTH_START, BREAST_GROWTH_END, parent.pawn.GetFarthestPregnancyProgress()) * MAX_BREAST_INCREMENT; float pregnancySize = Mathf.InverseLerp(breastGrowthStart, breastGrowthEnd, parent.pawn.GetFarthestPregnancyProgress()) * MaxBreastIncrement;
if (breastSizeIncreased > pregnancySize) if (breastSizeIncreased > pregnancySize)
{ {
debugGrowthStatus = "Shrinking due to being oversize for pregnancy"; debugGrowthStatus = "Shrinking due to being oversize for pregnancy";
// Breasts still large from the last kid // Breasts still large from the last kid
ShrinkBreasts(); ShrinkBreasts();
} }
else if (breastSizeIncreased < MAX_BREAST_INCREMENT) else if (breastSizeIncreased < MaxBreastIncrement)
{ {
// Time to grow // Time to grow
float growAmount = pregnancySize - breastSizeIncreased; float growAmount = pregnancySize - breastSizeIncreased;
@ -310,123 +296,95 @@ namespace RJW_Menstruation
else debugGrowthStatus = "Base size"; else debugGrowthStatus = "Base size";
} }
public void ChangeColorFermanant(float alpha) protected void CalculateNipples()
{ {
alphaPermanent = alpha; float newNippleProgress;
if (ageOfLastBirth + BabyHalfAge * GenDate.TicksPerYear > parent.pawn.ageTracker.AgeBiologicalTicks)
newNippleProgress = 1f;
else if (parent.pawn.IsPregnant())
newNippleProgress = nippleTransitions.Evaluate(parent.pawn.GetFarthestPregnancyProgress());
else
newNippleProgress = 0f;
if (newNippleProgress == nippleProgress) return; // Nothing to change
else if (newNippleProgress > nippleProgress)
{
float progressDifference = newNippleProgress - nippleProgress;
// All nipple growth has a slight effect on the base
// Not mathematically precise in hitting the goal at the end of the term, but close enough
baseAlpha *= 1.0f + progressDifference * Configurations.PermanentNippleChange;
if (baseAlpha > 1.0f) baseAlpha = 1.0f;
baseAreola *= 1.0f + progressDifference * Configurations.PermanentNippleChange;
if (baseAreola > 1.0f) baseAreola = 1.0f;
baseNipple *= 1.0f + progressDifference * Configurations.PermanentNippleChange;
if (baseNipple > 1.0f) baseNipple = 1.0f;
}
else
{
nippleProgress -= tickInterval / (BabyHalfAge * GenDate.TicksPerYear);
if (nippleProgress < newNippleProgress) nippleProgress = newNippleProgress;
}
} }
public void ChangeColor(float alpha) public void AdjustNippleProgress(float amount)
{ {
this.alpha = alpha; nippleProgress = Mathf.Clamp01(nippleProgress + amount);
} }
public void PregnancyTransition() public void AdjustNippleSizeImmediately(float amount)
{ {
alphaPermanent = Math.Min(MaxAlpha, alphaPermanent + Configurations.NipplePermanentTransitionVariance.VariationRange(VARIANT)); baseNipple = Mathf.Clamp01(baseNipple + amount);
areolaSizePermanent = Math.Min(MaxAreola, areolaSizePermanent + Configurations.NipplePermanentTransitionVariance.VariationRange(VARIANT)); UpdateNipples();
nippleSizePermanent = Math.Min(MaxNipple, nippleSizePermanent + Configurations.NipplePermanentTransitionVariance.VariationRange(VARIANT));
alpha = Math.Min(MaxAlpha, alpha + Configurations.NippleTransitionVariance.VariationRange(VARIANT));
areolaSize = Math.Min(MaxAreola, areolaSize + Configurations.NippleTransitionVariance.VariationRange(VARIANT));
nippleSize = Math.Min(MaxNipple, nippleSize + Configurations.NippleTransitionVariance.VariationRange(VARIANT));
pregnant = true;
} }
public void BirthTransition() public void AdjustAreolaSizeImmediately(float amount)
{ {
alpha = alphaPermanent; baseAreola = Mathf.Clamp01(baseAreola + amount);
areolaSize = areolaSizePermanent; UpdateNipples();
nippleSize = nippleSizePermanent;
pregnant = false;
ageOfLastBirth = parent.pawn.ageTracker.AgeBiologicalTicks;
} }
public void UpdateNipples()
public void AdjustBreastSize(float amount)
{ {
parent.Severity += amount; cachedAlpha = baseAlpha + nippleProgress * nippleChange;
breastSizeIncreased += amount; cachedAreola = baseAreola + nippleProgress * maxAreolaIncrement;
cachedNipple = baseNipple + nippleProgress * nippleChange;
cachedColor = Colors.CMYKLerp(parent.pawn.story?.SkinColor ?? Color.white, Props.BlackNippleColor, Alpha);
} }
public void AdjustNippleSize(float amount) protected int GetNextUpdate()
{ {
nippleSizePermanent = Math.Min(MaxNipple, nippleSizePermanent + amount); // Just like the menstruation code
nippleSize = Math.Min(MaxNipple, nippleSize + amount); int currentOffset = Find.TickManager.TicksGame % tickInterval;
} int nextOffset = (parent.pawn.HashOffset() % tickInterval + tickInterval) % tickInterval;
public void AdjustAreolaSize(float amount) return ((nextOffset - currentOffset + tickInterval - 1) % tickInterval) + 1;
{
areolaSizePermanent = Math.Min(MaxAreola, areolaSizePermanent + amount);
areolaSize = Math.Min(MaxAreola, areolaSize + amount);
}
public void RestoreBreastSize(float ratio)
{
float variance = breastSizeIncreased * Math.Min(ratio, 1.0f);
breastSizeIncreased -= variance;
parent.Severity -= variance;
}
public void AdjustNippleSizeImmidiately(float amount)
{
originnipple = Math.Max(0, originnipple + amount);
nippleSizePermanent = Math.Min(MaxNipple, nippleSizePermanent + amount);
nippleSize = Math.Min(MaxNipple, nippleSize + amount);
nippleSizeCurrent = nippleSize;
}
public void AdjustAreolaSizeImmidiately(float amount)
{
originareola = Math.Max(0, originareola + amount);
areolaSizePermanent = Math.Min(MaxAreola, areolaSizePermanent + amount);
areolaSize = Math.Min(MaxAreola, areolaSize + amount);
areolaSizeCurrent = areolaSize;
}
public void UpdateColor()
{
cachedcolor = Colors.CMYKLerp(parent?.pawn?.story?.SkinColor ?? Color.white, Props.BlackNippleColor, Alpha);
} }
public void CopyBreastProperties(HediffComp_Breast original) public void CopyBreastProperties(HediffComp_Breast original)
{ {
alphaPermanent = original.alphaPermanent; maxBreastIncrement = original.maxBreastIncrement;
alphaCurrent = original.alphaCurrent; maxAreolaIncrement = original.maxAreolaIncrement;
alpha = original.alpha; baseAlpha = original.baseAlpha;
areolaSizePermanent = original.areolaSizePermanent; baseAreola = original.baseAreola;
areolaSizeCurrent = original.areolaSizeCurrent; baseNipple = original.baseNipple;
areolaSize = original.areolaSize; UpdateNipples();
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 "Size: " + parent.Severity +
"\nIncrease: " + breastSizeIncreased +
"\n" + debugGrowthStatus + "\n" + debugGrowthStatus +
"\nAlpha: " + alpha + "\nNipple progress: " + nippleProgress +
"\nNippleSize: " + nippleSize + "\nBase alpha: " + baseAlpha +
"\nAreolaSize: " + areolaSize + "\nAlpha: " + cachedAlpha +
"\nAlphaCurrent: " + alphaCurrent + "\nBase areola: " + baseAreola +
"\nNippleSizeCurrent: " + nippleSizeCurrent + "\nAreola: " + cachedAreola +
"\nAreolaSizeCurrent: " + areolaSizeCurrent + "\nDisplayed areola: " + AreolaSize +
"\nAlphaOrigin: " + originalpha + "\nBase nipple: " + baseNipple +
"\nNippleSizeOrigin: " + originnipple + "\nNipple: " + cachedNipple +
"\nAreolaSizeOrigin: " + originareola + "\nDisplayed nipple: " + NippleSize;
"\nAlphaMax: " + MaxAlpha +
"\nNippleSizeMax: " + MaxNipple +
"\nAreolaSizeMax: " + MaxAreola +
"\nPermanentAlpha:" + alphaPermanent +
"\nPermanentNipple:" + nippleSizePermanent +
"\nPermanentAreola:" + areolaSizePermanent;
} }
} }
} }

View file

@ -1394,10 +1394,6 @@ namespace RJW_Menstruation
EggDecay(); EggDecay();
if (Implant()) if (Implant())
{ {
if (Breast != null)
{
Breast.PregnancyTransition();
}
GoNextStage(Stage.Pregnant); GoNextStage(Stage.Pregnant);
} }
else else
@ -1459,10 +1455,6 @@ namespace RJW_Menstruation
else else
{ {
if (pregnancy != null) pregnancy = null; if (pregnancy != null) pregnancy = null;
if (Breast != null)
{
Breast.BirthTransition();
}
GoNextStage(Stage.Recover); GoNextStage(Stage.Recover);
} }
} }

View file

@ -48,7 +48,7 @@ namespace RJW_Menstruation
{ {
protected override void SurgeryResult(HediffComp_Breast breast) protected override void SurgeryResult(HediffComp_Breast breast)
{ {
breast.AdjustAreolaSizeImmidiately(0.1f); breast.AdjustAreolaSizeImmediately(0.2f);
} }
} }
@ -56,7 +56,7 @@ namespace RJW_Menstruation
{ {
protected override void SurgeryResult(HediffComp_Breast breast) protected override void SurgeryResult(HediffComp_Breast breast)
{ {
breast.AdjustAreolaSizeImmidiately(-0.1f); breast.AdjustAreolaSizeImmediately(-0.2f);
} }
} }
@ -64,7 +64,7 @@ namespace RJW_Menstruation
{ {
protected override void SurgeryResult(HediffComp_Breast breast) protected override void SurgeryResult(HediffComp_Breast breast)
{ {
breast.AdjustNippleSizeImmidiately(0.1f); breast.AdjustNippleSizeImmediately(0.2f);
} }
} }
@ -72,7 +72,7 @@ namespace RJW_Menstruation
{ {
protected override void SurgeryResult(HediffComp_Breast breast) protected override void SurgeryResult(HediffComp_Breast breast)
{ {
breast.AdjustNippleSizeImmidiately(-0.1f); breast.AdjustNippleSizeImmediately(-0.2f);
} }
} }
} }

View file

@ -98,14 +98,6 @@ namespace RJW_Menstruation
public static readonly string Option23_Label = "Option23_Label".Translate(); public static readonly string Option23_Label = "Option23_Label".Translate();
public static readonly string Option23_Label_1 = "Option23_Label_1".Translate(); public static readonly string Option23_Label_1 = "Option23_Label_1".Translate();
public static readonly string Option23_Label_2 = "Option23_Label_2".Translate(); public static readonly string Option23_Label_2 = "Option23_Label_2".Translate();
public static readonly string Option24_Label = "Option24_Label".Translate();
public static readonly string Option24_Desc = "Option24_Desc".Translate();
public static readonly string Option25_Label = "Option25_Label".Translate();
public static readonly string Option25_Desc = "Option25_Desc".Translate();
public static readonly string Option26_Label = "Option26_Label".Translate();
public static readonly string Option26_Desc = "Option26_Desc".Translate();
public static readonly string Option27_Label = "Option27_Label".Translate();
public static readonly string Option27_Desc = "Option27_Desc".Translate();
public static readonly string Option28_Label = "Option28_Label".Translate(); public static readonly string Option28_Label = "Option28_Label".Translate();
public static readonly string Option28_Tooltip = "Option28_Tooltip".Translate(); public static readonly string Option28_Tooltip = "Option28_Tooltip".Translate();
public static readonly string Option29_Label = "Option29_Label".Translate(); public static readonly string Option29_Label = "Option29_Label".Translate();
@ -116,6 +108,12 @@ namespace RJW_Menstruation
public static readonly string Option31_Desc = "Option31_Desc".Translate(); public static readonly string Option31_Desc = "Option31_Desc".Translate();
public static readonly string Option32_Label = "Option32_Label".Translate(); public static readonly string Option32_Label = "Option32_Label".Translate();
public static readonly string Option32_Desc = "Option32_Desc".Translate(); public static readonly string Option32_Desc = "Option32_Desc".Translate();
public static readonly string Option_MaxBreastIncrementFactor_Label = "Option_MaxBreastIncrementFactor_Label".Translate();
public static readonly string Option_MaxBreastIncrementFactor_Desc = "Option_MaxBreastIncrementFactor_Desc".Translate();
public static readonly string Option_MaxNippleIncrementFactor_Label = "Option_MaxNippleIncrementFactor_Label".Translate();
public static readonly string Option_MaxNippleIncrementFactor_Desc = "Option_MaxNippleIncrementFactor_Desc".Translate();
public static readonly string Option_PermanentNippleChange_Label = "Option_PermanentNippleChange_Label".Translate();
public static readonly string Option_PermanentNippleChange_Desc = "Option_PermanentNippleChange_Desc".Translate();
public static readonly string Option_EnableGatherCumGizmo_Label = "Option_EnableGatherCumGizmo_Label".Translate(); public static readonly string Option_EnableGatherCumGizmo_Label = "Option_EnableGatherCumGizmo_Label".Translate();
public static readonly string Option_EstrusOverride_Label = "Option_EstrusOverride_Label".Translate(); public static readonly string Option_EstrusOverride_Label = "Option_EstrusOverride_Label".Translate();
public static readonly string Option_EstrusOverride_Desc = "Option_EstrusOverride_Desc".Translate(); public static readonly string Option_EstrusOverride_Desc = "Option_EstrusOverride_Desc".Translate();

View file

@ -370,7 +370,7 @@ namespace RJW_Menstruation
pawn.DrawBreastIcon(BreastIconRect, Mouse.IsOver(BreastIconRect) && Input.GetMouseButton(0)); pawn.DrawBreastIcon(BreastIconRect);
GUI.color = Color.white; GUI.color = Color.white;

View file

@ -159,7 +159,7 @@ namespace RJW_Menstruation
} }
} }
public static void DrawBreastIcon(this Pawn pawn, Rect rect, bool drawOrigin = false) public static void DrawBreastIcon(this Pawn pawn, Rect rect)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast")); Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("breast"));
Texture2D breast, nipple, areola; Texture2D breast, nipple, areola;
@ -191,16 +191,8 @@ namespace RJW_Menstruation
string nippleicon, areolaicon; string nippleicon, areolaicon;
float nipplesize, areolasize; float nipplesize, areolasize;
if (drawOrigin) nipplesize = comp.NippleSize;
{ areolasize = comp.AreolaSize;
nipplesize = comp.OriginNipple;
areolasize = comp.OriginAreola;
}
else
{
nipplesize = comp.NippleSize;
areolasize = comp.AreolaSize;
}
nippleicon = icon + "_Nipple0" + GetNippleIndex(nipplesize); nippleicon = icon + "_Nipple0" + GetNippleIndex(nipplesize);
areolaicon = icon + "_Areola0" + GetAreolaIndex(areolasize); areolaicon = icon + "_Areola0" + GetAreolaIndex(areolasize);
@ -212,14 +204,8 @@ namespace RJW_Menstruation
GUI.color = pawn.story.SkinColor; GUI.color = pawn.story.SkinColor;
GUI.DrawTexture(rect, breast, ScaleMode.ScaleToFit); GUI.DrawTexture(rect, breast, ScaleMode.ScaleToFit);
if (drawOrigin) GUI.color = comp.NippleColor;
{
GUI.color = comp.OriginColor;
}
else
{
GUI.color = comp.NippleColor;
}
GUI.DrawTexture(rect, areola, ScaleMode.ScaleToFit); GUI.DrawTexture(rect, areola, ScaleMode.ScaleToFit);
GUI.DrawTexture(rect, nipple, ScaleMode.ScaleToFit); GUI.DrawTexture(rect, nipple, ScaleMode.ScaleToFit);