Don't allow ovum extraction for menopausal pawns

This commit is contained in:
lutepickle 2022-11-10 21:25:07 -08:00
parent 4f2830084c
commit 0154f89438
3 changed files with 28 additions and 1 deletions

View File

@ -132,6 +132,7 @@
<CustomHybrid_List_Title>Custom Hybrid Editor</CustomHybrid_List_Title>
<CustomHybrid_Title>Hybrids of {0}</CustomHybrid_Title>
<CustomHybrid_Tooltip>When {0} breed with {1}, {2} will be born at {3} chance.&#10;If both races have hybrid definitions for each other, the father's definition will be used.</CustomHybrid_Tooltip>
<CannotNoEggs>No eggs</CannotNoEggs>
</LanguageData>

View File

@ -2,6 +2,7 @@
using System.Linq;
using RimWorld;
using Verse;
using System.Collections.Generic;
namespace RJW_Menstruation
{
@ -61,4 +62,27 @@ namespace RJW_Menstruation
__result = 0.999f;
}
}
[HarmonyPatch(typeof(Recipe_ExtractOvum), nameof(Recipe_ExtractOvum.AvailableReport))]
public class ExtractOvum_AvailableReport_Patch
{
public static void PostFix(Thing thing, ref AcceptanceReport __result)
{
if (!__result.Accepted) return;
Pawn pawn = (Pawn)thing;
if (pawn.IsRJWPregnant())
{
__result = "CannotPregnant".Translate();
return;
}
List<HediffComp_Menstruation> comps = pawn.GetMenstruationComps().ToList();
if (!comps.Any()) return;
if (comps.All(comp => comp.ovarypower <= 0))
{
__result = Translations.CannotNoEggs;
return;
}
return;
}
}
}

View File

@ -135,6 +135,8 @@ namespace RJW_Menstruation
public static readonly string Gizmo_GatherCum = "Gizmo_GatherCum".Translate();
public static readonly string FloatMenu_CleanSelf = "FloatMenu_CleanSelf".Translate();
public static readonly string CannotNoEggs = "CannotNoEggs".Translate();
public static readonly string CustomHybrid_List_Title = "CustomHybrid_List_Title".Translate();
static public string CustomHybrid_Title(string label) { return TranslatorFormattedStringExtensions.Translate("CustomHybrid_Title", label); }
static public string CustomHybrid_Tooltip(string label, string breedee, string baby, string chance) { return TranslatorFormattedStringExtensions.Translate("CustomHybrid_Tooltip", label, breedee, baby, chance); }