Merge branch 'dev'

This commit is contained in:
lutepickle 2024-01-27 05:50:11 -08:00
commit 51c23f5aba
8 changed files with 30 additions and 57 deletions

Binary file not shown.

View file

@ -198,20 +198,9 @@ namespace RJW_Menstruation
get
{
if (opcache > 0) return opcache;
float avglittersize;
try
{
avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f);
}
catch
{
// Any exceptions in that will have been reported elsewhere in the code by now
avglittersize = 1.0f;
};
avglittersize *= ovulationFactor;
const float yearsBeforeMenopause = 6.0f;
opcache = (int)(RaceCyclesPerYear() *
avglittersize *
AverageLitterSize() *
yearsBeforeMenopause *
(Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy));
if (opcache == 0) opcache = 1;
@ -689,6 +678,7 @@ namespace RJW_Menstruation
estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible;
ovulationFactor = 1f;
noBleeding = false;
opcache = -1;
if (Pawn.genes == null || !ModsConfig.BiotechActive) return;
@ -1220,6 +1210,21 @@ namespace RJW_Menstruation
{
}
protected float AverageLitterSize()
{
float avglittersize;
try
{
avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f);
}
catch (NullReferenceException)
{
avglittersize = 1.0f;
}
avglittersize *= ovulationFactor;
return avglittersize;
}
protected virtual float RaceCyclesPerYear()
{
int breedingSeasons = 0;
@ -1242,16 +1247,7 @@ namespace RJW_Menstruation
public int GetOvaryPowerByAge()
{
float avglittersize;
try
{
avglittersize = Mathf.Max(Rand.ByCurveAverage(Pawn.RaceProps.litterSizeCurve), 1.0f);
}
catch (NullReferenceException)
{
avglittersize = 1.0f;
}
avglittersize *= ovulationFactor;
float avglittersize = AverageLitterSize();
float fertStartAge = Pawn.RaceProps.lifeStageAges?.Find(stage => stage.def.reproductive)?.minAge ?? 0.0f;
float fertEndAge = Pawn.RaceProps.lifeExpectancy * (Pawn.IsAnimal() ? RJWPregnancySettings.fertility_endage_female_animal : RJWPregnancySettings.fertility_endage_female_humanlike);
@ -1972,7 +1968,7 @@ namespace RJW_Menstruation
public int EggsRestoredPerBiosculptor(float yearsWorth)
{
return Math.Max(1, (int)((float)RaceCyclesPerYear() * yearsWorth));
return Math.Max(1, (int)(RaceCyclesPerYear() * yearsWorth * AverageLitterSize()));
}
public void RestoreEggs(float yearsWorth)

View file

@ -396,12 +396,10 @@ namespace RJW_Menstruation
public static bool ShouldCycle(this Pawn pawn)
{
if (!Configurations.EnableAnimalCycle && pawn.IsAnimal()) return false;
if (pawn.GetComp<CompEggLayer>() != null) return false;
if (pawn.RaceHasOviPregnancy()) return false;
if (ModsConfig.BiotechActive && pawn.genes != null)
{
foreach (Gene gene in pawn.genes.GenesListForReading)
if (VariousDefOf.EggLayerGenes.Contains(gene.def)) return false;
}
if (ModsConfig.BiotechActive && pawn.genes != null &&
pawn.genes.GenesListForReading.Select(gene => gene.def).Intersect(VariousDefOf.EggLayerGenes).Any()) return false;
return true;
}

View file

@ -192,23 +192,6 @@ namespace RJW_Menstruation
}
}
[HarmonyPatch(typeof(Pawn_GeneTracker), "AddGene", new Type[] { typeof(Gene), typeof(bool) })]
public class AddGene_Patch
{
public static bool Prefix(ref Gene __result, Gene gene, Pawn ___pawn)
{
if (!VariousDefOf.WombGenes.Contains(gene.def)) return true;
bool keepGene;
if (PawnGenerator.IsBeingGenerated(___pawn))
// During pawn generation, the vagina hediff doesn't exist yet, so use gender to decide instead
// Not the most accurate, but close enough
keepGene = ___pawn.gender == Gender.Female;
else keepGene = ___pawn.GetMenstruationComps().Any();
if (!keepGene) __result = null;
return keepGene;
}
}
[HarmonyPatch(typeof(Pawn_GeneTracker), "Notify_GenesChanged")]
public class Notify_GenesChanged_Patch
{

View file

@ -219,7 +219,7 @@ namespace RJW_Menstruation
public void CheckDirty()
{
if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && (Wearer?.apparel?.IsLocked(this) ?? false))
if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && !(Wearer?.apparel?.IsLocked(this) ?? false))
{
def = DirtyDef;
dirty = true;

View file

@ -54,16 +54,6 @@ namespace RJW_Menstruation
public static readonly GeneDef QuadOvulation = DefDatabase<GeneDef>.GetNamed("Menstruation_QuadOvulation");
public static readonly GeneDef NoBleeding = DefDatabase<GeneDef>.GetNamed("Menstruation_NoBleeding");
public static readonly HashSet<GeneDef> WombGenes = new HashSet<GeneDef>() {
ShortEggLifetime,
DoubleEggLifetime,
QuadEggLifetime,
NeverEstrus,
FullEstrus,
DoubleOvulation,
QuadOvulation,
NoBleeding };
private static List<ThingDef> allraces = null;
private static List<PawnKindDef> allkinds = null;
private static HashSet<HediffDef> allvaginas = null;

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>RJW Menstruation</identifier>
<version>1.0.9.2</version>
<version>1.0.9.3</version>
<dependencies>
</dependencies>
<incompatibleWith />

View file

@ -1,3 +1,9 @@
Version 1.0.9.3
- The biosculptor egg restoration cycle will now give more eggs to races that ovulate more than one egg at a time.
- All pawns can now use all menstruation genes, regardless of gender or having a womb.
- Egglaying animals no longer have a menstrual cycle.
- Fix bug preventing absorbers from becoming dirty.
Version 1.0.9.2
- Updated Traditional Chinese translation by Hydrogen.
- Fixed the no bleeding gene having positive metabolic efficiency instead of negative.