Cache the ovulation and implantation chances to spare the UI

This commit is contained in:
lutepickle 2023-05-01 14:22:22 -07:00
parent 152a745af2
commit 82a34f8ea8
2 changed files with 59 additions and 42 deletions

Binary file not shown.

View File

@ -123,6 +123,8 @@ namespace RJW_Menstruation
protected string customwombtex = null;
protected string customvagtex = null;
protected bool estrusflag = false;
protected float ovulationChanceCache = -1.0f; // Dirtied every simulation
protected float implantationChanceCache = -1.0f;
protected int opcache = -1;
protected float antisperm = 0.0f;
protected float? originvagsize = null;
@ -294,9 +296,7 @@ namespace RJW_Menstruation
// I hate doing this, but it's the least bad option
public bool calculatingOvulationChance = false;
public float OvulationChance
{
get
protected float CalcuatedOvulationChance()
{
float ovulationChance = 1.0f;
if (EggHealth <= 0.0f) return 0.0f;
@ -327,10 +327,8 @@ namespace RJW_Menstruation
}
return ovulationChance;
}
}
public float ImplantChance
{
get
protected float CalcuatedImplantChance()
{
float factor = 1.0f;
if (ModsConfig.BiotechActive && xxx.is_human(Pawn))
@ -347,6 +345,23 @@ namespace RJW_Menstruation
return Pawn.health.capacities.GetLevel(xxx.reproduction) * Props.baseImplantationChanceFactor * FertilityModifier * factor;
}
}
public float OvulationChance
{
get
{
if (ovulationChanceCache < 0.0f) ovulationChanceCache = CalcuatedOvulationChance();
return ovulationChanceCache;
}
}
public float ImplantChance
{
get
{
if (implantationChanceCache < 0.0f) implantationChanceCache = CalcuatedImplantChance();
return implantationChanceCache;
}
}
public IEnumerable<string> GetCumsInfo
@ -1260,6 +1275,8 @@ namespace RJW_Menstruation
protected virtual void BeforeSimulator()
{
ovulationChanceCache = -1.0f;
implantationChanceCache = -1.0f;
CumOut();
}