diff --git a/1.3/Assemblies/RJW_Menstruation.dll b/1.3/Assemblies/RJW_Menstruation.dll index 541fc71..2663071 100644 Binary files a/1.3/Assemblies/RJW_Menstruation.dll and b/1.3/Assemblies/RJW_Menstruation.dll differ diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index 8fcd081..9b53c81 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -136,39 +136,24 @@ namespace RJW_Menstruation { get { - float res = 0; if (cums.NullOrEmpty()) return 0; - foreach (Cum cum in cums) - { - res += cum.Volume; - } - return res; + return cums.Sum(cum => cum.Volume); } } public float TotalFertCum { get { - float res = 0; if (cums.NullOrEmpty()) return 0; - foreach (Cum cum in cums) - { - if (!cum.notcum) res += cum.FertVolume; - } - return res; + return cums.Sum(cum => cum.FertVolume); } } public float TotalCumPercent { get { - float res = 0; if (cums.NullOrEmpty()) return 0; - foreach (Cum cum in cums) - { - res += cum.Volume; - } - return res / Props.maxCumCapacity; + return cums.Sum(cum => cum.Volume) / Props.maxCumCapacity; } } public float CumCapacity @@ -372,11 +357,7 @@ namespace RJW_Menstruation get { if (eggs.NullOrEmpty() || cums.NullOrEmpty()) return false; - foreach (Cum cum in cums) - { - if (cum.FertVolume > 0) return true; - } - return false; + return cums.Any(cum => cum.FertVolume > 0); } } /// @@ -573,11 +554,8 @@ namespace RJW_Menstruation /// public Cum GetCum(Pawn pawn) { - if (!cums.NullOrEmpty()) foreach (Cum cum in cums) - { - if (!cum.notcum && cum.pawn.Equals(pawn)) return cum; - } - return null; + if (cums.NullOrEmpty()) return null; + return cums.Find(cum => !cum.notcum && cum.pawn == pawn); } /// @@ -1076,10 +1054,8 @@ namespace RJW_Menstruation List eligibleCum = cums.FindAll(cum => !cum.notcum && cum.FertVolume > 0 && cum.pawn != null && (RJWPregnancySettings.bestial_pregnancy_enabled || xxx.is_animal(parent.pawn) == xxx.is_animal(cum.pawn))); if (eligibleCum.Count == 0) return null; - float totalFertPower = 0; - foreach (Cum cum in eligibleCum) - totalFertPower += cum.FertVolume; - + float totalFertPower = eligibleCum.Sum(cum => cum.FertVolume); + if (Rand.Range(0.0f, 1.0f) > 1.0f - Mathf.Pow(1.0f - Configurations.FertilizeChance, totalFertPower * Props.basefertilizationChanceFactor)) return null; @@ -1093,20 +1069,7 @@ namespace RJW_Menstruation } // We shouldn't reach here, but floating point errors exist, so just to be sure, select whomever came the most - - float mostCum = 0; - Pawn mostCummer = null; - - foreach (Cum cum in eligibleCum) - { - if (cum.FertVolume > mostCum) - { - mostCum = cum.FertVolume; - mostCummer = cum.pawn; - } - } - - return mostCummer; + return eligibleCum.MaxBy(cum => cum.FertVolume).pawn; } diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs index ebc4d4e..186356b 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs @@ -59,11 +59,9 @@ namespace RJW_Menstruation Pawn pawn = props.partner; Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs().MaxBy(hediff => hediff.loadID); if (newestPregnancy == null) return; - foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps()) - { - if (comp.Pregnancy == newestPregnancy) return; // One of the wombs did get it - } - __state.Pregnancy = newestPregnancy; + + if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it + else __state.Pregnancy = newestPregnancy; } ///