Merge branch 'dev'

This commit is contained in:
lutepickle 2024-01-08 13:55:51 -08:00
commit 23ae342722
29 changed files with 368 additions and 314 deletions

Binary file not shown.

View File

@ -99,7 +99,7 @@
<displayCategory>Menstruation</displayCategory> <displayCategory>Menstruation</displayCategory>
<description>Carriers of this gene will not bleed at the end of their cycle.</description> <description>Carriers of this gene will not bleed at the end of their cycle.</description>
<iconPath>UI/Genes/Placeholder</iconPath> <iconPath>UI/Genes/Placeholder</iconPath>
<biostatMet>1</biostatMet> <biostatMet>-1</biostatMet>
<displayOrderInCategory>40</displayOrderInCategory> <displayOrderInCategory>40</displayOrderInCategory>
</GeneDef> </GeneDef>

View File

@ -59,9 +59,16 @@
<tags> <tags>
<li>Absorber</li> <li>Absorber</li>
</tags> </tags>
<defaultOutfitTags>
<li>Worker</li>
<li>Soldier</li>
<li>Nudist</li>
<li>Slave</li>
</defaultOutfitTags>
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.2</passiveAbsorptionPerHour>
<leakAfterDirty>false</leakAfterDirty> <leakAfterDirty>false</leakAfterDirty>
<effectsAfterDirty>true</effectsAfterDirty> <effectsAfterDirty>true</effectsAfterDirty>
<minHourstoDirtyEffect>10</minHourstoDirtyEffect> <minHourstoDirtyEffect>10</minHourstoDirtyEffect>
@ -116,6 +123,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.2</passiveAbsorptionPerHour>
<leakAfterDirty>false</leakAfterDirty> <leakAfterDirty>false</leakAfterDirty>
<effectsAfterDirty>true</effectsAfterDirty> <effectsAfterDirty>true</effectsAfterDirty>
<minHourstoDirtyEffect>8</minHourstoDirtyEffect> <minHourstoDirtyEffect>8</minHourstoDirtyEffect>
@ -190,9 +198,15 @@
<tags> <tags>
<li>Absorber</li> <li>Absorber</li>
</tags> </tags>
<defaultOutfitTags>
<li>Worker</li>
<li>Soldier</li>
<li>Slave</li>
</defaultOutfitTags>
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.04</passiveAbsorptionPerHour>
<leakAfterDirty>true</leakAfterDirty> <leakAfterDirty>true</leakAfterDirty>
<effectsAfterDirty>false</effectsAfterDirty> <effectsAfterDirty>false</effectsAfterDirty>
<dirtyDef>Absorber_Pad_Dirty</dirtyDef> <dirtyDef>Absorber_Pad_Dirty</dirtyDef>
@ -254,6 +268,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.04</passiveAbsorptionPerHour>
<leakAfterDirty>true</leakAfterDirty> <leakAfterDirty>true</leakAfterDirty>
<effectsAfterDirty>false</effectsAfterDirty> <effectsAfterDirty>false</effectsAfterDirty>
<dirtyDef>Absorber_Pad_Dirty</dirtyDef> <dirtyDef>Absorber_Pad_Dirty</dirtyDef>

View File

@ -13,4 +13,10 @@
<Hediff_PainReliever.description>緩解源自於痛經及此類神經痛的苦楚。</Hediff_PainReliever.description> <Hediff_PainReliever.description>緩解源自於痛經及此類神經痛的苦楚。</Hediff_PainReliever.description>
<Hediff_Cyclosporine.label>環孢素</Hediff_Cyclosporine.label> <Hediff_Cyclosporine.label>環孢素</Hediff_Cyclosporine.label>
<Hediff_Cyclosporine.description>由於免疫抑製劑的作用,身體抵抗感染和疾病的能力受扼制。</Hediff_Cyclosporine.description> <Hediff_Cyclosporine.description>由於免疫抑製劑的作用,身體抵抗感染和疾病的能力受扼制。</Hediff_Cyclosporine.description>
<!--Auto generated: Wed Aug 30 16:05:07 2023-->
<Hediff_AffectedByPheromones.label>受費洛蒙影響</Hediff_AffectedByPheromones.label>
<Hediff_AffectedByPheromones.description>受附近某人處於發情期之故,此人的性需求及娛樂需求正急遽上升。</Hediff_AffectedByPheromones.description>
<Hediff_AffectedByPheromones.stages.0.label></Hediff_AffectedByPheromones.stages.0.label>
<Hediff_AffectedByPheromones.stages.1.label></Hediff_AffectedByPheromones.stages.1.label>
<Hediff_AffectedByPheromones.stages.2.label></Hediff_AffectedByPheromones.stages.2.label>
</LanguageData> </LanguageData>

View File

@ -11,4 +11,13 @@
<!--Auto generated: Thu Jan 5 22:13:15 2023--> <!--Auto generated: Thu Jan 5 22:13:15 2023-->
<EggRestorationReceived.stages.0.label>卵母細胞再生術</EggRestorationReceived.stages.0.label> <EggRestorationReceived.stages.0.label>卵母細胞再生術</EggRestorationReceived.stages.0.label>
<EggRestorationReceived.stages.0.description>我可以繼續繁衍一小段時間了!</EggRestorationReceived.stages.0.description> <EggRestorationReceived.stages.0.description>我可以繼續繁衍一小段時間了!</EggRestorationReceived.stages.0.description>
<!--Auto generated: Wed Aug 30 16:05:07 2023-->
<CameInsideMIdeo.stages.0.label>內射了{0}</CameInsideMIdeo.stages.0.label>
<CameInsideMIdeo.stages.0.description>讓她懷孕正是我的職責所在。</CameInsideMIdeo.stages.0.description>
<CameInsideFIdeo.stages.0.label>{0}內射了我</CameInsideFIdeo.stages.0.label>
<CameInsideFIdeo.stages.0.description>我希望這次能懷上,讓我盡到責任。</CameInsideFIdeo.stages.0.description>
<HaterCameInsideFIdeo.stages.0.label>{0}內射了我</HaterCameInsideFIdeo.stages.0.label>
<HaterCameInsideFIdeo.stages.0.description>我知道我有生育的義務,但是難道非他不可嗎?</HaterCameInsideFIdeo.stages.0.description>
<HateTookContraceptivePillIdeo.stages.0.label>服用避孕藥</HateTookContraceptivePillIdeo.stages.0.label>
<HateTookContraceptivePillIdeo.stages.0.description>我的信仰要求我能夠懷孕。</HateTookContraceptivePillIdeo.stages.0.description>
</LanguageData> </LanguageData>

View File

@ -154,4 +154,18 @@
<Option_EnableBiotechTwins_Label>(測試中!) 允許在「生機」(Biotech)追加的懷孕機制中出現多胞胎。</Option_EnableBiotechTwins_Label> <Option_EnableBiotechTwins_Label>(測試中!) 允許在「生機」(Biotech)追加的懷孕機制中出現多胞胎。</Option_EnableBiotechTwins_Label>
<Option_EnableBiotechTwins_Desc>啟用這個選項將允許同卵或異卵雙胞胎出現在「生機」(Biotech)追加的懷孕機制中。 <Option_EnableBiotechTwins_Desc>啟用這個選項將允許同卵或異卵雙胞胎出現在「生機」(Biotech)追加的懷孕機制中。
一併將啟用雜交系統;然而兩個類人(humanlikes)生物絕不可能生出動物。</Option_EnableBiotechTwins_Desc> 一併將啟用雜交系統;然而兩個類人(humanlikes)生物絕不可能生出動物。</Option_EnableBiotechTwins_Desc>
<!--Auto generated: Wed Aug 30 16:05:07 2023-->
<Option_ColonistUpdateInterval_Label>玩家小人刷新間隔</Option_ColonistUpdateInterval_Label>
<Option_ColonistUpdateInterval_Desc>殖民者、囚犯和奴隸的子宮狀態應該每隔多久刷新一次?
較小的刷新間隔可以更精確地模擬真實子宮;較大的刷新間隔可以提升遊戲流暢度</Option_ColonistUpdateInterval_Desc>
<Option_NonColonistUpdateInterval_Label>非玩家小人刷新間隔</Option_NonColonistUpdateInterval_Label>
<Option_NonColonistUpdateInterval_Desc>非玩家勢力控制下的小人的子宮應該每隔多久刷新一次?
較小的刷新間隔可以更精確地模擬真實子宮;較大的刷新間隔可以提升遊戲流暢度</Option_NonColonistUpdateInterval_Desc>
<Option_AnimalUpdateInterval_Label>動物子宮刷新間隔</Option_AnimalUpdateInterval_Label>
<Option_AnimalUpdateInterval_Desc>動物們的子宮應該多久刷新一次?
較小的刷新間隔可以更精確地模擬真實子宮;較大的刷新間隔可以提升遊戲流暢度</Option_AnimalUpdateInterval_Desc>
<Option_EnablePheromones_Label>啟用費洛蒙機制</Option_EnablePheromones_Label>
<Option_EnablePheromones_Desc>擁有發情期的類人生物在發情期將刺激附近的雄性類人生物,使其性慾大增。</Option_EnablePheromones_Desc>
<Option_AnimalPheromoneEffect_Label>動物費洛蒙效果</Option_AnimalPheromoneEffect_Label>
<Option_AnimalPheromoneEffect_Desc>選定擁有發情期的動物在發情期內對類人生物的影響。</Option_AnimalPheromoneEffect_Desc>
</LanguageData> </LanguageData>

