Compare commits

..

No commits in common. "d1d4398aa4f0489646dc524ee88d4d12aac62fba" and "b70b4a6c903bf7e9a1b9f1c6404d85f243d948fb" have entirely different histories.

6 changed files with 43 additions and 23 deletions

View file

@ -133,7 +133,7 @@
<Option_PregnancyFromBaseRJW_Label>Use basic RJW pregnancy</Option_PregnancyFromBaseRJW_Label>
<Option_PregnancyFromMultiplePregnancy_Label>Use menstruation multiple pregnancy</Option_PregnancyFromMultiplePregnancy_Label>
<Option_PregnancyFromBiotech_Label>Use Biotech pregnancy</Option_PregnancyFromBiotech_Label>
<Option_EnableBiotechTwins_Label>Enable multiple babies/twins in a single Biotech pregnancy.</Option_EnableBiotechTwins_Label>
<Option_EnableBiotechTwins_Label>(EXPERIMENTAL) Enable multiple babies/twins in a single Biotech pregnancy.</Option_EnableBiotechTwins_Label>
<Option_EnableBiotechTwins_Desc>Enabling this option will allow identical and hetero ovular twins with Biotech.&#10;Also allows the hybrid system, but two humanlikes cannot produce an animal.</Option_EnableBiotechTwins_Desc>
<Option_EnableDraftedIcon_Label>Show womb status when drafted</Option_EnableDraftedIcon_Label>
<Option_EnableDraftedIcon_Desc>Draw womb icon for drafted pawns</Option_EnableDraftedIcon_Desc>

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 = null;
protected int opcache = -1;
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.HasValue) return opcache.Value;
if (opcache > 0) return opcache;
const float yearsBeforeMenopause = 6.0f;
opcache = (int)(RaceCyclesPerYear() *
AverageLitterSize() *
yearsBeforeMenopause *
(Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy));
if (opcache <= 0) opcache = 1;
return opcache.Value;
if (opcache == 0) opcache = 1;
return opcache;
}
}
@ -655,7 +655,7 @@ namespace RJW_Menstruation
estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible;
ovulationFactor = 1f;
noBleeding = false;
opcache = null;
opcache = -1;
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))
@ -971,7 +971,7 @@ namespace RJW_Menstruation
if (Pawn.HasIUD()) antisperm = 0.70f + asafactor;
else antisperm = 0.0f + asafactor;
absorber = Pawn.apparel?.WornApparel.OfType<Absorber>().FirstOrDefault();
absorber = (Absorber)Pawn.apparel?.WornApparel.Find(x => x is Absorber);
if (absorber != null)
{
absorber.WearEffect(TickInterval);
@ -1390,12 +1390,6 @@ namespace RJW_Menstruation
deadeggs.Add(egg);
continue;
}
else if (ModsConfig.BiotechActive && !Find.Storyteller.difficulty.ChildrenAllowed)
{
if (Configurations.Debug) Log.Message($"Could not implant {Pawn}'s egg due to children being disabled");
deadeggs.Add(egg);
continue;
}
else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer)))
{
try

View file

@ -43,14 +43,14 @@ namespace RJW_Menstruation
switch (parent)
{
case Hediff_Pregnant hediff_Pregnant:
Hediff_Labor labor = Pawn.health.hediffSet.hediffs.OfType<Hediff_Labor>().MaxByWithFallback(hediff => hediff.loadID);
Hediff_Labor labor = (Hediff_Labor)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_Labor).MaxByWithFallback(hediff => hediff.loadID);
HediffComp_PregeneratedBabies laborcomp = labor?.TryGetComp<HediffComp_PregeneratedBabies>();
if (laborcomp == null) return;
laborcomp.babies = this.babies;
laborcomp.enzygoticSiblings = this.enzygoticSiblings;
break;
case Hediff_Labor hediff_Labor:
Hediff_LaborPushing pushing = Pawn.health.hediffSet.hediffs.OfType<Hediff_LaborPushing>().MaxByWithFallback(hediff => hediff.loadID);
Hediff_LaborPushing pushing = (Hediff_LaborPushing)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_LaborPushing).MaxByWithFallback(hediff => hediff.loadID);
HediffComp_PregeneratedBabies pushingcomp = pushing?.TryGetComp<HediffComp_PregeneratedBabies>();
if (pushingcomp == null) return;
pushingcomp.babies = this.babies;
@ -103,6 +103,7 @@ namespace RJW_Menstruation
{
firstbaby = baby;
request.FixedGender = baby.gender;
request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList();
}
else
{

View file

@ -395,10 +395,23 @@ namespace RJW_Menstruation
public static HediffComp_Menstruation.EstrusLevel HighestEstrus(this Pawn pawn)
{
return pawn.GetMenstruationComps().
Select(comp => comp.GetEstrusLevel()).
DefaultIfEmpty(HediffComp_Menstruation.EstrusLevel.None).
Max();
HediffComp_Menstruation.EstrusLevel res = HediffComp_Menstruation.EstrusLevel.None;
foreach(HediffComp_Menstruation comp in pawn.GetMenstruationComps())
{
switch (comp.GetEstrusLevel())
{
case HediffComp_Menstruation.EstrusLevel.None:
break;
case HediffComp_Menstruation.EstrusLevel.Concealed:
res = HediffComp_Menstruation.EstrusLevel.Concealed;
break;
case HediffComp_Menstruation.EstrusLevel.Visible:
return HediffComp_Menstruation.EstrusLevel.Visible;
}
}
return res;
}
public static bool HasIUD(this Pawn pawn)
@ -428,10 +441,21 @@ namespace RJW_Menstruation
public static float DamagePants(this Pawn pawn, float fluidAmount)
{
if (pawn.apparel == null) return 0;
if (!pawn.apparel.WornApparel.
Where(apparel => apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)).
TryMinBy(apparel => apparel.def.apparel.LastLayer.drawOrder, out Apparel pants))
return 0;
Apparel pants = null;
foreach(Apparel apparel in pawn.apparel.WornApparel.Where(app => app.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)))
{
if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin)
{
pants = apparel;
break;
}
else if (pants == null || apparel.def.apparel.LastLayer == ApparelLayerDefOf.Middle)
// Either grab whatever's available or reassign the pants from shell to a middle
pants = apparel;
// Pants are middle and this is a shell
else continue;
}
if (pants == null) return 0;
const float HPPerMl = 0.5f;

View file

@ -343,6 +343,7 @@ namespace RJW_Menstruation
firstbaby = baby;
request.FixedGender = baby.gender;
request.ForcedEndogenes = baby.genes?.Endogenes.Select(gene => gene.def).ToList();
}
else
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB