Rename source folder

This commit is contained in:
amevarashi 2022-09-08 19:59:25 +05:00
parent 0a412a0060
commit a4c046a841
55 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,31 @@
using RJWSexperience.Logs;
using RJWSexperience.SexHistory;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace RJWSexperience
{
[StaticConstructorOnStartup]
public static class DefInjection
{
static DefInjection()
{
if (SexperienceMod.Settings.History.EnableSexHistory)
InjectRaces();
}
private static void InjectRaces()
{
IEnumerable<ThingDef> PawnDefs = DefDatabase<ThingDef>.AllDefs.Where(x => x.race != null && !x.race.IsMechanoid);
if (PawnDefs.EnumerableNullOrEmpty())
return;
CompProperties comp = new CompProperties(typeof(SexHistoryComp));
foreach (ThingDef def in PawnDefs)
def.comps.Add(comp);
LogManager.GetLogger<DebugLogProvider>("StaticConstructorOnStartup").Message($"Injected SexHistoryComp into {PawnDefs.Count()} pawn Defs");
}
}
}

View file

@ -0,0 +1,52 @@
using HarmonyLib;
using RJWSexperience.Logs;
using RJWSexperience.SexHistory;
using System.Collections.Generic;
using System.Reflection;
using Verse;
namespace RJWSexperience
{
public static class Pawn_GetGizmos
{
private static Settings.SettingsTabHistory Settings => SexperienceMod.Settings.History;
public static void DoConditionalPatch(Harmony harmony)
{
if (!Settings.EnableSexHistory)
return;
MethodInfo original = typeof(Pawn).GetMethod(nameof(Pawn.GetGizmos));
MethodInfo postfix = typeof(Pawn_GetGizmos).GetMethod(nameof(Pawn_GetGizmos.Postfix));
harmony.Patch(original, postfix: new HarmonyMethod(postfix));
LogManager.GetLogger<DebugLogProvider>(nameof(Pawn_GetGizmos)).Message("Applied conditional patch to Pawn.GetGizmos()");
}
public static void Postfix(ref IEnumerable<Gizmo> __result, Pawn __instance)
{
if (Settings.HideGizmoWhenDrafted && __instance.Drafted)
return;
if (Find.Selector.NumSelected > 1)
return;
if (Settings.HideGizmoWithRJW && !rjw.RJWSettings.show_RJW_designation_box)
return;
SexHistoryComp history = __instance.TryGetComp<SexHistoryComp>();
if (history == null)
return;
__result = AddHistoryGizmo(history.Gizmo, __result);
}
private static IEnumerable<Gizmo> AddHistoryGizmo(Gizmo historyGizmo, IEnumerable<Gizmo> gizmos)
{
foreach (Gizmo gizmo in gizmos)
yield return gizmo;
yield return historyGizmo;
}
}
}

View file

@ -0,0 +1,173 @@
using HarmonyLib;
using RimWorld;
using rjw;
using RJWSexperience.Cum;
using RJWSexperience.Logs;
using RJWSexperience.SexHistory;
using System;
using UnityEngine;
using Verse;
namespace RJWSexperience
{
[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))
{
if (__instance.Sexprops.isRape && __instance.Sexprops.isReceiver)
{
__instance.pawn?.skills?.Learn(VariousDefOf.Sex, 0.05f, true);
}
else
{
__instance.pawn?.skills?.Learn(VariousDefOf.Sex, 0.35f, true);
}
}
}
}
[HarmonyPatch(typeof(SexUtility), nameof(SexUtility.SatisfyPersonal))]
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)
{
LustUtility.UpdateLust(props, satisfaction, base_sat_per_fuck);
CumUtility.FillCumBuckets(props);
props.pawn.records?.Increment(VariousDefOf.OrgasmCount);
if (SexperienceMod.Settings.History.EnableSexHistory && props.partner != null)
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSatisfaction(props.partner, props, satisfaction);
}
}
[HarmonyPatch(typeof(SexUtility), "TransferNutrition")]
public static class RJW_Patch_TransferNutrition
{
public static void Postfix(SexProps props)
{
CumUtility.TryFeedCum(props);
}
}
[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);
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);
if (!SexperienceMod.Settings.History.EnableSexHistory || props.partner == null)
return;
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSex(props.partner, props);
props.partner.TryGetComp<SexHistoryComp>()?.RecordSex(props.pawn, props);
}
}
[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);
}
}
}
[HarmonyPatch(typeof(CasualSex_Helper), nameof(CasualSex_Helper.FindSexLocation))]
public static class RJW_Patch_CasualSex_Helper_FindSexLocation
{
/// <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)
{
if (partner != null)
return true; // Not masturbation
var log = LogManager.GetLogger<DebugLogProvider>("RJW_Patch_CasualSex_Helper_FindSexLocation");
log.Message($"Called for {pawn.NameShortColored}");
if (pawn.Faction?.IsPlayer != true && !pawn.IsPrisonerOfColony)
{
log.Message("Not a player's faction or a prisoner");
return true;
}
Building_CumBucket bucket = pawn.FindClosestBucket();
if (bucket == null)
{
log.Message("Bucket not found");
return true;
}
__result = bucket.RandomAdjacentCell8Way();
log.Message($"Bucket location: {__result}");
return false;
}
}
[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;
}
}
}
}

View file

@ -0,0 +1,43 @@
using HarmonyLib;
using RimWorld;
using rjw;
using System;
using Verse;
namespace RJWSexperience
{
[HarmonyPatch(typeof(PawnGenerator), "GeneratePawn", new Type[] { typeof(PawnGenerationRequest) })]
public static class Rimworld_Patch_GeneratePawn
{
public static void Postfix(PawnGenerationRequest request, ref Pawn __result)
{
if (__result == null)
return;
bool doVirginTrait = true;
if (SexperienceMod.Settings.History.EnableRecordRandomizer && !request.Newborn && xxx.is_human(__result))
doVirginTrait = SexHistory.RecordRandomizer.Randomize(__result);
if (doVirginTrait)
Virginity.TraitHandler.GenerateVirginTrait(__result);
}
}
[HarmonyPatch(typeof(ParentRelationUtility), nameof(ParentRelationUtility.SetMother))]
public static class Rimworld_Patch_RemoveVirginOnSetMother
{
public static void Postfix(Pawn pawn, Pawn newMother)
{
if (!pawn.relations.DirectRelationExists(PawnRelationDefOf.Parent, newMother))
return;
Trait virgin = newMother.story?.traits?.GetTrait(VariousDefOf.Virgin, Virginity.TraitDegree.FemaleVirgin);
if (virgin != null)
{
newMother.story.traits.RemoveTrait(virgin);
newMother.story.traits.GainTrait(new Trait(VariousDefOf.Virgin, Virginity.TraitDegree.FemaleAfterSurgery));
}
}
}
}