diff --git a/Common/Defs/GeneDefs/GeneCategories.xml b/Common/Defs/GeneDefs/GeneCategories.xml
index e506741..e799489 100644
--- a/Common/Defs/GeneDefs/GeneCategories.xml
+++ b/Common/Defs/GeneDefs/GeneCategories.xml
@@ -67,5 +67,11 @@
8
+
+ rjw_genes_diseases
+ genetic STDs
+ 22
+
+
\ No newline at end of file
diff --git a/Common/Defs/GeneDefs/GeneDefs_Diseases.xml b/Common/Defs/GeneDefs/GeneDefs_Diseases.xml
new file mode 100644
index 0000000..e4fead1
--- /dev/null
+++ b/Common/Defs/GeneDefs/GeneDefs_Diseases.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ rjw_genes_diseases
+ rjw_genes_genetic_disease_immunity
+
+ 1
+
+ genetic disease immunity
+ This gene makes the pawn immune against genetic STDs and other genes that imply negative side-effects.
+ 2
+ -1
+ UI/Icons/ColonistBar/Idle
+
+ Genes/Icons/RJW_Genes_Endogene_Background
+ Genes/Icons/RJW_Genes_Xenogene_Background
+
+
+
+
+ rjw_genes_diseases
+ rjw_genes_minor_vulnerability
+
+ RJW_Genes.DiseaseGene
+
+ minor vulnerability
+ This gene makes the pawn more vulnerable, and a more attractive target for rape.
+ 2
+ -1
+ UI/Icons/ColonistBar/Idle
+ 3
+
+
+
+ Genes/Icons/RJW_Genes_Endogene_Background
+ Genes/Icons/RJW_Genes_Xenogene_Background
+
+
+
+ 1.0
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/Common/ModLog.cs b/Source/Common/ModLog.cs
index 407520a..b78e675 100644
--- a/Source/Common/ModLog.cs
+++ b/Source/Common/ModLog.cs
@@ -30,5 +30,12 @@ namespace RJW_Genes
Log.Warning($"[{ModId}] {message}");
}
+ public static void Debug(string message)
+ {
+ if (RJW_Genes_Settings.rjw_genes_detailed_debug)
+ {
+ Log.Message($"[{ModId}][debug] {message}");
+ }
+ }
}
}
diff --git a/Source/GeneDefOf.cs b/Source/GeneDefOf.cs
index 6049b8b..af53f67 100644
--- a/Source/GeneDefOf.cs
+++ b/Source/GeneDefOf.cs
@@ -109,7 +109,7 @@ namespace RJW_Genes
public static readonly GeneDef rjw_genes_succubus_tail;
public static readonly GeneDef rjw_genes_succubus_wings;
- //life force
+ // Life force | Fertilin
public static readonly GeneDef rjw_genes_lifeforce;
public static readonly GeneDef rjw_genes_pussyhealing;
public static readonly GeneDef rjw_genes_lifeforce_drain;
@@ -121,6 +121,10 @@ namespace RJW_Genes
public static readonly GeneDef rjw_genes_cockeater;
public static readonly GeneDef rjw_genes_lifeforce_empath;
+ // Diseases
+ public static readonly GeneDef rjw_genes_genetic_disease_immunity;
+ public static readonly GeneDef rjw_genes_minor_vulnerability;
+
//Other Defs
public static readonly XenotypeDef rjw_genes_succubus;
public static readonly DutyDef rjw_genes_flirt;
diff --git a/Source/Genes/Diseases/Defs/GeneticDiseaseExtension.cs b/Source/Genes/Diseases/Defs/GeneticDiseaseExtension.cs
new file mode 100644
index 0000000..e156195
--- /dev/null
+++ b/Source/Genes/Diseases/Defs/GeneticDiseaseExtension.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes
+{
+ public class GeneticDiseaseExtension : DefModExtension
+ {
+ ///
+ /// The chance for this gene to spread upon (finished) sex.
+ ///
+ public float infectionChance;
+ }
+
+}
diff --git a/Source/Genes/Diseases/Genes/DiseaseGene.cs b/Source/Genes/Diseases/Genes/DiseaseGene.cs
new file mode 100644
index 0000000..deba64f
--- /dev/null
+++ b/Source/Genes/Diseases/Genes/DiseaseGene.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes
+{
+ public class DiseaseGene : Gene
+ {
+
+ }
+}
diff --git a/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs b/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs
new file mode 100644
index 0000000..bf6e26c
--- /dev/null
+++ b/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs
@@ -0,0 +1,86 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes.Genes.Diseases.Patches
+{
+ [HarmonyPatch(typeof(SexUtility), "Aftersex")]
+ public class Patch_AftersexUtility_TransferGeneticDiseases
+ {
+
+ public static void Postfix(SexProps props)
+ {
+ if (props == null || props.pawn == null || props.partner == null) return;
+
+ Pawn pawn = props.pawn;
+ Pawn partner = props.partner;
+
+ if (pawn == partner) return;
+ if (pawn.IsAnimal() || partner.IsAnimal()) return;
+ if (pawn.genes == null || partner.genes == null) return;
+ // No Infections on Condom Use
+ if (props.usedCondom) return;
+
+ ModLog.Debug($"Firing Patch_TransferGeneticDiseases for {pawn} and {partner}");
+ TryTransferGeneticDiseases(pawn, partner, props);
+ TryTransferGeneticDiseases(partner, pawn, props);
+ }
+
+ private static void TryTransferGeneticDiseases(Pawn infector, Pawn infected, SexProps props)
+ {
+ if (infected.genes.HasActiveGene(GeneDefOf.rjw_genes_genetic_disease_immunity))
+ {
+ ModLog.Debug($"{infected} is immune to genetic diseases");
+ return;
+ }
+
+ foreach (GeneDef disease in GetGeneticDiseaseGenes(infector)) {
+ ModLog.Debug($"Found genetic disease {disease} in {infector}, trying to infect {infected}");
+
+ if (infected.genes.HasActiveGene(disease))
+ continue;
+
+ if ((new Random()).NextDouble() <= LookupDiseaseInfectionChance(disease))
+ {
+ infected.genes.AddGene(disease, false);
+ }
+ }
+ }
+
+ private static List GetGeneticDiseaseGenes(Pawn pawn)
+ {
+ if (pawn != null && pawn.genes != null)
+ {
+ return pawn.genes
+ .GenesListForReading
+ .ConvertAll(gene => gene.def)
+ .Where(genedef => pawn.genes.HasActiveGene(genedef))
+ .Where(IsGeneticDiseaseGene)
+ .ToList();
+ }
+
+ return new List() { };
+ }
+
+ private static bool IsGeneticDiseaseGene(GeneDef geneDef)
+ {
+ return geneDef.geneClass.FullName.Contains("DiseaseGene");
+ }
+
+ private static float LookupDiseaseInfectionChance(GeneDef geneDef)
+ {
+ if (IsGeneticDiseaseGene(geneDef))
+ {
+ GeneticDiseaseExtension diseaseExt = geneDef.GetModExtension();
+ return diseaseExt != null ? diseaseExt.infectionChance : 0.0f;
+ }
+ else
+ return 0.0f;
+ }
+ }
+}
diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj
index dadf954..0abf68c 100644
--- a/Source/Rjw-Genes.csproj
+++ b/Source/Rjw-Genes.csproj
@@ -74,6 +74,9 @@
+
+
+