diff --git a/CHANGELOG.md b/CHANGELOG.md
index c177c58..d41f131 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
# 2.2.0 (dd-mm-2024)
-**Genetic Diseases**
+## Explanations
+
+**Genetic Diseases**:
This update introduces genetic diseases that are shared on sex.
Infection is handled when sex finishes, so a coitus-interruptus will not result in infections.
@@ -20,6 +22,50 @@ Most of the genes so far were positive or neutral,
so I got some fair requests to introduce negative genes to keep xenotypes balanced.
I know that this is some overlap with the STD mod, but well ... you are free to turn things off?
+**Genetic Infectors**:
+
+These Genes can apply a genetic disease, but are not genetic diseases themselves.
+A single infector gene can have multiple resulting diseases, see this extension example:
+
+```xml
+
+ 0.05
+
+
rjw_genes_size_blinded
+
rjw_genes_infectious_bisexuality
+
+
+```
+
+The infection-chance is applied per gene - for the example above there would be a 5% chance to apply `size_blinded` and 5% chance to apply `infectious_bisexuality`.
+Multiple infections can happen on a single sex.
+The `infectionGenes` can be any gene, this is not limited to genetic diseases (e.g. ugly or something).
+
+*Infectors* are always applied even if the genetic disease spread is turned off.
+The created genetic diseases will follow the logic outlined above.
+
+**Disease Immunity**:
+
+Pawns can be immune to genetic diseases.
+
+This is either done with a specialised gene (`rjw_genes_genetic_disease_immunity`)
+or by genes giving specific immunities.
+
+Any gene can give immunity against any genetic disease using an extension:
+
+```xml
+
+
+
rjw_genes_size_blinded
+
+
+```
+
+These extensions can be slapped on any gene,
+but they are meant mostly to have infectors immune against their own diseases.
+
+## Changelog
+
**Additions:**
- Passive Gene: *Genetic Disease Immunity* - cannot get infected by any genetic diseases, and won't be affected by some other genes (see relevant genes)
@@ -28,6 +74,7 @@ I know that this is some overlap with the STD mod, but well ... you are free to
- Disease Gene: Infectious Homosexuality & Bisexuality
- Disease Gene: Fluctual Sexual Need. (Configurable) Chance to reset sex-need to near-zero and gain a bit of rest-need.
- Disease Gene: Size Blinded. Pawns have a higher chance for hooking up with pawns with a big cock, lower chance for small cocks.
+- Infector Gene: Genetic Stretcher. Pawns can infect other pawns with *Size Blinded*
**Fixes:**
diff --git a/Common/Defs/GeneDefs/GeneDefs_Diseases.xml b/Common/Defs/GeneDefs/GeneDefs_Diseases.xml
index d5a8d3a..2570b65 100644
--- a/Common/Defs/GeneDefs/GeneDefs_Diseases.xml
+++ b/Common/Defs/GeneDefs/GeneDefs_Diseases.xml
@@ -205,7 +205,7 @@
rjw_genes_stretcher
- Pawns with this gene have a chance to make sexual partners prefer large genitalia as part of their genetics.
+ Pawns with this gene have a chance to alter the genes of their sexual partners to prefer large cocks.UI/Icons/ColonistBar/Idle10
@@ -216,6 +216,12 @@
rjw_genes_size_blinded
+
+ 0.05
+
+
rjw_genes_size_blinded
+
+
diff --git a/Source/Genes/Diseases/Defs/GeneticInfectorExtension.cs b/Source/Genes/Diseases/Defs/GeneticInfectorExtension.cs
new file mode 100644
index 0000000..2f00ce5
--- /dev/null
+++ b/Source/Genes/Diseases/Defs/GeneticInfectorExtension.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes
+{
+ public class GeneticInfectorExtension : DefModExtension
+ {
+ public float infectionChance;
+
+ public List infectionGenes;
+ }
+
+}
diff --git a/Source/Genes/Diseases/DiseaseHelper.cs b/Source/Genes/Diseases/DiseaseHelper.cs
index 1af745b..873a0e1 100644
--- a/Source/Genes/Diseases/DiseaseHelper.cs
+++ b/Source/Genes/Diseases/DiseaseHelper.cs
@@ -71,6 +71,31 @@ namespace RJW_Genes
return new List() { };
}
+ public static List GetGeneticInfectorGenes(Pawn pawn)
+ {
+ if (pawn != null && pawn.genes != null)
+ {
+ return pawn.genes
+ .GenesListForReading
+ .ConvertAll(gene => gene.def)
+ .Where(genedef => pawn.genes.HasActiveGene(genedef))
+ .Where(IsGeneticInfectorGene)
+ .ToList();
+ }
+
+ return new List() { };
+ }
+
+ public static List LookupInfectionGeneDefs(GeneticInfectorExtension infectorExt)
+ {
+ if (infectorExt == null) new List();
+
+ return RimWorld.GeneUtility
+ .GenesInOrder
+ .Where(genedef => infectorExt.infectionGenes.Contains(genedef.defName))
+ .ToList();
+ }
+
///
/// Checks if the performed sex was penetrative.
/// Condom check is not done here!
@@ -97,6 +122,13 @@ namespace RJW_Genes
return diseaseExt != null;
}
+ public static bool IsGeneticInfectorGene(GeneDef geneDef)
+ {
+ if (geneDef == null) return false;
+ GeneticInfectorExtension infectorExt = geneDef.GetModExtension();
+ return infectorExt != null;
+ }
+
public static float LookupDiseaseInfectionChance(GeneDef geneDef)
{
if (IsGeneticDiseaseGene(geneDef))
@@ -107,5 +139,7 @@ namespace RJW_Genes
else
return 0.0f;
}
+
+
}
}
diff --git a/Source/Genes/Diseases/Patches/Patch_AfterSexUtility_ApplyGeneticInfectors.cs b/Source/Genes/Diseases/Patches/Patch_AfterSexUtility_ApplyGeneticInfectors.cs
new file mode 100644
index 0000000..1ee1e9f
--- /dev/null
+++ b/Source/Genes/Diseases/Patches/Patch_AfterSexUtility_ApplyGeneticInfectors.cs
@@ -0,0 +1,57 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Remoting.Lifetime;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace RJW_Genes
+{
+
+ [HarmonyPatch(typeof(SexUtility), "Aftersex")]
+ public class Patch_AfterSexUtility_ApplyGeneticInfectors
+ {
+ 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;
+
+ // Exit early if settings require penetrative sex, but this is not penetrative sex
+ if (!DiseaseHelper.IsPenetrativeSex(props) && RJW_Genes_Settings.rjw_genes_genetic_disease_spread_only_on_penetrative_sex) return;
+
+ TryApplyGeneticInfections(pawn, partner);
+ TryApplyGeneticInfections(partner, pawn);
+ }
+
+ private static void TryApplyGeneticInfections(Pawn infector, Pawn partner)
+ {
+ foreach (GeneDef infectorGeneDef in DiseaseHelper.GetGeneticInfectorGenes(infector))
+ {
+ GeneticInfectorExtension diseaseExt = infectorGeneDef.GetModExtension();
+ if (diseaseExt == null) continue;
+ float application_chance = diseaseExt.infectionChance;
+
+ foreach (GeneDef diseaseGeneDef in DiseaseHelper.LookupInfectionGeneDefs(diseaseExt))
+ {
+ if (DiseaseHelper.IsImmuneAgainstGeneticDisease(partner, diseaseGeneDef))
+ continue;
+
+ if ((new Random()).NextDouble() < application_chance)
+ partner.genes.AddGene(diseaseGeneDef, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
+ }
+ }
+ }
+
+ }
+}
diff --git a/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs b/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs
index b068c38..e33079f 100644
--- a/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs
+++ b/Source/Genes/Diseases/Patches/Patch_AftersexUtility_TransferGeneticDiseases.cs
@@ -7,7 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using Verse;
-namespace RJW_Genes.Genes.Diseases.Patches
+namespace RJW_Genes
{
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
public class Patch_AftersexUtility_TransferGeneticDiseases
@@ -31,7 +31,7 @@ namespace RJW_Genes.Genes.Diseases.Patches
// Exit early if settings require penetrative sex, but this is not penetrative sex
if (!DiseaseHelper.IsPenetrativeSex(props) && RJW_Genes_Settings.rjw_genes_genetic_disease_spread_only_on_penetrative_sex) return;
- ModLog.Debug($"Firing Patch_TransferGeneticDiseases for {pawn} and {partner}");
+ //ModLog.Debug($"Firing Patch_TransferGeneticDiseases for {pawn} and {partner}");
TryTransferGeneticDiseases(pawn, partner, props);
TryTransferGeneticDiseases(partner, pawn, props);
}
diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj
index bd03e87..f42e885 100644
--- a/Source/Rjw-Genes.csproj
+++ b/Source/Rjw-Genes.csproj
@@ -76,9 +76,11 @@
+
+