MaxSingleLustChange option and settings window refactor

This commit is contained in:
amevarashi 2022-03-27 21:05:10 +05:00
parent 43053d4296
commit 2bf95036d3
5 changed files with 129 additions and 145 deletions

View file

@ -81,6 +81,8 @@
<RSOption_10_Desc>Set probability of virgin regardless of age.</RSOption_10_Desc> <RSOption_10_Desc>Set probability of virgin regardless of age.</RSOption_10_Desc>
<RSOption_MinSexableFromLifestage_Label>Minimum sexable age from life stages</RSOption_MinSexableFromLifestage_Label> <RSOption_MinSexableFromLifestage_Label>Minimum sexable age from life stages</RSOption_MinSexableFromLifestage_Label>
<RSOption_MinSexableFromLifestage_Desc>Only used for generating records. Get minimum sexable age from the first reproductive life stage. Works better for races with a long lifespan</RSOption_MinSexableFromLifestage_Desc> <RSOption_MinSexableFromLifestage_Desc>Only used for generating records. Get minimum sexable age from the first reproductive life stage. Works better for races with a long lifespan</RSOption_MinSexableFromLifestage_Desc>
<RSOption_MaxSingleLustChange_Label>Maximum lust change per sex</RSOption_MaxSingleLustChange_Label>
<RSOption_MaxSingleLustChange_Desc>Set how much lust can change from a single sex act</RSOption_MaxSingleLustChange_Desc>
<Vaginal>Vaginal</Vaginal> <Vaginal>Vaginal</Vaginal>
<Anal>Anal</Anal> <Anal>Anal</Anal>

View file

@ -5,168 +5,148 @@ using Verse;
namespace RJWSexperience namespace RJWSexperience
{ {
public class Configurations : ModSettings public class Configurations : ModSettings
{ {
public const float MaxInitialLustDefault = 500; public const float MaxInitialLustDefault = 400f;
public const float AvgLustDefault = 0; public const float AvgLustDefault = 0f;
public const float MaxSexCountDeviationDefault = 90; public const float MaxSexCountDeviationDefault = 90f;
public const float LustEffectPowerDefault = 0.5f; public const float LustEffectPowerDefault = 0.5f;
public const float SexPerYearDefault = 30; public const float SexPerYearDefault = 30f;
public const bool SlavesBeenRapedExpDefault = true; public const bool SlavesBeenRapedExpDefault = true;
public const bool EnableStatRandomizerDefault = true; public const bool EnableStatRandomizerDefault = true;
public const float LustLimitDefault = 500f/3f; public const float LustLimitDefault = MaxInitialLustDefault / 3f;
public const bool MinSexableFromLifestageDefault = true; public const float MaxSingleLustChangeDefault = 0.5f;
public const float MinSexablePercentDefault = 0.2f; public const bool MinSexableFromLifestageDefault = true;
public const float VirginRatioDefault = 0.01f; public const float MinSexablePercentDefault = 0.2f;
public const float VirginRatioDefault = 0.01f;
public static float MaxLustDeviation = MaxInitialLustDefault; private float maxSingleLustChange = MaxSingleLustChangeDefault;
public static float AvgLust = AvgLustDefault; private bool minSexableFromLifestage = MinSexableFromLifestageDefault;
public static float MaxSexCountDeviation = MaxSexCountDeviationDefault;
public static float LustEffectPower = LustEffectPowerDefault;
public static float SexPerYear = SexPerYearDefault;
public static bool SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
public static bool EnableRecordRandomizer = EnableStatRandomizerDefault;
public static float LustLimit = LustLimitDefault;
public static bool MinSexableFromLifestage = MinSexableFromLifestageDefault;
public static float MinSexablePercent = MinSexablePercentDefault;
public static float VirginRatio = VirginRatioDefault;
public static bool SelectionLocked = false; public static float MaxLustDeviation = MaxInitialLustDefault;
public static float AvgLust = AvgLustDefault;
public static float MaxSexCountDeviation = MaxSexCountDeviationDefault;
public static float LustEffectPower = LustEffectPowerDefault;
public static float SexPerYear = SexPerYearDefault;
public static bool SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
public static bool EnableRecordRandomizer = EnableStatRandomizerDefault;
public static float LustLimit = LustLimitDefault;
public bool MinSexableFromLifestage { get => minSexableFromLifestage; }
public static float MinSexablePercent = MinSexablePercentDefault;
public static float VirginRatio = VirginRatioDefault;
public float MaxSingleLustChange { get => maxSingleLustChange; }
public void ResetToDefault() public static bool SelectionLocked = false;
{
MaxLustDeviation = MaxInitialLustDefault;
AvgLust = AvgLustDefault;
MaxSexCountDeviation = MaxSexCountDeviationDefault;
LustEffectPower = LustEffectPowerDefault;
SexPerYear = SexPerYearDefault;
SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
EnableRecordRandomizer = EnableStatRandomizerDefault;
LustLimit = LustLimitDefault;
MinSexableFromLifestage = MinSexableFromLifestageDefault;
MinSexablePercent = MinSexablePercentDefault;
VirginRatio = VirginRatioDefault;
}
public override void ExposeData() public void ResetToDefault()
{ {
Scribe_Values.Look(ref MaxLustDeviation, "MaxLustDeviation", MaxInitialLustDefault, true); MaxLustDeviation = MaxInitialLustDefault;
Scribe_Values.Look(ref AvgLust, "AvgLust", AvgLust, true); AvgLust = AvgLustDefault;
Scribe_Values.Look(ref MaxSexCountDeviation, "MaxSexCountDeviation", MaxSexCountDeviation, true); MaxSexCountDeviation = MaxSexCountDeviationDefault;
Scribe_Values.Look(ref LustEffectPower, "LustEffectPower", LustEffectPower, true); LustEffectPower = LustEffectPowerDefault;
Scribe_Values.Look(ref SexPerYear, "SexPerYear", SexPerYear, true); SexPerYear = SexPerYearDefault;
Scribe_Values.Look(ref SlavesBeenRapedExp, "SlavesBeenRapedExp", SlavesBeenRapedExp, true); SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
Scribe_Values.Look(ref EnableRecordRandomizer, "EnableRecordRandomizer", EnableRecordRandomizer, true); EnableRecordRandomizer = EnableStatRandomizerDefault;
Scribe_Values.Look(ref LustLimit, "LustLimit", LustLimit, true); LustLimit = LustLimitDefault;
Scribe_Values.Look(ref MinSexableFromLifestage, "MinSexableFromLifestage", MinSexableFromLifestage, true); maxSingleLustChange = MaxSingleLustChangeDefault;
Scribe_Values.Look(ref MinSexablePercent, "MinSexablePercent", MinSexablePercent, true); minSexableFromLifestage = MinSexableFromLifestageDefault;
Scribe_Values.Look(ref VirginRatio, "VirginRatio", VirginRatio, true); MinSexablePercent = MinSexablePercentDefault;
Scribe_Values.Look(ref SelectionLocked, "SelectionLocked", SelectionLocked, true); VirginRatio = VirginRatioDefault;
base.ExposeData(); }
}
}
public class RjwSexperienceMod : Mod public override void ExposeData()
{ {
private Vector2 scroll; Scribe_Values.Look(ref MaxLustDeviation, "MaxLustDeviation", MaxInitialLustDefault, true);
Scribe_Values.Look(ref AvgLust, "AvgLust", AvgLust, true);
Scribe_Values.Look(ref MaxSexCountDeviation, "MaxSexCountDeviation", MaxSexCountDeviation, true);
Scribe_Values.Look(ref LustEffectPower, "LustEffectPower", LustEffectPower, true);
Scribe_Values.Look(ref SexPerYear, "SexPerYear", SexPerYear, true);
Scribe_Values.Look(ref SlavesBeenRapedExp, "SlavesBeenRapedExp", SlavesBeenRapedExp, true);
Scribe_Values.Look(ref EnableRecordRandomizer, "EnableRecordRandomizer", EnableRecordRandomizer, true);
Scribe_Values.Look(ref LustLimit, "LustLimit", LustLimit, true);
Scribe_Values.Look(ref maxSingleLustChange, "maxSingleLustChange", MaxSingleLustChangeDefault, true);
Scribe_Values.Look(ref minSexableFromLifestage, "MinSexableFromLifestage", MinSexableFromLifestage, true);
Scribe_Values.Look(ref MinSexablePercent, "MinSexablePercent", MinSexablePercent, true);
Scribe_Values.Look(ref VirginRatio, "VirginRatio", VirginRatio, true);
Scribe_Values.Look(ref SelectionLocked, "SelectionLocked", SelectionLocked, true);
base.ExposeData();
}
public Configurations Settings { get; } public void DoSettingsWindowContents(Rect inRect)
{
const float lineHeight = 24f;
public RjwSexperienceMod(ModContentPack content) : base(content) Listing_Standard listmain = new Listing_Standard();
{ listmain.maxOneColumn = true;
Settings = GetSettings<Configurations>(); listmain.Begin(inRect);
}
public override string SettingsCategory() SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_2_Label + " x" + LustEffectPower, Keyed.Option_2_Desc, ref LustEffectPower, 0f, 2f, 0.001f);
{ SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_8_Label + " " + LustLimit, Keyed.Option_8_Desc, ref LustLimit, 0f, 5000f, 1f);
return Keyed.Mod_Title; SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_MaxSingleLustChange_Label + " " + maxSingleLustChange, Keyed.Option_MaxSingleLustChange_Desc, ref maxSingleLustChange, 0f, 10f, 0.05f);
}
public override void DoSettingsWindowContents(Rect inRect) listmain.CheckboxLabeled(Keyed.Option_1_Label, ref EnableRecordRandomizer, Keyed.Option_1_Desc);
{ if (EnableRecordRandomizer)
const float lineHeight = 24f; {
float sectionHeight = 12f;
if (!MinSexableFromLifestage) sectionHeight += 2f;
int Adjuster; Listing_Standard section = listmain.BeginSection(lineHeight * sectionHeight);
float fAdjuster;
Rect outRect = new Rect(0f, 30f, inRect.width, inRect.height - 30f);
Rect mainRect = new Rect(0f, 0f, inRect.width - 30f, inRect.height + 480f);
Listing_Standard listmain = new Listing_Standard();
listmain.maxOneColumn = true;
Widgets.BeginScrollView(outRect, ref scroll, mainRect);
listmain.Begin(mainRect);
listmain.Gap(20f);
LabelwithTextfield(listmain.GetRect(lineHeight), Keyed.Option_2_Label + " x" + Configurations.LustEffectPower, Keyed.Option_2_Desc, ref Configurations.LustEffectPower, 0f, 100f); SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_3_Label + " " + MaxLustDeviation, Keyed.Option_3_Desc, ref MaxLustDeviation, 0f, 2000f, 1f);
Adjuster = (int)(Configurations.LustEffectPower * 1000); SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_4_Label + " " + AvgLust, Keyed.Option_4_Desc, ref AvgLust, -1000f, 1000f, 1f);
Adjuster = (int)listmain.Slider(Adjuster, 0, 2000); SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_5_Label + " " + MaxSexCountDeviation, Keyed.Option_5_Desc, ref MaxSexCountDeviation, 0f, 2000f, 1f);
Configurations.LustEffectPower = (float)Adjuster / 1000; SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_6_Label + " " + SexPerYear, Keyed.Option_6_Desc, ref SexPerYear, 0f, 2000f, 1f);
fAdjuster = Configurations.LustLimit * 3; section.CheckboxLabeled(Keyed.Option_MinSexableFromLifestage_Label, ref minSexableFromLifestage, Keyed.Option_MinSexableFromLifestage_Desc);
LabelwithTextfield(listmain.GetRect(lineHeight), Keyed.Option_8_Label + " " + fAdjuster, Keyed.Option_8_Desc, ref fAdjuster, 0, 10000f);
fAdjuster = (int)listmain.Slider(fAdjuster, 0, 1000);
Configurations.LustLimit = fAdjuster / 3;
listmain.CheckboxLabeled(Keyed.Option_1_Label, ref Configurations.EnableRecordRandomizer, Keyed.Option_1_Desc); if (!MinSexableFromLifestage)
if (Configurations.EnableRecordRandomizer) SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_9_Label + " " + MinSexablePercent * 100 + "% " + ThingDefOf.Human.race.lifeExpectancy * MinSexablePercent + " human years", Keyed.Option_9_Desc, ref MinSexablePercent, 0, 1, 0.001f);
{
Listing_Standard section = listmain.BeginSection(lineHeight * 14f);
LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_3_Label + " " + Configurations.MaxLustDeviation, Keyed.Option_3_Label, ref Configurations.MaxLustDeviation, 0f, 2000f); SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_10_Label + " " + VirginRatio * 100 + "%", Keyed.Option_10_Desc, ref VirginRatio, 0, 1, 0.001f);
Adjuster = (int)Configurations.MaxLustDeviation;
Adjuster = (int)section.Slider(Adjuster, 0, 2000);
Configurations.MaxLustDeviation = Adjuster;
LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_4_Label + " " + Configurations.AvgLust, Keyed.Option_4_Desc, ref Configurations.AvgLust, -1000f, 1000f); section.CheckboxLabeled(Keyed.Option_7_Label, ref SlavesBeenRapedExp, Keyed.Option_7_Desc);
Adjuster = (int)Configurations.AvgLust;
Adjuster = (int)section.Slider(Adjuster, -1000, 1000);
Configurations.AvgLust = Adjuster;
LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_5_Label + " " + Configurations.MaxSexCountDeviation, Keyed.Option_5_Desc, ref Configurations.MaxSexCountDeviation, 0f, 2000f); listmain.EndSection(section);
Adjuster = (int)Configurations.MaxSexCountDeviation; }
Adjuster = (int)section.Slider(Adjuster, 0, 2000);
Configurations.MaxSexCountDeviation = Adjuster;
LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_6_Label + " " + Configurations.SexPerYear, Keyed.Option_6_Desc, ref Configurations.SexPerYear, 0f, 2000f); if (listmain.ButtonText("reset to default"))
Adjuster = (int)Configurations.SexPerYear; {
Adjuster = (int)section.Slider(Adjuster, 0, 2000); ResetToDefault();
Configurations.SexPerYear = Adjuster; }
listmain.End();
}
section.CheckboxLabeled(Keyed.Option_MinSexableFromLifestage_Label, ref Configurations.MinSexableFromLifestage, Keyed.Option_MinSexableFromLifestage_Desc); private void LabelwithTextfield(Rect rect, string label, string tooltip, ref float value, float min, float max)
{
Rect textfieldRect = new Rect(rect.xMax - 100f, rect.y, 100f, rect.height);
string valuestr = value.ToString();
Widgets.Label(rect, label);
Widgets.TextFieldNumeric(textfieldRect, ref value, ref valuestr, min, max);
Widgets.DrawHighlightIfMouseover(rect);
TooltipHandler.TipRegion(rect, tooltip);
}
if (!Configurations.MinSexableFromLifestage) private void SliderOption(Rect doublerect, string label, string tooltip, ref float value, float min, float max, float roundTo = -1f)
SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_9_Label + " " + Configurations.MinSexablePercent*100 + "% " + ThingDefOf.Human.race.lifeExpectancy * Configurations.MinSexablePercent + "years", Keyed.Option_9_Desc, ref Configurations.MinSexablePercent, 0, 1, 1000f); {
LabelwithTextfield(doublerect.TopHalf(), label, tooltip, ref value, min, max);
value = Widgets.HorizontalSlider(doublerect.BottomHalf(), value, min, max, roundTo: roundTo);
}
}
SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_10_Label + " " + Configurations.VirginRatio*100 + "%" , Keyed.Option_10_Desc, ref Configurations.VirginRatio, 0, 1, 1000f); public class SexperienceMod : Mod
{
private static Configurations settings;
public static Configurations Settings { get => settings; }
section.CheckboxLabeled(Keyed.Option_7_Label, ref Configurations.SlavesBeenRapedExp, Keyed.Option_7_Desc); public SexperienceMod(ModContentPack content) : base(content)
{
settings = GetSettings<Configurations>();
}
listmain.EndSection(section); public override string SettingsCategory()
} {
return Keyed.Mod_Title;
}
if (listmain.ButtonText("reset to default")) public override void DoSettingsWindowContents(Rect inRect) => Settings.DoSettingsWindowContents(inRect);
{ }
Settings.ResetToDefault();
}
listmain.End();
Widgets.EndScrollView();
}
public void LabelwithTextfield(Rect rect, string label, string tooltip, ref float value, float min, float max)
{
Rect textfieldRect = new Rect(rect.xMax - 100f, rect.y, 100f, rect.height);
string valuestr = value.ToString();
Widgets.Label(rect, label);
Widgets.TextFieldNumeric(textfieldRect,ref value, ref valuestr, min, max);
Widgets.DrawHighlightIfMouseover(rect);
TooltipHandler.TipRegion(rect, tooltip);
}
public void SliderOption(Rect doublerect, string label, string tooltip, ref float value, float min, float max, float division)
{
int Adjuster;
LabelwithTextfield(doublerect.TopHalf(), label, tooltip, ref value, min, max);
Adjuster = (int)(value.Normalization(min,max)*division);
Adjuster = (int)Widgets.HorizontalSlider(doublerect.BottomHalf(), Adjuster, 0, division);
value = (Adjuster / division).Denormalization(min,max);
}
}
} }

View file

@ -85,6 +85,8 @@ namespace RJWSexperience
public static readonly string Option_10_Desc = "RSOption_10_Desc".Translate(); public static readonly string Option_10_Desc = "RSOption_10_Desc".Translate();
public static readonly string Option_MinSexableFromLifestage_Label = "RSOption_MinSexableFromLifestage_Label".Translate(); public static readonly string Option_MinSexableFromLifestage_Label = "RSOption_MinSexableFromLifestage_Label".Translate();
public static readonly string Option_MinSexableFromLifestage_Desc = "RSOption_MinSexableFromLifestage_Desc".Translate(); public static readonly string Option_MinSexableFromLifestage_Desc = "RSOption_MinSexableFromLifestage_Desc".Translate();
public static readonly string Option_MaxSingleLustChange_Label = "RSOption_MaxSingleLustChange_Label".Translate();
public static readonly string Option_MaxSingleLustChange_Desc = "RSOption_MaxSingleLustChange_Desc".Translate();
public static string Translate(this PartnerOrderMode mode) public static string Translate(this PartnerOrderMode mode)
{ {

View file

@ -86,17 +86,17 @@ namespace RJWSexperience
lustDelta = satisfaction - base_sat_per_fuck; lustDelta = satisfaction - base_sat_per_fuck;
if (Mathf.Sign(lustDelta) == Mathf.Sign((float)lust)) // Only if getting closer to the limit if (Mathf.Sign(lustDelta) == Mathf.Sign((float)lust)) // Only if getting closer to the limit
lustDelta *= LustIncrementFactor((float)lust); lustDelta *= LustIncrementFactor((float)lust);
lustDelta = Mathf.Clamp(lustDelta, -0.5f, 0.5f); // If the sex is satisfactory, lust grows up. Declines at the opposite. lustDelta = Mathf.Clamp(lustDelta, -SexperienceMod.Settings.MaxSingleLustChange, SexperienceMod.Settings.MaxSingleLustChange); // If the sex is satisfactory, lust grows up. Declines at the opposite.
} }
else else
{ {
lustDelta = Mathf.Clamp(satisfaction * satisfaction * LustIncrementFactor((float)lust), 0, 0.5f); // Masturbation always increases lust. lustDelta = Mathf.Clamp(satisfaction * satisfaction * LustIncrementFactor((float)lust), 0, SexperienceMod.Settings.MaxSingleLustChange); // Masturbation always increases lust.
} }
if (lustDelta == 0) if (lustDelta == 0)
return; return;
rjw.Modules.Shared.Logs.LogManager.GetLogger<RjwSexperienceMod>().Message($"{props.pawn.NameShortColored}'s lust changed by {lustDelta} (from {lust})"); rjw.Modules.Shared.Logs.LogManager.GetLogger<SexperienceMod>().Message($"{props.pawn.NameShortColored}'s lust changed by {lustDelta} (from {lust})");
props.pawn.records.AddTo(VariousDefOf.Lust, lustDelta); props.pawn.records.AddTo(VariousDefOf.Lust, lustDelta);
} }

View file

@ -22,7 +22,7 @@ namespace RJWSexperience
int sexableage = 0; int sexableage = 0;
int minsexage = 0; int minsexage = 0;
if (Configurations.MinSexableFromLifestage) if (SexperienceMod.Settings.MinSexableFromLifestage)
minsexage = (int)pawn.RaceProps.lifeStageAges.Find(x => x.def.reproductive).minAge; minsexage = (int)pawn.RaceProps.lifeStageAges.Find(x => x.def.reproductive).minAge;
else else
minsexage = (int)(pawn.RaceProps.lifeExpectancy * Configurations.MinSexablePercent); minsexage = (int)(pawn.RaceProps.lifeExpectancy * Configurations.MinSexablePercent);