Compare commits

...

3 Commits

Author SHA1 Message Date
lutepickle 9a6efaf37d Have pheromones apply in caravans 2024-03-13 10:07:25 -07:00
lutepickle cca7676bc0 Have ovulation and implant chance cache be nullable 2024-03-13 08:10:50 -07:00
lutepickle ba8801370f Have TotalFertCum account for destroyed pawns and animals 2024-03-13 08:03:02 -07:00
4 changed files with 24 additions and 12 deletions

Binary file not shown.

View File

@ -123,8 +123,8 @@ namespace RJW_Menstruation
protected string customwombtex = null; protected string customwombtex = null;
protected string customvagtex = null; protected string customvagtex = null;
protected bool estrusflag = false; protected bool estrusflag = false;
protected float ovulationChanceCache = -1.0f; // Dirtied every simulation protected float? ovulationChanceCache = null; // Dirtied every simulation
protected float implantationChanceCache = -1.0f; protected float? implantationChanceCache = null;
protected int opcache = -1; protected int opcache = -1;
protected float antisperm = 0.0f; protected float antisperm = 0.0f;
// RJW pregnancy, or Biotech pregnancy/labor/laborpushing // RJW pregnancy, or Biotech pregnancy/labor/laborpushing
@ -259,7 +259,7 @@ namespace RJW_Menstruation
} }
public float TotalFertCum public float TotalFertCum
{ {
get => cums?.Sum(cum => cum.FertVolume) ?? 0; get => cums?.Where(cum => CumCanFertilize(cum)).Sum(cum => cum.FertVolume) ?? 0;
} }
public float TotalCumPercent public float TotalCumPercent
{ {
@ -289,7 +289,7 @@ namespace RJW_Menstruation
private bool calculatingOvulationChance = false; private bool calculatingOvulationChance = false;
public bool CalculatingOvulationChance { get => calculatingOvulationChance; } public bool CalculatingOvulationChance { get => calculatingOvulationChance; }
protected float CalculatedOvulationChance() private float CalculatedOvulationChance()
{ {
float ovulationChance = 1.0f; float ovulationChance = 1.0f;
if (EggHealth <= 0.0f) return 0.0f; if (EggHealth <= 0.0f) return 0.0f;
@ -315,7 +315,7 @@ namespace RJW_Menstruation
return ovulationChance; return ovulationChance;
} }
protected float CalculatedImplantChance() private float CalculatedImplantChance()
{ {
if (ModsConfig.BiotechActive && xxx.is_human(Pawn)) if (ModsConfig.BiotechActive && xxx.is_human(Pawn))
{ {
@ -336,8 +336,8 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (ovulationChanceCache < 0.0f) ovulationChanceCache = CalculatedOvulationChance(); if (ovulationChanceCache == null) ovulationChanceCache = CalculatedOvulationChance();
return ovulationChanceCache; return ovulationChanceCache.Value;
} }
} }
@ -346,8 +346,8 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (implantationChanceCache < 0.0f) implantationChanceCache = CalculatedImplantChance(); if (implantationChanceCache == null) implantationChanceCache = CalculatedImplantChance();
return implantationChanceCache; return implantationChanceCache.Value;
} }
} }
@ -1266,8 +1266,8 @@ namespace RJW_Menstruation
protected virtual void BeforeSimulator() protected virtual void BeforeSimulator()
{ {
ovulationChanceCache = -1.0f; ovulationChanceCache = null;
implantationChanceCache = -1.0f; implantationChanceCache = null;
CumOut(); CumOut();
} }
@ -1335,10 +1335,18 @@ namespace RJW_Menstruation
} }
} }
public bool CumCanFertilize(Cum cum)
{
return !cum.notcum &&
cum.FertVolume > 0 &&
!(cum.pawn?.Destroyed ?? true) &&
(RJWPregnancySettings.bestial_pregnancy_enabled || xxx.is_animal(Pawn) == xxx.is_animal(cum.pawn));
}
protected Pawn Fertilize() protected Pawn Fertilize()
{ {
if (cums.NullOrEmpty()) return null; if (cums.NullOrEmpty()) return null;
List<Cum> eligibleCum = cums.FindAll(cum => !cum.notcum && cum.FertVolume > 0 && !(cum.pawn?.Destroyed ?? true) && (RJWPregnancySettings.bestial_pregnancy_enabled || xxx.is_animal(Pawn) == xxx.is_animal(cum.pawn))); List<Cum> eligibleCum = cums.FindAll(cum => CumCanFertilize(cum));
if (eligibleCum.Count == 0) return null; if (eligibleCum.Count == 0) return null;
float totalFertPower = eligibleCum.Sum(cum => cum.FertVolume); float totalFertPower = eligibleCum.Sum(cum => cum.FertVolume);

View File

@ -1,6 +1,7 @@
 
using RimWorld; using RimWorld;
using RimWorld.Planet;
using rjw; using rjw;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -46,6 +47,8 @@ namespace RJW_Menstruation
protected IEnumerable<Pawn> AffectedPawns() protected IEnumerable<Pawn> AffectedPawns()
{ {
if(Pawn.GetCaravan() is Caravan caravan)
foreach (Pawn p in caravan.PawnsListForReading.Where(p => p != Pawn)) yield return p;
Map mapHeld = Pawn.MapHeld; Map mapHeld = Pawn.MapHeld;
if (mapHeld == null) yield break; if (mapHeld == null) yield break;
foreach (Pawn pawn in mapHeld.mapPawns.AllPawnsSpawned) foreach (Pawn pawn in mapHeld.mapPawns.AllPawnsSpawned)

View File

@ -1,5 +1,6 @@
Version 1.0.9.4 Version 1.0.9.4
- Added graphics for the menstruation genes with thanks to Alpenglow. - Added graphics for the menstruation genes with thanks to Alpenglow.
- Pawns in estrus now give their pheromones to their caravan-mates.
- Pawns with the egglaying genes from Erin's Corvyia and Outland - Genetics no longer have a menstrual cycle. - Pawns with the egglaying genes from Erin's Corvyia and Outland - Genetics no longer have a menstrual cycle.
Version 1.0.9.3 Version 1.0.9.3