From ee2be0375c4727c561054e1008867c4617f99266 Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Thu, 30 May 2024 08:52:58 +0200 Subject: [PATCH] Put Licentia Parts back in, but commented out so I dont forget --- Source/Common/Helpers/MapUtility.cs | 32 +++++++++++ Source/Genes/Cum/Patch_TransferNutrition.cs | 11 ++++ Source/Genes/Damage/Gene_Elasticity.cs | 56 +++++++++++++++++++ ...ghtWorker_Aphrodisiac_Pheromones_Social.cs | 8 +-- Source/Rjw-Genes.csproj | 2 + 5 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 Source/Common/Helpers/MapUtility.cs create mode 100644 Source/Genes/Damage/Gene_Elasticity.cs diff --git a/Source/Common/Helpers/MapUtility.cs b/Source/Common/Helpers/MapUtility.cs new file mode 100644 index 0000000..79e45a6 --- /dev/null +++ b/Source/Common/Helpers/MapUtility.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Verse; + +namespace RJW_Genes +{ + public class MapUtility + { + /// + /// Checks if the pawn is on the players home map. + /// + /// Reason is that drones should only be punished for absence of queen if they are on the map and there is no queen. + /// If they are on a mission, transport-pod etc. they should not get boni or mali. + /// + /// The pawn for which to check map-presence. + /// True if the pawn is on the home-map, False otherwise. + public static bool PawnIsOnHomeMap(Pawn pawn) + { + if (Find.Maps.NullOrEmpty() || !Find.Maps.Where(mapCandidate => mapCandidate.IsPlayerHome).Any()) + { + return false; + } + Map homeMap = Find.Maps.Where(mapCandidate => mapCandidate.IsPlayerHome).First(); + return + homeMap != null && pawn != null + && pawn.Spawned + && pawn.Map == homeMap; + } + + } +} diff --git a/Source/Genes/Cum/Patch_TransferNutrition.cs b/Source/Genes/Cum/Patch_TransferNutrition.cs index 9c17d2a..1f3f0bb 100644 --- a/Source/Genes/Cum/Patch_TransferNutrition.cs +++ b/Source/Genes/Cum/Patch_TransferNutrition.cs @@ -29,6 +29,17 @@ namespace RJW_Genes // I could have done some transpiler stuff, but that is scary and might need to be adjusted quite a lot // Hence, I simply re-book the nutrition back to the giver in the Postfix. That should be robust and easy. + /* + TODO: Move this back in, once Licentia is 1.5 compatible. It should not drastically change. + if (GeneUtility.IsGenerousDonor(giver)) + { + float donatedNutrition = CumflationHelper.CalculateNutritionAmount(giver, cumAmount); + // TODO: In theory, there could be something weird happening if the donor has food less than X and the "IgnoreThermodynamics" is set on. + // Then it can happen that the donor ends up with more food than he had before cumshot, but I think that is somewhat funny given that you have ignore Thermodynamics on. + Need_Food inflatorFood = giver.needs.TryGetNeed(); + inflatorFood.CurLevel += donatedNutrition; + } + */ } } } \ No newline at end of file diff --git a/Source/Genes/Damage/Gene_Elasticity.cs b/Source/Genes/Damage/Gene_Elasticity.cs new file mode 100644 index 0000000..5d26c07 --- /dev/null +++ b/Source/Genes/Damage/Gene_Elasticity.cs @@ -0,0 +1,56 @@ +//using LicentiaLabs; +using Verse; + + +// TODO: Re-Introduce this once Licentia is 1.5 +// It should be rather simple +namespace RJW_Genes +{ + /// + /// This Gene adds Licentia-Labs Elasticised Hediff to a Pawn. + /// Note: I had a HarmonyPatch first, similar to skipping cumflation, but the Stretching Logic is called quite a lot and for both pawns actually. + /// Hence, I think choosing the Elasticiced Hediff was good as then everything is covered by "Licentia-Logic". + /// + public class Gene_Elasticity : Gene + { + private const int RESET_INTERVAL = 60000; // 60k should be 1 day + + /* + public override void PostAdd() + { + base.PostAdd(); + // Doing it like this will add the hediff with a severity of ~0.5, but it will decay. + // Hence we check with the Ticks to update. + this.pawn.health.AddHediff(Licentia.HediffDefs.Elasticised); + ResetSeverity(); + } + + public override void Tick() + { + base.Tick(); + if (pawn.IsHashIntervalTick(RESET_INTERVAL)) + ResetSeverity(); + } + + public override void PostRemove() + { + Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised); + if (candidate != null) + { + pawn.health.RemoveHediff(candidate); + } + base.PostRemove(); + } + + + private void ResetSeverity(float severity = 0.7f) + { + Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised); + if (candidate != null) + { + candidate.Severity = severity; + } + } + */ + } +} \ No newline at end of file diff --git a/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs b/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs index 4f3a03f..b236fc9 100644 --- a/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs +++ b/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs @@ -33,15 +33,15 @@ namespace RJW_Genes if (!other.RaceProps.Humanlike) return (ThoughtState)false; + // Pawns that have not "met" wont give each other Mali + // Known-Each-Other is a key-word for Rimworld that shows they have had any interaction and stored each other in relations. if (!RelationsUtility.PawnsKnowEachOther(pawn, other)) return (ThoughtState)false; // If the pawn is not on Map (e.g. caravan), no mali - - - + if (!MapUtility.PawnIsOnHomeMap(pawn)) + return (ThoughtState)false; // Do nothing for pawns that also have pheromones if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones)) - return (ThoughtState)false; // Actual Logic: diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 11312b8..c257868 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -60,9 +60,11 @@ + +