Disease Spread uses settings

This commit is contained in:
Vegapnk 2024-07-03 10:14:05 +02:00
parent 0d3a5c75a2
commit bccd258d13

View file

@ -15,6 +15,8 @@ namespace RJW_Genes.Genes.Diseases.Patches
public static void Postfix(SexProps props) public static void Postfix(SexProps props)
{ {
if (!RJW_Genes_Settings.rjw_genes_genetic_disease_spread) return;
if (props == null || props.pawn == null || props.partner == null) return; if (props == null || props.pawn == null || props.partner == null) return;
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
@ -26,6 +28,9 @@ namespace RJW_Genes.Genes.Diseases.Patches
// No Infections on Condom Use // No Infections on Condom Use
if (props.usedCondom) return; if (props.usedCondom) return;
// Exit early if settings require penetrative sex, but this is not penetrative sex
if (!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(pawn, partner, props);
TryTransferGeneticDiseases(partner, pawn, props); TryTransferGeneticDiseases(partner, pawn, props);
@ -47,7 +52,7 @@ namespace RJW_Genes.Genes.Diseases.Patches
if ((new Random()).NextDouble() <= LookupDiseaseInfectionChance(disease)) if ((new Random()).NextDouble() <= LookupDiseaseInfectionChance(disease))
{ {
infected.genes.AddGene(disease, false); infected.genes.AddGene(disease, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
} }
} }
} }
@ -67,6 +72,19 @@ namespace RJW_Genes.Genes.Diseases.Patches
return new List<GeneDef>() { }; return new List<GeneDef>() { };
} }
private static bool IsPenetrativeSex(SexProps props)
{
if (props == null) return false;
return props.sexType ==
xxx.rjwSextype.Vaginal
|| props.sexType == xxx.rjwSextype.Anal
|| props.sexType == xxx.rjwSextype.Oral
|| props.sexType == xxx.rjwSextype.DoublePenetration
|| props.sexType == xxx.rjwSextype.Fellatio
|| props.sexType == xxx.rjwSextype.Sixtynine;
}
private static bool IsGeneticDiseaseGene(GeneDef geneDef) private static bool IsGeneticDiseaseGene(GeneDef geneDef)
{ {
return geneDef.geneClass.FullName.Contains("DiseaseGene"); return geneDef.geneClass.FullName.Contains("DiseaseGene");