mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Added the first genetic infector gene, stretcher, and docs for it
This commit is contained in:
parent
65ff62cbf9
commit
56f8c2b6b2
7 changed files with 167 additions and 4 deletions
49
CHANGELOG.md
49
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
|
||||
<li Class="RJW_Genes.GeneticInfectorExtension">
|
||||
<infectionChance>0.05</infectionChance>
|
||||
<infectionGenes>
|
||||
<li>rjw_genes_size_blinded</li>
|
||||
<li>rjw_genes_infectious_bisexuality</li>
|
||||
</infectionGenes>
|
||||
</li>
|
||||
```
|
||||
|
||||
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
|
||||
<li Class="RJW_Genes.ImmunityAgainstGenesExtension">
|
||||
<givesImmunityAgainst>
|
||||
<li>rjw_genes_size_blinded</li>
|
||||
</givesImmunityAgainst>
|
||||
</li>
|
||||
```
|
||||
|
||||
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:**
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@
|
|||
<GeneDef ParentName="RJWGeneDisease">
|
||||
<defName>rjw_genes_stretcher</defName>
|
||||
<label>genetic stretcher</label>
|
||||
<description>Pawns with this gene have a chance to make sexual partners prefer large genitalia as part of their genetics.</description>
|
||||
<description>Pawns with this gene have a chance to alter the genes of their sexual partners to prefer large cocks.</description>
|
||||
<iconPath>UI/Icons/ColonistBar/Idle</iconPath>
|
||||
<biostatCpx>1</biostatCpx>
|
||||
<biostatMet>0</biostatMet>
|
||||
|
@ -216,6 +216,12 @@
|
|||
<li>rjw_genes_size_blinded</li>
|
||||
</givesImmunityAgainst>
|
||||
</li>
|
||||
<li Class="RJW_Genes.GeneticInfectorExtension">
|
||||
<infectionChance>0.05</infectionChance>
|
||||
<infectionGenes>
|
||||
<li>rjw_genes_size_blinded</li>
|
||||
</infectionGenes>
|
||||
</li>
|
||||
</modExtensions>
|
||||
</GeneDef>
|
||||
|
||||
|
|
17
Source/Genes/Diseases/Defs/GeneticInfectorExtension.cs
Normal file
17
Source/Genes/Diseases/Defs/GeneticInfectorExtension.cs
Normal file
|
@ -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<string> infectionGenes;
|
||||
}
|
||||
|
||||
}
|
|
@ -71,6 +71,31 @@ namespace RJW_Genes
|
|||
return new List<GeneDef>() { };
|
||||
}
|
||||
|
||||
public static List<GeneDef> 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<GeneDef>() { };
|
||||
}
|
||||
|
||||
public static List<GeneDef> LookupInfectionGeneDefs(GeneticInfectorExtension infectorExt)
|
||||
{
|
||||
if (infectorExt == null) new List<GeneDef>();
|
||||
|
||||
return RimWorld.GeneUtility
|
||||
.GenesInOrder
|
||||
.Where(genedef => infectorExt.infectionGenes.Contains(genedef.defName))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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<GeneticInfectorExtension>();
|
||||
return infectorExt != null;
|
||||
}
|
||||
|
||||
public static float LookupDiseaseInfectionChance(GeneDef geneDef)
|
||||
{
|
||||
if (IsGeneticDiseaseGene(geneDef))
|
||||
|
@ -107,5 +139,7 @@ namespace RJW_Genes
|
|||
else
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<GeneticInfectorExtension>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -76,9 +76,11 @@
|
|||
<Compile Include="Genes\Cum\Patch_LikesCumflation.cs" />
|
||||
<Compile Include="Genes\Damage\Gene_Elasticity.cs" />
|
||||
<Compile Include="Genes\Diseases\Defs\GeneticDiseaseExtension.cs" />
|
||||
<Compile Include="Genes\Diseases\Defs\GeneticInfectorExtension.cs" />
|
||||
<Compile Include="Genes\Diseases\Defs\ImmunityAgainstGenesExtension.cs" />
|
||||
<Compile Include="Genes\Diseases\DiseaseHelper.cs" />
|
||||
<Compile Include="Genes\Diseases\Genes\Gene_FluctualSexualNeed.cs" />
|
||||
<Compile Include="Genes\Diseases\Patches\Patch_AfterSexUtility_ApplyGeneticInfectors.cs" />
|
||||
<Compile Include="Genes\Diseases\Patches\Patch_AftersexUtility_TransferGeneticDiseases.cs" />
|
||||
<Compile Include="Genes\Diseases\Patches\Patch_SecondaryRomanceChanceFactor_Gene_SizeBlinded.cs" />
|
||||
<Compile Include="Genes\Diseases\Thoughts\ThoughtWorker_SizeBlinded_Social.cs" />
|
||||
|
|
Loading…
Reference in a new issue