Switch opcache to a nullable

This commit is contained in:
lutepickle 2024-05-12 22:27:09 -07:00
parent 3cd1220283
commit a0d0993560

View file

@ -125,7 +125,7 @@ namespace RJW_Menstruation
protected bool estrusflag = false;
protected float? ovulationChanceCache = null; // Dirtied every simulation
protected float? implantationChanceCache = null;
protected int opcache = -1;
protected int? opcache = null;
protected float antisperm = 0.0f;
// RJW pregnancy, or Biotech pregnancy/labor/laborpushing
protected Hediff pregnancy = null;
@ -197,14 +197,14 @@ namespace RJW_Menstruation
{
get
{
if (opcache > 0) return opcache;
if (opcache.HasValue) return opcache.Value;
const float yearsBeforeMenopause = 6.0f;
opcache = (int)(RaceCyclesPerYear() *
AverageLitterSize() *
yearsBeforeMenopause *
(Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy));
if (opcache == 0) opcache = 1;
return opcache;
if (opcache <= 0) opcache = 1;
return opcache.Value;
}
}
@ -655,7 +655,7 @@ namespace RJW_Menstruation
estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible;
ovulationFactor = 1f;
noBleeding = false;
opcache = -1;
opcache = null;
if (Pawn.genes == null || !ModsConfig.BiotechActive) return;
foreach (MenstruationModExtension extension in Pawn.genes.GenesListForReading.Where(gene => gene.Active).Select(gene => gene.def.GetModExtension<MenstruationModExtension>()).Where(ext => ext != null))