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,57 @@
using UnityEngine;
using Verse;
namespace RJWSexperience.SexHistory
{
[StaticConstructorOnStartup]
public static class HistoryUtility
{
public static readonly Texture2D HistoryIcon = ContentFinder<Texture2D>.Get("UI/buttons/OpenStatsReport");
public static readonly Texture2D UnknownPawn = ContentFinder<Texture2D>.Get("UI/Icon/UnknownPawn");
public static readonly Texture2D FirstOverlay = ContentFinder<Texture2D>.Get("UI/Icon/FirstBG");
public static readonly Texture2D Heart = ContentFinder<Texture2D>.Get("Things/Mote/Heart");
public static readonly Texture2D Incest = ContentFinder<Texture2D>.Get("UI/Icon/Incest");
public static readonly Texture2D Locked = ContentFinder<Texture2D>.Get("UI/Icon/RSLocked");
public static readonly Texture2D Unlocked = ContentFinder<Texture2D>.Get("UI/Icon/RSUnlocked");
public static readonly Texture2D Slaanesh = SolidColorMaterials.NewSolidColorTexture(0.686f, 0.062f, 0.698f, 1.0f);
public static readonly Texture2D Khorne = SolidColorMaterials.NewSolidColorTexture(0.415f, 0.0f, 0.003f, 1.0f);
public static readonly Texture2D Tzeentch = SolidColorMaterials.NewSolidColorTexture(0.082f, 0.453f, 0.6f, 1.0f);
public static readonly Texture2D Nurgle = SolidColorMaterials.NewSolidColorTexture(0.6f, 0.83f, 0.35f, 1.0f);
public static readonly Texture2D Partners = SolidColorMaterials.NewSolidColorTexture(0.843f, 0.474f, 0.6f, 1.0f);
public static readonly Texture2D TotalSex = SolidColorMaterials.NewSolidColorTexture(0.878f, 0.674f, 0.411f, 1.0f);
public static readonly Texture2D Satisfaction = SolidColorMaterials.NewSolidColorTexture(0.325f, 0.815f, 0.729f, 1.0f);
public static readonly Color HistoryColor = new Color(0.9f, 0.5f, 0.5f);
public static readonly Texture2D[] SextypeColor = new Texture2D[]
{
Texture2D.linearGrayTexture, //None = 0,
SolidColorMaterials.NewSolidColorTexture(0.900f, 0.500f, 0.500f, 1.0f), //Vaginal = 1, Light Salmon Pink
SolidColorMaterials.NewSolidColorTexture(0.529f, 0.313f, 0.113f, 1.0f), //Anal = 2, Brown
SolidColorMaterials.NewSolidColorTexture(0.529f, 0.113f, 0.305f, 1.0f), //Oral = 3, Purple
SolidColorMaterials.NewSolidColorTexture(0.000f, 0.819f, 0.219f, 1.0f), //Masturbation = 4, Slightly Dark Green
SolidColorMaterials.NewSolidColorTexture(0.000f, 0.560f, 0.090f, 1.0f), //DoublePenetration = 5, Dark Green
SolidColorMaterials.NewSolidColorTexture(0.839f, 0.850f, 0.505f, 1.0f), //Boobjob = 6,
SolidColorMaterials.NewSolidColorTexture(0.858f, 0.886f, 0.113f, 1.0f), //Handjob = 7,
SolidColorMaterials.NewSolidColorTexture(0.752f, 0.780f, 0.000f, 1.0f), //Footjob = 8,
SolidColorMaterials.NewSolidColorTexture(0.484f, 0.500f, 0.241f, 1.0f), //Fingering = 9,
SolidColorMaterials.NewSolidColorTexture(0.000f, 0.500f, 0.080f, 1.0f), //Scissoring = 10, Dark Green
SolidColorMaterials.NewSolidColorTexture(0.588f, 0.576f, 0.431f, 1.0f), //MutualMasturbation = 11,
SolidColorMaterials.NewSolidColorTexture(0.741f, 0.000f, 0.682f, 1.0f), //Fisting = 12,
SolidColorMaterials.NewSolidColorTexture(0.121f, 0.929f, 1.000f, 1.0f), //MechImplant = 13,
SolidColorMaterials.NewSolidColorTexture(0.478f, 0.274f, 0.160f, 1.0f), //Rimming = 14,
SolidColorMaterials.NewSolidColorTexture(0.819f, 0.301f, 0.552f, 1.0f), //Fellatio = 15,
SolidColorMaterials.NewSolidColorTexture(0.819f, 0.301f, 0.552f, 1.0f), //Cunnilingus = 16,
SolidColorMaterials.NewSolidColorTexture(0.529f, 0.113f, 0.305f, 1.0f), //Sixtynine = 17
Texture2D.linearGrayTexture, //? = 18
Texture2D.linearGrayTexture, //? = 19
Texture2D.linearGrayTexture //? = 20
};
public static readonly Texture2D[] PassionBG = new Texture2D[]
{
Texture2D.blackTexture, //None = 0,
SolidColorMaterials.NewSolidColorTexture(0.800f, 0.800f, 0.800f, 1.0f), //Minor = 1,
SolidColorMaterials.NewSolidColorTexture(1.000f, 0.875f, 0.000f, 1.0f) //Major = 2,
};
}
}

View file

@ -0,0 +1,247 @@
using rjw;
using System;
using Verse;
using RimWorld;
using UnityEngine;
using RJWSexperience.Logs;
namespace RJWSexperience.SexHistory
{
public static class RecordRandomizer
{
private static readonly rjw.Modules.Shared.Logs.ILog log = LogManager.GetLogger<DebugLogProvider>("RecordRandomizer");
private static Settings.SettingsTabHistory Settings => SexperienceMod.Settings.History;
public static bool Randomize(Pawn pawn)
{
log.Message($"Randomize request for {pawn.NameShortColored}");
int avgsex = -500;
bool isvirgin = Rand.Chance(Settings.VirginRatio);
int totalsex = 0;
int totalbirth = 0;
if (isvirgin)
log.Message("Rand.Chance rolled virgin");
if (pawn.story != null)
{
int sexableage = 0;
int minsexage = 0;
if (Settings.MinSexableFromLifestage)
{
LifeStageAge lifeStageAges = pawn.RaceProps.lifeStageAges.Find(x => x.def.reproductive);
if (lifeStageAges == null)
{
log.Message($"No reproductive life stage! {pawn.NameShortColored}'s randomization cancelled");
return false;
}
minsexage = (int)lifeStageAges.minAge;
}
else
{
minsexage = (int)(pawn.RaceProps.lifeExpectancy * Settings.MinSexablePercent);
}
log.Message($"Min sex age is {minsexage}");
float lust = RandomizeLust(pawn);
log.Message($"Lust set to {lust}");
if (pawn.ageTracker.AgeBiologicalYears > minsexage)
{
sexableage = pawn.ageTracker.AgeBiologicalYears - minsexage;
avgsex = (int)(sexableage * Settings.SexPerYear * LustUtility.GetLustFactor(lust));
}
log.Message($"Generating {sexableage} years of sex life");
log.Message($"Average sex/year: {avgsex}");
if (pawn.relations != null && pawn.gender == Gender.Female)
{
totalbirth += pawn.relations.ChildrenCount;
totalsex += totalbirth;
pawn.records?.AddTo(xxx.CountOfSexWithHumanlikes, totalbirth);
pawn.records?.SetTo(xxx.CountOfBirthHuman, totalbirth);
if (totalbirth > 0) isvirgin = false;
}
if (!isvirgin)
{
totalsex += GeneratePartnerTypeRecords(pawn, avgsex);
if (Settings.SlavesBeenRapedExp && pawn.IsSlave)
{
totalsex += RandomizeRecord(pawn, xxx.CountOfBeenRapedByAnimals, Rand.Range(-50, 10), Rand.Range(0, 10) * sexableage);
totalsex += RandomizeRecord(pawn, xxx.CountOfBeenRapedByHumanlikes, 0, Rand.Range(0, 100) * sexableage);
}
}
}
pawn.records?.SetTo(xxx.CountOfSex, totalsex);
log.Message($"Splitting {totalsex} sex acts between sex types");
GenerateSextypeRecords(pawn, totalsex);
log.Message($"{pawn.NameShortColored} randomized");
return true;
}
public static float RandomizeLust(Pawn pawn)
{
float value = Utility.RandGaussianLike(Settings.AvgLust - Settings.MaxLustDeviation, Settings.AvgLust + Settings.MaxLustDeviation);
float minValue;
if (xxx.is_nympho(pawn))
minValue = 0;
else
minValue = float.MinValue;
value = Mathf.Clamp(value, minValue, float.MaxValue);
float recordvalue = pawn.records.GetValue(VariousDefOf.Lust);
pawn.records.AddTo(VariousDefOf.Lust, value - recordvalue);
return value;
}
private static int RandomizeRecord(Pawn pawn, RecordDef record, int avg, int dist, int min = 0, int max = int.MaxValue)
{
int value = (int)Mathf.Clamp(Utility.RandGaussianLike(avg - dist, avg + dist), min, max);
int recordvalue = pawn.records.GetAsInt(record);
pawn.records.AddTo(record, value - recordvalue);
return value;
}
private static int GeneratePartnerTypeRecords(Pawn pawn, int avgsex)
{
int deviation = (int)Settings.MaxSexCountDeviation;
int totalSexCount = 0;
if (xxx.is_rapist(pawn))
{
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalSexCount += RandomizeRecord(pawn, xxx.CountOfRapedInsects, avgsex, deviation);
else totalSexCount += RandomizeRecord(pawn, xxx.CountOfRapedAnimals, avgsex, deviation);
}
else
{
totalSexCount += RandomizeRecord(pawn, xxx.CountOfRapedHumanlikes, avgsex, deviation);
}
avgsex /= 8;
}
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalSexCount += RandomizeRecord(pawn, xxx.CountOfRapedInsects, avgsex, deviation);
else totalSexCount += RandomizeRecord(pawn, xxx.CountOfSexWithAnimals, avgsex, deviation);
avgsex /= 10;
}
else if (xxx.is_necrophiliac(pawn))
{
totalSexCount += RandomizeRecord(pawn, xxx.CountOfSexWithCorpse, avgsex, deviation);
avgsex /= 4;
}
totalSexCount += RandomizeRecord(pawn, xxx.CountOfSexWithHumanlikes, avgsex, deviation);
if (totalSexCount > 0)
pawn.records.AddTo(VariousDefOf.SexPartnerCount, Math.Max(1, Rand.Range(0, totalSexCount / 7)));
return totalSexCount;
}
private static void GenerateSextypeRecords(Pawn pawn, int totalsex)
{
float totalweight =
RJWPreferenceSettings.vaginal +
RJWPreferenceSettings.anal +
RJWPreferenceSettings.fellatio +
RJWPreferenceSettings.cunnilingus +
RJWPreferenceSettings.rimming +
RJWPreferenceSettings.double_penetration +
RJWPreferenceSettings.breastjob +
RJWPreferenceSettings.handjob +
RJWPreferenceSettings.mutual_masturbation +
RJWPreferenceSettings.fingering +
RJWPreferenceSettings.footjob +
RJWPreferenceSettings.scissoring +
RJWPreferenceSettings.fisting +
RJWPreferenceSettings.sixtynine;
Gender prefer = PreferredGender(pawn);
int sex = (int)(totalsex * RJWPreferenceSettings.vaginal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.anal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fellatio / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, sex);
else pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.cunnilingus / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.rimming / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.double_penetration / totalweight) / 2;
totalsex -= sex;
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.breastjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.handjob / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fingering / totalweight);
totalsex -= sex;
if (prefer == Gender.Female) pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.mutual_masturbation / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.footjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.FootjobCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.scissoring / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fisting / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
pawn.records.AddTo(VariousDefOf.OralSexCount, totalsex);
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, totalsex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, totalsex);
}
private static Gender PreferredGender(Pawn pawn)
{
if (xxx.is_homosexual(pawn))
return pawn.gender;
if (pawn.gender == Gender.Male)
return Gender.Female;
else
return Gender.Male;
}
}
}

View file

@ -0,0 +1,444 @@
using rjw;
using RJWSexperience.ExtensionMethods;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace RJWSexperience.SexHistory
{
public class SexHistoryComp : ThingComp
{
public const int ARRLEN = 20;
protected Dictionary<string, SexPartnerHistoryRecord> histories = new Dictionary<string, SexPartnerHistoryRecord>();
protected string first = "";
protected bool dirty = true;
protected xxx.rjwSextype recentSex = xxx.rjwSextype.None;
protected float recentSat = 0;
protected string recentPartner = "";
protected int[] sextypeCount = new int[ARRLEN];
protected float[] sextypeSat = new float[ARRLEN];
protected int[] sextypeRecentTickAbs = new int[ARRLEN];
protected int virginsTaken = 0;
protected int incestuous = 0;
protected int bestiality = 0;
protected int corpsefuck = 0;
protected int interspecies = 0;
protected int firstSexTickAbs = 0;
protected string mostPartnerCache = "";
protected xxx.rjwSextype mostSextypeCache = xxx.rjwSextype.None;
protected xxx.rjwSextype mostSatSextypeCache = xxx.rjwSextype.None;
protected xxx.rjwSextype bestSextypeCache = xxx.rjwSextype.None;
protected float bestSextypeSatCache = 0;
protected string bestPartnerCache = "";
protected int totalSexCache = 0;
protected int totalRapedCache = 0;
protected int totalBeenRapedCache = 0;
protected ThingDef preferRaceCache = null;
protected int preferRaceSexCountCache = 0;
protected Pawn preferRacePawnCache = null;
protected int recentSexTickAbsCache = 0;
protected int mostSexTickAbsCache = 0;
protected int bestSexTickAbsCache = 0;
public Gizmo Gizmo { get; private set; }
public SexPartnerHistoryRecord GetFirstPartnerHistory => histories.TryGetValue(first);
public SexPartnerHistoryRecord GetMostPartnerHistory
{
get
{
Update();
return histories.TryGetValue(mostPartnerCache);
}
}
public xxx.rjwSextype MostSextype
{
get
{
Update();
return mostSextypeCache;
}
}
public xxx.rjwSextype MostSatisfiedSex
{
get
{
Update();
return mostSatSextypeCache;
}
}
public SexPartnerHistoryRecord GetRecentPartnersHistory => histories.TryGetValue(recentPartner);
public SexPartnerHistoryRecord GetBestSexPartnerHistory
{
get
{
Update();
return histories.TryGetValue(bestPartnerCache);
}
}
public float TotalSexHad
{
get
{
Update();
return totalSexCache;
}
}
public int VirginsTaken => virginsTaken;
public List<SexPartnerHistoryRecord> PartnerList
{
get
{
List<SexPartnerHistoryRecord> res = null;
Update();
if (!histories.NullOrEmpty())
{
res = histories.Values.ToList();
}
return res;
}
}
public int PartnerCount
{
get
{
if (histories == null) histories = new Dictionary<string, SexPartnerHistoryRecord>();
return histories.Count;
}
}
public int IncestuousCount => incestuous;
public int RapedCount
{
get
{
Update();
return totalRapedCache;
}
}
public int BeenRapedCount
{
get
{
Update();
return totalBeenRapedCache;
}
}
public ThingDef PreferRace
{
get
{
Update();
return preferRaceCache;
}
}
public int PreferRaceSexCount
{
get
{
Update();
return preferRaceSexCountCache;
}
}
public int BestialityCount => bestiality;
public int CorpseFuckCount => corpsefuck;
public int InterspeciesCount => interspecies;
public float AVGSat
{
get
{
Update();
if (totalSexCache == 0) return 0;
return sextypeSat.Sum() / totalSexCache;
}
}
public int RecentSexTickAbs => recentSexTickAbsCache;
public int FirstSexTickAbs => firstSexTickAbs;
public int MostSexTickAbs => mostSexTickAbsCache;
public int BestSexTickAbs => bestSexTickAbsCache;
public Pawn PreferRacePawn
{
get
{
Update();
return preferRacePawnCache;
}
}
public float GetBestSextype(out xxx.rjwSextype sextype)
{
Update();
sextype = bestSextypeCache;
return bestSextypeSatCache;
}
public float GetRecentSextype(out xxx.rjwSextype sextype)
{
Update();
sextype = recentSex;
return recentSat;
}
public int GetSextypeRecentTickAbs(int sextype) => sextypeRecentTickAbs[sextype];
public float GetAVGSat(int index)
{
float res = sextypeSat[index] / sextypeCount[index];
return float.IsNaN(res) ? 0f : res;
}
public int GetSexCount(int sextype) => sextypeCount[sextype];
public override void PostExposeData()
{
List<int> sextypecountsave;
List<float> sextypesatsave;
List<int> sextyperecenttickabssave;
if (Scribe.mode == LoadSaveMode.Saving)
{
sextypecountsave = sextypeCount.ToList();
sextypesatsave = sextypeSat.ToList();
sextyperecenttickabssave = sextypeRecentTickAbs.ToList();
}
else
{
sextypecountsave = new List<int>();
sextypesatsave = new List<float>();
sextyperecenttickabssave = new List<int>();
}
Scribe_Collections.Look(ref histories, "histories", LookMode.Value, LookMode.Deep);
Scribe_Values.Look(ref first, "first", string.Empty);
Scribe_Values.Look(ref recentSex, "recentsex", xxx.rjwSextype.None);
Scribe_Values.Look(ref recentSat, "recentsat", 0);
Scribe_Values.Look(ref recentPartner, "recentpartner", string.Empty);
Scribe_Values.Look(ref virginsTaken, "virginstaken", 0);
Scribe_Values.Look(ref incestuous, "incestous", 0);
Scribe_Values.Look(ref bestiality, "bestiality", 0);
Scribe_Values.Look(ref corpsefuck, "corpsefuck", 0);
Scribe_Values.Look(ref interspecies, "interspecies", 0);
Scribe_Values.Look(ref firstSexTickAbs, "firstsextickabs", 0);
Scribe_Collections.Look(ref sextypecountsave, "sextypecountsave", LookMode.Value);
Scribe_Collections.Look(ref sextypesatsave, "sextypesatsave", LookMode.Value);
Scribe_Collections.Look(ref sextyperecenttickabssave, "sextyperecenttickabssave", LookMode.Value);
if (histories == null)
histories = new Dictionary<string, SexPartnerHistoryRecord>();
if (Scribe.mode == LoadSaveMode.LoadingVars)
{
sextypeCount = sextypecountsave?.ToArray() ?? new int[ARRLEN];
sextypeSat = sextypesatsave?.ToArray() ?? new float[ARRLEN];
sextypeRecentTickAbs = sextyperecenttickabssave?.ToArray() ?? new int[ARRLEN];
foreach (KeyValuePair<string, SexPartnerHistoryRecord> element in histories)
{
element.Value.PartnerID = element.Key;
}
}
base.PostExposeData();
}
public void RecordSex(Pawn partner, SexProps props)
{
Pawn pawn = parent as Pawn;
RecordFirst(partner, props);
GetPartnerRecord(partner)?.RecordSex(props);
recentPartner = partner.ThingID;
recentSex = props.sexType;
sextypeCount[(int)props.sexType]++;
sextypeRecentTickAbs[(int)props.sexType] = GenTicks.TicksAbs;
if (partner.IsIncest(pawn)) incestuous++;
if (partner.Dead) corpsefuck++;
if (props.IsBestiality()) bestiality++;
else if (pawn.def != partner.def) interspecies++;
dirty = true;
}
public void RecordSatisfaction(Pawn partner, SexProps props, float satisfaction)
{
RecordFirst(partner, props);
GetPartnerRecord(partner)?.RecordSatisfaction(props, satisfaction);
recentSat = satisfaction;
sextypeSat[(int)props.sexType] += satisfaction;
dirty = true;
}
public void RecordFirst(Pawn partner, SexProps props)
{
if (VirginCheck() && props.sexType == xxx.rjwSextype.Vaginal)
{
first = partner.ThingID;
SexHistoryComp history = partner.TryGetComp<SexHistoryComp>();
firstSexTickAbs = GenTicks.TicksAbs;
history?.TakeSomeonesVirgin(parent as Pawn);
}
}
protected SexPartnerHistoryRecord GetPartnerRecord(Pawn partner)
{
string partnerId = partner.ThingID;
if (histories.TryGetValue(partnerId, out SexPartnerHistoryRecord record))
{
return record;
}
SexPartnerHistoryRecord newRecord = new SexPartnerHistoryRecord(partner, partner.IsIncest(parent as Pawn));
histories.Add(partnerId, newRecord);
if (parent is Pawn pawn)
{
pawn.records.Increment(VariousDefOf.SexPartnerCount);
}
return newRecord;
}
public void TakeSomeonesVirgin(Pawn partner)
{
GetPartnerRecord(partner)?.TookVirgin();
virginsTaken++;
}
#region Cache update
protected void Update()
{
if (dirty)
{
UpdateStatistics();
UpdateBestSex();
dirty = false;
}
}
protected void UpdateStatistics()
{
int max = 0;
float maxsat = 0;
float maxf = 0;
int maxindex = 0;
string mostID = Keyed.Unknown;
string bestID = Keyed.Unknown;
totalSexCache = 0;
totalRapedCache = 0;
totalBeenRapedCache = 0;
Dictionary<ThingDef, int> racetotalsat = new Dictionary<ThingDef, int>();
List<Pawn> allpartners = new List<Pawn>();
foreach (KeyValuePair<string, SexPartnerHistoryRecord> element in histories)
{
SexPartnerHistoryRecord h = element.Value;
//find most sex partner
if (max < h.TotalSexCount)
{
max = h.TotalSexCount;
mostID = element.Key;
}
if (maxsat < h.BestSatisfaction)
{
maxsat = h.BestSatisfaction;
bestID = element.Key;
}
if (h.Partner != null)
{
Pawn partner = h.Partner;
allpartners.Add(partner);
if (racetotalsat.ContainsKey(h.Race))
{
racetotalsat[h.Race] += h.TotalSexCount - h.RapedMe;
}
else
{
racetotalsat.Add(h.Race, h.TotalSexCount - h.RapedMe);
}
}
totalSexCache += h.TotalSexCount;
totalRapedCache += h.Raped;
totalBeenRapedCache += h.RapedMe;
}
if (!racetotalsat.NullOrEmpty())
{
KeyValuePair<ThingDef, int> prefer = racetotalsat.MaxBy(x => x.Value);
preferRaceCache = prefer.Key;
preferRaceSexCountCache = prefer.Value;
preferRacePawnCache = allpartners.Find(x => x.def == preferRaceCache);
}
for (int i = 0; i < sextypeCount.Length; i++)
{
float avgsat = sextypeSat[i] / sextypeCount[i];
if (maxf < avgsat)
{
maxf = avgsat;
maxindex = i;
}
}
mostSatSextypeCache = (xxx.rjwSextype)maxindex;
mostSextypeCache = (xxx.rjwSextype)sextypeCount.FirstIndexOf(x => x == sextypeCount.Max());
mostPartnerCache = mostID;
bestPartnerCache = bestID;
recentSexTickAbsCache = histories.TryGetValue(recentPartner)?.RecentSexTickAbs ?? 0;
mostSexTickAbsCache = histories.TryGetValue(mostPartnerCache)?.RecentSexTickAbs ?? 0;
bestSexTickAbsCache = histories.TryGetValue(bestPartnerCache)?.BestSexTickAbs ?? 0;
racetotalsat.Clear();
allpartners.Clear();
}
protected void UpdateBestSex()
{
int bestindex = 0;
float bestsat = 0;
float avgsat;
for (int i = 0; i < sextypeCount.Length; i++)
{
avgsat = sextypeSat[i] / sextypeCount[i];
if (bestsat < avgsat)
{
bestindex = i;
bestsat = avgsat;
}
}
bestSextypeCache = (xxx.rjwSextype)bestindex;
bestSextypeSatCache = bestsat;
}
#endregion Cache update
protected bool VirginCheck()
{
if (histories.TryGetValue(first) != null) return false;
Pawn pawn = parent as Pawn;
return pawn?.IsVirgin() == true;
}
public override void Initialize(CompProperties props)
{
base.Initialize(props);
Gizmo = new Command_Action
{
defaultLabel = Keyed.RS_Sex_History,
icon = HistoryUtility.HistoryIcon,
defaultIconColor = HistoryUtility.HistoryColor,
hotKey = VariousDefOf.OpenSexStatistics,
action = delegate
{
UI.SexStatusWindow.ToggleWindow(parent as Pawn, this);
}
};
}
}
}

View file

@ -0,0 +1,163 @@
using rjw;
using RJWSexperience.ExtensionMethods;
using System.Collections.Generic;
using Verse;
namespace RJWSexperience.SexHistory
{
public class SexPartnerHistoryRecord : IExposable
{
public string PartnerID { get; set; }
protected Pawn partner = null;
protected string labelCache;
protected int totalSexCount = 0;
protected int raped = 0;
protected int rapedMe = 0;
protected int orgasms = 0;
protected xxx.rjwSextype bestSextype = xxx.rjwSextype.None;
protected float bestSatisfaction = 0;
protected bool iTookVirgin = false;
protected bool incest = false;
protected int recentSexTickAbs = 0;
protected int bestSexTickAbs = 0;
protected bool cannotLoadPawnData = false;
protected ThingDef raceCache;
public xxx.rjwSextype BestSextype => bestSextype;
public float BestSatisfaction => bestSatisfaction;
public int TotalSexCount => totalSexCount;
public int OrgasmCount => orgasms;
public bool IamFirst => iTookVirgin;
public bool Incest => incest;
public int Raped => raped;
public int RapedMe => rapedMe;
public int RecentSexTickAbs => recentSexTickAbs;
public int BestSexTickAbs => bestSexTickAbs;
public int BestSexElapsedTicks => GenTicks.TicksAbs - bestSexTickAbs;
public Pawn Partner
{
get
{
if (!cannotLoadPawnData && partner == null)
{
LoadPartnerPawn(PartnerID);
if (partner == null) cannotLoadPawnData = true;
}
return partner;
}
}
public string Label
{
get
{
if (Partner != null)
labelCache = Partner.Label;
return labelCache;
}
}
public ThingDef Race
{
get
{
if (Partner != null)
raceCache = Partner.def;
return raceCache;
}
}
public SexPartnerHistoryRecord() { }
public SexPartnerHistoryRecord(Pawn pawn, bool incest = false)
{
this.partner = pawn;
this.labelCache = pawn.Label;
this.incest = incest;
this.raceCache = pawn.def;
}
public void ExposeData()
{
Scribe_Values.Look(ref labelCache, "namecache");
Scribe_Values.Look(ref totalSexCount, "totalsexhad", 0);
Scribe_Values.Look(ref raped, "raped", 0);
Scribe_Values.Look(ref rapedMe, "rapedme", 0);
Scribe_Values.Look(ref orgasms, "orgasms", 0);
Scribe_Values.Look(ref bestSextype, "bestsextype", xxx.rjwSextype.None);
Scribe_Values.Look(ref bestSatisfaction, "bestsatisfaction", 0f);
Scribe_Values.Look(ref iTookVirgin, "itookvirgin", false);
Scribe_Values.Look(ref incest, "incest", false);
Scribe_Values.Look(ref recentSexTickAbs, "recentsextickabs", 0);
Scribe_Values.Look(ref bestSexTickAbs, "bestsextickabs", 0);
Scribe_Defs.Look(ref raceCache, "race");
}
public void RecordSex(SexProps props)
{
totalSexCount++;
if (props.isRape)
{
if (partner == props.GetInteractionInitiator())
rapedMe++;
else
raped++;
}
recentSexTickAbs = GenTicks.TicksAbs;
}
public void RecordSatisfaction(SexProps props, float satisfaction)
{
orgasms++;
if (satisfaction > bestSatisfaction)
{
bestSextype = props.sexType;
bestSatisfaction = satisfaction;
bestSexTickAbs = GenTicks.TicksAbs;
}
}
public void TookVirgin()
{
iTookVirgin = true;
}
protected void LoadPartnerPawn(string partnerID)
{
foreach (Map map in Find.Maps)
{
partner = map.mapPawns.AllPawns.Find(x => x.ThingID.Equals(partnerID));
if (partner != null) return;
}
partner = Find.WorldPawns.AllPawnsAliveOrDead.Find(x => x.ThingID.Equals(partnerID));
}
#region OrderComparers
public class RecentOrderComparer : IComparer<SexPartnerHistoryRecord>
{
public int Compare(SexPartnerHistoryRecord x, SexPartnerHistoryRecord y)
{
return y.RecentSexTickAbs.CompareTo(x.RecentSexTickAbs);
}
}
public class MostOrderComparer : IComparer<SexPartnerHistoryRecord>
{
public int Compare(SexPartnerHistoryRecord x, SexPartnerHistoryRecord y)
{
return y.TotalSexCount.CompareTo(x.TotalSexCount);
}
}
public class NameOrderComparer : IComparer<SexPartnerHistoryRecord>
{
public int Compare(SexPartnerHistoryRecord x, SexPartnerHistoryRecord y)
{
return x.Label.CompareTo(y.Label);
}
}
#endregion OrderComparers
}
}

View file

@ -0,0 +1,101 @@
using RimWorld;
using rjw;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse;
namespace RJWSexperience.SexHistory.UI
{
public static class RJWUIUtility
{
public const float FONTHEIGHT = 22f;
public const float CARDHEIGHT = 110f;
public const float LISTPAWNSIZE = 100f;
public const float BASESAT = 0.40f;
public const float ICONSIZE = 30f;
public static void DrawQuirk(this Rect rect, Pawn pawn)
{
List<Quirk> quirks = Quirk.All.FindAll(x => pawn.Has(x));
string quirkstr = quirks.Select(x => x.Key).ToCommaList();
string tooltip = "";
Widgets.Label(rect, "Quirks".Translate() + quirkstr);
if (Mouse.IsOver(rect))
{
if (quirks.NullOrEmpty())
{
tooltip = "NoQuirks".Translate();
}
else
{
StringBuilder stringBuilder = new StringBuilder();
foreach (var q in quirks)
{
stringBuilder.AppendLine(q.Key.Colorize(Color.yellow));
stringBuilder.AppendLine(q.LocaliztionKey.Translate(pawn.Named("pawn")).AdjustedFor(pawn).Resolve());
stringBuilder.AppendLine("");
}
tooltip = stringBuilder.ToString().TrimEndNewlines();
}
Widgets.DrawHighlight(rect);
}
TooltipHandler.TipRegion(rect, tooltip);
}
public static void DrawSexuality(this Rect rect, CompRJW comp)
{
if (comp != null)
{
string sexuality = Keyed.Sexuality[(int)comp.orientation];
Widgets.Label(rect, Keyed.RS_Sexuality + ": " + sexuality);
Widgets.DrawHighlightIfMouseover(rect);
}
}
public static string GetRelationsString(this Pawn pawn, Pawn otherpawn)
{
if (otherpawn != null)
{
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
if (!relations.EnumerableNullOrEmpty()) return relations.Select(x => x.GetGenderSpecificLabel(otherpawn)).ToCommaList().CapitalizeFirst();
}
return "";
}
public static void DrawBorder(this Rect rect, Texture border, float thickness = 1f)
{
GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, thickness), border);
GUI.DrawTexture(new Rect(rect.x + rect.width - thickness, rect.y, thickness, rect.height), border);
GUI.DrawTexture(new Rect(rect.x, rect.y + rect.height - thickness, rect.width, thickness), border);
GUI.DrawTexture(new Rect(rect.x, rect.y, thickness, rect.height), border);
}
public static string GetStatExplanation(Pawn pawn, StatDef stat, float val)
{
if (!pawn.Dead)
return stat.description + "\n" + stat.Worker.GetExplanationFull(StatRequest.For(pawn), ToStringNumberSense.Undefined, val);
return "Dead".Translate();
}
public static string GetSexDays(int absticks, bool printUnknown = false)
{
if (absticks != 0)
return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago;
else if (printUnknown)
return Keyed.Unknown;
return "";
}
public static Texture GetRaceIcon(Pawn pawn, Vector2 size)
{
if (pawn != null)
return PortraitsCache.Get(pawn, size, Rot4.South, default, 1, true, true, false, false);
return HistoryUtility.UnknownPawn;
}
}
}

View file

@ -0,0 +1,654 @@
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Verse;
using Verse.Sound;
namespace RJWSexperience.SexHistory.UI
{
public enum PartnerOrderMode
{
Normal = 0,
Recent = 1,
Most = 2,
Name, MaxValue = 3
};
public static class PartnerOrderModeExtension
{
public static PartnerOrderMode Next(this PartnerOrderMode mode)
{
return (PartnerOrderMode)(((int)mode + 1) % ((int)PartnerOrderMode.MaxValue + 1));
}
}
public class SexStatusWindow : Window
{
public const float WINDOW_WIDTH = 900f;
public const float WINDOW_HEIGHT = 600f;
public const float FONTHEIGHT = RJWUIUtility.FONTHEIGHT;
public const float CARDHEIGHT = RJWUIUtility.CARDHEIGHT;
public const float LISTPAWNSIZE = RJWUIUtility.LISTPAWNSIZE;
public const float BASESAT = RJWUIUtility.BASESAT;
public const float ICONSIZE = RJWUIUtility.ICONSIZE;
public static readonly int[] Sextype =
{
(int)xxx.rjwSextype.Vaginal,
(int)xxx.rjwSextype.Anal,
(int)xxx.rjwSextype.Oral,
(int)xxx.rjwSextype.Fellatio,
(int)xxx.rjwSextype.Cunnilingus,
(int)xxx.rjwSextype.DoublePenetration,
(int)xxx.rjwSextype.Boobjob,
(int)xxx.rjwSextype.Handjob,
(int)xxx.rjwSextype.Footjob,
(int)xxx.rjwSextype.Fingering,
(int)xxx.rjwSextype.Scissoring,
(int)xxx.rjwSextype.MutualMasturbation,
(int)xxx.rjwSextype.Fisting,
(int)xxx.rjwSextype.Rimming,
(int)xxx.rjwSextype.Sixtynine
};
protected Pawn pawn;
protected SexPartnerHistoryRecord selectedPawn;
protected SexHistoryComp history;
protected CompRJW rjwcomp;
protected List<SexPartnerHistoryRecord> partnerList;
protected PartnerOrderMode orderMode;
private static GUIStyle fontStyleCenter;
private static GUIStyle fontStyleRight;
private static GUIStyle fontStyleLeft;
private static GUIStyle boxStyle;
private static GUIStyle buttonStyle;
private static Vector2 LastWindowPosition { get; set; }
private Vector2 scroll;
private static void InitStyles()
{
if (fontStyleCenter != null)
{
return;
}
GUIStyleState fontStyleState = new GUIStyleState() { textColor = Color.white };
GUIStyleState boxStyleState = GUI.skin.textArea.normal;
GUIStyleState buttonStyleState = GUI.skin.button.normal;
fontStyleCenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter, normal = fontStyleState };
fontStyleRight = new GUIStyle() { alignment = TextAnchor.MiddleRight, normal = fontStyleState };
fontStyleLeft = new GUIStyle() { alignment = TextAnchor.MiddleLeft, normal = fontStyleState };
boxStyle = new GUIStyle(GUI.skin.textArea) { hover = boxStyleState, onHover = boxStyleState, onNormal = boxStyleState };
buttonStyle = new GUIStyle(GUI.skin.button) { hover = buttonStyleState, onHover = buttonStyleState, onNormal = buttonStyleState };
}
public SexStatusWindow(Pawn pawn, SexHistoryComp history)
{
this.pawn = pawn;
this.history = history;
this.selectedPawn = null;
this.rjwcomp = pawn.TryGetComp<CompRJW>();
this.partnerList = history?.PartnerList;
orderMode = PartnerOrderMode.Recent;
SortPartnerList(orderMode);
soundClose = SoundDefOf.CommsWindow_Close;
absorbInputAroundWindow = false;
forcePause = false;
preventCameraMotion = false;
draggable = true;
doCloseX = true;
}
protected override void SetInitialSizeAndPosition()
{
base.SetInitialSizeAndPosition();
if (LastWindowPosition == Vector2.zero)
return;
windowRect.x = LastWindowPosition.x;
windowRect.y = LastWindowPosition.y;
}
public override Vector2 InitialSize => new Vector2(WINDOW_WIDTH, WINDOW_HEIGHT);
public override void PreOpen()
{
base.PreOpen();
InitStyles();
}
public override void PreClose()
{
base.PreClose();
LastWindowPosition = windowRect.position;
}
public override void DoWindowContents(Rect inRect)
{
if (!SexperienceMod.Settings.SelectionLocked)
{
List<Pawn> selected = Find.Selector.SelectedPawns;
if (selected.Count == 1)
{
Pawn p = selected.First();
if (p != pawn)
{
SexHistoryComp h = p.TryGetComp<SexHistoryComp>();
if (h != null) ChangePawn(p, h);
}
}
}
DrawSexStatus(inRect, history);
}
public static void ToggleWindow(Pawn pawn, SexHistoryComp history)
{
SexStatusWindow window = (SexStatusWindow)Find.WindowStack.Windows.FirstOrDefault(x => x.GetType() == typeof(SexStatusWindow));
if (window != null)
{
if (window.pawn != pawn)
{
SoundDefOf.TabOpen.PlayOneShotOnCamera();
window.ChangePawn(pawn, history);
}
}
else
{
Find.WindowStack.Add(new SexStatusWindow(pawn, history));
}
}
public void ChangePawn(Pawn pawn, SexHistoryComp history)
{
List<Pawn> selected = Find.Selector.SelectedPawns;
if (!selected.NullOrEmpty())
{
foreach (Pawn p in selected)
{
Find.Selector.Deselect(p);
}
}
this.pawn = pawn;
this.history = history;
this.selectedPawn = null;
this.rjwcomp = pawn.TryGetComp<CompRJW>();
this.partnerList = history?.PartnerList;
if (!pawn.DestroyedOrNull() && Find.CurrentMap == pawn.Map) Find.Selector.Select(pawn);
SortPartnerList(orderMode);
}
public void SortPartnerList(PartnerOrderMode mode)
{
if (partnerList.NullOrEmpty()) return;
switch (mode)
{
default:
partnerList = history?.PartnerList;
break;
case PartnerOrderMode.Recent:
partnerList.Sort(new SexPartnerHistoryRecord.RecentOrderComparer());
break;
case PartnerOrderMode.Most:
partnerList.Sort(new SexPartnerHistoryRecord.MostOrderComparer());
break;
case PartnerOrderMode.Name:
partnerList.Sort(new SexPartnerHistoryRecord.NameOrderComparer());
break;
}
}
/// <summary>
/// Main contents
/// </summary>
protected void DrawSexStatus(Rect mainrect, SexHistoryComp history)
{
float sectionwidth = mainrect.width / 3;
Rect leftRect = new Rect(mainrect.x, mainrect.y, sectionwidth, mainrect.height);
Rect centerRect = new Rect(mainrect.x + sectionwidth, mainrect.y, sectionwidth, mainrect.height);
Rect rightRect = new Rect(mainrect.x + (sectionwidth * 2), mainrect.y, sectionwidth, mainrect.height);
if (history != null)
{
//Left section
DrawBaseSexInfoLeft(leftRect.ContractedBy(4f));
//Center section
DrawBaseSexInfoCenter(centerRect.ContractedBy(4f), history.parent as Pawn);
//Right section
DrawBaseSexInfoRight(rightRect.ContractedBy(4f));
}
}
protected void DrawInfoWithPortrait(Rect rect, SexPartnerHistoryRecord history, string tooltip = "")
{
Widgets.DrawMenuSection(rect);
string str = tooltip;
Rect portraitRect = new Rect(rect.x, rect.y, rect.height - FONTHEIGHT, rect.height - FONTHEIGHT);
Rect nameRect = new Rect(rect.x + portraitRect.width, rect.y, rect.width - portraitRect.width, FONTHEIGHT);
Rect sexinfoRect = new Rect(rect.x + portraitRect.width, rect.y + FONTHEIGHT, rect.width - portraitRect.width, FONTHEIGHT);
Rect sexinfoRect2 = new Rect(rect.x + portraitRect.width, rect.y + (FONTHEIGHT * 2), rect.width - portraitRect.width, FONTHEIGHT);
Rect bestsexRect = new Rect(rect.x + 2f, rect.y + (FONTHEIGHT * 3), rect.width - 4f, FONTHEIGHT - 2f);
if (history != null)
{
if (history.Incest) str += " - " + Keyed.Incest;
Pawn partner = history.Partner;
DrawPawn(portraitRect, history);
Widgets.DrawHighlightIfMouseover(portraitRect);
if (Widgets.ButtonInvisible(portraitRect))
{
SexHistoryComp pawnhistory = partner?.TryGetComp<SexHistoryComp>();
if (pawnhistory != null)
{
ChangePawn(partner, pawnhistory);
SoundDefOf.Click.PlayOneShotOnCamera();
}
else
{
SoundDefOf.ClickReject.PlayOneShotOnCamera();
}
}
string rapeInfo = "";
if (history.Raped > 0) rapeInfo += Keyed.RS_Raped + history.Raped + " ";
if (history.RapedMe > 0) rapeInfo += Keyed.RS_RapedMe + history.RapedMe;
GUI.Label(nameRect, partner?.Name?.ToStringFull ?? history.Label.CapitalizeFirst(), fontStyleLeft);
GUI.Label(sexinfoRect, Keyed.RS_Sex_Count + history.TotalSexCount + " " + rapeInfo, fontStyleLeft);
GUI.Label(sexinfoRect2, Keyed.RS_Orgasms + history.OrgasmCount, fontStyleLeft);
GUI.Label(sexinfoRect2, pawn.GetRelationsString(partner) + " ", fontStyleRight);
float p = history.BestSatisfaction / BASESAT;
FillableBarLabeled(bestsexRect, String.Format(Keyed.RS_Best_Sextype + ": {0}", Keyed.Sextype[(int)history.BestSextype]), p / 2, HistoryUtility.SextypeColor[(int)history.BestSextype], Texture2D.blackTexture, null, String.Format("{0:P2}", p));
if (history.IamFirst)
str += "\n" + Keyed.RS_LostVirgin(history.Label, pawn.LabelShort);
if (history.BestSexTickAbs != 0)
str += "\n" + Keyed.RS_HadBestSexDaysAgo(history.BestSexElapsedTicks.ToStringTicksToDays() + " " + Keyed.RS_Ago);
TooltipHandler.TipRegion(rect, str);
}
else
{
Widgets.DrawTextureFitted(portraitRect, HistoryUtility.UnknownPawn, 1.0f);
Widgets.Label(nameRect, Keyed.Unknown);
Widgets.Label(sexinfoRect, Keyed.RS_Sex_Count + "?");
Widgets.Label(sexinfoRect2, Keyed.RS_Orgasms + "?");
FillableBarLabeled(bestsexRect, String.Format(Keyed.RS_Best_Sextype + ": {0}", Keyed.Sextype[(int)xxx.rjwSextype.None]), 0, Texture2D.linearGrayTexture, Texture2D.blackTexture);
}
}
protected void DrawSexInfoCard(Rect rect, SexPartnerHistoryRecord history, string label, string tooltip, string rightlabel = "")
{
Rect labelRect = new Rect(rect.x, rect.y, rect.width, FONTHEIGHT);
Rect infoRect = new Rect(rect.x, rect.y + FONTHEIGHT, rect.width, rect.height - FONTHEIGHT);
GUI.Label(labelRect, label, fontStyleLeft);
GUI.Label(labelRect, rightlabel, fontStyleRight);
DrawInfoWithPortrait(infoRect, history, tooltip);
}
/// <summary>
/// Right section
/// </summary>
protected void DrawBaseSexInfoRight(Rect rect)
{
Listing_Standard listmain = new Listing_Standard();
listmain.Begin(rect.ContractedBy(4f));
DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), history.GetRecentPartnersHistory, Keyed.RS_Recent_Sex_Partner, Keyed.RS_Recent_Sex_Partner_ToolTip, RJWUIUtility.GetSexDays(history.RecentSexTickAbs));
DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), history.GetFirstPartnerHistory, Keyed.RS_First_Sex_Partner, Keyed.RS_First_Sex_Partner_ToolTip, RJWUIUtility.GetSexDays(history.FirstSexTickAbs));
DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), history.GetMostPartnerHistory, Keyed.RS_Most_Sex_Partner, Keyed.RS_Most_Sex_Partner_ToolTip, RJWUIUtility.GetSexDays(history.MostSexTickAbs));
DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), history.GetBestSexPartnerHistory, Keyed.RS_Best_Sex_Partner, Keyed.RS_Best_Sex_Partner_ToolTip, RJWUIUtility.GetSexDays(history.BestSexTickAbs));
GUI.Label(listmain.GetRect(FONTHEIGHT), Keyed.RS_PreferRace, fontStyleLeft);
DrawPreferRace(listmain.GetRect(66f + 15f));
listmain.GetRect(15f);
listmain.End();
}
protected void DrawPreferRace(Rect rect)
{
Widgets.DrawMenuSection(rect);
Rect portraitRect = new Rect(rect.x, rect.y, rect.height - 15f, rect.height - 15f);
Rect infoRect1 = new Rect(rect.x + portraitRect.width, rect.y, rect.width - portraitRect.width, FONTHEIGHT);
Rect infoRect2 = new Rect(rect.x + portraitRect.width, rect.y + FONTHEIGHT, rect.width - portraitRect.width, FONTHEIGHT);
Rect infoRect3 = new Rect(rect.x + portraitRect.width, rect.y + (FONTHEIGHT * 2), rect.width - portraitRect.width - 2f, FONTHEIGHT);
if (history.PreferRace != null)
{
Widgets.DrawTextureFitted(portraitRect, RJWUIUtility.GetRaceIcon(history.PreferRacePawn, portraitRect.size), 1.0f);
GUI.Label(infoRect1, history.PreferRace?.label.CapitalizeFirst() ?? Keyed.None, fontStyleLeft);
GUI.Label(infoRect2, Keyed.RS_Sex_Count + history.PreferRaceSexCount, fontStyleLeft);
if (history.PreferRace != pawn.def)
{
if (history.PreferRace.race.Animal ^ pawn.def.race.Animal)
{
GUI.Label(infoRect1, Keyed.RS_Bestiality + " ", fontStyleRight);
FillableBarLabeled(infoRect3, Keyed.RS_Sex_Info(Keyed.RS_Bestiality, history.BestialityCount.ToString()), history.BestialityCount / 100f, Texture2D.linearGrayTexture, Texture2D.blackTexture);
}
else
{
GUI.Label(infoRect1, Keyed.RS_Interspecies + " ", fontStyleRight);
FillableBarLabeled(infoRect3, Keyed.RS_Sex_Info(Keyed.RS_Interspecies, history.InterspeciesCount.ToString()), history.InterspeciesCount / 100f, Texture2D.linearGrayTexture, Texture2D.blackTexture);
}
}
}
else
{
Widgets.DrawTextureFitted(portraitRect, HistoryUtility.UnknownPawn, 1.0f);
GUI.Label(infoRect1, Keyed.None, fontStyleLeft);
}
}
/// <summary>
/// Center section
/// </summary>
protected void DrawBaseSexInfoCenter(Rect rect, Pawn pawn)
{
Rect portraitRect = new Rect(rect.x + (rect.width / 4), rect.y, rect.width / 2, rect.width / 1.5f);
Rect nameRect = new Rect(portraitRect.x, portraitRect.yMax - (FONTHEIGHT * 2), portraitRect.width, FONTHEIGHT * 2);
Rect infoRect = new Rect(rect.x, rect.y + portraitRect.height, rect.width, rect.height - portraitRect.height);
Rect lockRect = new Rect(portraitRect.xMax - ICONSIZE, portraitRect.y, ICONSIZE, ICONSIZE);
Rect tmp;
if (Mouse.IsOver(portraitRect))
{
Configurations settings = SexperienceMod.Settings;
Texture lockicon = settings.SelectionLocked ? HistoryUtility.Locked : HistoryUtility.Unlocked;
Widgets.DrawTextureFitted(lockRect, lockicon, 1.0f);
if (Widgets.ButtonInvisible(lockRect))
{
SoundDefOf.Click.PlayOneShotOnCamera();
settings.SelectionLocked = !settings.SelectionLocked;
}
}
GUI.Box(portraitRect, "", boxStyle);
Widgets.DrawTextureFitted(portraitRect, PortraitsCache.Get(pawn, portraitRect.size, Rot4.South, default, 1, true, true, false, false), 1.0f);
Widgets.DrawHighlightIfMouseover(portraitRect);
if (Widgets.ButtonInvisible(portraitRect))
{
SoundDefOf.Click.PlayOneShotOnCamera();
selectedPawn = null;
}
GUI.Box(nameRect, "", boxStyle);
GUI.Label(nameRect.TopHalf(), pawn.Name?.ToStringFull ?? pawn.Label, fontStyleCenter);
if (pawn.story != null) GUI.Label(nameRect.BottomHalf(), pawn.ageTracker.AgeBiologicalYears + ", " + pawn.story.Title, fontStyleCenter);
else GUI.Label(nameRect.BottomHalf(), pawn.ageTracker.AgeBiologicalYears + ", " + pawn.def.label, fontStyleCenter);
Listing_Standard listmain = new Listing_Standard();
listmain.Begin(infoRect);
listmain.Gap(20f);
float p;
Trait virginity = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin);
if (virginity != null && virginity.Degree != Virginity.TraitDegree.FemaleAfterSurgery)
{
tmp = listmain.GetRect(FONTHEIGHT);
GUI.color = Color.red;
GUI.Box(tmp, "", boxStyle);
GUI.color = Color.white;
GUI.Label(tmp, virginity.Label, fontStyleCenter);
}
else
{
p = history.TotalSexHad;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_TotalSexHad + ": {0:0} ({1:0})", p, pawn.records.GetValue(xxx.CountOfSex)), p / 100, HistoryUtility.TotalSex, Texture2D.blackTexture, null, Keyed.RS_SAT_AVG(String.Format("{0:P2}", history.AVGSat)));
}
listmain.Gap(1f);
tmp = listmain.GetRect(FONTHEIGHT);
p = pawn.records.GetValue(VariousDefOf.Lust);
FillableBarLabeled(tmp, String.Format(Keyed.Lust + ": {0:0.00}", p), Mathf.Clamp01(p.Normalization(-SexperienceMod.Settings.LustLimit * 3, SexperienceMod.Settings.LustLimit * 3)), HistoryUtility.Slaanesh, Texture2D.blackTexture, null, String.Format(xxx.sex_drive_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_drive_stat)));
listmain.Gap(1f);
if (Mouse.IsOver(tmp))
{
TooltipHandler.TipRegion(tmp, RJWUIUtility.GetStatExplanation(pawn, xxx.sex_drive_stat, pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_drive_stat)));
}
p = history.GetBestSextype(out xxx.rjwSextype sextype) / BASESAT;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_Best_Sextype + ": {0}", Keyed.Sextype[(int)sextype]), p / 2, HistoryUtility.SextypeColor[(int)sextype], Texture2D.blackTexture, null, Keyed.RS_SAT_AVG(String.Format("{0:P2}", p)));
listmain.Gap(1f);
p = history.GetRecentSextype(out sextype) / BASESAT;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_Recent_Sextype + ": {0}", Keyed.Sextype[(int)sextype]), p / 2, HistoryUtility.SextypeColor[(int)sextype], Texture2D.blackTexture, null, String.Format("{0:P2}", p));
listmain.Gap(1f);
if (history.IncestuousCount < history.CorpseFuckCount)
{
p = history.CorpseFuckCount;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_Necrophile + ": {0}", p), p / 50, HistoryUtility.Nurgle, Texture2D.blackTexture);
listmain.Gap(1f);
}
else
{
p = history.IncestuousCount;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.Incest + ": {0}", p), p / 50, HistoryUtility.Nurgle, Texture2D.blackTexture);
listmain.Gap(1f);
}
p = pawn.records.GetValue(VariousDefOf.AmountofEatenCum);
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_Cum_Swallowed + ": {0} mL, {1} " + Keyed.RS_NumofTimes, p, pawn.records.GetValue(VariousDefOf.NumofEatenCum)), p / 1000, Texture2D.linearGrayTexture, Texture2D.blackTexture);
listmain.Gap(1f);
Hediff addiction = pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.CumAddiction)
?? pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.CumTolerance);
if (addiction != null)
{
p = addiction.Severity;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), $"{addiction.Label}: {p.ToStringPercent()}", p, Texture2D.linearGrayTexture, Texture2D.blackTexture, addiction.GetTooltip(pawn, false));
}
else
{
listmain.GetRect(FONTHEIGHT);
}
listmain.Gap(1f);
p = history.RapedCount;
tmp = listmain.GetRect(FONTHEIGHT);
if (p < history.BeenRapedCount)
{
p = history.BeenRapedCount;
FillableBarLabeled(tmp, String.Format(Keyed.RS_BeenRaped + ": {0}", p), p / 50, Texture2D.grayTexture, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
listmain.Gap(1f);
}
else
{
FillableBarLabeled(tmp, String.Format(Keyed.RS_RapedSomeone + ": {0}", p), p / 50, HistoryUtility.Khorne, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
listmain.Gap(1f);
}
if (Mouse.IsOver(tmp))
{
TooltipHandler.TipRegion(tmp, RJWUIUtility.GetStatExplanation(pawn, xxx.vulnerability_stat, pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
}
p = pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_satisfaction);
tmp = listmain.GetRect(FONTHEIGHT);
FillableBarLabeled(tmp, String.Format(xxx.sex_satisfaction.LabelCap.CapitalizeFirst() + ": {0:P2}", p), p / 2, HistoryUtility.Satisfaction, Texture2D.blackTexture);
listmain.Gap(1f);
if (Mouse.IsOver(tmp))
{
TooltipHandler.TipRegion(tmp, RJWUIUtility.GetStatExplanation(pawn, xxx.sex_satisfaction, pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_satisfaction)));
}
SkillRecord skill = pawn.skills?.GetSkill(VariousDefOf.Sex);
p = skill?.Level ?? 0;
tmp = listmain.GetRect(FONTHEIGHT);
FillableBarLabeled(tmp, $"{Keyed.RS_SexSkill}: {p}, {skill?.xpSinceLastLevel / skill?.XpRequiredForLevelUp:P2}", p / 20, HistoryUtility.Tzeentch, Texture2D.blackTexture, null, $"{VariousDefOf.SexAbility.LabelCap.CapitalizeFirst()}: {pawn.GetSexStat():P2}", HistoryUtility.PassionBG[(int)(skill?.passion ?? 0)]);
if (Mouse.IsOver(tmp))
{
TooltipHandler.TipRegion(tmp, RJWUIUtility.GetStatExplanation(pawn, VariousDefOf.SexAbility, pawn.GetSexStat()));
}
listmain.Gap(1f);
if (selectedPawn != null) DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), selectedPawn, Keyed.RS_Selected_Partner, Keyed.RS_Selected_Partner, RJWUIUtility.GetSexDays(selectedPawn.RecentSexTickAbs));
else DrawExtraInfo(listmain.GetRect(CARDHEIGHT));
listmain.End();
}
protected void DrawExtraInfo(Rect rect)
{
Widgets.DrawMenuSection(rect);
Rect inRect = rect.ContractedBy(4f);
Listing_Standard listmain = new Listing_Standard();
listmain.Begin(inRect);
listmain.Gap(4f);
listmain.GetRect(FONTHEIGHT).DrawSexuality(rjwcomp);
listmain.Gap(1f);
listmain.GetRect(FONTHEIGHT * 3f).DrawQuirk(pawn);
listmain.End();
}
/// <summary>
/// Left section
/// </summary>
protected void DrawBaseSexInfoLeft(Rect rect)
{
Listing_Standard listmain = new Listing_Standard();
listmain.Begin(rect);
float p;
//Sex statistics
GUI.Label(listmain.GetRect(FONTHEIGHT), " " + Keyed.RS_Statistics, fontStyleLeft);
listmain.Gap(1f);
float maxSatisfaction = history.GetBestSextype(out _);
if (maxSatisfaction == 0f) maxSatisfaction = BASESAT;
for (int i = 0; i < Sextype.Length; i++)
{
int sexindex = Sextype[i];
float relativeSat = history.GetAVGSat(sexindex) / maxSatisfaction;
p = history.GetAVGSat(sexindex) / BASESAT;
string label = Keyed.RS_Sex_Info(Keyed.Sextype[sexindex], history.GetSexCount(sexindex).ToString());
Rect tmpRect = listmain.GetRect(FONTHEIGHT);
FillableBarLabeled(tmpRect, label, relativeSat, HistoryUtility.SextypeColor[sexindex], Texture2D.blackTexture, null, Keyed.RS_SAT_AVG(String.Format("{0:P2}", p)));
if (Mouse.IsOver(tmpRect))
{
TooltipHandler.TipRegion(tmpRect, Keyed.RS_LastSex.CapitalizeFirst() + ": " + RJWUIUtility.GetSexDays(history.GetSextypeRecentTickAbs(Sextype[i]), true));
}
listmain.Gap(1f);
}
p = history.PartnerCount;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_Sex_Partners + ": {0} ({1})", p, pawn.records.GetValue(VariousDefOf.SexPartnerCount)), p / 50, HistoryUtility.Partners, Texture2D.blackTexture);
listmain.Gap(1f);
p = history.VirginsTaken;
FillableBarLabeled(listmain.GetRect(FONTHEIGHT), String.Format(Keyed.RS_VirginsTaken + ": {0:0}", p), p / 100, HistoryUtility.Partners, Texture2D.blackTexture);
listmain.Gap(1f);
//Partner list
Rect listLabelRect = listmain.GetRect(FONTHEIGHT);
Rect sortbtnRect = new Rect(listLabelRect.xMax - 80f, listLabelRect.y, 80f, listLabelRect.height);
GUI.Label(listLabelRect, " " + Keyed.RS_PartnerList, fontStyleLeft);
if (Widgets.ButtonText(sortbtnRect, orderMode.Translate()))
{
SoundDefOf.Click.PlayOneShotOnCamera();
orderMode = orderMode.Next();
SortPartnerList(orderMode);
}
listmain.Gap(1f);
Rect scrollRect = listmain.GetRect(CARDHEIGHT + 1f);
GUI.Box(scrollRect, "", buttonStyle);
if (!partnerList.NullOrEmpty())
{
Rect listRect = new Rect(scrollRect.x, scrollRect.y, LISTPAWNSIZE * partnerList.Count, scrollRect.height - 30f);
Widgets.ScrollHorizontal(scrollRect, ref scroll, listRect);
Widgets.BeginScrollView(scrollRect, ref scroll, listRect);
DrawPartnerList(listRect, partnerList);
Widgets.EndScrollView();
}
listmain.End();
}
protected void DrawPartnerList(Rect rect, List<SexPartnerHistoryRecord> partnerList)
{
Rect pawnRect = new Rect(rect.x, rect.y, LISTPAWNSIZE, LISTPAWNSIZE);
for (int i = 0; i < partnerList.Count; i++)
{
Rect labelRect = new Rect(pawnRect.x, pawnRect.yMax - FONTHEIGHT, pawnRect.width, FONTHEIGHT);
DrawPawn(pawnRect, partnerList[i]);
Widgets.DrawHighlightIfMouseover(pawnRect);
GUI.Label(labelRect, partnerList[i].Label, fontStyleCenter);
if (Widgets.ButtonInvisible(pawnRect))
{
selectedPawn = partnerList[i];
SoundDefOf.Click.PlayOneShotOnCamera();
}
if (partnerList[i] == selectedPawn)
{
Widgets.DrawHighlightSelected(pawnRect);
}
pawnRect.x += LISTPAWNSIZE;
}
}
protected void DrawPawn(Rect rect, SexPartnerHistoryRecord history)
{
if (history != null)
{
bool drawheart = false;
Rect iconRect = new Rect(rect.x + (rect.width * 3 / 4), rect.y, rect.width / 4, rect.height / 4);
Texture img = HistoryUtility.UnknownPawn;
if (history.IamFirst)
{
GUI.color = HistoryUtility.HistoryColor;
Widgets.DrawTextureFitted(rect, HistoryUtility.FirstOverlay, 1.0f);
GUI.color = Color.white;
}
if (history.Partner != null)
{
img = PortraitsCache.Get(history.Partner, rect.size, Rot4.South, default, 1, true, true, false, false);
drawheart = LovePartnerRelationUtility.LovePartnerRelationExists(pawn, history.Partner);
}
else if (history.Race?.uiIcon != null)
{
img = history.Race.uiIcon;
}
if (history.Incest)
{
Widgets.DrawTextureFitted(iconRect, HistoryUtility.Incest, 1.0f);
iconRect.x -= iconRect.width;
}
Widgets.DrawTextureFitted(rect, img, 1.0f);
if (drawheart)
{
Widgets.DrawTextureFitted(iconRect, HistoryUtility.Heart, 1.0f);
iconRect.x -= iconRect.width;
}
}
}
public static void FillableBarLabeled(Rect rect, string label, float fillPercent, Texture2D filltexture, Texture2D bgtexture, string tooltip = null, string rightlabel = "", Texture2D border = null)
{
Widgets.FillableBar(rect, Math.Min(fillPercent, 1.0f), filltexture, bgtexture, true);
GUI.Label(rect, " " + label.CapitalizeFirst(), fontStyleLeft);
GUI.Label(rect, rightlabel.CapitalizeFirst() + " ", fontStyleRight);
Widgets.DrawHighlightIfMouseover(rect);
if (tooltip != null) TooltipHandler.TipRegion(rect, tooltip);
if (border != null)
{
rect.DrawBorder(border, 2f);
}
}
}
}