mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Move RandomVariabilityPercent to MenstruationUtility
This commit is contained in:
parent
afc04d2fa5
commit
f585499871
3 changed files with 16 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue