Log lust changes

This commit is contained in:
amevarashi 2022-03-07 09:57:23 +05:00
parent 8b2d1b3dc7
commit 02bcd44a90
4 changed files with 211 additions and 209 deletions

View file

@ -1,4 +1,7 @@
using HarmonyLib; extern alias BaseSexperience;
using BaseSexperience::RJWSexperience.ExtensionMethods;
using BaseSexperience::RJWSexperience;
using HarmonyLib;
using System.Reflection; using System.Reflection;
using Verse; using Verse;
@ -15,11 +18,11 @@ namespace RJWSexperience.Ideology
if (ModLister.HasActiveModWithName("RJW Sexperience")) if (ModLister.HasActiveModWithName("RJW Sexperience"))
{ {
//Log.Message("[RJWSexperience.Ideology] Found RJWSexperience, patching"); //Log.Message("[RJWSexperience.Ideology] Found RJWSexperience, patching");
harmony.Patch(AccessTools.Method(typeof(ExtensionMethods.PawnExtensions), nameof(ExtensionMethods.PawnExtensions.IsIncest)), harmony.Patch(AccessTools.Method(typeof(PawnExtensions), nameof(PawnExtensions.IsIncest)),
prefix: new HarmonyMethod(typeof(Sexperience_Patch_IsIncest), nameof(Sexperience_Patch_IsIncest.Prefix)), prefix: new HarmonyMethod(typeof(Sexperience_Patch_IsIncest), nameof(Sexperience_Patch_IsIncest.Prefix)),
postfix: null postfix: null
); );
harmony.Patch(AccessTools.Method(typeof(RJWSexperience.RJWUtility), nameof(RJWSexperience.RJWUtility.ThrowVirginHIstoryEvent)), harmony.Patch(AccessTools.Method(typeof(RJWUtility), nameof(RJWUtility.ThrowVirginHIstoryEvent)),
prefix: null, prefix: null,
postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHIstoryEvent), nameof(Sexperience_Patch_ThrowVirginHIstoryEvent.Postfix)) postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHIstoryEvent), nameof(Sexperience_Patch_ThrowVirginHIstoryEvent.Postfix))
); );

View file

@ -84,6 +84,8 @@
<ProjectReference Include="..\RJWSexperience\RJWSexperience.csproj"> <ProjectReference Include="..\RJWSexperience\RJWSexperience.csproj">
<Project>{9c728e06-573b-4b04-a07f-acbf60cb424d}</Project> <Project>{9c728e06-573b-4b04-a07f-acbf60cb424d}</Project>
<Name>RJWSexperience</Name> <Name>RJWSexperience</Name>
<Private>False</Private>
<Aliases>BaseSexperience</Aliases>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View file

@ -1,22 +1,14 @@
using System; using HarmonyLib;
using System.Collections.Generic; using RimWorld;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using rjw; using rjw;
using rjw.Modules.Interactions.Enums; using rjw.Modules.Interactions.Enums;
using RimWorld; using RJWSexperience.ExtensionMethods;
using UnityEngine;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
using UnityEngine;
using RJWSexperience.ExtensionMethods;
namespace RJWSexperience namespace RJWSexperience
{ {
[HarmonyPatch(typeof(JobDriver_Sex), "Orgasm")] [HarmonyPatch(typeof(JobDriver_Sex), "Orgasm")]
public static class RJW_Patch_Orgasm public static class RJW_Patch_Orgasm
{ {
@ -60,40 +52,46 @@ namespace RJWSexperience
public static void Prefix(SexProps props, ref float satisfaction) public static void Prefix(SexProps props, ref float satisfaction)
{ {
Pawn pawn = props.pawn; satisfaction = Mathf.Max(base_sat_per_fuck, satisfaction * props.partner.GetSexStat());
Pawn partner = props.partner;
satisfaction = Mathf.Max(base_sat_per_fuck, satisfaction * partner.GetSexStat());
} }
public static void Postfix(SexProps props, ref float satisfaction) public static void Postfix(SexProps props, ref float satisfaction)
{ {
Pawn pawn = props.pawn; Pawn pawn = props.pawn;
Pawn partner = props.partner; Pawn partner = props.partner;
float? lust = pawn.records?.GetValue(VariousDefOf.Lust); UpdateLust(props, satisfaction);
xxx.rjwSextype sextype = props.sexType;
if (lust != null)
{
if (sextype != xxx.rjwSextype.Masturbation || partner != null) pawn.records.AddTo(VariousDefOf.Lust, Mathf.Clamp((satisfaction - base_sat_per_fuck) * RJWUtility.LustIncrementFactor(lust ?? 0), -0.5f, 0.5f)); // If the sex is satisfactory, lust grows up. Declines at the opposite.
else pawn.records.AddTo(VariousDefOf.Lust, Mathf.Clamp(satisfaction * satisfaction * RJWUtility.LustIncrementFactor(lust ?? 0), 0, 0.5f)); // Masturbation always increases lust.
}
if (sextype == xxx.rjwSextype.Masturbation || partner == null) if (props.sexType == xxx.rjwSextype.Masturbation || partner == null)
{ {
Building_CumBucket cumbucket = (Building_CumBucket)pawn.GetAdjacentBuilding<Building_CumBucket>(); Building_CumBucket cumbucket = pawn.GetAdjacentBuilding<Building_CumBucket>();
if (cumbucket != null) cumbucket?.AddCum(pawn.GetCumVolume());
{
cumbucket.AddCum(pawn.GetCumVolume());
}
} }
RJWUtility.UpdateSatisfactionHIstory(pawn, partner, props, satisfaction); RJWUtility.UpdateSatisfactionHIstory(pawn, partner, props, satisfaction);
pawn.records?.Increment(VariousDefOf.OrgasmCount); pawn.records?.Increment(VariousDefOf.OrgasmCount);
} }
private static void UpdateLust(SexProps props, float satisfaction)
{
float? lust = props.pawn.records?.GetValue(VariousDefOf.Lust);
if (lust == null)
return;
float lustDelta;
if (props.sexType != xxx.rjwSextype.Masturbation || props.partner != null)
{
lustDelta = Mathf.Clamp((satisfaction - base_sat_per_fuck) * RJWUtility.LustIncrementFactor(lust ?? 0), -0.5f, 0.5f); // If the sex is satisfactory, lust grows up. Declines at the opposite.
}
else
{
lustDelta = Mathf.Clamp(satisfaction * satisfaction * RJWUtility.LustIncrementFactor(lust ?? 0), 0, 0.5f); // Masturbation always increases lust.
}
rjw.Modules.Shared.Logs.LogManager.GetLogger<RjwSexperienceMod>().Message($"{props.pawn.NameShortColored}'s lust changed by {lustDelta} (from {lust})");
props.pawn.records.AddTo(VariousDefOf.Lust, lustDelta);
}
} }
[HarmonyPatch(typeof(SexUtility), "TransferNutrition")] [HarmonyPatch(typeof(SexUtility), "TransferNutrition")]

View file

@ -38,7 +38,6 @@ namespace RJWSexperience
return false; return false;
} }
/// <summary> /// <summary>
/// For ideo patch /// For ideo patch
/// </summary> /// </summary>