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
				
			
		| 
						 | 
				
			
			@ -71,6 +71,8 @@ namespace RJW_Genes
 | 
			
		|||
 | 
			
		||||
		// Special
 | 
			
		||||
		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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,24 @@ namespace RJW_Genes
 | 
			
		|||
            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)
 | 
			
		||||
        {
 | 
			
		||||
            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…
	
	Add table
		Add a link
		
	
		Reference in a new issue