View File

@ -37,7 +37,7 @@
<Dialog_WombInfo08></Dialog_WombInfo08> <Dialog_WombInfo08></Dialog_WombInfo08>
<Dialog_WombInfo09></Dialog_WombInfo09> <Dialog_WombInfo09></Dialog_WombInfo09>
<Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown> <Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown>
<Description_Absorbed>Absorbed</Description_Absorbed>
<Option1_Label_1>Enable womb icon</Option1_Label_1> <Option1_Label_1>Enable womb icon</Option1_Label_1>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<JobDef>
<defName>LactateSelf_MC</defName>
<driverClass>MilkModule.JobDriver_MilkSelf_MC</driverClass>
<reportString>lactating self</reportString>
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
</JobDef>
</Defs>

View File

@ -5,8 +5,6 @@ VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RJW_Menstruation", "RJW_Menstruation\RJW_Menstruation.csproj", "{EED2F3B9-8C20-4194-919E-8D151B29F70B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RJW_Menstruation", "RJW_Menstruation\RJW_Menstruation.csproj", "{EED2F3B9-8C20-4194-919E-8D151B29F70B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MilkModule", "MilkModule\MilkModule.csproj", "{3591B3C1-EB57-44BF-AB69-A613E097A7F8}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -17,10 +15,6 @@ Global
{EED2F3B9-8C20-4194-919E-8D151B29F70B}.Debug|Any CPU.Build.0 = Debug|Any CPU {EED2F3B9-8C20-4194-919E-8D151B29F70B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EED2F3B9-8C20-4194-919E-8D151B29F70B}.Release|Any CPU.ActiveCfg = Release|Any CPU {EED2F3B9-8C20-4194-919E-8D151B29F70B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EED2F3B9-8C20-4194-919E-8D151B29F70B}.Release|Any CPU.Build.0 = Release|Any CPU {EED2F3B9-8C20-4194-919E-8D151B29F70B}.Release|Any CPU.Build.0 = Release|Any CPU
{3591B3C1-EB57-44BF-AB69-A613E097A7F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3591B3C1-EB57-44BF-AB69-A613E097A7F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3591B3C1-EB57-44BF-AB69-A613E097A7F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3591B3C1-EB57-44BF-AB69-A613E097A7F8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -150,7 +150,7 @@ namespace RJW_Menstruation
public bool ShouldSimulate() public bool ShouldSimulate()
{ {
if (!Configurations.EnableAnimalCycle && Pawn.IsAnimal()) return false; if (!Pawn.ShouldCycle()) return false;
if (Pawn.SpawnedOrAnyParentSpawned || Pawn.IsCaravanMember() || PawnUtility.IsTravelingInTransportPodWorldObject(Pawn)) return true; if (Pawn.SpawnedOrAnyParentSpawned || Pawn.IsCaravanMember() || PawnUtility.IsTravelingInTransportPodWorldObject(Pawn)) return true;
return false; return false;

View File

@ -30,7 +30,7 @@ namespace RJW_Menstruation
switch (CurrentVisibleStage) switch (CurrentVisibleStage)
{ {
case Stage.Follicular: case Stage.Follicular:
return Translations.Stage_Follicular_Induced_Desc + (EggHealth < 1f ? Translations.Stage_Climacteric_Desc : ""); return Translations.Stage_Follicular_Induced_Desc + (EggHealth < 1f ? " " + Translations.Stage_Climacteric_Desc : "");
default: default:
return base.GetCurStageDesc; return base.GetCurStageDesc;
} }
@ -106,19 +106,8 @@ namespace RJW_Menstruation
protected override bool ShouldBeInEstrus() protected override bool ShouldBeInEstrus()
{ {
if (!loaded) if (curStage == Stage.Luteal && !hadOvulatoryStage) return false;
Initialize(); else return base.ShouldBeInEstrus();
switch (curStage)
{
case Stage.Follicular:
return curStageTicks > currentIntervalTicks - Props.estrusDaysBeforeOvulation * GenDate.TicksPerDay;
case Stage.Ovulatory:
return true;
case Stage.Luteal:
return hadOvulatoryStage && curStageTicks < EggLifespanTicks;
default:
return false;
}
} }
} }
} }

View File

@ -290,7 +290,7 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (QuirkUtility.HasQuirk(Pawn, QuirkUtility.Quirks.Breeder)) return 0.5f; if (Pawn.IsBreeder()) return 0.5f;
return 1.0f; return 1.0f;
} }
@ -300,7 +300,7 @@ namespace RJW_Menstruation
private bool calculatingOvulationChance = false; private bool calculatingOvulationChance = false;
public bool CalculatingOvulationChance { get => calculatingOvulationChance; } public bool CalculatingOvulationChance { get => calculatingOvulationChance; }
protected float CalcuatedOvulationChance() protected float CalculatedOvulationChance()
{ {
float ovulationChance = 1.0f; float ovulationChance = 1.0f;
if (EggHealth <= 0.0f) return 0.0f; if (EggHealth <= 0.0f) return 0.0f;
@ -308,20 +308,14 @@ namespace RJW_Menstruation
if (ModsConfig.BiotechActive && xxx.is_human(Pawn)) if (ModsConfig.BiotechActive && xxx.is_human(Pawn))
{ {
if (Pawn.SterileGenes()) return 0.0f; if (Pawn.SterileGenes()) return 0.0f;
// Replicate how rjw.PawnCapacityWorker_Fertility.CalculateCapacityLevel does it, but without the age factor
if (!Pawn.RaceHasFertility()) return 0.0f; if (!Pawn.RaceHasFertility()) return 0.0f;
if (AndroidsCompatibility.IsAndroid(Pawn) && parent.def != Genital_Helper.archotech_vagina) return 0.0f; if (AndroidsCompatibility.IsAndroid(Pawn) && parent.def != Genital_Helper.archotech_vagina) return 0.0f;
foreach (var part in StatDefOf.Fertility.parts)
{ float ageFactor = 1.0f;
if(part is StatPart_FertilityByGenderAge fertilityByAge) StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>()?.TransformValue(StatRequest.For(Pawn), ref ageFactor);
{ if (ageFactor <= 0.0f) return 0.0f; // Too young or too old
float factor = 1.0f;
fertilityByAge.TransformValue(StatRequest.For(Pawn), ref factor); if (Pawn.IsBreeder()) ovulationChance *= 10.0f;
if (factor <= 0.0f) return 0.0f; // Too young or too old
}
else part.TransformValue(StatRequest.For(Pawn), ref ovulationChance);
}
if (Pawn.HasQuirk(QuirkUtility.Quirks.Breeder)) ovulationChance *= 10.0f;
try try
{ {
calculatingOvulationChance = true; calculatingOvulationChance = true;
@ -332,20 +326,19 @@ namespace RJW_Menstruation
return ovulationChance; return ovulationChance;
} }
protected float CalcuatedImplantChance() protected float CalculatedImplantChance()
{ {
float factor = 1.0f;
if (ModsConfig.BiotechActive && xxx.is_human(Pawn)) if (ModsConfig.BiotechActive && xxx.is_human(Pawn))
{ {
// Implant factor will be based solely on pawn age, plus any rollover from ovulation chance // Implant factor will be based solely on pawn age, plus any rollover from ovulation chance
StatPart_FertilityByGenderAge fertilityStatPart = StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>(); float factor = 1.0f;
fertilityStatPart?.TransformValue(StatRequest.For(Pawn), ref factor); StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>()?.TransformValue(StatRequest.For(Pawn), ref factor);
if (OvulationChance > 1.0f) factor *= OvulationChance; if (OvulationChance > 1.0f) factor *= OvulationChance;
return Props.baseImplantationChanceFactor * FertilityModifier * factor; return Props.baseImplantationChanceFactor * FertilityModifier * factor;
} }
else else
{ {
return Pawn.health.capacities.GetLevel(xxx.reproduction) * Props.baseImplantationChanceFactor * FertilityModifier * factor; return Pawn.health.capacities.GetLevel(xxx.reproduction) * Props.baseImplantationChanceFactor * FertilityModifier;
} }
} }
@ -353,16 +346,17 @@ namespace RJW_Menstruation
{ {
get get
{ {
if (ovulationChanceCache < 0.0f) ovulationChanceCache = CalcuatedOvulationChance(); if (ovulationChanceCache < 0.0f) ovulationChanceCache = CalculatedOvulationChance();
return ovulationChanceCache; return ovulationChanceCache;
} }
} }
// Before configuration setting
public float ImplantChance public float ImplantChance
{ {
get get
{ {
if (implantationChanceCache < 0.0f) implantationChanceCache = CalcuatedImplantChance(); if (implantationChanceCache < 0.0f) implantationChanceCache = CalculatedImplantChance();
return implantationChanceCache; return implantationChanceCache;
} }
} }
@ -698,22 +692,25 @@ namespace RJW_Menstruation
if (Pawn.genes == null || !ModsConfig.BiotechActive) return; if (Pawn.genes == null || !ModsConfig.BiotechActive) return;
if (Pawn.genes.HasGene(VariousDefOf.ShortEggLifetime)) eggLifeSpanTicks = eggLifeSpanTicks * 3 / 4; foreach (GeneDef geneDef in Pawn.genes.GenesListForReading.Select(gene => gene.def))
else if (Pawn.genes.HasGene(VariousDefOf.DoubleEggLifetime)) eggLifeSpanTicks *= 2; {
else if (Pawn.genes.HasGene(VariousDefOf.QuadEggLifetime)) eggLifeSpanTicks *= 4; if (geneDef == VariousDefOf.ShortEggLifetime) eggLifeSpanTicks = eggLifeSpanTicks * 3 / 4;
else if (geneDef == VariousDefOf.DoubleEggLifetime) eggLifeSpanTicks *= 2;
else if (geneDef == VariousDefOf.QuadEggLifetime) eggLifeSpanTicks *= 4;
if (Pawn.genes.HasGene(VariousDefOf.NeverEstrus)) estrusLevel = EstrusLevel.None; else if (geneDef == VariousDefOf.NeverEstrus) estrusLevel = EstrusLevel.None;
else if (Pawn.genes.HasGene(VariousDefOf.FullEstrus)) estrusLevel = EstrusLevel.Visible; else if (geneDef == VariousDefOf.FullEstrus) estrusLevel = EstrusLevel.Visible;
if (Pawn.genes.HasGene(VariousDefOf.DoubleOvulation)) ovulationFactor = 2f; else if (geneDef == VariousDefOf.DoubleOvulation) ovulationFactor = 2f;
else if (Pawn.genes.HasGene(VariousDefOf.QuadOvulation)) ovulationFactor = 4f; else if (geneDef == VariousDefOf.QuadOvulation) ovulationFactor = 4f;
noBleeding = Pawn.genes.HasGene(VariousDefOf.NoBleeding); else if (geneDef == VariousDefOf.NoBleeding) noBleeding = true;
}
} }
public bool ShouldSimulate() public bool ShouldSimulate()
{ {
if (!Configurations.EnableAnimalCycle && Pawn.IsAnimal()) return false; if (!Pawn.ShouldCycle()) return false;
if (Pawn.SpawnedOrAnyParentSpawned || Pawn.IsCaravanMember() || PawnUtility.IsTravelingInTransportPodWorldObject(Pawn)) return true; if (Pawn.SpawnedOrAnyParentSpawned || Pawn.IsCaravanMember() || PawnUtility.IsTravelingInTransportPodWorldObject(Pawn)) return true;
return false; return false;
@ -735,6 +732,9 @@ namespace RJW_Menstruation
// If an exception makes it out, RW will remove the hediff, so catch it here // If an exception makes it out, RW will remove the hediff, so catch it here
try try
{ {
if (Pawn.IsHashIntervalTick(recalculateTickInterval)) TickInterval = -1; // Every so often, force TickInterval to be recalculated in case the pawn's status changed.
if (!Pawn.IsHashIntervalTick(TickInterval)) return;
if (!ShouldSimulate()) return; if (!ShouldSimulate()) return;
// Initialize immediately if needed, but if there's an error, then don't spam it every tick // Initialize immediately if needed, but if there's an error, then don't spam it every tick
@ -744,9 +744,6 @@ namespace RJW_Menstruation
Initialize(); Initialize();
} }
if (Pawn.IsHashIntervalTick(recalculateTickInterval)) TickInterval = -1; // Every so often, force TickInterval to be recalculated in case the pawn's status changed.
if (!Pawn.IsHashIntervalTick(TickInterval)) return;
if (initError) Log.Warning($"Attempting to process {Pawn}'s womb uninitialized"); if (initError) Log.Warning($"Attempting to process {Pawn}'s womb uninitialized");
if (Pregnancy != null && curStage != Stage.Pregnant) if (Pregnancy != null && curStage != Stage.Pregnant)
@ -889,8 +886,8 @@ namespace RJW_Menstruation
if (!precum && fertility > 0 && IsDangerDay && cummer.relations.GetPregnancyApproachForPartner(Pawn) == PregnancyApproach.AvoidPregnancy) if (!precum && fertility > 0 && IsDangerDay && cummer.relations.GetPregnancyApproachForPartner(Pawn) == PregnancyApproach.AvoidPregnancy)
{ {
float successChance = pulloutSuccessRate; float successChance = pulloutSuccessRate;
if (cummer.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish)) successChance *= fetishPulloutSuccessModifier; if (cummer.HasImpregnationFetish()) successChance *= fetishPulloutSuccessModifier;
if (Pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish)) successChance *= fetishPulloutSuccessModifier; if (Pawn.HasImpregnationFetish()) successChance *= fetishPulloutSuccessModifier;
if (Rand.Chance(successChance)) return; if (Rand.Chance(successChance)) return;
} }
if (Pawn.HasIUD()) fertility /= 100f; if (Pawn.HasIUD()) fertility /= 100f;
@ -1413,39 +1410,11 @@ namespace RJW_Menstruation
continue; continue;
} }
else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer))) else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer)))
{
try
{ {
if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}"); if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}");
if (pregnancy != null) if (pregnancy == null)
{
if (Configurations.PregnancySource == Configurations.PregnancyType.Biotech && Configurations.EnableBiotechTwins && Configurations.EnableHeteroOvularTwins)
{
if (Configurations.Debug) Log.Message($"Adding to existing Biotech pregnancy {pregnancy}");
HediffComp_PregeneratedBabies comp = pregnancy.TryGetComp<HediffComp_PregeneratedBabies>();
if (comp == null) Log.Warning($"Trying to add Biotech egg to {Pawn}'s pregnancy without a pregenerated baby comp: {pregnancy}");
else
{
comp.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
}
}
else if (Configurations.PregnancySource == Configurations.PregnancyType.MultiplePregnancy && Configurations.EnableHeteroOvularTwins)
{
if (pregnancy is Hediff_MultiplePregnancy h)
{
if (Configurations.Debug) Log.Message($"Adding to existing pregnancy {h}");
h.AddNewBaby(Pawn, egg.fertilizer);
}
pregnant = true;
deadeggs.Add(egg);
}
else
{
pregnant = true;
break;
}
}
else
{ {
Configurations.PregnancyType usePregnancy = xxx.is_human(Pawn) ? Configurations.PregnancySource : Configurations.PregnancyType.MultiplePregnancy; Configurations.PregnancyType usePregnancy = xxx.is_human(Pawn) ? Configurations.PregnancySource : Configurations.PregnancyType.MultiplePregnancy;
switch (usePregnancy) switch (usePregnancy)
@ -1486,25 +1455,72 @@ namespace RJW_Menstruation
rjw_preg.p_end_tick -= egg.ticksSinceFertilization / Configurations.CycleAcceleration; rjw_preg.p_end_tick -= egg.ticksSinceFertilization / Configurations.CycleAcceleration;
} }
} }
else
{
switch (pregnancy)
{
case Hediff_Pregnant vanillaPreg: // Not going to do the labor ones
if (!Configurations.EnableBiotechTwins || !Configurations.EnableHeteroOvularTwins) goto default;
if (Configurations.Debug) Log.Message($"Adding to existing Biotech pregnancy {vanillaPreg.GetUniqueLoadID()}");
HediffComp_PregeneratedBabies comp = vanillaPreg.TryGetComp<HediffComp_PregeneratedBabies>();
if (comp == null) Log.Warning($"Trying to add Biotech egg to {Pawn}'s pregnancy without a pregenerated baby comp: {vanillaPreg.GetUniqueLoadID()}");
else
comp.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
break;
case Hediff_MultiplePregnancy multiPreg:
if (!Configurations.EnableHeteroOvularTwins) goto default;
if (Configurations.Debug) Log.Message($"Adding to existing pregnancy {multiPreg.GetUniqueLoadID()}");
multiPreg.AddNewBaby(Pawn, egg.fertilizer);
pregnant = true;
deadeggs.Add(egg);
break;
case Hediff_BasePregnancy _:
default:
pregnant = true;
deadeggs.Add(egg);
break;
}
}
}
catch (Exception ex)
{
Log.Error($"Error creating pregnancy in {Pawn}'s womb, father {egg.fertilizer}: {ex}");
TakeLoosePregnancy();
deadeggs.Add(egg);
}
} }
else else
{ {
if (Configurations.Debug) if (Configurations.Debug)
{ {
float implantChance = Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer); float interspeciesFactor = InterspeciesImplantFactor(egg.fertilizer);
Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, father {egg.fertilizer})"); float implantChance = Configurations.ImplantationChance * ImplantChance * interspeciesFactor;
Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, " +
(interspeciesFactor < 1.0f ? $"interspecies factor {interspeciesFactor.ToStringPercent()}, " : "" ) +
$"father {egg.fertilizer})");
} }
deadeggs.Add(egg); deadeggs.Add(egg);
} }
} }
if (pregnant && bool clearAllEggs = true;
(Configurations.PregnancySource != Configurations.PregnancyType.MultiplePregnancy || !Configurations.EnableHeteroOvularTwins) && switch (Configurations.PregnancySource)
(Configurations.PregnancySource != Configurations.PregnancyType.Biotech || !Configurations.EnableBiotechTwins || !Configurations.EnableHeteroOvularTwins))
{ {
eggs.Clear(); case Configurations.PregnancyType.BaseRJW:
return true; clearAllEggs = true;
break;
case Configurations.PregnancyType.MultiplePregnancy:
clearAllEggs = !Configurations.EnableHeteroOvularTwins;
break;
case Configurations.PregnancyType.Biotech:
clearAllEggs = !(Configurations.EnableBiotechTwins && Configurations.EnableHeteroOvularTwins);
break;
} }
if (pregnant && clearAllEggs)
eggs.Clear();
else else
eggs.RemoveAll(egg => deadeggs.Contains(egg)); eggs.RemoveAll(egg => deadeggs.Contains(egg));
return pregnant; return pregnant;
@ -1554,12 +1570,7 @@ namespace RJW_Menstruation
return amount; return amount;
} }
absorber.absorbedfluids += amount; absorber.absorbedfluids += amount;
if (absorber.absorbedfluids > absorbable && !Pawn.apparel.IsLocked(absorber)) absorber.CheckDirty();
{
absorber.def = absorber.DirtyDef;
//absorber.fluidColor = GetCumMixtureColor;
absorber.dirty = true;
}
return 0; return 0;
} }
@ -1601,6 +1612,11 @@ namespace RJW_Menstruation
Pawn.health.AddHediff(hediff, parent.Part); Pawn.health.AddHediff(hediff, parent.Part);
} }
protected void AdvanceStageTime()
{
curStageTicks += TickInterval * Configurations.CycleAcceleration;
}
protected virtual void FollicularAction() protected virtual void FollicularAction()
{ {
if (!IsBreedingSeason()) if (!IsBreedingSeason())
@ -1615,13 +1631,12 @@ namespace RJW_Menstruation
} }
else else
{ {
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
if (!estrusflag && curStageTicks > currentIntervalTicks - Props.estrusDaysBeforeOvulation * GenDate.TicksPerDay) if (!estrusflag && curStageTicks > currentIntervalTicks - Props.estrusDaysBeforeOvulation * GenDate.TicksPerDay)
{ {
estrusflag = true; estrusflag = true;
SetEstrus(); SetEstrus();
} }
StayCurrentStage();
} }
} }
@ -1629,7 +1644,7 @@ namespace RJW_Menstruation
{ {
if (curStageTicks < currentIntervalTicks) if (curStageTicks < currentIntervalTicks)
{ {
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
return; return;
} }
estrusflag = false; estrusflag = false;
@ -1644,7 +1659,7 @@ namespace RJW_Menstruation
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
Log.Warning($"Invalid litterSizeCurve for {Pawn.def}: {e}"); Log.WarningOnce($"Invalid litterSizeCurve for {Pawn.def}: {e}", 642201874 + Pawn.thingIDNumber);
eggnum = 1f; eggnum = 1f;
} }
eggnum *= ovulationFactor; eggnum *= ovulationFactor;
@ -1689,21 +1704,19 @@ namespace RJW_Menstruation
} }
else else
{ {
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
StayCurrentStage();
} }
} }
else else
{ {
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
StayCurrentStage();
} }
} }
protected virtual void BleedingAction() protected virtual void BleedingAction()
{ {
if (curStageTicks >= currentIntervalTicks) if (curStageTicks >= currentIntervalTicks || noBleeding)
{ {
Hediff hediff = Pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_MenstrualCramp); Hediff hediff = Pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_MenstrualCramp);
if (hediff != null && !Pawn.GetMenstruationComps().Any(comp => comp != this && comp.curStage == Stage.Bleeding)) Pawn.health.RemoveHediff(hediff); if (hediff != null && !Pawn.GetMenstruationComps().Any(comp => comp != this && comp.curStage == Stage.Bleeding)) Pawn.health.RemoveHediff(hediff);
@ -1712,15 +1725,13 @@ namespace RJW_Menstruation
GoOvulatoryStage(); GoOvulatoryStage();
else else
{ {
currentIntervalTicks = totalFollicularTicks - currentIntervalTicks; // I.e., the remaining follicular time equals the total minus the bleeding time elapsed GoNextStage(Stage.Follicular, totalFollicularTicks - currentIntervalTicks); // I.e., the remaining follicular time equals the total minus the bleeding time elapsed
GoNextStage(Stage.Follicular, false);
} }
} }
else else
{ {
if (curStageTicks < currentIntervalTicks / 4) BleedOut(); if (curStageTicks < currentIntervalTicks / 4) BleedOut();
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
StayCurrentStage();
} }
} }
@ -1733,17 +1744,11 @@ namespace RJW_Menstruation
Implant(); Implant();
} }
if (pregnancy != null && Pawn.health.hediffSet.hediffs.Contains(pregnancy)) if (Pregnancy != null)
{
curStageTicks += TickInterval; curStageTicks += TickInterval;
StayCurrentStageConst(Stage.Pregnant);
}
else else
{
if (pregnancy != null) pregnancy = null;
GoNextStage(Stage.Recover); GoNextStage(Stage.Recover);
} }
}
protected virtual void RecoverAction() protected virtual void RecoverAction()
{ {
@ -1764,22 +1769,18 @@ namespace RJW_Menstruation
} }
else else
{ {
curStageTicks += TickInterval * Configurations.CycleAcceleration; AdvanceStageTime();
StayCurrentStage();
} }
} }
protected virtual void InfertileAction() protected virtual void InfertileAction()
{ {
if (ShouldBeInfertile()) if (ShouldBeInfertile())
{ return;
StayCurrentStageConst(Stage.Infertile); else if (IsBreedingSeason())
} GoNextStage(Stage.Follicular);
else else
{ GoNextStage(Stage.Anestrus);
bool breedingSeason = IsBreedingSeason();
GoNextStage(breedingSeason ? Stage.Follicular : Stage.Anestrus, breedingSeason);
}
} }
protected virtual void AnestrusAction() protected virtual void AnestrusAction()
@ -1788,10 +1789,6 @@ namespace RJW_Menstruation
{ {
GoFollicularOrBleeding(); GoFollicularOrBleeding();
} }
else
{
StayCurrentStage();
}
} }
protected virtual void ThoughtCumInside(Pawn cummer) protected virtual void ThoughtCumInside(Pawn cummer)
@ -1801,7 +1798,7 @@ namespace RJW_Menstruation
MemoryThoughtHandler cummerMemories = cummer.needs.mood.thoughts.memories; MemoryThoughtHandler cummerMemories = cummer.needs.mood.thoughts.memories;
MemoryThoughtHandler pawnMemories = Pawn.needs.mood.thoughts.memories; MemoryThoughtHandler pawnMemories = Pawn.needs.mood.thoughts.memories;
if (cummer.IsProPregnancy(out Precept preceptm) || (cummer.HasQuirk(QuirkUtility.Quirks.Teratophile) != (Pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0))) if (cummer.IsProPregnancy(out Precept preceptm) || (cummer.IsTeratophile() != (Pawn.GetStatValue(StatDefOf.PawnBeauty) >= 0)))
{ {
if (cummer.relations.OpinionOf(Pawn) <= -5) if (cummer.relations.OpinionOf(Pawn) <= -5)
cummerMemories.TryGainMemory(VariousDefOf.HaterCameInsideM, Pawn); cummerMemories.TryGainMemory(VariousDefOf.HaterCameInsideM, Pawn);
@ -1853,10 +1850,10 @@ namespace RJW_Menstruation
TaleRecorder.RecordTale(VariousDefOf.TaleCameInside, new object[] { cummer, Pawn }); TaleRecorder.RecordTale(VariousDefOf.TaleCameInside, new object[] { cummer, Pawn });
} }
public void GoNextStage(Stage nextstage, bool calculateHours = true) public void GoNextStage(Stage nextstage, int? stageTicks = null)
{ {
curStageTicks = 0; curStageTicks = 0;
if (calculateHours) currentIntervalTicks = PeriodRandomizer(nextstage); currentIntervalTicks = stageTicks ?? PeriodRandomizer(nextstage);
curStage = nextstage; curStage = nextstage;
} }
@ -1865,16 +1862,6 @@ namespace RJW_Menstruation
GoNextStage(Stage.Ovulatory); GoNextStage(Stage.Ovulatory);
} }
//stage can be interrupted in other reasons
protected void StayCurrentStage()
{
}
//stage never changes
protected void StayCurrentStageConst(Stage curstage)
{
}
protected void GoFollicularOrBleeding() protected void GoFollicularOrBleeding()
{ {
if (Props.bleedingIntervalDays == 0 || noBleeding) if (Props.bleedingIntervalDays == 0 || noBleeding)

View File

@ -104,13 +104,11 @@ namespace RJW_Menstruation
protected override void AnestrusAction() protected override void AnestrusAction()
{ {
if (ticksToNextCycle <= 0) if (ticksToNextCycle <= 0 && IsBreedingSeason())
{ {
ticksToNextCycle = (int)(averageCycleIntervalTicks * (1 + Rand.Range(-cycleVariability, cycleVariability))); ticksToNextCycle = (int)(averageCycleIntervalTicks * (1 + Rand.Range(-cycleVariability, cycleVariability)));
if (IsBreedingSeason()) GoNextStage(Stage.Follicular); GoNextStage(Stage.Follicular);
return;
} }
StayCurrentStage();
} }
public override void CopyCycleProperties(HediffComp_Menstruation original) public override void CopyCycleProperties(HediffComp_Menstruation original)

View File

@ -40,7 +40,7 @@ namespace RJW_Menstruation
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error when trying to emit pheromones: {ex}"); Log.Error($"Error when trying to emit pheromones from pawn {Pawn}: {ex}");
} }
} }

View File

@ -179,7 +179,7 @@ namespace RJW_Menstruation
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (birtherThing < 0) throw new InvalidOperationException("Could not locate index of birtherThing"); if (birtherThing < 0) throw new InvalidOperationException("Could not locate index of birtherThing");
if (GeneratePawn == null || GeneratePawn.ReturnType != typeof(Pawn)) throw new InvalidOperationException("GeneratePawn not found"); if (GeneratePawn?.ReturnType != typeof(Pawn)) throw new InvalidOperationException("GeneratePawn not found");
foreach (CodeInstruction instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
if (instruction.Calls(GeneratePawn)) if (instruction.Calls(GeneratePawn))
@ -233,7 +233,7 @@ namespace RJW_Menstruation
new Type[] {typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)}); new Type[] {typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments)});
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (ApplyBirthOutcome == null || ApplyBirthOutcome.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found");
foreach (CodeInstruction instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
if (instruction.Calls(ApplyBirthOutcome)) if (instruction.Calls(ApplyBirthOutcome))
@ -283,8 +283,8 @@ namespace RJW_Menstruation
new Type[] { typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) }); new Type[] { typeof(OutcomeChance), typeof(float), typeof(Precept_Ritual), typeof(List<GeneDef>), typeof(Pawn), typeof(Thing), typeof(Pawn), typeof(Pawn), typeof(LordJob_Ritual), typeof(RitualRoleAssignments) });
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (ApplyBirthOutcome == null || ApplyBirthOutcome.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found"); if (ApplyBirthOutcome?.ReturnType != typeof(Thing)) throw new InvalidOperationException("ApplyBirthOutcome not found");
foreach (var instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
if (instruction.Calls(ApplyBirthOutcome)) if (instruction.Calls(ApplyBirthOutcome))
yield return CodeInstruction.Call(typeof(Ritual_ChildBirth_Apply_Patch), nameof(Ritual_ChildBirth_Apply_Patch.ApplyBirthLoop)); yield return CodeInstruction.Call(typeof(Ritual_ChildBirth_Apply_Patch), nameof(Ritual_ChildBirth_Apply_Patch.ApplyBirthLoop));

View File

@ -22,7 +22,7 @@ namespace RJW_Menstruation
public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn) public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn)
{ {
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll(h => VariousDefOf.AllVaginas.Contains(h.def)); List<Hediff> hedifflist = pawn.health.hediffSet.hediffs.FindAll(h => VariousDefOf.AllVaginas.Contains(h.def));
if (hedifflist == null) yield break; if (hedifflist == null) yield break;
foreach (Hediff hediff in hedifflist) foreach (Hediff hediff in hedifflist)
{ {
@ -63,17 +63,7 @@ namespace RJW_Menstruation
public static HediffComp_Anus GetAnusComp(this Pawn pawn) public static HediffComp_Anus GetAnusComp(this Pawn pawn)
{ {
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("anus")); return pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => VariousDefOf.AllAnuses.Contains(h.def))?.TryGetComp<HediffComp_Anus>();
HediffComp_Anus result;
if (!hedifflist.NullOrEmpty())
{
foreach (Hediff h in hedifflist)
{
result = h.TryGetComp<HediffComp_Anus>();
if (result != null) return result;
}
}
return null;
} }
[Obsolete("This method is obsolete and can cause ambiguity. Use GetMenstruationCompFromVagina or GetMenstruationCompFromPregnancy instead.", true)] [Obsolete("This method is obsolete and can cause ambiguity. Use GetMenstruationCompFromVagina or GetMenstruationCompFromPregnancy instead.", true)]
@ -346,8 +336,8 @@ namespace RJW_Menstruation
public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false) public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ?? Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus")); pawn.health.hediffSet.hediffs.FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true); if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
string icon; string icon;
@ -403,6 +393,19 @@ namespace RJW_Menstruation
else return variability; else return variability;
} }
public static bool ShouldCycle(this Pawn pawn)
{
if (!Configurations.EnableAnimalCycle && pawn.IsAnimal()) return false;
if (pawn.RaceHasOviPregnancy()) return false;
if (ModsConfig.BiotechActive && pawn.genes != null)
{
foreach (Gene gene in pawn.genes.GenesListForReading)
if (VariousDefOf.EggLayerGenes.Contains(gene.def)) return false;
}
return true;
}
public static bool IsInEstrus(this Pawn pawn, bool visible = true) public static bool IsInEstrus(this Pawn pawn, bool visible = true)
{ {
if (pawn.Dead) return false; if (pawn.Dead) return false;
@ -450,8 +453,8 @@ namespace RJW_Menstruation
} }
if (precept != null) return true; if (precept != null) return true;
else return pawn.HasQuirk(QuirkUtility.Quirks.Breeder) || else return pawn.IsBreeder() ||
pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish); pawn.HasImpregnationFetish();
} }
public static float DamagePants(this Pawn pawn, float fluidAmount) public static float DamagePants(this Pawn pawn, float fluidAmount)

View File

@ -23,7 +23,7 @@ namespace RJW_Menstruation
{ {
if (is_discovered || if (is_discovered ||
!xxx.is_human(pawn) || !xxx.is_human(pawn) ||
pawn.HasQuirk(QuirkUtility.Quirks.Breeder) || (pawn.Ideo?.HasPrecept(VariousDefOf.Pregnancy_Required) ?? false) || pawn.IsBreeder() || (pawn.Ideo?.HasPrecept(VariousDefOf.Pregnancy_Required) ?? false) ||
(pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) || (pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) ||
x.def.Equals(PawnRelationDefOf.Fiance))) != null) x.def.Equals(PawnRelationDefOf.Fiance))) != null)
return; return;

View File

@ -155,7 +155,7 @@ namespace RJW_Menstruation
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (GetPregnancyHediff == null || GetPregnancyHediff.ReturnType != typeof(Hediff)) throw new InvalidOperationException("GetPregnancyHediff not found"); if (GetPregnancyHediff?.ReturnType != typeof(Hediff)) throw new InvalidOperationException("GetPregnancyHediff not found");
if (Get_Attitude == null || Nullable.GetUnderlyingType(Get_Attitude.ReturnType) != typeof(PregnancyAttitude)) throw new InvalidOperationException("get_Attitude not found"); if (Get_Attitude == null || Nullable.GetUnderlyingType(Get_Attitude.ReturnType) != typeof(PregnancyAttitude)) throw new InvalidOperationException("get_Attitude not found");
foreach (CodeInstruction instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
@ -219,6 +219,17 @@ namespace RJW_Menstruation
} }
} }
[HarmonyPatch(typeof(StatPart_FertilityByGenderAge), "AgeFactor")]
public class AgeFactor_Patch
{
public static void Postfix(ref float __result, Pawn pawn)
{
if (__result <= 0.0f) return;
if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance))
__result = 1.0f;
}
}
//[HarmonyPatch(typeof(ChildcareUtility), nameof(ChildcareUtility.SuckleFromLactatingPawn))] //[HarmonyPatch(typeof(ChildcareUtility), nameof(ChildcareUtility.SuckleFromLactatingPawn))]
//public class GreedyConsume_Patch //public class GreedyConsume_Patch
//{ //{

View File

@ -1,5 +1,6 @@
using HarmonyLib; using HarmonyLib;
using RimWorld; using RimWorld;
using rjw;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -36,10 +37,6 @@ namespace RJW_Menstruation
if (t.Pawn == pawn && pawn.HasMenstruationComp()) opts.AddDistinct(MakeSelfMenu(pawn, t)); if (t.Pawn == pawn && pawn.HasMenstruationComp()) opts.AddDistinct(MakeSelfMenu(pawn, t));
break; break;
} }
} }
public static FloatMenuOption MakeSelfMenu(Pawn pawn, LocalTargetInfo target) public static FloatMenuOption MakeSelfMenu(Pawn pawn, LocalTargetInfo target)
@ -53,60 +50,28 @@ namespace RJW_Menstruation
} }
} }
//[HarmonyPatch(typeof(HealthCardUtility), "DrawHediffListing")] [HarmonyPatch(typeof(HealthCardUtility), "DrawOverviewTab")]
//public class DrawHediffListing_Patch public class DrawOverviewTab_Patch
//{
// public const float buttonWidth = 80f;
// public const float buttonHeight = 20f;
//
// public static void Postfix(Rect rect, Pawn pawn, bool showBloodLoss)
// {
// if (Configurations.EnableButtonInHT && pawn.HasMenstruationComp())
// {
// Rect buttonrect = new Rect(rect.xMax - buttonWidth, rect.yMax - buttonHeight, buttonWidth, buttonHeight);
// if (Widgets.ButtonText(buttonrect, "Status"))
// {
// Dialog_WombStatus.ToggleWindow(pawn,pawn.GetMenstruationComp());
// }
// }
//
//
// }
//}
[HarmonyPatch(typeof(HealthCardUtility), "DrawHediffRow")]
public class DrawHediffRow_Patch
{ {
public const float buttonWidth = 50f; public const float buttonWidth = 50f;
public const float buttonHeight = 20f; public const float buttonHeight = 20f;
private static HediffComp_Menstruation GetFirstMenstruation(IEnumerable<Hediff> diffs) public static void Prefix(Rect leftRect, Pawn pawn, float curY)
{ {
foreach (Hediff diff in diffs) if (Configurations.EnableButtonInHT && pawn.ShowStatus() && pawn.ShouldCycle())
{ {
HediffComp_Menstruation comp = diff.GetMenstruationCompFromVagina(); HediffComp_Menstruation comp = pawn.GetFirstMenstruationComp();
if (comp != null) return comp;
}
return null;
}
public static void Prefix(Rect rect, Pawn pawn, IEnumerable<Hediff> diffs, ref float curY)
{
if (Configurations.EnableButtonInHT && pawn.ShowStatus())
{
HediffComp_Menstruation comp = GetFirstMenstruation(diffs);
if (comp != null) if (comp != null)
{ {
Rect buttonrect = new Rect((rect.xMax) / 2 - 5f, curY + 2f, buttonWidth, buttonHeight); Text.Font = GameFont.Tiny;
if (Widgets.ButtonText(buttonrect, Translations.Button_HealthTab)) Rect buttonRect = new Rect(leftRect.xMax - buttonWidth - 8f, curY + 4f, buttonWidth, buttonHeight);
if (Widgets.ButtonText(buttonRect, Translations.Button_HealthTab))
{ {
Dialog_WombStatus.ToggleWindow(pawn, comp); Dialog_WombStatus.ToggleWindow(pawn, comp);
} }
} }
} }
} }
} }
[HarmonyPatch(typeof(CompBiosculpterPod), nameof(CompBiosculpterPod.CannotUseNowPawnCycleReason), new Type[] { typeof(Pawn), typeof(Pawn), typeof(CompBiosculpterPod_Cycle), typeof(bool) })] [HarmonyPatch(typeof(CompBiosculpterPod), nameof(CompBiosculpterPod.CannotUseNowPawnCycleReason), new Type[] { typeof(Pawn), typeof(Pawn), typeof(CompBiosculpterPod_Cycle), typeof(bool) })]
@ -120,4 +85,28 @@ namespace RJW_Menstruation
__result = Translations.CannotNoWomb; __result = Translations.CannotNoWomb;
} }
} }
// Doesn't cover everything, but at least it'll get the auto equip
[HarmonyPatch(typeof(Apparel), nameof(Apparel.PawnCanWear))]
public class PawnCanWear_Patch
{
public static void Postfix(ref bool __result, Apparel __instance, Pawn pawn)
{
if (__result && __instance is Absorber)
{
__result = pawn.ShouldCycle() && pawn.GetMenstruationComps().Any();
}
}
}
// Might cause issues when it comes to caravans
//[HarmonyPatch(typeof(JobGiver_OptimizeApparel), nameof(JobGiver_OptimizeApparel.ApparelScoreRaw))]
//public class ApparelScoreRaw_Patch
//{
// public static void Postfix(ref float __result, Pawn pawn, Apparel ap)
// {
// if (__result > 0f && ap is Absorber && !pawn.GetMenstruationComps().Any(comp => comp.TotalCum > 0))
// __result = -10f;
// }
//}
} }

View File

@ -24,14 +24,14 @@ namespace RJW_Menstruation
if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return true; if (sextype != xxx.rjwSextype.Vaginal && sextype != xxx.rjwSextype.DoublePenetration) return true;
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; if (!partner.ShouldCycle()) return true;
if (!InteractionCanCausePregnancy(props)) return false; if (!InteractionCanCausePregnancy(props)) return false;
List<Hediff> pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); List<Hediff> pawnparts = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
HediffComp_Menstruation comp; HediffComp_Menstruation comp;
if (pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.IsInEstrus()) if (pawn.HasImpregnationFetish() || partner.HasImpregnationFetish() || partner.IsInEstrus())
comp = partner.GetFertileMenstruationComp(); comp = partner.GetFertileMenstruationComp();
else comp = partner.GetRandomMenstruationComp(); else comp = partner.GetRandomMenstruationComp();
if (comp == null) return true; if (comp == null) return true;
@ -100,9 +100,9 @@ namespace RJW_Menstruation
{ {
public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina
{ {
if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; if (!partner.ShouldCycle()) return true;
HediffComp_Menstruation comp; HediffComp_Menstruation comp;
if (pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || partner.IsInEstrus()) if (pawn.HasImpregnationFetish() || partner.HasImpregnationFetish() || partner.IsInEstrus())
comp = partner.GetFertileMenstruationComp(); comp = partner.GetFertileMenstruationComp();
else comp = partner.GetRandomMenstruationComp(); else comp = partner.GetRandomMenstruationComp();
if (comp == null) if (comp == null)
@ -125,14 +125,14 @@ namespace RJW_Menstruation
{ {
private static bool PregnancyBlocksImpregnation(this Pawn pawn, bool _) private static bool PregnancyBlocksImpregnation(this Pawn pawn, bool _)
{ {
if (!Configurations.EnableAnimalCycle && pawn.IsAnimal()) return pawn.IsPregnant(); if (!pawn.ShouldCycle()) return pawn.IsPregnant();
else if (pawn.GetMenstruationComps().Any()) return false; else if (pawn.GetMenstruationComps().Any()) return false;
else return pawn.IsPregnant(); else return pawn.IsPregnant();
} }
private static readonly MethodInfo IsPregnant = AccessTools.Method(typeof(PawnExtensions), nameof(PawnExtensions.IsPregnant), new System.Type[] { typeof(Pawn), typeof(bool) }); private static readonly MethodInfo IsPregnant = AccessTools.Method(typeof(PawnExtensions), nameof(PawnExtensions.IsPregnant), new System.Type[] { typeof(Pawn), typeof(bool) });
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (IsPregnant == null || IsPregnant.ReturnType != typeof(bool)) throw new System.InvalidOperationException("IsPregnant not found"); if (IsPregnant?.ReturnType != typeof(bool)) throw new System.InvalidOperationException("IsPregnant not found");
foreach (CodeInstruction instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
if (instruction.Calls(IsPregnant)) if (instruction.Calls(IsPregnant))
@ -179,7 +179,7 @@ namespace RJW_Menstruation
{ {
// Awkward, but it'll have to do // Awkward, but it'll have to do
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
if (__result == 0 || !pawn.HasQuirk(QuirkUtility.Quirks.ImpregnationFetish) || !props.hasPartner()) return; if (__result == 0 || !pawn.HasImpregnationFetish() || !props.hasPartner()) return;
// Check if the existing code would have added the count // Check if the existing code would have added the count
Pawn partner = props.partner; Pawn partner = props.partner;
@ -238,7 +238,7 @@ namespace RJW_Menstruation
private static readonly FieldInfo MinimumFuckabilityToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumFuckabilityToHookup)); private static readonly FieldInfo MinimumFuckabilityToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumFuckabilityToHookup));
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (MinimumFuckabilityToHookup == null || MinimumFuckabilityToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumFuckabilityToHookup not found"); if (MinimumFuckabilityToHookup?.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumFuckabilityToHookup not found");
bool first_fuckability = true; bool first_fuckability = true;
foreach (CodeInstruction instruction in instructions) foreach (CodeInstruction instruction in instructions)
{ {
@ -274,8 +274,8 @@ namespace RJW_Menstruation
private static readonly FieldInfo MinimumRelationshipToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumRelationshipToHookup)); private static readonly FieldInfo MinimumRelationshipToHookup = AccessTools.Field(typeof(RJWHookupSettings), nameof(RJWHookupSettings.MinimumRelationshipToHookup));
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{ {
if (MinimumAttractivenessToHookup == null || MinimumAttractivenessToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumAttractivenessToHookup not found"); if (MinimumAttractivenessToHookup?.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumAttractivenessToHookup not found");
if (MinimumRelationshipToHookup == null || MinimumRelationshipToHookup.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumRelationshipToHookup not found"); if (MinimumRelationshipToHookup?.FieldType != typeof(float)) throw new System.InvalidOperationException("MinimumRelationshipToHookup not found");
LocalBuilder pawn_index = null; LocalBuilder pawn_index = null;
// Like in the last one, we switch the arguments around for the second load // Like in the last one, we switch the arguments around for the second load
bool first_attractiveness = true; bool first_attractiveness = true;
@ -347,7 +347,7 @@ namespace RJW_Menstruation
if (__instance.Sexprops.usedCondom) return; if (__instance.Sexprops.usedCondom) return;
if (AndroidsCompatibility.IsAndroid(pawn)) return; if (AndroidsCompatibility.IsAndroid(pawn)) return;
if (!Impregnate_Patch.InteractionCanCausePregnancy(__instance.Sexprops)) return; if (!Impregnate_Patch.InteractionCanCausePregnancy(__instance.Sexprops)) return;
if (!Configurations.EnableAnimalCycle && xxx.is_animal(partner)) return; if (!partner.ShouldCycle()) return;
// Archotech penises have more control. Or something. // Archotech penises have more control. Or something.
CompHediffBodyPart penisComp = pawn.GetGenitalsList()?.Find(genital => (genital as Hediff_PartBaseNatural)?.def.defName.ToLower().Contains("penis") ?? false)?.TryGetComp<CompHediffBodyPart>(); CompHediffBodyPart penisComp = pawn.GetGenitalsList()?.Find(genital => (genital as Hediff_PartBaseNatural)?.def.defName.ToLower().Contains("penis") ?? false)?.TryGetComp<CompHediffBodyPart>();
@ -374,26 +374,14 @@ namespace RJW_Menstruation
} }
} }
[HarmonyPatch(typeof(PawnCapacityWorker_Fertility), nameof(PawnCapacityWorker_Fertility.CalculateCapacityLevel))] [HarmonyPatch(typeof(PawnCapacityWorker_Fertility), "CalculateAgeImpact")]
public static class PawnCapacityWorker_Fertility_Patch public static class PawnCapacityWorker_Fertility_Age_Patch
{ {
private static float GetFertilityStatOrOne(Thing thing, StatDef stat, bool applyPostProcess, int cacheStaleAfterTicks) public static void Postfix(ref float __result, Pawn pawn)
{ {
Pawn pawn = (Pawn)thing; if (__result <= 0.0f) return;
if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance)) if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance))
return 1.0f; __result = 1.0f;
else return thing.GetStatValue(stat, applyPostProcess, cacheStaleAfterTicks);
}
private static readonly MethodInfo GetStatValue = AccessTools.Method(typeof(StatExtension), "GetStatValue", new System.Type[] { typeof(Thing), typeof(StatDef), typeof(bool), typeof(int) });
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (GetStatValue == null || GetStatValue.ReturnType != typeof(float)) throw new System.InvalidOperationException("GetStatValue not found");
foreach (CodeInstruction instruction in instructions)
{
if (instruction.Calls(GetStatValue))
yield return CodeInstruction.Call(typeof(PawnCapacityWorker_Fertility_Patch), nameof(GetFertilityStatOrOne));
else yield return instruction;
}
} }
} }
} }

View File

@ -6,14 +6,14 @@ namespace RJW_Menstruation
public static class QuirkUtility public static class QuirkUtility
{ {
// All quirks used in Menstruation // All quirks used in Menstruation
public enum Quirks private enum Quirks
{ {
Breeder, Breeder,
ImpregnationFetish, ImpregnationFetish,
Messy, Messy,
Teratophile, Teratophile,
} }
public static bool HasQuirk(this Pawn pawn, Quirks quirk) private static bool HasQuirk(Pawn pawn, Quirks quirk)
{ {
switch (quirk) switch (quirk)
{ {
@ -29,5 +29,9 @@ namespace RJW_Menstruation
return false; return false;
} }
} }
public static bool IsBreeder(this Pawn pawn) => HasQuirk(pawn, Quirks.Breeder);
public static bool HasImpregnationFetish(this Pawn pawn) => HasQuirk(pawn, Quirks.ImpregnationFetish);
public static bool IsMessy(this Pawn pawn) => HasQuirk(pawn, Quirks.Messy);
public static bool IsTeratophile(this Pawn pawn) => HasQuirk(pawn, Quirks.Teratophile);
} }
} }

View File

@ -1,6 +1,7 @@
using RimWorld; using RimWorld;
using rjw; using rjw;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Xml; using System.Xml;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@ -186,6 +187,7 @@ namespace RJW_Menstruation
} }
public class AbsorberModExtension : DefModExtension public class AbsorberModExtension : DefModExtension
{ {
public float passiveAbsorptionPerHour = 0.1f;
public bool leakAfterDirty = false; public bool leakAfterDirty = false;
public bool effectsAfterDirty = false; public bool effectsAfterDirty = false;
public ThingDef dirtyDef = null; public ThingDef dirtyDef = null;
@ -198,7 +200,7 @@ namespace RJW_Menstruation
public float absorbedfluids = 0; public float absorbedfluids = 0;
public bool dirty = false; public bool dirty = false;
public int wearTicks = 0; public int wearTicks = 0;
protected virtual float PassiveAbsorptionPerHour => 0.1f; public virtual float PassiveAbsorptionPerHour => def.GetModExtension<AbsorberModExtension>().passiveAbsorptionPerHour;
public virtual bool LeakAfterDirty => def.GetModExtension<AbsorberModExtension>().leakAfterDirty; public virtual bool LeakAfterDirty => def.GetModExtension<AbsorberModExtension>().leakAfterDirty;
public virtual bool EffectAfterDirty => def.GetModExtension<AbsorberModExtension>().effectsAfterDirty; public virtual bool EffectAfterDirty => def.GetModExtension<AbsorberModExtension>().effectsAfterDirty;
public virtual ThingDef DirtyDef => def.GetModExtension<AbsorberModExtension>().dirtyDef; public virtual ThingDef DirtyDef => def.GetModExtension<AbsorberModExtension>().dirtyDef;
@ -211,9 +213,25 @@ namespace RJW_Menstruation
public virtual void WearEffect(int tickInterval) public virtual void WearEffect(int tickInterval)
{ {
absorbedfluids += PassiveAbsorptionPerHour * tickInterval / GenDate.TicksPerHour; absorbedfluids += PassiveAbsorptionPerHour * tickInterval / GenDate.TicksPerHour;
CheckDirty();
if (dirty) wearTicks += tickInterval; if (dirty) wearTicks += tickInterval;
} }
public void CheckDirty()
{
if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && (Wearer?.apparel?.IsLocked(this) ?? false))
{
def = DirtyDef;
dirty = true;
OutfitForcedHandler forcedHandler = Wearer.outfits?.forcedHandler;
if (forcedHandler?.IsForced(this) ?? false)
forcedHandler.SetForced(this, false);
if (!def.equippedStatOffsets.NullOrEmpty())
Wearer.health.capacities.Notify_CapacityLevelsDirty();
Wearer.apparel.Notify_ApparelChanged();
}
}
public override Color DrawColorTwo => fluidColor; public override Color DrawColorTwo => fluidColor;
public override void ExposeData() public override void ExposeData()
@ -231,11 +249,26 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref fluidColor, "fluidColor", Color.white); Scribe_Values.Look(ref fluidColor, "fluidColor", Color.white);
} }
public override string DescriptionDetailed
{
get
{
StringBuilder text = new StringBuilder(base.DescriptionDetailed);
text.AppendLine();
text.Append(Translations.Description_Absorbed);
text.Append(": ");
text.Append(absorbedfluids.ToStringDecimalIfSmall());
text.Append("/");
text.Append(this.GetStatValue(VariousDefOf.MaxAbsorbable).ToStringDecimalIfSmall());
text.Append("ml");
return text.ToString();
}
}
} }
public class Absorber_Tampon : Absorber public class Absorber_Tampon : Absorber
{ {
protected override float PassiveAbsorptionPerHour => 0.5f;
public override void DirtyEffect(int tickInterval) public override void DirtyEffect(int tickInterval)
{ {

View File

@ -44,6 +44,7 @@ namespace RJW_Menstruation
public static readonly string Dialog_WombInfo08 = "Dialog_WombInfo08".Translate(); public static readonly string Dialog_WombInfo08 = "Dialog_WombInfo08".Translate();
public static readonly string Dialog_WombInfo09 = "Dialog_WombInfo09".Translate(); public static readonly string Dialog_WombInfo09 = "Dialog_WombInfo09".Translate();
public static readonly string Dialog_WombInfo10 = "Dialog_WombInfo10".Translate(); public static readonly string Dialog_WombInfo10 = "Dialog_WombInfo10".Translate();
public static readonly string Description_Absorbed = "Description_Absorbed".Translate();
public static readonly string Option1_Label_1 = "Option1_Label_1".Translate(); public static readonly string Option1_Label_1 = "Option1_Label_1".Translate();

View File

@ -86,7 +86,7 @@ namespace RJW_Menstruation
{ {
res = 0.0f; res = 0.0f;
} }
if (pawn.HasQuirk(QuirkUtility.Quirks.Messy)) res *= Rand.Range(4.0f, 8.0f); if (pawn.IsMessy()) res *= Rand.Range(4.0f, 8.0f);
return res; return res;
} }
@ -95,16 +95,7 @@ namespace RJW_Menstruation
public static HediffComp_Breast GetBreastComp(this Pawn pawn) public static HediffComp_Breast GetBreastComp(this Pawn pawn)
{ {
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn))?.FindAll(h => VariousDefOf.AllBreasts.Contains(h.def)); return pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => VariousDefOf.AllBreasts.Contains(h.def))?.TryGetComp<HediffComp_Breast>();
if (hedifflist.NullOrEmpty()) hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn))?.FindAll(h => VariousDefOf.AllBreasts.Contains(h.def));
if (hedifflist.NullOrEmpty()) return null;
HediffComp_Breast result;
foreach (Hediff h in hedifflist)
{
result = h.TryGetComp<HediffComp_Breast>();
if (result != null) return result;
}
return null;
} }
public static HediffComp_Breast GetBreastComp(this Hediff hediff) public static HediffComp_Breast GetBreastComp(this Hediff hediff)
@ -192,8 +183,7 @@ namespace RJW_Menstruation
public static void DrawBreastIcon(this Pawn pawn, Rect rect) public static void DrawBreastIcon(this Pawn pawn, Rect rect)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def)) ?? Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
Texture2D breast, nipple, areola; Texture2D breast, nipple, areola;
if (hediff != null) if (hediff != null)
{ {
@ -351,20 +341,19 @@ namespace RJW_Menstruation
public static string GetVaginaLabel(this Pawn pawn) public static string GetVaginaLabel(this Pawn pawn)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).Find(h => VariousDefOf.AllVaginas.Contains(h.def)); Hediff hediff = pawn.health.hediffSet.hediffs.Find(h => VariousDefOf.AllVaginas.Contains(h.def));
return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")" + "\n" + xxx.CountOfSex.LabelCap.CapitalizeFirst() + ": " + pawn.records.GetAsInt(xxx.CountOfSex); return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")" + "\n" + xxx.CountOfSex.LabelCap.CapitalizeFirst() + ": " + pawn.records.GetAsInt(xxx.CountOfSex);
} }
public static string GetAnusLabel(this Pawn pawn) public static string GetAnusLabel(this Pawn pawn)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ?? Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus")); Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")"; if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
else return ""; else return "";
} }
public static string GetBreastLabel(this Pawn pawn) public static string GetBreastLabel(this Pawn pawn)
{ {
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def)) ?? Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")"; if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
else return ""; else return "";
} }
@ -416,7 +405,7 @@ namespace RJW_Menstruation
{ {
Pawn res = pawn.GetFather(); Pawn res = pawn.GetFather();
if (res != null) return res; if (res != null) return res;
else res = pawn.relations?.GetFirstDirectRelationPawn(PawnRelationDefOf.Parent, x => x != mother) ?? null; else res = pawn.relations?.GetFirstDirectRelationPawn(PawnRelationDefOf.Parent, x => x != mother);
return res; return res;
} }
@ -448,7 +437,7 @@ namespace RJW_Menstruation
{ {
if (!Configurations.EnableWombIcon) return false; if (!Configurations.EnableWombIcon) return false;
if (pawn.Drafted && !Configurations.EnableDraftedIcon) return false; if (pawn.Drafted && !Configurations.EnableDraftedIcon) return false;
if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return false; if (!pawn.ShouldCycle()) return false;
return true; return true;
} }

View File

@ -40,7 +40,7 @@ namespace RJW_Menstruation
public static readonly ThoughtDef TookContraceptivePill = DefDatabase<ThoughtDef>.GetNamed("TookContraceptivePill"); public static readonly ThoughtDef TookContraceptivePill = DefDatabase<ThoughtDef>.GetNamed("TookContraceptivePill");
public static readonly ThoughtDef HateTookContraceptivePill = DefDatabase<ThoughtDef>.GetNamed("HateTookContraceptivePill"); public static readonly ThoughtDef HateTookContraceptivePill = DefDatabase<ThoughtDef>.GetNamed("HateTookContraceptivePill");
public static readonly ThoughtDef EggRestorationReceived = DefDatabase<ThoughtDef>.GetNamed("EggRestorationReceived"); public static readonly ThoughtDef EggRestorationReceived = DefDatabase<ThoughtDef>.GetNamed("EggRestorationReceived");
public static readonly CompProperties_Menstruation HumanVaginaCompProperties = (CompProperties_Menstruation)Genital_Helper.average_vagina.comps.FirstOrDefault(x => x is CompProperties_Menstruation); public static readonly CompProperties_Menstruation HumanVaginaCompProperties = Genital_Helper.average_vagina.CompProps<CompProperties_Menstruation>();
public static readonly KeyBindingDef OpenStatusWindowKey = DefDatabase<KeyBindingDef>.GetNamed("OpenStatusWindow"); public static readonly KeyBindingDef OpenStatusWindowKey = DefDatabase<KeyBindingDef>.GetNamed("OpenStatusWindow");
public static readonly RecordDef AmountofCreampied = DefDatabase<RecordDef>.GetNamed("AmountofCreampied"); public static readonly RecordDef AmountofCreampied = DefDatabase<RecordDef>.GetNamed("AmountofCreampied");
public static readonly RecordDef AmountofFertilizedEggs = DefDatabase<RecordDef>.GetNamed("AmountofFertilizedEggs"); public static readonly RecordDef AmountofFertilizedEggs = DefDatabase<RecordDef>.GetNamed("AmountofFertilizedEggs");
@ -69,6 +69,7 @@ namespace RJW_Menstruation
private static HashSet<HediffDef> allvaginas = null; private static HashSet<HediffDef> allvaginas = null;
private static HashSet<HediffDef> allanuses = null; private static HashSet<HediffDef> allanuses = null;
private static HashSet<HediffDef> allbreasts = null; private static HashSet<HediffDef> allbreasts = null;
private static HashSet<GeneDef> egglayergenes = null;
public static List<ThingDef> AllRaces public static List<ThingDef> AllRaces
{ {
@ -161,6 +162,22 @@ namespace RJW_Menstruation
return allbreasts; return allbreasts;
} }
} }
public static HashSet<GeneDef> EggLayerGenes
{
get
{
if (egglayergenes != null) return egglayergenes;
egglayergenes = new HashSet<GeneDef>
{
DefDatabase<GeneDef>.GetNamedSilentFail("AG_EggLaying"), // Alpha Genes
DefDatabase<GeneDef>.GetNamedSilentFail("VRESaurids_Oviparous"), // VE Saurid
DefDatabase<GeneDef>.GetNamedSilentFail("VRE_SaplingBirth"), // VE Phytokin
};
egglayergenes.Remove(null);
return egglayergenes;
}
}
// Defs from Milkable Colonists // Defs from Milkable Colonists
public static readonly HediffDef Hediff_Lactating_Drug = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Drug"); public static readonly HediffDef Hediff_Lactating_Drug = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Drug");

View File

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

View File

@ -14,6 +14,5 @@
<v1.4> <v1.4>
<li>1.4</li> <li>1.4</li>
<li IfModActive="ASMR.RJW.RaceSupport">1.4/RJW Menstruation Race Support</li> <li IfModActive="ASMR.RJW.RaceSupport">1.4/RJW Menstruation Race Support</li>
<!-- <li IfModActive="rjw.milk.humanoid">1.3/MilkModule</li> -->
</v1.4> </v1.4>
</loadFolders> </loadFolders>

View File

@ -1,3 +1,20 @@
Version 1.0.9.2
- Updated Traditional Chinese translation by Hydrogen.
- Fixed the no bleeding gene having positive metabolic efficiency instead of negative.
- Fixed ovulation chance not accounting for genes or precepts.
- Better handle wombs that are not in the genitals body part.
- Handle errors more gracefully when starting a pregnancy.
- Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies.
- An equipped tampon or pad will now show how much fluid it has absorbed in its tooltip.
- Passive absorption will now make a tampon or pad dirty after enough time, even if no fluid was added.
- It will take a cloth tampon about 2 days to become dirty passively. A cloth pad will take about 10 days.
- An absorber that was force worn will no longer be forced once it becomes dirty.
- Pawns without a menstrual cycle will no longer equip absorbers.
- Egglaying races no longer have a menstrual cycle, regardless of vagina type.
- Pawns with the egglaying genes from Alpha Genes, VE Saurids, or Phytokin no longer have a menstrual cycle.
- The womb status button will now appear in a pawn's health tab when using Compact Hediffs, with thanks to Fern.
- Tampons and pads are now allowed by default in the worker, soldier, and slave starting outfits.
Version 1.0.9.1 Version 1.0.9.1
- Japanese translation for most text by Lokuzt. - Japanese translation for most text by Lokuzt.
- New womb, cum, and fetus graphics by Euldrop. - New womb, cum, and fetus graphics by Euldrop.