Move RandomVariabilityPercent to MenstruationUtility

This commit is contained in:
lutepickle 2022-07-11 07:33:42 -07:00
parent afc04d2fa5
commit f585499871
3 changed files with 16 additions and 16 deletions

View File

@ -887,7 +887,7 @@ namespace RJW_Menstruation
if (!Props.infertile)
{
if (cycleSpeed < 0f) cycleSpeed = Utility.RandGaussianLike(0.8f, 1.2f);
if (cycleVariability < 0f) cycleVariability = Utility.RandomVariabilityPercent();
if (cycleVariability < 0f) cycleVariability = MenstruationUtility.RandomVariabilityPercent();
if (currentIntervalHours < 0)
{
if (parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) curStage = Stage.Young;

View File

@ -280,6 +280,21 @@ namespace RJW_Menstruation
else return (hediff.p_end_tick - hediff.p_start_tick) / GenDate.TicksPerHour;
}
public static float RandomVariabilityPercent(int recursion = 0)
{
// Humans, in days
const float mean = 1.635f;
const float stddev = 0.9138f;
const float lambda = 0.234f;
if (recursion >= 10) return mean / (28 * 2);
float variability = Rand.Gaussian(mean, stddev) - Mathf.Log(Rand.Value) / lambda;
variability /= 28 * 2; // Convert to percentage
if (variability < 0 || variability > 0.35f) return RandomVariabilityPercent(recursion + 1); // ~2% chance, about the limit on how far variability can go before things start to break
else return variability;
}
public static bool IsInEstrus(this Pawn pawn, bool visible = true)
{
if (pawn.Dead) return false;

View File

@ -439,21 +439,6 @@ namespace RJW_Menstruation
}
public static float RandomVariabilityPercent(int recursion = 0)
{
// Humans, in days
const float mean = 1.635f;
const float stddev = 0.9138f;
const float lambda = 0.234f;
if (recursion >= 10) return mean / (28 * 2);
float variability = Rand.Gaussian(mean, stddev) - Mathf.Log(Rand.Value) / lambda;
variability /= 28 * 2; // Convert to percentage
if (variability < 0 || variability > 0.35f) return RandomVariabilityPercent(recursion + 1); // ~2% chance, about the limit on how far variability can go before things start to break
else return variability;
}
public static float LerpMultiple(this float a, float b, float t, int num)
{
float tmult = Mathf.Pow(1 - t, num);