Compare commits

...

8 commits

Author SHA1 Message Date
lutepickle
d1d4398aa4 Add mod icon 2024-05-14 21:44:39 -07:00
lutepickle
c9c5e70246 Refactor HighestEstrus 2024-05-14 21:15:49 -07:00
lutepickle
2516ed1439 Refactor DamagePants 2024-05-14 20:51:18 -07:00
lutepickle
9a495ad32b Remove redundant setting of ForcedEndogenes for enzygotic twins 2024-05-13 07:05:45 -07:00
lutepickle
26864e4025 Remove experimental tag from Biotech multiple pregnancy option 2024-05-13 05:56:22 -07:00
lutepickle
a0d0993560 Switch opcache to a nullable 2024-05-12 22:27:09 -07:00
lutepickle
3cd1220283 Use OfType in places where it'd be useful 2024-05-10 21:23:46 -07:00
lutepickle
7f6309466a Log a message if an egg would implant but children are disabled 2024-05-10 21:06:51 -07:00
6 changed files with 23 additions and 43 deletions

View file

@ -133,7 +133,7 @@
<Option_PregnancyFromBaseRJW_Label>Use basic RJW pregnancy</Option_PregnancyFromBaseRJW_Label> <Option_PregnancyFromBaseRJW_Label>Use basic RJW pregnancy</Option_PregnancyFromBaseRJW_Label>
<Option_PregnancyFromMultiplePregnancy_Label>Use menstruation multiple pregnancy</Option_PregnancyFromMultiplePregnancy_Label> <Option_PregnancyFromMultiplePregnancy_Label>Use menstruation multiple pregnancy</Option_PregnancyFromMultiplePregnancy_Label>
<Option_PregnancyFromBiotech_Label>Use Biotech pregnancy</Option_PregnancyFromBiotech_Label> <Option_PregnancyFromBiotech_Label>Use Biotech pregnancy</Option_PregnancyFromBiotech_Label>
<Option_EnableBiotechTwins_Label>(EXPERIMENTAL) Enable multiple babies/twins in a single Biotech pregnancy.</Option_EnableBiotechTwins_Label> <Option_EnableBiotechTwins_Label>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_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_Label>Show womb status when drafted</Option_EnableDraftedIcon_Label>
<Option_EnableDraftedIcon_Desc>Draw womb icon for drafted pawns</Option_EnableDraftedIcon_Desc> <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 bool estrusflag = false;
protected float? ovulationChanceCache = null; // Dirtied every simulation protected float? ovulationChanceCache = null; // Dirtied every simulation
protected float? implantationChanceCache = null; protected float? implantationChanceCache = null;
protected int opcache = -1; protected int? opcache = null;
protected float antisperm = 0.0f; protected float antisperm = 0.0f;
// RJW pregnancy, or Biotech pregnancy/labor/laborpushing // RJW pregnancy, or Biotech pregnancy/labor/laborpushing
protected Hediff pregnancy = null; protected Hediff pregnancy = null;
@ -197,14 +197,14 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (opcache > 0) return opcache; if (opcache.HasValue) return opcache.Value;
const float yearsBeforeMenopause = 6.0f; const float yearsBeforeMenopause = 6.0f;
opcache = (int)(RaceCyclesPerYear() * opcache = (int)(RaceCyclesPerYear() *
AverageLitterSize() * AverageLitterSize() *
yearsBeforeMenopause * yearsBeforeMenopause *
(Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)); (Pawn.RaceProps.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy));
if (opcache == 0) opcache = 1; if (opcache <= 0) opcache = 1;
return opcache; return opcache.Value;
} }
} }
@ -655,7 +655,7 @@ namespace RJW_Menstruation
estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible; estrusLevel = Props.concealedEstrus ? EstrusLevel.Concealed : EstrusLevel.Visible;
ovulationFactor = 1f; ovulationFactor = 1f;
noBleeding = false; noBleeding = false;
opcache = -1; opcache = null;
if (Pawn.genes == null || !ModsConfig.BiotechActive) return; 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)) 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; if (Pawn.HasIUD()) antisperm = 0.70f + asafactor;
else antisperm = 0.0f + asafactor; else antisperm = 0.0f + asafactor;
absorber = (Absorber)Pawn.apparel?.WornApparel.Find(x => x is Absorber); absorber = Pawn.apparel?.WornApparel.OfType<Absorber>().FirstOrDefault();
if (absorber != null) if (absorber != null)
{ {
absorber.WearEffect(TickInterval); absorber.WearEffect(TickInterval);
@ -1390,6 +1390,12 @@ namespace RJW_Menstruation
deadeggs.Add(egg); deadeggs.Add(egg);
continue; 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))) else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer)))
{ {
try try

View file

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

View file

@ -395,23 +395,10 @@ namespace RJW_Menstruation
public static HediffComp_Menstruation.EstrusLevel HighestEstrus(this Pawn pawn) public static HediffComp_Menstruation.EstrusLevel HighestEstrus(this Pawn pawn)
{ {
HediffComp_Menstruation.EstrusLevel res = HediffComp_Menstruation.EstrusLevel.None; return pawn.GetMenstruationComps().
Select(comp => comp.GetEstrusLevel()).
foreach(HediffComp_Menstruation comp in pawn.GetMenstruationComps()) DefaultIfEmpty(HediffComp_Menstruation.EstrusLevel.None).
{ Max();
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) public static bool HasIUD(this Pawn pawn)
@ -441,21 +428,10 @@ namespace RJW_Menstruation
public static float DamagePants(this Pawn pawn, float fluidAmount) public static float DamagePants(this Pawn pawn, float fluidAmount)
{ {
if (pawn.apparel == null) return 0; if (pawn.apparel == null) return 0;
Apparel pants = null; if (!pawn.apparel.WornApparel.
foreach(Apparel apparel in pawn.apparel.WornApparel.Where(app => app.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))) Where(apparel => apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)).
{ TryMinBy(apparel => apparel.def.apparel.LastLayer.drawOrder, out Apparel pants))
if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin) return 0;
{
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; const float HPPerMl = 0.5f;

View file

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

BIN
About/ModIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB