RJW-Sexperience/Source/RJWSexperience/Patches/RJW_Patch.cs

174 lines
4.9 KiB
C#
Raw Normal View History

2022-03-07 04:57:23 +00:00
using HarmonyLib;
using RimWorld;
2021-09-24 15:14:02 +00:00
using rjw;
using RJWSexperience.Cum;
2022-04-21 18:36:14 +00:00
using RJWSexperience.Logs;
2022-06-13 05:51:09 +00:00
using RJWSexperience.SexHistory;
2022-07-15 17:49:04 +00:00
using System;
2022-03-07 04:57:23 +00:00
using UnityEngine;
2021-09-24 15:14:02 +00:00
using Verse;
namespace RJWSexperience
{
2022-03-07 04:57:23 +00:00
[HarmonyPatch(typeof(JobDriver_Sex), "Orgasm")]
public static class RJW_Patch_Orgasm
{
public static void Postfix(JobDriver_Sex __instance)
{
if (__instance.Sexprops.sexType != xxx.rjwSextype.Masturbation && !(__instance is JobDriver_Masturbate))
{
2022-03-24 17:31:07 +00:00
if (__instance.Sexprops.isRape && __instance.Sexprops.isReceiver)
2022-03-07 04:57:23 +00:00
{
__instance.pawn?.skills?.Learn(VariousDefOf.Sex, 0.05f, true);
2022-03-07 04:57:23 +00:00
}
2022-03-24 17:31:07 +00:00
else
2022-03-07 04:57:23 +00:00
{
__instance.pawn?.skills?.Learn(VariousDefOf.Sex, 0.35f, true);
2022-03-07 04:57:23 +00:00
}
}
}
}
2022-05-23 17:29:00 +00:00
[HarmonyPatch(typeof(SexUtility), nameof(SexUtility.SatisfyPersonal))]
2022-03-07 04:57:23 +00:00
public static class RJW_Patch_SatisfyPersonal
{
private const float base_sat_per_fuck = 0.4f;
public static void Prefix(SexProps props, ref float satisfaction)
{
satisfaction = Mathf.Max(base_sat_per_fuck, satisfaction * props.partner.GetSexStat());
}
public static void Postfix(SexProps props, ref float satisfaction)
{
2022-05-23 17:29:00 +00:00
LustUtility.UpdateLust(props, satisfaction, base_sat_per_fuck);
CumUtility.FillCumBuckets(props);
2022-05-23 17:29:00 +00:00
props.pawn.records?.Increment(VariousDefOf.OrgasmCount);
2023-03-24 15:22:54 +00:00
if (SexperienceMod.Settings.EnableSexHistory && props.partner != null)
2022-05-23 17:29:00 +00:00
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSatisfaction(props.partner, props, satisfaction);
2022-05-07 16:05:27 +00:00
}
2022-03-07 04:57:23 +00:00
}
[HarmonyPatch(typeof(SexUtility), "TransferNutrition")]
public static class RJW_Patch_TransferNutrition
{
public static void Postfix(SexProps props)
{
CumUtility.TryFeedCum(props);
2022-03-07 04:57:23 +00:00
}
}
[HarmonyPatch(typeof(Nymph_Generator), "set_skills")]
public static class RJW_Patch_Nymph_set_skills
{
public static void Postfix(Pawn pawn)
{
SkillRecord sexskill = pawn.skills.GetSkill(VariousDefOf.Sex);
2022-03-07 04:57:23 +00:00
if (sexskill != null)
{
sexskill.passion = Passion.Major;
sexskill.Level = (int)Utility.RandGaussianLike(7f, 20.99f);
sexskill.xpSinceLastLevel = sexskill.XpRequiredForLevelUp * Rand.Range(0.10f, 0.90f);
}
}
}
[HarmonyPatch(typeof(AfterSexUtility), "UpdateRecords")]
public static class RJW_Patch_UpdateRecords
{
public static void Postfix(SexProps props)
{
RJWUtility.UpdateSextypeRecords(props);
2023-03-24 15:22:54 +00:00
if (!SexperienceMod.Settings.EnableSexHistory || props.partner == null)
2022-06-04 08:02:23 +00:00
return;
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSex(props.partner, props);
props.partner.TryGetComp<SexHistoryComp>()?.RecordSex(props.pawn, props);
}
2022-03-07 04:57:23 +00:00
}
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")]
public static class RJW_Patch_LogSextype
{
public static void Postfix(JobDriver_SexBaseInitiator __instance)
{
if (__instance.Partner != null)
{
__instance.pawn.PoptheCherry(__instance.Partner, __instance.Sexprops);
__instance.Partner.PoptheCherry(__instance.pawn, __instance.Sexprops);
}
}
}
2022-03-24 17:31:07 +00:00
[HarmonyPatch(typeof(CasualSex_Helper), nameof(CasualSex_Helper.FindSexLocation))]
public static class RJW_Patch_CasualSex_Helper_FindSexLocation
2022-03-07 04:57:23 +00:00
{
2022-03-24 17:31:07 +00:00
/// <summary>
/// If masturbation and current map has a bucket, return location near the bucket
/// </summary>
/// <param name="pawn"></param>
/// <param name="partner"></param>
/// <param name="__result"></param>
/// <returns></returns>
public static bool Prefix(Pawn pawn, Pawn partner, ref IntVec3 __result)
2022-03-07 04:57:23 +00:00
{
2022-03-24 17:31:07 +00:00
if (partner != null)
return true; // Not masturbation
2022-04-21 18:36:14 +00:00
var log = LogManager.GetLogger<DebugLogProvider>("RJW_Patch_CasualSex_Helper_FindSexLocation");
log.Message($"Called for {pawn.NameShortColored}");
2022-03-24 17:31:07 +00:00
2022-04-27 05:37:40 +00:00
if (pawn.Faction?.IsPlayer != true && !pawn.IsPrisonerOfColony)
2022-03-07 04:57:23 +00:00
{
2022-04-27 05:37:40 +00:00
log.Message("Not a player's faction or a prisoner");
2022-03-24 17:31:07 +00:00
return true;
}
Building_CumBucket bucket = pawn.FindClosestBucket();
if (bucket == null)
{
2022-04-21 18:36:14 +00:00
log.Message("Bucket not found");
2022-03-24 17:31:07 +00:00
return true;
2022-03-07 04:57:23 +00:00
}
2022-03-24 17:31:07 +00:00
__result = bucket.RandomAdjacentCell8Way();
2022-04-21 18:36:14 +00:00
log.Message($"Bucket location: {__result}");
2022-03-24 17:31:07 +00:00
return false;
2022-03-07 04:57:23 +00:00
}
}
2022-07-15 17:49:04 +00:00
[HarmonyPatch(typeof(SexUtility), nameof(SexUtility.Aftersex), new Type[] { typeof(SexProps) })]
public static class RJW_Patch_SexUtility_Aftersex_RapeEffects
{
public static void Postfix(SexProps props)
{
if (!props.hasPartner() || !props.isRape || !xxx.is_human(props.partner))
return;
if (props.partner.IsPrisoner)
RapeEffectPrisoner(props.partner);
if (props.partner.IsSlave)
RapeEffectSlave(props.partner);
}
private static void RapeEffectPrisoner(Pawn victim)
{
victim.guest.will = Math.Max(0, victim.guest.will - 0.2f);
}
private static void RapeEffectSlave(Pawn victim)
{
Need_Suppression suppression = victim.needs.TryGetNeed<Need_Suppression>();
if (suppression != null)
{
Hediff broken = victim.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken);
if (broken != null) suppression.CurLevel += (0.3f * broken.Severity) + 0.05f;
else suppression.CurLevel += 0.05f;
}
}
}
2021-09-24 15:14:02 +00:00
}