diff --git a/Common/Defs/GeneDefs/GeneDefs_SexSpecial.xml b/Common/Defs/GeneDefs/GeneDefs_SexSpecial.xml index f68126f..b72778d 100644 --- a/Common/Defs/GeneDefs/GeneDefs_SexSpecial.xml +++ b/Common/Defs/GeneDefs/GeneDefs_SexSpecial.xml @@ -12,17 +12,17 @@ - + rjw_genes_orgasm_rush - On Orgasm, carriers of this gene get a boost in activity. (rest-need is partially filled) + On orgasm, carriers of this gene get a boost in activity. (rest-need is partially filled) 1 -2 UI/Memes/FleshPurity 1 - + rjw_genes_youth_fountain Having sex with a carrier of this gene makes the partner slightly younger. (Partner stays adult) @@ -30,9 +30,16 @@ -2 UI/Ideoligions/FireLeaves 2 + +
  • + + 60000 + 18 +
  • +
    - + rjw_genes_sex_age_drain Having sex transfers some of the partners life-time to themselves. (Pawn stays adult) @@ -40,12 +47,19 @@ -1 UI/Icons/ColonistBar/Idle 3 + +
  • + + 120000 + 18 +
  • +
    - + rjw_genes_aphrodisiac_pheromones - RJW_Genes.Gene_Aphrodisiac_Pheromones + RJW_Genes.Gene_Aphrodisiac_Pheromones Pheremones of this pawn induce an incressed sexdrive to others nearby. Genes/Icons/Pheromones 4 diff --git a/Source/Genes/Special/AgeTransferExtension.cs b/Source/Genes/Special/AgeTransferExtension.cs new file mode 100644 index 0000000..e309381 --- /dev/null +++ b/Source/Genes/Special/AgeTransferExtension.cs @@ -0,0 +1,17 @@ +using Verse; + +namespace RJW_Genes +{ + public class AgeTransferExtension : DefModExtension + { + /// + /// Amount by which the Biological Age Ticks will be changed. + /// + public int ageTickChange; + + /// + /// Minimum Age for youthing to take place - pawns cannot end up underaged. + /// + public int minAgeInYears; + } +} \ No newline at end of file diff --git a/Source/Genes/Special/Patch_AgeDrain.cs b/Source/Genes/Special/Patch_AgeDrain.cs index 4138a78..060c20d 100644 --- a/Source/Genes/Special/Patch_AgeDrain.cs +++ b/Source/Genes/Special/Patch_AgeDrain.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using UnityEngine; +using Verse; namespace RJW_Genes.Genes.Special { @@ -18,9 +20,9 @@ namespace RJW_Genes.Genes.Special * I am not sure how I feel about this, but as some people that I consider "normal" asked me about this I changed it as requested in #26 and #28 */ - const long AGE_TRANSFERED = 120000; // 120k == 2 days + const long AGE_TRANSFERED_FALLBACK = 120000; // 120k == 2 days // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety - const long MINIMUM_AGE = 18 * 60 * 60000 + 1; + const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1; public static void Postfix(SexProps props) { @@ -28,18 +30,50 @@ namespace RJW_Genes.Genes.Special { return; } - if (GeneUtility.IsAgeDrainer(props.pawn) && props.pawn.ageTracker.AgeBiologicalTicks > MINIMUM_AGE) + + Pawn pawn = props.pawn; + Pawn partner = props.partner; + + if (GeneUtility.IsAgeDrainer(pawn) && !GeneUtility.IsAgeDrainer(partner)) { - var pawnAge = props.pawn.ageTracker.AgeBiologicalTicks; - //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 if he is older than minimum age - if (pawnAge - AGE_TRANSFERED > MINIMUM_AGE) - props.pawn.ageTracker.AgeBiologicalTicks = Math.Max(MINIMUM_AGE, (pawnAge - AGE_TRANSFERED)); + TransferAge(pawn, partner); } + else if (GeneUtility.IsAgeDrainer(partner) && !GeneUtility.IsAgeDrainer(pawn)) + { + TransferAge(partner,pawn); + } + else if (GeneUtility.IsAgeDrainer(partner) && GeneUtility.IsAgeDrainer(pawn) && RJW_Genes_Settings.rjw_genes_detailed_debug) + { + ModLog.Message($"[Sexual Age Drainer] both {pawn} and {partner} are sexual-age-drainers - nothing happens."); + } + } + /// + /// Transfers age from the giver to the receiver. + /// + /// The pawn that will receive biological-Age-Ticks, and becomes younger if they are not already young. + /// The pawn that will be giving biological-Age-Ticks. This pawn is always aged, even if the other pawn is too young. + private static void TransferAge(Pawn receiver, Pawn giver) + { + AgeTransferExtension transferExt = GeneDefOf.rjw_genes_sex_age_drain.GetModExtension(); + long age_transfered = transferExt?.ageTickChange ?? AGE_TRANSFERED_FALLBACK; + long minimum_age = transferExt?.minAgeInYears * 60 * 60000 + 1 ?? MINIMUM_AGE_FALLBACK; + + var pawnAge = receiver.ageTracker.AgeBiologicalTicks; + + if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"[Sexual Age Drainer] {receiver} is aging {giver} by {age_transfered} ({Math.Round(age_transfered / 60000.0, 2)} days)"); + + // Giver ALWAYS ages + giver.ageTracker.AgeBiologicalTicks += age_transfered; + + // Make Receiver younger if they are older than minimum age + if (pawnAge - age_transfered > minimum_age) + receiver.ageTracker.AgeBiologicalTicks = Math.Max(minimum_age, (pawnAge - age_transfered)); + else { + if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"[Sexual Age Drainer] {receiver} was too young ({receiver.ageTracker.AgeBiologicalYears}), and remains unchanged."); + } } } } diff --git a/Source/Genes/Special/Patch_Youth_Fountain.cs b/Source/Genes/Special/Patch_Youth_Fountain.cs index bc07f1b..b64ca83 100644 --- a/Source/Genes/Special/Patch_Youth_Fountain.cs +++ b/Source/Genes/Special/Patch_Youth_Fountain.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Verse; namespace RJW_Genes.Genes.Special { @@ -18,9 +19,9 @@ namespace RJW_Genes.Genes.Special * I am not sure how I feel about this, but as some people that I consider "normal" asked me about this I changed it as requested in #26 and #28 */ - const long AGE_REDUCTION = 60000; // 60k == 1 day + const long AGE_REDUCTION_FALLBACK = 60000; // 60k == 1 day // 18 Years * 60 Days / Year * 60k Ticks/Day + 1 for safety - const long MINIMUM_AGE = 18 * 60 * 60000 + 1; + const long MINIMUM_AGE_FALLBACK = 18 * 60 * 60000 + 1; public static void Postfix(SexProps props) { @@ -28,16 +29,36 @@ namespace RJW_Genes.Genes.Special { return; } - if (GeneUtility.IsYouthFountain(props.pawn) && props.pawn.ageTracker.AgeBiologicalTicks >= MINIMUM_AGE) - { - var partnerAge = props.partner.ageTracker.AgeBiologicalTicks; - if(partnerAge - AGE_REDUCTION > MINIMUM_AGE) - props.partner.ageTracker.AgeBiologicalTicks = Math.Max(MINIMUM_AGE, partnerAge - AGE_REDUCTION); + if (GeneUtility.IsYouthFountain(props.pawn)) + { + ChangeAgeForPawn(props.partner, props.pawn); + } + if (GeneUtility.IsYouthFountain(props.partner)) + { + ChangeAgeForPawn(props.pawn,props.partner); } } + private static void ChangeAgeForPawn(Pawn ToYouth, Pawn YouthingPawn) + { + AgeTransferExtension transferExt = GeneDefOf.rjw_genes_youth_fountain.GetModExtension(); + long age_reduction = transferExt?.ageTickChange ?? AGE_REDUCTION_FALLBACK; + long minimum_age = transferExt?.minAgeInYears * 60 * 60000 + 1 ?? MINIMUM_AGE_FALLBACK; + + var partnerAge = ToYouth.ageTracker.AgeBiologicalTicks; + + if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"Firing Youth Fountain - {YouthingPawn} is youthing {ToYouth} by {age_reduction} ({Math.Round(age_reduction / 60000.0, 2)} days)"); + + if (partnerAge - age_reduction > minimum_age) { + ToYouth.ageTracker.AgeBiologicalTicks = Math.Max(minimum_age, partnerAge - age_reduction); + } + else if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"[Youth Fountain] {ToYouth} was too young ({ToYouth.ageTracker.AgeBiologicalYears}), and remains unchanged."); + } + } } diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 3084f31..21e7967 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -137,6 +137,7 @@ +