mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Draft for Pregnancy Overwrite
This commit is contained in:
parent
4623333605
commit
ebf7efb730
4 changed files with 95 additions and 0 deletions
|
@ -152,4 +152,16 @@
|
|||
<biostatCpx>1</biostatCpx>
|
||||
<biostatMet>0</biostatMet>
|
||||
</GeneDef>
|
||||
|
||||
<GeneDef ParentName="BreedingBase">
|
||||
<defName>rjw_genes_pregnancy_overwrite</defName>
|
||||
<label>Sperm Displacement</label>
|
||||
<description>Carriers of this gene can 'overwrite' an existing pregnancy, keeping the progress but effectively replacing the father.</description>
|
||||
<iconPath>Genes/Icons/RJW_Genes_PheromoneSpit</iconPath>
|
||||
<displayOrderInCategory>75</displayOrderInCategory>
|
||||
|
||||
<biostatCpx>4</biostatCpx>
|
||||
<biostatMet>-2</biostatMet>
|
||||
</GeneDef>
|
||||
|
||||
</Defs>
|
|
@ -107,6 +107,7 @@ namespace RJW_Genes
|
|||
public static readonly GeneDef rjw_genes_sex_tamer;
|
||||
public static readonly GeneDef rjw_genes_sexual_genetic_swap;
|
||||
public static readonly GeneDef rjw_genes_sexual_genetic_thief;
|
||||
public static readonly GeneDef rjw_genes_pregnancy_overwrite;
|
||||
|
||||
// Cosmetic
|
||||
public static readonly GeneDef rjw_genes_succubus_tail;
|
||||
|
|
80
Source/Genes/Special/Patches/Patch_PregnancyOverwrite.cs
Normal file
80
Source/Genes/Special/Patches/Patch_PregnancyOverwrite.cs
Normal file
|
@ -0,0 +1,80 @@
|
|||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using static HarmonyLib.Code;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
|
||||
public class Patch_PregnancyOverwrite
|
||||
{
|
||||
public const int FACTION_GOODWILL_CHANGE = -5;
|
||||
|
||||
public static void Postfix(SexProps props)
|
||||
{
|
||||
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pawn pawn = props.pawn;
|
||||
Pawn partner = props.partner;
|
||||
|
||||
if (pawn.genes == null || partner.genes == null) return;
|
||||
|
||||
// If both have the swap gene, nothing happens
|
||||
if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_pregnancy_overwrite)
|
||||
&& GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_pregnancy_overwrite))
|
||||
return;
|
||||
|
||||
// If both are pregnant, we have some weird interaction. Exit Early
|
||||
if (pawn.IsPregnant() && partner.IsPregnant())
|
||||
return;
|
||||
// If neither are pregnant, nothing can happen.
|
||||
if (!pawn.IsPregnant() && !partner.IsPregnant())
|
||||
return;
|
||||
|
||||
ModLog.Debug("Firing Pregnancy Overwrite Patch - Passed Simple NullChecks");
|
||||
|
||||
if (pawn.IsPregnant()
|
||||
&& GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_pregnancy_overwrite))
|
||||
TryReplacePregnancy(partner, pawn);
|
||||
|
||||
if (partner.IsPregnant()
|
||||
&& GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_pregnancy_overwrite))
|
||||
TryReplacePregnancy(pawn, partner);
|
||||
}
|
||||
|
||||
public static void TryReplacePregnancy(Pawn replacer, Pawn pregnant)
|
||||
{
|
||||
// TODO: This mostly works, but needs some more checks.
|
||||
// - Check if there is a pregnancy occurring
|
||||
// - Check for Disease Immunity
|
||||
// - Add Faction Penalties
|
||||
|
||||
ModLog.Debug($"Firing Pregnancy Overwrite for {replacer} and {pregnant}");
|
||||
|
||||
// The "CanImpregnate" does not work as I want, as the pawn is already pregnant, so it wont allow to be pregnated.
|
||||
//PregnancyHelper.CanImpregnate(pawn, partner, props.sexType)
|
||||
|
||||
Hediff pregnancyHediff = PregnancyUtility.GetPregnancyHediff(pregnant);
|
||||
if (pregnancyHediff == null)
|
||||
return;
|
||||
|
||||
float gestationProgress = pregnancyHediff.Severity;
|
||||
|
||||
PregnancyUtility.ForceEndPregnancy(pregnant);
|
||||
|
||||
PregnancyHelper.StartVanillaPregnancy(pregnant, replacer);
|
||||
Hediff replacementPregnancyHediff = PregnancyUtility.GetPregnancyHediff(pregnant);
|
||||
replacementPregnancyHediff.Severity = gestationProgress;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
<Compile Include="Common\Defs\ModExtensionHelper.cs" />
|
||||
<Compile Include="Common\Defs\TickBasedChanceExtension.cs" />
|
||||
<Compile Include="Common\Either.cs" />
|
||||
<Compile Include="Common\Helpers\FactionUtility.cs" />
|
||||
<Compile Include="Common\Helpers\LaborState.cs" />
|
||||
<Compile Include="Common\Helpers\MapUtility.cs" />
|
||||
<Compile Include="Common\ModLog.cs" />
|
||||
|
@ -193,6 +194,7 @@
|
|||
<Compile Include="Genes\Special\Patches\Patch_GeneticSexThief.cs" />
|
||||
<Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" />
|
||||
<Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" />
|
||||
<Compile Include="Genes\Special\Patches\Patch_PregnancyOverwrite.cs" />
|
||||
<Compile Include="Genes\Special\Patches\Patch_SexualTamer.cs" />
|
||||
<Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" />
|
||||
<Compile Include="LetterDefOf.cs" />
|
||||
|
|
Loading…
Reference in a new issue