Add a biosculptor recipe to restore eggs

This commit is contained in:
lutepickle 2022-12-24 19:44:07 -08:00
parent 2bc1133861
commit f6552b3a68
12 changed files with 100 additions and 4 deletions

Binary file not shown.

View File

@ -225,7 +225,20 @@
</li>
</stages>
</ThoughtDef>
<ThoughtDef MayRequire="Ludeon.Rimworld.Ideology">
<defName>EggRestorationReceived</defName>
<thoughtClass>Thought_Memory</thoughtClass>
<durationDays>4</durationDays>
<stackLimit>1</stackLimit>
<stages>
<li>
<label>egg restoration received</label>
<description>I can breed for a little longer now.</description>
<baseMoodEffect>2</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
</Defs>

View File

@ -136,5 +136,7 @@
<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>
<CannotNoWomb>Must have a womb</CannotNoWomb>
<EggRestorationCompleted>{PAWN_labelShort} has completed {PAWN_possessive} egg restoration cycle.</EggRestorationCompleted>
</LanguageData>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationFindMod">
<mods>
<li>Ideology</li>
</mods>
<match Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="BiosculpterPod"]/comps</xpath>
<value>
<li Class="RJW_Menstruation.CompProperties_BiosculpterPod_EggRestorationCycle">
<key>eggRestoration</key>
<label>egg restoration</label>
<description>Restore one year worth of eggs in each womb.</description>
<iconPath>Eggs/Egg</iconPath>
<durationDays>4</durationDays>
<!--Apparently the game is hardcoded to give the age reversal thought to anything with gainThoughtOnCompletion-->
<!--<gainThoughtOnCompletion>EggRestorationReceived</gainThoughtOnCompletion>-->
<operatingColor>(0.867, 0.373, 0.396)</operatingColor>
<yearsToRestore>1.0</yearsToRestore>
</li>
</value>
</match>
</Operation>
</Patch>

View File

@ -0,0 +1,27 @@
using RimWorld;
using Verse;
namespace RJW_Menstruation
{
public class CompProperties_BiosculpterPod_EggRestorationCycle : CompProperties_BiosculpterPod_BaseCycle
{
public CompProperties_BiosculpterPod_EggRestorationCycle()
{
compClass = typeof(CompBiosculpterPod_EggRestorationCycle);
}
public float yearsToRestore;
}
public class CompBiosculpterPod_EggRestorationCycle : CompBiosculpterPod_Cycle
{
public override void CycleCompleted(Pawn occupant)
{
foreach (HediffComp_Menstruation comp in occupant.GetMenstruationComps())
comp.RestoreEggs(((CompProperties_BiosculpterPod_EggRestorationCycle)Props).yearsToRestore);
Messages.Message(Translations.EggRestorationCompleted(occupant.Named("PAWN")), occupant, MessageTypeDefOf.PositiveEvent);
}
}
}

View File

@ -1792,6 +1792,16 @@ namespace RJW_Menstruation
crampPain = original.crampPain;
}
public int EggsRestoredPerBiosculptor(float yearsWorth)
{
return Math.Max(1, (int)((float)RaceCyclesPerYear() * yearsWorth));
}
public void RestoreEggs(float yearsWorth)
{
ovarypower += EggsRestoredPerBiosculptor(yearsWorth);
}
public class Egg : IExposable
{
public bool fertilized;

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using System;
using System.Linq;
using RimWorld;
using Verse;
@ -132,7 +133,7 @@ namespace RJW_Menstruation
if (pregnancy == null) continue;
if (Earliest_Pregnancy == null || Earliest_Pregnancy.Severity > pregnancy.Severity) Earliest_Pregnancy = pregnancy;
}
return Earliest_Pregnancy;
}
@ -176,4 +177,16 @@ namespace RJW_Menstruation
return TryTerminatePregnancy_Patch.Transpiler(instructions);
}
}
[HarmonyPatch(typeof(CompBiosculpterPod), nameof(CompBiosculpterPod.CannotUseNowPawnCycleReason), new Type[] { typeof(Pawn), typeof(Pawn), typeof(CompBiosculpterPod_Cycle), typeof(bool) } )]
public class CannotUseNowPawnCycleReason_Patch
{
private const string eggRestorationKey = "eggRestoration";
public static void Postfix(ref string __result, Pawn biosculptee, CompBiosculpterPod_Cycle cycle)
{
if (__result != null) return;
if(cycle.Props.key == eggRestorationKey && !biosculptee.GetMenstruationComps().Any())
__result = Translations.CannotNoWomb;
}
}
}

View File

@ -61,6 +61,7 @@
<ItemGroup>
<Compile Include="Compatibility\AnimalGeneticsCompatibility.cs" />
<Compile Include="Compatibility\HARCompatibility.cs" />
<Compile Include="CompBiosclupterPod_EggRestorationCycle.cs" />
<Compile Include="Configurations.cs" />
<Compile Include="Cum.cs" />
<Compile Include="DebugActions.cs" />

View File

@ -139,6 +139,9 @@ namespace RJW_Menstruation
public static readonly string CannotNoEggs = "CannotNoEggs".Translate();
public static readonly string CannotNoWomb = "CannotNoWomb".Translate();
public static string EggRestorationCompleted(NamedArgument name) { return "EggRestorationCompleted".Translate(name); }
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); }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>RJW Menstruation</identifier>
<version>1.0.8.4</version>
<version>1.0.8.5</version>
<dependencies>
</dependencies>
<incompatibleWith />

View File

@ -1,3 +1,6 @@
Version 1.0.8.5
- Added biosculptor recipe to restore 1 year's worth of eggs.
Version 1.0.8.4
- Fix Biotech xenotype inheritance for single-child pregnancies.
- Fix error in Traditional Chinese translation.