mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Compare commits
	
		
			3 commits
		
	
	
		
			b12e9afbc0
			...
			ebf7efb730
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						ebf7efb730 | ||
| 
							 | 
						4623333605 | ||
| 
							 | 
						f5917052ab | 
					 13 changed files with 199 additions and 0 deletions
				
			
		| 
						 | 
					@ -81,6 +81,7 @@ but they are meant mostly to have infectors immune against their own diseases.
 | 
				
			||||||
- Gene: Sexual Genetic Swap. Pawns have a chance to switch a random gene with their sexpartner. 
 | 
					- Gene: Sexual Genetic Swap. Pawns have a chance to switch a random gene with their sexpartner. 
 | 
				
			||||||
- (Archite) Gene: Sexual Genetic Thief. Pawns have a chance to steal a gene from their sexpartner. Genetic Disease Immunity shields against this. 
 | 
					- (Archite) Gene: Sexual Genetic Thief. Pawns have a chance to steal a gene from their sexpartner. Genetic Disease Immunity shields against this. 
 | 
				
			||||||
- Pawns will have negative thoughts about pawns with more genetic diseases than themselves. 
 | 
					- Pawns will have negative thoughts about pawns with more genetic diseases than themselves. 
 | 
				
			||||||
 | 
					- Faction Penalties for spreading diseases, stealing genes and aging pawns with age transfer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Fixes:**
 | 
					**Fixes:**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -152,4 +152,16 @@
 | 
				
			||||||
    <biostatCpx>1</biostatCpx>
 | 
					    <biostatCpx>1</biostatCpx>
 | 
				
			||||||
    <biostatMet>0</biostatMet>
 | 
					    <biostatMet>0</biostatMet>
 | 
				
			||||||
  </GeneDef>
 | 
					  </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>
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										18
									
								
								Common/Defs/HistoryEventDefs/DiseaseHistoryEventDefs.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Common/Defs/HistoryEventDefs/DiseaseHistoryEventDefs.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Defs>
 | 
				
			||||||
 | 
					    <HistoryEventDef>
 | 
				
			||||||
 | 
					        <defName>rjw_genes_GoodwillChangedReason_StoleGene</defName>
 | 
				
			||||||
 | 
					        <label>Stole a gene</label>
 | 
				
			||||||
 | 
					    </HistoryEventDef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <HistoryEventDef>
 | 
				
			||||||
 | 
					        <defName>rjw_genes_GoodwillChangedReason_infected_with_disease</defName>
 | 
				
			||||||
 | 
					        <label>Infected a pawn with a genetic disease</label>
 | 
				
			||||||
 | 
					    </HistoryEventDef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <HistoryEventDef>
 | 
				
			||||||
 | 
					        <defName>rjw_genes_GoodwillChangedReason_spread_genetic_disease</defName>
 | 
				
			||||||
 | 
					        <label>Spread a genetic disease</label>
 | 
				
			||||||
 | 
					    </HistoryEventDef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										13
									
								
								Common/Defs/HistoryEventDefs/SpecialHistoryEventDefs.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Common/Defs/HistoryEventDefs/SpecialHistoryEventDefs.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<Defs>
 | 
				
			||||||
 | 
					    <HistoryEventDef>
 | 
				
			||||||
 | 
					        <defName>rjw_genes_GoodwillChangedReason_aged_pawn_with_sex_gene</defName>
 | 
				
			||||||
 | 
					        <label>Aged a pawn with sexual age transfer</label>
 | 
				
			||||||
 | 
					    </HistoryEventDef>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <HistoryEventDef>
 | 
				
			||||||
 | 
					        <defName>rjw_genes_GoodwillChangedReason_youthed_pawn_with_sex_gene</defName>
 | 
				
			||||||
 | 
					        <label>Youthed a pawn with youth fountain</label>
 | 
				
			||||||
 | 
					    </HistoryEventDef>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					</Defs>
 | 
				
			||||||
							
								
								
									
										42
									
								
								Source/Common/Helpers/FactionUtility.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Source/Common/Helpers/FactionUtility.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,42 @@
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace RJW_Genes
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class FactionUtility
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Tries to change the goodwill between the factions of two pawns. 
 | 
				
			||||||
 | 
					        /// Exceptions when nothing happens:
 | 
				
			||||||
 | 
					        /// - Pawns, or Pawns Factions, are null 
 | 
				
			||||||
 | 
					        /// - The `actors` Faction is not the players faction
 | 
				
			||||||
 | 
					        /// - Both pawns have the same faction
 | 
				
			||||||
 | 
					        /// - The Event is not found
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="actor">The pawn that initiated a faction-goodwill change by his actions</param>
 | 
				
			||||||
 | 
					        /// <param name="target">The pawn that was harmed/affected by the action</param>
 | 
				
			||||||
 | 
					        /// <param name="HistoryEventDefname">The event defname, for proper reporting</param>
 | 
				
			||||||
 | 
					        /// <param name="goodWillChange">How much (positive or negative) the goodwill will change</param>
 | 
				
			||||||
 | 
					        public static void HandleFactionGoodWillPenalties(Pawn actor, Pawn target, string HistoryEventDefname, int goodWillChange, bool canSendHostileLetter=true)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (actor == null) return;
 | 
				
			||||||
 | 
					            if (target == null) return;
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					                target.Faction != null && actor.Faction != null
 | 
				
			||||||
 | 
					                && target.Faction != actor.Faction
 | 
				
			||||||
 | 
					                && target.Faction != Faction.OfPlayer)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                HistoryEventDef reason = DefDatabase<HistoryEventDef>.GetNamedSilentFail(HistoryEventDefname);
 | 
				
			||||||
 | 
					                if (reason == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                target.Faction.TryAffectGoodwillWith(actor.Faction, goodWillChange, true, canSendHostileLetter, reason, target);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -107,6 +107,7 @@ namespace RJW_Genes
 | 
				
			||||||
        public static readonly GeneDef rjw_genes_sex_tamer;
 | 
					        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_swap;
 | 
				
			||||||
		public static readonly GeneDef rjw_genes_sexual_genetic_thief;
 | 
							public static readonly GeneDef rjw_genes_sexual_genetic_thief;
 | 
				
			||||||
 | 
							public static readonly GeneDef rjw_genes_pregnancy_overwrite;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Cosmetic
 | 
					        // Cosmetic
 | 
				
			||||||
        public static readonly GeneDef rjw_genes_succubus_tail;
 | 
					        public static readonly GeneDef rjw_genes_succubus_tail;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
| 
						 | 
					@ -14,6 +15,9 @@ namespace RJW_Genes
 | 
				
			||||||
    [HarmonyPatch(typeof(SexUtility), "Aftersex")]
 | 
					    [HarmonyPatch(typeof(SexUtility), "Aftersex")]
 | 
				
			||||||
    public class Patch_AfterSexUtility_ApplyGeneticInfectors
 | 
					    public class Patch_AfterSexUtility_ApplyGeneticInfectors
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const int FACTION_GOODWILL_CHANGE = -3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Postfix(SexProps props)
 | 
					        public static void Postfix(SexProps props)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (props == null || props.pawn == null || props.partner == null) return;
 | 
					            if (props == null || props.pawn == null || props.partner == null) return;
 | 
				
			||||||
| 
						 | 
					@ -48,7 +52,10 @@ namespace RJW_Genes
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((new Random()).NextDouble() < application_chance)
 | 
					                    if ((new Random()).NextDouble() < application_chance)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
                        partner.genes.AddGene(diseaseGeneDef, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
 | 
					                        partner.genes.AddGene(diseaseGeneDef, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
 | 
				
			||||||
 | 
					                        FactionUtility.HandleFactionGoodWillPenalties(infector, partner, "rjw_genes_GoodwillChangedReason_infected_with_disease",FACTION_GOODWILL_CHANGE);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
| 
						 | 
					@ -13,6 +14,8 @@ namespace RJW_Genes
 | 
				
			||||||
    public class Patch_AftersexUtility_TransferGeneticDiseases
 | 
					    public class Patch_AftersexUtility_TransferGeneticDiseases
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public const int FACTION_GOODWILL_CHANGE = -2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Postfix(SexProps props)
 | 
					        public static void Postfix(SexProps props)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!RJW_Genes_Settings.rjw_genes_genetic_disease_spread) return;
 | 
					            if (!RJW_Genes_Settings.rjw_genes_genetic_disease_spread) return;
 | 
				
			||||||
| 
						 | 
					@ -48,6 +51,7 @@ namespace RJW_Genes
 | 
				
			||||||
                if ((new Random()).NextDouble() <= DiseaseHelper.LookupDiseaseInfectionChance(disease))
 | 
					                if ((new Random()).NextDouble() <= DiseaseHelper.LookupDiseaseInfectionChance(disease))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    infected.genes.AddGene(disease, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
 | 
					                    infected.genes.AddGene(disease, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
 | 
				
			||||||
 | 
					                    FactionUtility.HandleFactionGoodWillPenalties(infector, infected, "rjw_genes_GoodwillChangedReason_spread_genetic_disease", FACTION_GOODWILL_CHANGE);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
| 
						 | 
					@ -24,6 +25,8 @@ namespace RJW_Genes.Genes.Special
 | 
				
			||||||
        // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
 | 
					        // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
 | 
				
			||||||
        const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1;
 | 
					        const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const int FACTION_GOODWILL_CHANGE = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Postfix(SexProps props)
 | 
					        public static void Postfix(SexProps props)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal() )
 | 
					            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal() )
 | 
				
			||||||
| 
						 | 
					@ -80,6 +83,9 @@ namespace RJW_Genes.Genes.Special
 | 
				
			||||||
                if (RJW_Genes_Settings.rjw_genes_detailed_debug)
 | 
					                if (RJW_Genes_Settings.rjw_genes_detailed_debug)
 | 
				
			||||||
                    ModLog.Message($"[Sexual Age Drainer] {receiver} was too young ({receiver.ageTracker.AgeBiologicalYears}), and remains unchanged.");
 | 
					                    ModLog.Message($"[Sexual Age Drainer] {receiver} was too young ({receiver.ageTracker.AgeBiologicalYears}), and remains unchanged.");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FactionUtility.HandleFactionGoodWillPenalties(receiver, giver, "rjw_genes_GoodwillChangedReason_aged_pawn_with_sex_gene",FACTION_GOODWILL_CHANGE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,6 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using RimWorld.Planet;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
| 
						 | 
					@ -13,6 +15,9 @@ namespace RJW_Genes
 | 
				
			||||||
    [HarmonyPatch(typeof(SexUtility), "Aftersex")]
 | 
					    [HarmonyPatch(typeof(SexUtility), "Aftersex")]
 | 
				
			||||||
    public class Patch_GeneticSexThief
 | 
					    public class Patch_GeneticSexThief
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public const int FACTION_GOODWILL_CHANGE = -10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Postfix(SexProps props)
 | 
					        public static void Postfix(SexProps props)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
 | 
					            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
 | 
				
			||||||
| 
						 | 
					@ -62,6 +67,8 @@ namespace RJW_Genes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            stealer.genes.AddGene(stolenGene.def, AddAsXenogene);
 | 
					            stealer.genes.AddGene(stolenGene.def, AddAsXenogene);
 | 
				
			||||||
            victim.genes.RemoveGene(stolenGene);
 | 
					            victim.genes.RemoveGene(stolenGene);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FactionUtility.HandleFactionGoodWillPenalties(stealer, victim, "rjw_genes_GoodwillChangedReason_StoleGene", FACTION_GOODWILL_CHANGE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
| 
						 | 
					@ -23,6 +24,8 @@ namespace RJW_Genes.Genes.Special
 | 
				
			||||||
        // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
 | 
					        // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
 | 
				
			||||||
        const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1;
 | 
					        const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const int FACTION_GOODWILL_CHANGE = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Postfix(SexProps props)
 | 
					        public static void Postfix(SexProps props)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
 | 
					            if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
 | 
				
			||||||
| 
						 | 
					@ -39,10 +42,12 @@ namespace RJW_Genes.Genes.Special
 | 
				
			||||||
            if (GeneUtility.IsYouthFountain(props.pawn))
 | 
					            if (GeneUtility.IsYouthFountain(props.pawn))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                ChangeAgeForPawn(props.partner, props.pawn);
 | 
					                ChangeAgeForPawn(props.partner, props.pawn);
 | 
				
			||||||
 | 
					                FactionUtility.HandleFactionGoodWillPenalties(props.pawn, props.partner, "rjw_genes_GoodwillChangedReason_youthed_pawn_with_sex_gene",+1);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (GeneUtility.IsYouthFountain(props.partner))
 | 
					            if (GeneUtility.IsYouthFountain(props.partner))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                ChangeAgeForPawn(props.pawn,props.partner);
 | 
					                ChangeAgeForPawn(props.pawn,props.partner);
 | 
				
			||||||
 | 
					                FactionUtility.HandleFactionGoodWillPenalties(props.pawn, props.partner, "rjw_genes_GoodwillChangedReason_youthed_pawn_with_sex_gene", +1);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -65,6 +70,7 @@ namespace RJW_Genes.Genes.Special
 | 
				
			||||||
                ModLog.Message($"[Youth Fountain] {ToYouth} was too young ({ToYouth.ageTracker.AgeBiologicalYears}), and remains unchanged.");
 | 
					                ModLog.Message($"[Youth Fountain] {ToYouth} was too young ({ToYouth.ageTracker.AgeBiologicalYears}), and remains unchanged.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,7 @@
 | 
				
			||||||
    <Compile Include="Common\Defs\ModExtensionHelper.cs" />
 | 
					    <Compile Include="Common\Defs\ModExtensionHelper.cs" />
 | 
				
			||||||
    <Compile Include="Common\Defs\TickBasedChanceExtension.cs" />
 | 
					    <Compile Include="Common\Defs\TickBasedChanceExtension.cs" />
 | 
				
			||||||
    <Compile Include="Common\Either.cs" />
 | 
					    <Compile Include="Common\Either.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Common\Helpers\FactionUtility.cs" />
 | 
				
			||||||
    <Compile Include="Common\Helpers\LaborState.cs" />
 | 
					    <Compile Include="Common\Helpers\LaborState.cs" />
 | 
				
			||||||
    <Compile Include="Common\Helpers\MapUtility.cs" />
 | 
					    <Compile Include="Common\Helpers\MapUtility.cs" />
 | 
				
			||||||
    <Compile Include="Common\ModLog.cs" />
 | 
					    <Compile Include="Common\ModLog.cs" />
 | 
				
			||||||
| 
						 | 
					@ -193,6 +194,7 @@
 | 
				
			||||||
    <Compile Include="Genes\Special\Patches\Patch_GeneticSexThief.cs" />
 | 
					    <Compile Include="Genes\Special\Patches\Patch_GeneticSexThief.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" />
 | 
					    <Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.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\Patches\Patch_SexualTamer.cs" />
 | 
				
			||||||
    <Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" />
 | 
					    <Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" />
 | 
				
			||||||
    <Compile Include="LetterDefOf.cs" />
 | 
					    <Compile Include="LetterDefOf.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue