mirror of
				https://github.com/amevarashi/RJW-Sexperience.git
				synced 2024-08-14 23:54:08 +00:00 
			
		
		
		
	MaxSingleLustChange option and settings window refactor
This commit is contained in:
		
							parent
							
								
									43053d4296
								
							
						
					
					
						commit
						2bf95036d3
					
				
					 5 changed files with 129 additions and 145 deletions
				
			
		| 
						 | 
				
			
			@ -81,6 +81,8 @@
 | 
			
		|||
  <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_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>
 | 
			
		||||
  <Anal>Anal</Anal>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,18 +6,22 @@ namespace RJWSexperience
 | 
			
		|||
{
 | 
			
		||||
	public class Configurations : ModSettings
 | 
			
		||||
	{
 | 
			
		||||
        public const float MaxInitialLustDefault = 500;
 | 
			
		||||
        public const float AvgLustDefault = 0;
 | 
			
		||||
        public const float MaxSexCountDeviationDefault = 90;
 | 
			
		||||
		public const float MaxInitialLustDefault = 400f;
 | 
			
		||||
		public const float AvgLustDefault = 0f;
 | 
			
		||||
		public const float MaxSexCountDeviationDefault = 90f;
 | 
			
		||||
		public const float LustEffectPowerDefault = 0.5f;
 | 
			
		||||
        public const float SexPerYearDefault = 30;
 | 
			
		||||
		public const float SexPerYearDefault = 30f;
 | 
			
		||||
		public const bool SlavesBeenRapedExpDefault = true;
 | 
			
		||||
		public const bool EnableStatRandomizerDefault = true;
 | 
			
		||||
        public const float LustLimitDefault = 500f/3f;
 | 
			
		||||
		public const float LustLimitDefault = MaxInitialLustDefault / 3f;
 | 
			
		||||
		public const float MaxSingleLustChangeDefault = 0.5f;
 | 
			
		||||
		public const bool MinSexableFromLifestageDefault = true;
 | 
			
		||||
		public const float MinSexablePercentDefault = 0.2f;
 | 
			
		||||
		public const float VirginRatioDefault = 0.01f;
 | 
			
		||||
 | 
			
		||||
		private float maxSingleLustChange = MaxSingleLustChangeDefault;
 | 
			
		||||
		private bool minSexableFromLifestage = MinSexableFromLifestageDefault;
 | 
			
		||||
 | 
			
		||||
		public static float MaxLustDeviation = MaxInitialLustDefault;
 | 
			
		||||
		public static float AvgLust = AvgLustDefault;
 | 
			
		||||
		public static float MaxSexCountDeviation = MaxSexCountDeviationDefault;
 | 
			
		||||
| 
						 | 
				
			
			@ -26,9 +30,10 @@ namespace RJWSexperience
 | 
			
		|||
		public static bool SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
 | 
			
		||||
		public static bool EnableRecordRandomizer = EnableStatRandomizerDefault;
 | 
			
		||||
		public static float LustLimit = LustLimitDefault;
 | 
			
		||||
        public static bool MinSexableFromLifestage = MinSexableFromLifestageDefault;
 | 
			
		||||
		public bool MinSexableFromLifestage { get => minSexableFromLifestage; }
 | 
			
		||||
		public static float MinSexablePercent = MinSexablePercentDefault;
 | 
			
		||||
		public static float VirginRatio = VirginRatioDefault;
 | 
			
		||||
		public float MaxSingleLustChange { get => maxSingleLustChange; }
 | 
			
		||||
 | 
			
		||||
		public static bool SelectionLocked = false;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +47,8 @@ namespace RJWSexperience
 | 
			
		|||
			SlavesBeenRapedExp = SlavesBeenRapedExpDefault;
 | 
			
		||||
			EnableRecordRandomizer = EnableStatRandomizerDefault;
 | 
			
		||||
			LustLimit = LustLimitDefault;
 | 
			
		||||
            MinSexableFromLifestage = MinSexableFromLifestageDefault;
 | 
			
		||||
			maxSingleLustChange = MaxSingleLustChangeDefault;
 | 
			
		||||
			minSexableFromLifestage = MinSexableFromLifestageDefault;
 | 
			
		||||
			MinSexablePercent = MinSexablePercentDefault;
 | 
			
		||||
			VirginRatio = VirginRatioDefault;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -57,100 +63,59 @@ namespace RJWSexperience
 | 
			
		|||
			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 MinSexableFromLifestage, "MinSexableFromLifestage", MinSexableFromLifestage, 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 class RjwSexperienceMod : Mod
 | 
			
		||||
    {
 | 
			
		||||
        private Vector2 scroll;
 | 
			
		||||
 | 
			
		||||
		public Configurations Settings { get; }
 | 
			
		||||
 | 
			
		||||
		public RjwSexperienceMod(ModContentPack content) : base(content)
 | 
			
		||||
        {
 | 
			
		||||
			Settings = GetSettings<Configurations>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override string SettingsCategory()
 | 
			
		||||
        {
 | 
			
		||||
            return Keyed.Mod_Title;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void DoSettingsWindowContents(Rect inRect)
 | 
			
		||||
		public void DoSettingsWindowContents(Rect inRect)
 | 
			
		||||
		{
 | 
			
		||||
			const float lineHeight = 24f;
 | 
			
		||||
 | 
			
		||||
            int Adjuster;
 | 
			
		||||
            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);
 | 
			
		||||
			listmain.Begin(inRect);
 | 
			
		||||
 | 
			
		||||
            LabelwithTextfield(listmain.GetRect(lineHeight), Keyed.Option_2_Label + " x" + Configurations.LustEffectPower, Keyed.Option_2_Desc, ref Configurations.LustEffectPower, 0f, 100f);
 | 
			
		||||
            Adjuster = (int)(Configurations.LustEffectPower * 1000);
 | 
			
		||||
            Adjuster = (int)listmain.Slider(Adjuster, 0, 2000);
 | 
			
		||||
            Configurations.LustEffectPower = (float)Adjuster / 1000;
 | 
			
		||||
			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);
 | 
			
		||||
			SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_MaxSingleLustChange_Label + " " + maxSingleLustChange, Keyed.Option_MaxSingleLustChange_Desc, ref maxSingleLustChange, 0f, 10f, 0.05f);
 | 
			
		||||
 | 
			
		||||
            fAdjuster = Configurations.LustLimit * 3;
 | 
			
		||||
            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 (Configurations.EnableRecordRandomizer)
 | 
			
		||||
			listmain.CheckboxLabeled(Keyed.Option_1_Label, ref EnableRecordRandomizer, Keyed.Option_1_Desc);
 | 
			
		||||
			if (EnableRecordRandomizer)
 | 
			
		||||
			{
 | 
			
		||||
                Listing_Standard section = listmain.BeginSection(lineHeight * 14f);
 | 
			
		||||
				float sectionHeight = 12f;
 | 
			
		||||
				if (!MinSexableFromLifestage) sectionHeight += 2f;
 | 
			
		||||
 | 
			
		||||
                LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_3_Label + " " + Configurations.MaxLustDeviation, Keyed.Option_3_Label, ref Configurations.MaxLustDeviation, 0f, 2000f);
 | 
			
		||||
                Adjuster = (int)Configurations.MaxLustDeviation;
 | 
			
		||||
                Adjuster = (int)section.Slider(Adjuster, 0, 2000);
 | 
			
		||||
                Configurations.MaxLustDeviation = Adjuster;
 | 
			
		||||
				Listing_Standard section = listmain.BeginSection(lineHeight * sectionHeight);
 | 
			
		||||
 | 
			
		||||
                LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_4_Label + " " + Configurations.AvgLust, Keyed.Option_4_Desc, ref Configurations.AvgLust, -1000f, 1000f);
 | 
			
		||||
                Adjuster = (int)Configurations.AvgLust;
 | 
			
		||||
                Adjuster = (int)section.Slider(Adjuster, -1000, 1000);
 | 
			
		||||
                Configurations.AvgLust = Adjuster;
 | 
			
		||||
				SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_3_Label + " " + MaxLustDeviation, Keyed.Option_3_Desc, ref MaxLustDeviation, 0f, 2000f, 1f);
 | 
			
		||||
				SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_4_Label + " " + AvgLust, Keyed.Option_4_Desc, ref AvgLust, -1000f, 1000f, 1f);
 | 
			
		||||
				SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_5_Label + " " + MaxSexCountDeviation, Keyed.Option_5_Desc, ref MaxSexCountDeviation, 0f, 2000f, 1f);
 | 
			
		||||
				SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_6_Label + " " + SexPerYear, Keyed.Option_6_Desc, ref SexPerYear, 0f, 2000f, 1f);
 | 
			
		||||
 | 
			
		||||
                LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_5_Label + " " + Configurations.MaxSexCountDeviation, Keyed.Option_5_Desc, ref Configurations.MaxSexCountDeviation, 0f, 2000f);
 | 
			
		||||
                Adjuster = (int)Configurations.MaxSexCountDeviation;
 | 
			
		||||
                Adjuster = (int)section.Slider(Adjuster, 0, 2000);
 | 
			
		||||
                Configurations.MaxSexCountDeviation = Adjuster;
 | 
			
		||||
				section.CheckboxLabeled(Keyed.Option_MinSexableFromLifestage_Label, ref minSexableFromLifestage, Keyed.Option_MinSexableFromLifestage_Desc);
 | 
			
		||||
 | 
			
		||||
                LabelwithTextfield(section.GetRect(lineHeight), Keyed.Option_6_Label + " " + Configurations.SexPerYear, Keyed.Option_6_Desc, ref Configurations.SexPerYear, 0f, 2000f);
 | 
			
		||||
                Adjuster = (int)Configurations.SexPerYear;
 | 
			
		||||
                Adjuster = (int)section.Slider(Adjuster, 0, 2000);
 | 
			
		||||
                Configurations.SexPerYear = Adjuster;
 | 
			
		||||
				if (!MinSexableFromLifestage)
 | 
			
		||||
					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);
 | 
			
		||||
 | 
			
		||||
                section.CheckboxLabeled(Keyed.Option_MinSexableFromLifestage_Label, ref Configurations.MinSexableFromLifestage, Keyed.Option_MinSexableFromLifestage_Desc);
 | 
			
		||||
				SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_10_Label + " " + VirginRatio * 100 + "%", Keyed.Option_10_Desc, ref VirginRatio, 0, 1, 0.001f);
 | 
			
		||||
 | 
			
		||||
                if (!Configurations.MinSexableFromLifestage)
 | 
			
		||||
                    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);
 | 
			
		||||
 | 
			
		||||
                SliderOption(section.GetRect(lineHeight * 2f), Keyed.Option_10_Label + " " + Configurations.VirginRatio*100 + "%" , Keyed.Option_10_Desc, ref Configurations.VirginRatio, 0, 1, 1000f);
 | 
			
		||||
 | 
			
		||||
                section.CheckboxLabeled(Keyed.Option_7_Label, ref Configurations.SlavesBeenRapedExp, Keyed.Option_7_Desc);
 | 
			
		||||
				section.CheckboxLabeled(Keyed.Option_7_Label, ref SlavesBeenRapedExp, Keyed.Option_7_Desc);
 | 
			
		||||
 | 
			
		||||
				listmain.EndSection(section);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (listmain.ButtonText("reset to default"))
 | 
			
		||||
			{
 | 
			
		||||
                Settings.ResetToDefault();
 | 
			
		||||
				ResetToDefault();
 | 
			
		||||
			}
 | 
			
		||||
			listmain.End();
 | 
			
		||||
            Widgets.EndScrollView();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        public void LabelwithTextfield(Rect rect, string label, string tooltip, ref float value, float min, float max)
 | 
			
		||||
		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();
 | 
			
		||||
| 
						 | 
				
			
			@ -160,13 +125,28 @@ namespace RJWSexperience
 | 
			
		|||
			TooltipHandler.TipRegion(rect, tooltip);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        public void SliderOption(Rect doublerect, string label, string tooltip, ref float value, float min, float max, float division)
 | 
			
		||||
		private void SliderOption(Rect doublerect, string label, string tooltip, ref float value, float min, float max, float roundTo = -1f)
 | 
			
		||||
		{
 | 
			
		||||
            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);
 | 
			
		||||
			value = Widgets.HorizontalSlider(doublerect.BottomHalf(), value, min, max, roundTo: roundTo);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public class SexperienceMod : Mod
 | 
			
		||||
	{
 | 
			
		||||
		private static Configurations settings;
 | 
			
		||||
		public static Configurations Settings { get => settings; }
 | 
			
		||||
 | 
			
		||||
		public SexperienceMod(ModContentPack content) : base(content)
 | 
			
		||||
		{
 | 
			
		||||
			settings = GetSettings<Configurations>();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override string SettingsCategory()
 | 
			
		||||
		{
 | 
			
		||||
			return Keyed.Mod_Title;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void DoSettingsWindowContents(Rect inRect) => Settings.DoSettingsWindowContents(inRect);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,6 +85,8 @@ namespace RJWSexperience
 | 
			
		|||
		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_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)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,17 +86,17 @@ namespace RJWSexperience
 | 
			
		|||
				lustDelta = satisfaction - base_sat_per_fuck;
 | 
			
		||||
				if (Mathf.Sign(lustDelta) == Mathf.Sign((float)lust)) // Only if getting closer to the limit
 | 
			
		||||
					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
 | 
			
		||||
			{
 | 
			
		||||
				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)
 | 
			
		||||
				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);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ namespace RJWSexperience
 | 
			
		|||
 | 
			
		||||
				int sexableage = 0;
 | 
			
		||||
				int minsexage = 0;
 | 
			
		||||
				if (Configurations.MinSexableFromLifestage)
 | 
			
		||||
				if (SexperienceMod.Settings.MinSexableFromLifestage)
 | 
			
		||||
					minsexage = (int)pawn.RaceProps.lifeStageAges.Find(x => x.def.reproductive).minAge;
 | 
			
		||||
				else
 | 
			
		||||
					minsexage = (int)(pawn.RaceProps.lifeExpectancy * Configurations.MinSexablePercent);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue