diff --git a/1.4/Languages/English/Keyed/RimJobWorldKeys.xml b/1.4/Languages/English/Keyed/RimJobWorldKeys.xml index d56190c774785db5cf953e83998870e436c21b62..a6694ab1dd3d43c23dde87b58a95c8e93bc1f52c 100644 --- a/1.4/Languages/English/Keyed/RimJobWorldKeys.xml +++ b/1.4/Languages/English/Keyed/RimJobWorldKeys.xml @@ -97,4 +97,5 @@ <PawnLacksFunctionalGenitals>{PAWN} has no working genitals.</PawnLacksFunctionalGenitals> <PawnLacksVagina>{PAWN} does not have a vagina.</PawnLacksVagina> <PawnLacksFunctionalPenis>{PAWN} does not have a functional penis.</PawnLacksFunctionalPenis> + <VaginalWeight>vaginal sex chance</VaginalWeight> </LanguageData> \ No newline at end of file diff --git a/1.4/Source/Harmony/BiotechPatches.cs b/1.4/Source/Harmony/BiotechPatches.cs index 823a99306c883d81a38bb50d5bc722d233027b4d..45c5140e9fde2bec46ba736ec443b1e47e9bc33a 100644 --- a/1.4/Source/Harmony/BiotechPatches.cs +++ b/1.4/Source/Harmony/BiotechPatches.cs @@ -6,6 +6,7 @@ using System.Reflection.Emit; using HarmonyLib; using Verse; using RimWorld; +using UnityEngine; // Non-pregnancy Biotech-related patches namespace rjw @@ -20,12 +21,14 @@ namespace rjw yield return AccessTools.Method(typeof(LifeStageWorker_HumanlikeAdult), lifeStageStarted); } - // Fixes an error caused by trying to spawn a biotech-only effector when a child starts a new lifestage + // Fixes errors caused by trying to spawn a biotech-only effector when a child starts a new lifestage + // and by trying to send a biotech-only letter when a child turns three [HarmonyTranspiler] - static IEnumerable<CodeInstruction> FixLifeStageStartError(IEnumerable<CodeInstruction> instructions) + static IEnumerable<CodeInstruction> FixLifeStageStartError(IEnumerable<CodeInstruction> instructions, MethodBase original) { PropertyInfo thingSpawned = AccessTools.DeclaredProperty(typeof(Thing), nameof(Thing.Spawned)); - bool finished = false; + MethodInfo shouldSendNotificationsAbout = AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.ShouldSendNotificationAbout)); + bool foundAny = false; foreach (var instruction in instructions) { @@ -33,18 +36,34 @@ namespace rjw // if (pawn.Spawned) SpawnBiotechOnlyEffector() // => if (pawn.Spawned && ModsConfig.IsBiotechActive) SpawnBiotechOnlyEffector() - if (!finished && instruction.Calls(thingSpawned.GetMethod)) + if (instruction.Calls(thingSpawned.GetMethod) || instruction.Calls(shouldSendNotificationsAbout)) { yield return CodeInstruction.Call(typeof(ModsConfig), "get_BiotechActive"); yield return new CodeInstruction(OpCodes.And); - finished = true; + foundAny = true; } } - if (!finished) + if (!foundAny) { - ModLog.Error("Failed to patch LifeStageWorker_HumanlikeChild.Notify_LifeStageStarted"); + ModLog.Error("Failed to patch " + original.Name); } } } + + [HarmonyPatch(typeof(WidgetsWork), "get_WorkBoxBGTex_AgeDisabled")] + class WidgetsWork_WorkBoxBGTex_AgeDisabled + { + [HarmonyPrefix] + static bool DontLoadMissingTexture(ref Texture2D __result) + { + if (!ModsConfig.BiotechActive) + { + __result = WidgetsWork.WorkBoxBGTex_Awful; + return false; + } + + return true; + } + } } \ No newline at end of file diff --git a/1.4/Source/Harmony/patch_pregnancy.cs b/1.4/Source/Harmony/patch_pregnancy.cs index cc35ef8ba1de9b6faee103a67d1a52088e38ce40..02b825161fe41a0ab9f2751c88d21b092b1dbce1 100644 --- a/1.4/Source/Harmony/patch_pregnancy.cs +++ b/1.4/Source/Harmony/patch_pregnancy.cs @@ -444,6 +444,27 @@ namespace rjw } } + // Adjust the pregnancy approach tooltip to reflect the fact that it no longer affects the chance of pregnancy directly. + [HarmonyPatch(typeof(PregnancyUtility), nameof(PregnancyUtility.GetDescription))] + class PregnancyUtility_GetDescription + { + [HarmonyTranspiler] + static IEnumerable<CodeInstruction> ModifyPregnancyApproachTooltip(IEnumerable<CodeInstruction> instructions) + { + foreach (var instruction in instructions) + { + if (instruction.LoadsConstant("PregnancyChance")) + { + yield return new CodeInstruction(OpCodes.Ldstr, "VaginalWeight"); + } + else + { + yield return instruction; + } + } + } + } + [HarmonyPatch(typeof(PawnColumnWorker_Pregnant), "GetIconFor")] public class PawnColumnWorker_Patch_Icon { diff --git a/1.4/Source/Modules/Interactions/Internals/Implementation/PartPreferenceDetectorService.cs b/1.4/Source/Modules/Interactions/Internals/Implementation/PartPreferenceDetectorService.cs index 2bee3c6a6e1daa85241ed454118ccbbe4a5b1a13..86b112a4da108e1e239e8b5ab583693064466ee2 100644 --- a/1.4/Source/Modules/Interactions/Internals/Implementation/PartPreferenceDetectorService.cs +++ b/1.4/Source/Modules/Interactions/Internals/Implementation/PartPreferenceDetectorService.cs @@ -32,6 +32,7 @@ namespace rjw.Modules.Interactions.Internals.Implementation new RapePartKindUsageRule(), new SizeDifferencePartKindUsageRule(), new WhoringPartKindUsageRule(), + new PregnancyApproachPartKindUsageRule(), }; } diff --git a/1.4/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/PregnancyApproachPartKindUsageRule.cs b/1.4/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/PregnancyApproachPartKindUsageRule.cs new file mode 100644 index 0000000000000000000000000000000000000000..7422f7ef01dc52b1e9a1e99b7d5410319573c460 --- /dev/null +++ b/1.4/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/PregnancyApproachPartKindUsageRule.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using RimWorld; +using Verse; + +using rjw.Modules.Interactions.Contexts; +using rjw.Modules.Interactions.Enums; +using rjw.Modules.Shared; +using rjw.Modules.Interactions.Objects; +using System.Linq; + +namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation +{ + public class PregnancyApproachPartKindUsageRule : IPartPreferenceRule + { + public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context) + { + return ModifiersForEither(context.Internals.Dominant, context.Internals.Submissive); + } + + public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context) + { + return ModifiersForEither(context.Internals.Submissive, context.Internals.Dominant); + } + + public IEnumerable<Weighted<LewdablePartKind>> ModifiersForEither(InteractionPawn OwO, InteractionPawn UwU) + { + float weight = OwO.Pawn.relations.GetPregnancyApproachForPartner(UwU.Pawn).GetPregnancyChanceFactor(); + if (UwU.Parts.Penises.Any()) + { + yield return new Weighted<LewdablePartKind>(weight, LewdablePartKind.Vagina); + } + if (UwU.Parts.Vaginas.Any()) + { + yield return new Weighted<LewdablePartKind>(weight, LewdablePartKind.Penis); + } + } + } +} \ No newline at end of file diff --git a/1.4/Source/Modules/Pregnancy/Pregnancy_Helper.cs b/1.4/Source/Modules/Pregnancy/Pregnancy_Helper.cs index adccdb419b114770198fb64ddcfa1145f1e293c4..4c948f81e452dc78388cab37bda7d45f8112abc8 100644 --- a/1.4/Source/Modules/Pregnancy/Pregnancy_Helper.cs +++ b/1.4/Source/Modules/Pregnancy/Pregnancy_Helper.cs @@ -165,7 +165,7 @@ namespace rjw if (CanImpregnate(giver, receiver, props.sexType)) { - DoImpregnate(giver, receiver, props.isRape); + DoImpregnate(giver, receiver); } } @@ -336,7 +336,7 @@ namespace rjw } [SyncMethod] - public static void DoImpregnate(Pawn pawn, Pawn partner, bool isRape) + public static void DoImpregnate(Pawn pawn, Pawn partner) { if (RJWSettings.DevMode) ModLog.Message(" Doimpregnate " + xxx.get_pawnname(pawn) + " is a father, " + xxx.get_pawnname(partner) + " is a mother"); @@ -382,10 +382,6 @@ namespace rjw } float pregnancyChance = basePregnancyChance * fertility; - if (!isRape && RJWPregnancySettings.UseVanillaPregnancy) - { - pregnancyChance *= partner.relations.GetPregnancyApproachForPartner(pawn).GetPregnancyChanceFactor(); - } if (!Rand.Chance(pregnancyChance)) { diff --git a/1.4/Source/RimJobWorld.Main.csproj b/1.4/Source/RimJobWorld.Main.csproj index 55460bc5cdf5be2c695244a767ff6be6b3e08a3c..b5b9330679175b8ae106122ee79b2aca4b22073c 100644 --- a/1.4/Source/RimJobWorld.Main.csproj +++ b/1.4/Source/RimJobWorld.Main.csproj @@ -228,6 +228,7 @@ <Compile Include="Modules\Interactions\Rules\PartPreferenceRules\Implementation\MainPartKindUsageRule.cs" /> <Compile Include="Modules\Interactions\Rules\PartPreferenceRules\Implementation\RapePartKindUsageRule.cs" /> <Compile Include="Modules\Interactions\Rules\PartPreferenceRules\Implementation\SizeDifferencePartKindUsageRule.cs" /> + <Compile Include="Modules\Interactions\Rules\PartPreferenceRules\Implementation\PregnancyApproachPartKindUsageRule.cs" /> <Compile Include="Modules\Interactions\Rules\PartPreferenceRules\IPartKindUsageRule.cs" /> <Compile Include="Modules\Shared\Comparers\StringComparer_IgnoreCase.cs" /> <Compile Include="Modules\Shared\Extensions\BodyPartRecordExtension.cs" />