Start on Living CumBucket

This commit is contained in:
Vegapnk 2024-07-16 17:36:33 +02:00
parent bd1ef6d5a2
commit 05770a834e
11 changed files with 164 additions and 4 deletions

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw;
using RimWorld;
using Verse;
namespace RJW_Genes
{
/// <summary>
/// Changes LicentiaLabs (if Present) to not cumflate pawns that are cumflation immune.
/// This code is exercised / loaded in the HarmonyInit.
/// Patched File: https://gitgud.io/John-the-Anabaptist/licentia-labs/-/blob/master/Source/LicentiaLabs/LicentiaLabs/Cumflation.cs
/// </summary>
///
class Patch_CumflationImmunity
{
// This patch does not need the normal Harmony Targetting,
// as it needs to be added only on demand (See HarmonyInit.cs)
public static bool Prefix(SexProps props)
{
// Harmony Logic skips the original Method after Prefix when "false" is returned
// See https://harmony.pardeike.net/articles/execution.html
// We skip the whole Cumflation Logic when the Partner is Cumflation Immune
if (props != null && props.partner != null && GeneUtility.IsCumflationImmune(props.partner))
{
return false;
}
return true;
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw;
using RimWorld;
using Verse;
namespace RJW_Genes
{
/// <summary>
/// Changes LicentiaLabs (if Present) to add a cumflation-counter hediff, when the pawn is cumflated.
/// The counter hediff takes away the negative stats of the original hediff.
/// This code is exercised / loaded in the HarmonyInit.
/// Patched File: https://gitgud.io/John-the-Anabaptist/licentia-labs/-/blob/master/Source/LicentiaLabs/LicentiaLabs/Cumflation.cs
/// </summary>
///
class Patch_LikesCumflation
{
// This patch does not need the normal Harmony Targetting,
// as it needs to be added only on demand (See HarmonyInit.cs)
public static void PostFix(SexProps props)
{
if (props == null || props.pawn == null || props.partner == null) return;
// Minor Hardening to help with #105
if (!ModsConfig.IsActive("LustLicentia.RJWLabs")) return;
if (props.pawn.genes != null && props.pawn.genes.HasActiveGene(GeneDefOf.rjw_genes_likes_cumflation) )
{
AddOrIncreaseCumflationCounterHediff(props.pawn);
}
if (props.partner.genes != null && props.partner.genes.HasActiveGene(GeneDefOf.rjw_genes_likes_cumflation))
{
AddOrIncreaseCumflationCounterHediff(props.partner);
}
}
public static void AddOrIncreaseCumflationCounterHediff(Pawn inflated)
{
Hediff cumstuffed_hediff = inflated.health.hediffSet.GetFirstHediffOfDef(LicentiaLabs.Licentia.HediffDefs.Cumstuffed);
//Hediff cumstuffed_hediff = LicentiaLabs.CumflationHelper.GetCumflationHediff(inflated, LicentiaLabs.Licentia.HediffDefs.Cumstuffed, "stomach");
if (cumstuffed_hediff != null && cumstuffed_hediff.Severity >= 0.01) {
ModLog.Message($"{inflated} got cumstuffed and gets the counter-part");
var bodyPartRecord = inflated.RaceProps.body.AllParts.Find(bpr => bpr.def.defName.Contains("stomach") || bpr.def.defName.Contains("stomach".ToLower()));
var counter_hediff = CreateOrGetCumflationCounterHediff(inflated, HediffDefOf.rjw_genes_cumstuffed_counter, bodyPartRecord);
counter_hediff.Severity = cumstuffed_hediff.Severity;
}
Hediff cumflation_hediff = inflated.health.hediffSet.GetFirstHediffOfDef(LicentiaLabs.Licentia.HediffDefs.Cumflation);
if (cumflation_hediff != null && cumflation_hediff.Severity >= 0.01)
{
ModLog.Message($"{inflated} got cumflated and gets the counter-part");
var bodyPartRecord = Genital_Helper.get_genitalsBPR(inflated);
var counter_hediff = CreateOrGetCumflationCounterHediff(inflated, HediffDefOf.rjw_genes_cumflation_counter, bodyPartRecord);
counter_hediff.Severity = cumflation_hediff.Severity;
}
}
public static Hediff CreateOrGetCumflationCounterHediff(Pawn inflated, HediffDef counterCumflationDef, BodyPartRecord bodyPartRecord)
{
Hediff cumflationHediff = inflated.health.hediffSet.GetFirstHediffOfDef(counterCumflationDef);
if (cumflationHediff == null)
{
cumflationHediff = HediffMaker.MakeHediff(counterCumflationDef, inflated, bodyPartRecord);
cumflationHediff.Severity = 0;
inflated.health.AddHediff(cumflationHediff, bodyPartRecord);
}
return cumflationHediff;
}
}
}

View file

@ -0,0 +1,64 @@
using HarmonyLib;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using static System.Net.Mime.MediaTypeNames;
namespace RJW_Genes
{
[HarmonyPatch(typeof(SexUtility), nameof(SexUtility.SatisfyPersonal))]
public class Patch_LivingCumbucket_StackHediff
{
/// <summary>
/// This is the amount of fluid required if the pawn has a bodysize of 1, to reach a severity in the hediff of 1.
/// The hediff can still be increased.
/// </summary>
const float fluid_amount_required_for_hediff_severity_ = 100.0f;
public static void Postfix(SexProps props)
{
if (!ModsConfig.IsActive("rjw.sexperience"))
return;
// ShortCuts: Exit Early if Pawn or Partner are null (can happen with Masturbation or other nieche-cases)
if (props == null || props.pawn == null || !props.hasPartner())
return;
Pawn pawnA = props.pawn;
Pawn pawnB = props.partner;
if (pawnA.genes != null && pawnA.genes.HasActiveGene(GeneDefOf.rjw_genes_living_cumbucket) && CumUtility.GetTotalFluidAmount(pawnB) > 0)
{
ProcessLivingCumbucket(pawnA, CumUtility.GetTotalFluidAmount(pawnB));
}
if (pawnB.genes != null && pawnB.genes.HasActiveGene(GeneDefOf.rjw_genes_living_cumbucket) && CumUtility.GetTotalFluidAmount(pawnA) > 0)
{
ProcessLivingCumbucket(pawnB, CumUtility.GetTotalFluidAmount(pawnA));
}
}
public static void ProcessLivingCumbucket(Pawn pawn, float cumamount)
{
float bodysize = pawn.BodySize;
float result_severity_increase = cumamount / (fluid_amount_required_for_hediff_severity_ * bodysize);
ModLog.Message($"Pumping the living cumbucket {pawn} (Bodysize {bodysize}) with {cumamount} cum, resulting in severity {result_severity_increase}");
Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.rjw_genes_filled_living_cumbucket);
if (hediff == null)
{
hediff = pawn.health.GetOrAddHediff(HediffDefOf.rjw_genes_filled_living_cumbucket);
hediff.Severity = 0.01f;
}
hediff.Severity += result_severity_increase;
}
}
}

View file

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw;
using RimWorld;
using Verse;
using LicentiaLabs;
namespace RJW_Genes
{
/// <summary>
/// Changes LicentiaLabs (if Present) to alter the TransferNutrition for rjw_genes_generous_donor.
/// This code is exercised / loaded in the HarmonyInit.
/// Patched File: https://gitgud.io/John-the-Anabaptist/licentia-labs/-/blob/master/Source/LicentiaLabs/LicentiaLabs/Cumflation.cs
/// </summary>
///
class Patch_TransferNutrition
{
// This patch does not need the normal Harmony Targetting,
// as it needs to be added only on demand (See HarmonyInit.cs)
public static void Postfix(Pawn giver, Pawn receiver, float cumAmount)
{
// Design decision:
// 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.
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<Need_Food>();
if (inflatorFood != null)
inflatorFood.CurLevel += donatedNutrition;
}
}
}
}