Fixed Age-Drain Meme to lock to 20y and not ... 14, which is rimworld adult age

This commit is contained in:
Vegapnk 2023-01-07 16:51:34 +01:00
parent 6ea89c189c
commit ee85bd750d
4 changed files with 51 additions and 7 deletions

34
Source/Common/ModLog.cs Normal file
View File

@ -0,0 +1,34 @@
using Verse;
namespace RJW_Genes
{
internal class ModLog
{
public static string ModId => "RJW-Genes";
/// <summary>
/// Logs the given message with [SaveStorage.ModId] appended.
/// </summary>
public static void Error(string message)
{
Log.Error($"[{ModId}] {message}");
}
/// <summary>
/// Logs the given message with [SaveStorage.ModId] appended.
/// </summary>
public static void Message(string message)
{
Log.Message($"[{ModId}] {message}");
}
/// <summary>
/// Logs the given message with [SaveStorage.ModId] appended.
/// </summary>
public static void Warning(string message)
{
Log.Warning($"[{ModId}] {message}");
}
}
}

View File

@ -32,7 +32,7 @@ namespace RJW_Genes
return pawn.genes.HasGene(GeneDefOf.rjw_genes_youth_fountain);
}
internal static bool IsAgeDrainer(Pawn pawn)
public static bool IsAgeDrainer(Pawn pawn)
{
if (pawn.genes == null)
{

View File

@ -13,9 +13,11 @@ namespace RJW_Genes.Genes.Special
{
const long AGE_TRANSFERED = 120000; // 120k == 2 days
// 20 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
const long MINIMUM_AGE = 20 * 60 * 60000 + 1;
// Comment Below in for debugging, changes years
// const long AGE_TRANSFERED = 6000000; // 6000k == 100 days
// const long AGE_TRANSFERED = 12000000;
public static void Postfix(SexProps props)
{
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal() )
@ -25,12 +27,12 @@ namespace RJW_Genes.Genes.Special
if (GeneUtility.IsAgeDrainer(props.pawn))
{
var pawnAge = props.pawn.ageTracker.AgeBiologicalTicks;
var pawnMinAge = props.pawn.ageTracker.AdultMinAgeTicks;
//ModLog.Error($"Firing Age Drain \nMinimum Age is \t{MINIMUM_AGE} \nPawn Age is \t{pawnAge} \nTransferred \t{AGE_TRANSFERED}\nResulting in \t{pawnAge - AGE_TRANSFERED}");
// Make Partner older
props.partner.ageTracker.AgeBiologicalTicks += AGE_TRANSFERED;
// Make Pawn younger
props.pawn.ageTracker.AgeBiologicalTicks = Math.Max(pawnMinAge, pawnAge - AGE_TRANSFERED);
props.pawn.ageTracker.AgeBiologicalTicks = Math.Max(MINIMUM_AGE, (pawnAge - AGE_TRANSFERED));
}
}

View File

@ -13,9 +13,11 @@ namespace RJW_Genes.Genes.Special
{
const long AGE_REDUCTION = 60000; // 60k == 1 day
// 20 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety
const long MINIMUM_AGE = 20 * 60 * 60000 + 1;
// Comment Below in for debugging
//const long AGE_REDUCTION = 6000000; // 6000k == 100 days
// 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())
@ -25,12 +27,18 @@ namespace RJW_Genes.Genes.Special
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);
//ModLog.Error($"Firing Youth Fountain \nMinimum Age is \t{MINIMUM_AGE}\t{ticksToYears(MINIMUM_AGE)}y\nPawn Age is \t{partnerAge}\t{ticksToYears(partnerAge)}y \nTransferred \t {AGE_REDUCTION}\t{ticksToYears(AGE_REDUCTION)}y\nResulting in \t{partnerAge - AGE_REDUCTION}\t{ticksToYears(partnerAge - AGE_REDUCTION)}y");
props.partner.ageTracker.AgeBiologicalTicks = Math.Max(MINIMUM_AGE, partnerAge - AGE_REDUCTION);
}
}
private static float ticksToYears(long ticks)
{
return (ticks / 60000f) / 60f;
}
}
}