Add option to disable sex history

This commit is contained in:
amevarashi 2022-06-07 08:46:19 +05:00
parent 7254769cf7
commit a91cf72896
8 changed files with 38 additions and 13 deletions

View File

@ -55,9 +55,9 @@
<RS_HadBestSexDaysAgo>Had best sex {0}.</RS_HadBestSexDaysAgo> <RS_HadBestSexDaysAgo>Had best sex {0}.</RS_HadBestSexDaysAgo>
<!-- Settings tab labels --> <!-- Settings tab labels -->
<TabLabelMain>Main</TabLabelMain> <RSTabLabelMain>Main</RSTabLabelMain>
<TabLabelHistory>Sex records</TabLabelHistory> <RSTabLabelHistory>Sex records</RSTabLabelHistory>
<TabLabelDebug>Debug</TabLabelDebug> <RSTabLabelDebug>Debug</RSTabLabelDebug>
<!-- Mod settings --> <!-- Mod settings -->
<RSOption_1_Label>Enable record randomizer</RSOption_1_Label> <RSOption_1_Label>Enable record randomizer</RSOption_1_Label>
@ -90,6 +90,8 @@
<RSOption_SexCanFillBuckets_Desc>If enabled boobjobs, footjobs and handjobs that happens near cum bucket will fill it</RSOption_SexCanFillBuckets_Desc> <RSOption_SexCanFillBuckets_Desc>If enabled boobjobs, footjobs and handjobs that happens near cum bucket will fill it</RSOption_SexCanFillBuckets_Desc>
<RSOption_Debug_Label>Debug</RSOption_Debug_Label> <RSOption_Debug_Label>Debug</RSOption_Debug_Label>
<RSOption_Debug_Desc>Enable debug logs</RSOption_Debug_Desc> <RSOption_Debug_Desc>Enable debug logs</RSOption_Debug_Desc>
<RSOption_EnableSexHistory_Label>[Caution] Enable Sex History*</RSOption_EnableSexHistory_Label>
<RSOption_EnableSexHistory_Desc>* Needs a game restart\n\nEnables Sex History window, information collection for the said window and save/load of this information. Also enables sex partners count in pawn's records.\n\n[Caution] Disabling this mid save will result in the loss of previously collected histories.</RSOption_EnableSexHistory_Desc>
<Button_ResetToDefault>Reset to default</Button_ResetToDefault> <Button_ResetToDefault>Reset to default</Button_ResetToDefault>
<!-- Sex types --> <!-- Sex types -->

View File

@ -81,12 +81,11 @@ namespace RJWSexperience
/// </summary> /// </summary>
public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props) public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props)
{ {
if (props != null && props.sexType == xxx.rjwSextype.Vaginal) if (props?.sexType == xxx.rjwSextype.Vaginal)
{ {
if (pawn.IsVirgin()) if (pawn.IsVirgin())
{ {
SexHistoryComp history = pawn.TryGetComp<SexHistoryComp>(); pawn.TryGetComp<SexHistoryComp>()?.RecordFirst(partner, props);
history?.RecordFirst(partner, props);
if (RJWUtility.RemoveVirginTrait(pawn, partner, props)) if (RJWUtility.RemoveVirginTrait(pawn, partner, props))
{ {
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true); Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);

View File

@ -16,6 +16,7 @@ namespace RJWSexperience
{ {
var har = new Harmony("RJW_Sexperience"); var har = new Harmony("RJW_Sexperience");
har.PatchAll(Assembly.GetExecutingAssembly()); har.PatchAll(Assembly.GetExecutingAssembly());
Pawn_GetGizmos.DoConditionalPatch(har);
InjectIntoRjwInteractionServices(); InjectIntoRjwInteractionServices();
} }

View File

@ -59,9 +59,9 @@ namespace RJWSexperience
public static readonly string RS_LastSex = "RS_LastSex".Translate(); public static readonly string RS_LastSex = "RS_LastSex".Translate();
[MayRequireRoyalty] public static readonly string Slave = "Slave".Translate(); [MayRequireRoyalty] public static readonly string Slave = "Slave".Translate();
public static readonly string TabLabelMain = "TabLabelMain".Translate(); public static readonly string TabLabelMain = "RSTabLabelMain".Translate();
public static readonly string TabLabelHistory = "TabLabelHistory".Translate(); public static readonly string TabLabelHistory = "RSTabLabelHistory".Translate();
public static readonly string TabLabelDebug = "TabLabelDebug".Translate(); public static readonly string TabLabelDebug = "RSTabLabelDebug".Translate();
public static readonly string Option_1_Label = "RSOption_1_Label".Translate(); public static readonly string Option_1_Label = "RSOption_1_Label".Translate();
public static readonly string Option_1_Desc = "RSOption_1_Desc".Translate(); public static readonly string Option_1_Desc = "RSOption_1_Desc".Translate();
@ -93,6 +93,8 @@ namespace RJWSexperience
public static readonly string Option_SexCanFillBuckets_Desc = "RSOption_SexCanFillBuckets_Desc".Translate(); public static readonly string Option_SexCanFillBuckets_Desc = "RSOption_SexCanFillBuckets_Desc".Translate();
public static readonly string Option_Debug_Label = "RSOption_Debug_Label".Translate(); public static readonly string Option_Debug_Label = "RSOption_Debug_Label".Translate();
public static readonly string Option_Debug_Desc = "RSOption_Debug_Desc".Translate(); public static readonly string Option_Debug_Desc = "RSOption_Debug_Desc".Translate();
public static readonly string Option_EnableSexHistory_Label = "RSOption_EnableSexHistory_Label".Translate();
public static readonly string Option_EnableSexHistory_Desc = "RSOption_EnableSexHistory_Desc".Translate();
public static readonly string Button_ResetToDefault = "Button_ResetToDefault".Translate(); public static readonly string Button_ResetToDefault = "Button_ResetToDefault".Translate();
public static string Translate(this PartnerOrderMode mode) public static string Translate(this PartnerOrderMode mode)

View File

@ -10,7 +10,8 @@ namespace RJWSexperience
{ {
static DefInjection() static DefInjection()
{ {
InjectRaces(); if (SexperienceMod.Settings.History.EnableSexHistory)
InjectRaces();
} }
private static void InjectRaces() private static void InjectRaces()

View File

@ -1,12 +1,25 @@
using HarmonyLib; using HarmonyLib;
using RJWSexperience.Logs;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using Verse; using Verse;
namespace RJWSexperience namespace RJWSexperience
{ {
[HarmonyPatch(typeof(Pawn), "GetGizmos")]
public static class Pawn_GetGizmos public static class Pawn_GetGizmos
{ {
public static void DoConditionalPatch(Harmony harmony)
{
if (!SexperienceMod.Settings.History.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) public static void Postfix(ref IEnumerable<Gizmo> __result, Pawn __instance)
{ {
if (Find.Selector.NumSelected > 1) if (Find.Selector.NumSelected > 1)

View File

@ -64,7 +64,7 @@ namespace RJWSexperience
LustUtility.UpdateLust(props, satisfaction, base_sat_per_fuck); LustUtility.UpdateLust(props, satisfaction, base_sat_per_fuck);
FillCumBuckets(props); FillCumBuckets(props);
props.pawn.records?.Increment(VariousDefOf.OrgasmCount); props.pawn.records?.Increment(VariousDefOf.OrgasmCount);
if (props.partner != null) if (SexperienceMod.Settings.History.EnableSexHistory && props.partner != null)
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSatisfaction(props.partner, props, satisfaction); props.pawn.TryGetComp<SexHistoryComp>()?.RecordSatisfaction(props.partner, props, satisfaction);
} }
@ -165,7 +165,7 @@ namespace RJWSexperience
{ {
RJWUtility.UpdateSextypeRecords(props); RJWUtility.UpdateSextypeRecords(props);
if (props.partner == null) if (!SexperienceMod.Settings.History.EnableSexHistory || props.partner == null)
return; return;
props.pawn.TryGetComp<SexHistoryComp>()?.RecordSex(props.partner, props); props.pawn.TryGetComp<SexHistoryComp>()?.RecordSex(props.partner, props);

View File

@ -18,6 +18,7 @@ namespace RJWSexperience.Settings
public const float MinSexablePercentDefault = 0.2f; public const float MinSexablePercentDefault = 0.2f;
public const float VirginRatioDefault = 0.01f; public const float VirginRatioDefault = 0.01f;
public const bool SlavesBeenRapedExpDefault = true; public const bool SlavesBeenRapedExpDefault = true;
public const bool EnableSexHistoryDefault = true;
// Private attributes // Private attributes
private bool enableRecordRandomizer = EnableStatRandomizerDefault; private bool enableRecordRandomizer = EnableStatRandomizerDefault;
@ -29,6 +30,7 @@ namespace RJWSexperience.Settings
private float minSexablePercent = MinSexablePercentDefault; private float minSexablePercent = MinSexablePercentDefault;
private float virginRatio = VirginRatioDefault; private float virginRatio = VirginRatioDefault;
private bool slavesBeenRapedExp = SlavesBeenRapedExpDefault; private bool slavesBeenRapedExp = SlavesBeenRapedExpDefault;
private bool enableSexHistory = EnableSexHistoryDefault;
//Public read-only properties //Public read-only properties
public bool EnableRecordRandomizer => enableRecordRandomizer; public bool EnableRecordRandomizer => enableRecordRandomizer;
@ -40,6 +42,7 @@ namespace RJWSexperience.Settings
public float MinSexablePercent => minSexablePercent; public float MinSexablePercent => minSexablePercent;
public float VirginRatio => virginRatio; public float VirginRatio => virginRatio;
public bool SlavesBeenRapedExp => slavesBeenRapedExp; public bool SlavesBeenRapedExp => slavesBeenRapedExp;
public bool EnableSexHistory => enableSexHistory;
public static SettingsTabHistory CreateDefault() public static SettingsTabHistory CreateDefault()
{ {
@ -59,6 +62,7 @@ namespace RJWSexperience.Settings
minSexablePercent = MinSexablePercentDefault; minSexablePercent = MinSexablePercentDefault;
virginRatio = VirginRatioDefault; virginRatio = VirginRatioDefault;
slavesBeenRapedExp = SlavesBeenRapedExpDefault; slavesBeenRapedExp = SlavesBeenRapedExpDefault;
enableSexHistory = EnableSexHistoryDefault;
} }
public void ExposeData() public void ExposeData()
@ -72,6 +76,7 @@ namespace RJWSexperience.Settings
Scribe_Values.Look(ref minSexablePercent, "MinSexablePercent", MinSexablePercentDefault); Scribe_Values.Look(ref minSexablePercent, "MinSexablePercent", MinSexablePercentDefault);
Scribe_Values.Look(ref virginRatio, "VirginRatio", VirginRatioDefault); Scribe_Values.Look(ref virginRatio, "VirginRatio", VirginRatioDefault);
Scribe_Values.Look(ref slavesBeenRapedExp, "SlavesBeenRapedExp", SlavesBeenRapedExpDefault); Scribe_Values.Look(ref slavesBeenRapedExp, "SlavesBeenRapedExp", SlavesBeenRapedExpDefault);
Scribe_Values.Look(ref enableSexHistory, "EnableSexHistory", EnableSexHistoryDefault);
} }
public void DoTabContents(Rect inRect) public void DoTabContents(Rect inRect)
@ -106,6 +111,8 @@ namespace RJWSexperience.Settings
listmain.EndSection(section); listmain.EndSection(section);
} }
listmain.CheckboxLabeled(Keyed.Option_EnableSexHistory_Label, ref enableSexHistory, Keyed.Option_EnableSexHistory_Desc);
if (listmain.ButtonText(Keyed.Button_ResetToDefault)) if (listmain.ButtonText(Keyed.Button_ResetToDefault))
{ {
Reset(); Reset();