Compare commits

...

7 Commits

8 changed files with 17 additions and 12 deletions

Binary file not shown.

View File

@ -17,9 +17,9 @@ namespace RJW_Menstruation
{ {
protected bool hadOvulatoryStage = false; // Regardless of whether an egg was actually produced protected bool hadOvulatoryStage = false; // Regardless of whether an egg was actually produced
protected override void InitializeExtraValues() protected override void PostInitialize()
{ {
base.InitializeExtraValues(); base.PostInitialize();
hadOvulatoryStage |= IsEggExist; hadOvulatoryStage |= IsEggExist;
} }

View File

@ -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 = (Absorber)Pawn.apparel?.WornApparel.Find(x => x is Absorber);
if (absorber != null) if (absorber != null)
{ {
absorber.WearEffect(TickInterval); absorber.WearEffect(TickInterval);
@ -1164,7 +1164,7 @@ namespace RJW_Menstruation
else if (currentIntervalTicks < curStageTicks) curStageTicks = currentIntervalTicks; else if (currentIntervalTicks < curStageTicks) curStageTicks = currentIntervalTicks;
} }
if (crampPain < 0) crampPain = PainRandomizer(); if (crampPain < 0) crampPain = PainRandomizer();
InitializeExtraValues(); PostInitialize();
TakeLoosePregnancy(); TakeLoosePregnancy();
@ -1178,7 +1178,7 @@ namespace RJW_Menstruation
Notify_UpdatedGenes(); Notify_UpdatedGenes();
} }
protected virtual void InitializeExtraValues() protected virtual void PostInitialize()
{ {
} }
@ -1459,6 +1459,7 @@ namespace RJW_Menstruation
break; break;
case Hediff_BasePregnancy _: case Hediff_BasePregnancy _:
default: default:
if (Configurations.Debug) Log.Message($"Not adding to existing pregnancy {pregnancy?.GetUniqueLoadID()}");
pregnant = true; pregnant = true;
deadeggs.Add(egg); deadeggs.Add(egg);
break; break;
@ -1479,7 +1480,7 @@ namespace RJW_Menstruation
float interspeciesFactor = InterspeciesImplantFactor(egg.fertilizer); float interspeciesFactor = InterspeciesImplantFactor(egg.fertilizer);
float implantChance = Configurations.ImplantationChance * ImplantChance * interspeciesFactor; float implantChance = Configurations.ImplantationChance * ImplantChance * interspeciesFactor;
Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, " + Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, " +
(interspeciesFactor < 1.0f ? $"interspecies factor {interspeciesFactor.ToStringPercent()}, " : "") + (interspeciesFactor != 1.0f ? $"interspecies factor {interspeciesFactor.ToStringPercent()}, " : "") +
$"father {egg.fertilizer})"); $"father {egg.fertilizer})");
} }
deadeggs.Add(egg); deadeggs.Add(egg);

View File

@ -26,9 +26,9 @@ namespace RJW_Menstruation
Props = (CompProperties_PeriodicOvulator)props; Props = (CompProperties_PeriodicOvulator)props;
} }
protected override void InitializeExtraValues() protected override void PostInitialize()
{ {
base.InitializeExtraValues(); base.PostInitialize();
if (averageCycleIntervalTicks < 0) if (averageCycleIntervalTicks < 0)
{ {
averageCycleIntervalTicks = (int)(Props.cycleIntervalDays.RandomInRange * GenDate.TicksPerDay / cycleSpeed); averageCycleIntervalTicks = (int)(Props.cycleIntervalDays.RandomInRange * GenDate.TicksPerDay / cycleSpeed);

View File

@ -48,7 +48,10 @@ namespace RJW_Menstruation
protected IEnumerable<Pawn> AffectedPawns() protected IEnumerable<Pawn> AffectedPawns()
{ {
if (Pawn.GetCaravan() is Caravan caravan) if (Pawn.GetCaravan() is Caravan caravan)
{
foreach (Pawn p in caravan.PawnsListForReading.Where(p => p != Pawn)) yield return p; foreach (Pawn p in caravan.PawnsListForReading.Where(p => p != Pawn)) yield return p;
yield break;
}
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

@ -204,7 +204,7 @@ namespace RJW_Menstruation
if (comp?.HasBaby ?? false) if (comp?.HasBaby ?? false)
{ {
RitualOutcomePossibility thisOutcome = outcome; RitualOutcomePossibility thisOutcome = outcome;
Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(PreceptDefOf.ChildBirth); Precept_Ritual precept_Ritual = (Precept_Ritual)comp.Pawn.Ideo.GetPrecept(RimWorld.PreceptDefOf.ChildBirth);
float birthQuality = PregnancyUtility.GetBirthQualityFor(mother); float birthQuality = PregnancyUtility.GetBirthQualityFor(mother);
do do
{ {

View File

@ -30,7 +30,8 @@ namespace RJW_Menstruation
base.PostAdd(dinfo); base.PostAdd(dinfo);
if (IsVisible) if (IsVisible)
{ {
List<Hediff> removals = pawn.health.hediffSet.hediffs.Where(hediff => hediff.def == VariousDefOf.Hediff_Estrus_Concealed).ToList(); List <Hediff> removals = new List <Hediff>();
pawn.health.hediffSet.GetHediffs(ref removals, hediff => hediff.def == VariousDefOf.Hediff_Estrus_Concealed);
foreach (Hediff concealedEstrus in removals) foreach (Hediff concealedEstrus in removals)
{ {
pawn.health.RemoveHediff(concealedEstrus); pawn.health.RemoveHediff(concealedEstrus);

View File

@ -174,7 +174,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Lib.Harmony"> <PackageReference Include="Lib.Harmony">
<Version>2.3.1.1</Version> <Version>2.3.2</Version>
<ExcludeAssets>runtime</ExcludeAssets> <ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>