mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Added two Genes for changing biological age by sex
This commit is contained in:
parent
8e63e69385
commit
5ae3d0b13f
5 changed files with 114 additions and 0 deletions
|
@ -10,4 +10,24 @@
|
||||||
<displayOrderInCategory>1</displayOrderInCategory>
|
<displayOrderInCategory>1</displayOrderInCategory>
|
||||||
</GeneDef>
|
</GeneDef>
|
||||||
|
|
||||||
|
<GeneDef>
|
||||||
|
<defName>rjw_genes_youth_fountain</defName>
|
||||||
|
<label>Youth Fountain</label>
|
||||||
|
<displayCategory>rjw_genes_special</displayCategory>
|
||||||
|
<description>Having sex with a carrier of this gene makes the partner slightly younger. (Partner stays adult)</description>
|
||||||
|
<biostatCpx>1</biostatCpx>
|
||||||
|
<iconPath>UI/Ideoligions/FireLeaves</iconPath>
|
||||||
|
<displayOrderInCategory>2</displayOrderInCategory>
|
||||||
|
</GeneDef>
|
||||||
|
|
||||||
|
<GeneDef>
|
||||||
|
<defName>rjw_genes_sex_age_drain</defName>
|
||||||
|
<label>Sexual Age Drain</label>
|
||||||
|
<displayCategory>rjw_genes_special</displayCategory>
|
||||||
|
<description>Having sex transfers some of the partners life-time to themselves. (Pawn stays adult)</description>
|
||||||
|
<biostatCpx>1</biostatCpx>
|
||||||
|
<iconPath>UI/Icons/ColonistBar/Idle</iconPath>
|
||||||
|
<displayOrderInCategory>3</displayOrderInCategory>
|
||||||
|
</GeneDef>
|
||||||
|
|
||||||
</Defs>
|
</Defs>
|
|
@ -71,6 +71,8 @@ namespace RJW_Genes
|
||||||
|
|
||||||
// Special
|
// Special
|
||||||
public static readonly GeneDef rjw_genes_orgasm_rush;
|
public static readonly GeneDef rjw_genes_orgasm_rush;
|
||||||
|
public static readonly GeneDef rjw_genes_youth_fountain;
|
||||||
|
public static readonly GeneDef rjw_genes_sex_age_drain;
|
||||||
|
|
||||||
|
|
||||||
public static readonly HediffDef rjw_genes_orgasm_rush_hediff;
|
public static readonly HediffDef rjw_genes_orgasm_rush_hediff;
|
||||||
|
|
|
@ -23,6 +23,24 @@ namespace RJW_Genes
|
||||||
return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectincubator);
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_insectincubator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsYouthFountain(Pawn pawn)
|
||||||
|
{
|
||||||
|
if (pawn.genes == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_youth_fountain);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsAgeDrainer(Pawn pawn)
|
||||||
|
{
|
||||||
|
if (pawn.genes == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return pawn.genes.HasGene(GeneDefOf.rjw_genes_sex_age_drain);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsInsectBreeder(Pawn pawn)
|
public static bool IsInsectBreeder(Pawn pawn)
|
||||||
{
|
{
|
||||||
if (pawn.genes == null)
|
if (pawn.genes == null)
|
||||||
|
|
38
Source/Genes/Special/Patch_AgeDrain.cs
Normal file
38
Source/Genes/Special/Patch_AgeDrain.cs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using rjw;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RJW_Genes.Genes.Special
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
|
||||||
|
public static class Patch_AgeDrain
|
||||||
|
{
|
||||||
|
|
||||||
|
const long AGE_TRANSFERED = 120000; // 120k == 2 days
|
||||||
|
|
||||||
|
// Comment Below in for debugging, changes years
|
||||||
|
// const long AGE_TRANSFERED = 6000000; // 6000k == 100 days
|
||||||
|
public static void Postfix(SexProps props)
|
||||||
|
{
|
||||||
|
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (GeneUtility.IsAgeDrainer(props.pawn))
|
||||||
|
{
|
||||||
|
var pawnAge = props.pawn.ageTracker.AgeBiologicalTicks;
|
||||||
|
var pawnMinAge = props.pawn.ageTracker.AdultMinAgeTicks;
|
||||||
|
|
||||||
|
// Make Partner older
|
||||||
|
props.partner.ageTracker.AgeBiologicalTicks += AGE_TRANSFERED;
|
||||||
|
// Make Pawn younger
|
||||||
|
props.pawn.ageTracker.AgeBiologicalTicks = Math.Max(pawnMinAge, pawnAge - AGE_TRANSFERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
Source/Genes/Special/Patch_Youth_Fountain.cs
Normal file
36
Source/Genes/Special/Patch_Youth_Fountain.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using rjw;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RJW_Genes.Genes.Special
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
|
||||||
|
public static class Patch_Youth_Fountain
|
||||||
|
{
|
||||||
|
|
||||||
|
const long AGE_REDUCTION = 60000; // 60k == 1 day
|
||||||
|
|
||||||
|
// Comment Below in for debugging
|
||||||
|
//const long AGE_REDUCTION = 6000000; // 6000k == 100 days
|
||||||
|
public static void Postfix(SexProps props)
|
||||||
|
{
|
||||||
|
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (GeneUtility.IsYouthFountain(props.pawn))
|
||||||
|
{
|
||||||
|
var partnerAge = props.partner.ageTracker.AgeBiologicalTicks;
|
||||||
|
var minAge = props.partner.ageTracker.AdultMinAgeTicks;
|
||||||
|
|
||||||
|
props.partner.ageTracker.AgeBiologicalTicks = Math.Max(minAge, partnerAge - AGE_REDUCTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue