Refactor SexPartnerHistory
This commit is contained in:
parent
54421f82f0
commit
0c7a762b9e
|
@ -10,58 +10,50 @@ namespace RJWSexperience
|
||||||
{
|
{
|
||||||
public class SexPartnerHistory : ThingComp
|
public class SexPartnerHistory : ThingComp
|
||||||
{
|
{
|
||||||
public SexPartnerHistory() { }
|
|
||||||
public const int ARRLEN = 20;
|
public const int ARRLEN = 20;
|
||||||
|
|
||||||
protected Dictionary<string, SexPartnerHistoryRecord> histories = new Dictionary<string, SexPartnerHistoryRecord>();
|
protected Dictionary<string, SexPartnerHistoryRecord> histories = new Dictionary<string, SexPartnerHistoryRecord>();
|
||||||
protected string first = "";
|
protected string first = "";
|
||||||
protected bool dirty = true;
|
protected bool dirty = true;
|
||||||
protected xxx.rjwSextype recentsex = xxx.rjwSextype.None;
|
protected xxx.rjwSextype recentSex = xxx.rjwSextype.None;
|
||||||
protected float recentsat = 0;
|
protected float recentSat = 0;
|
||||||
protected string recentpartner = "";
|
protected string recentPartner = "";
|
||||||
protected int[] sextypecount = new int[ARRLEN];
|
protected int[] sextypeCount = new int[ARRLEN];
|
||||||
protected float[] sextypesat = new float[ARRLEN];
|
protected float[] sextypeSat = new float[ARRLEN];
|
||||||
protected int[] sextyperecenttickabs = new int[ARRLEN];
|
protected int[] sextypeRecentTickAbs = new int[ARRLEN];
|
||||||
protected int virginstaken = 0;
|
protected int virginsTaken = 0;
|
||||||
protected int incestuous = 0;
|
protected int incestuous = 0;
|
||||||
protected int bestiality = 0;
|
protected int bestiality = 0;
|
||||||
protected int corpsefuck = 0;
|
protected int corpsefuck = 0;
|
||||||
protected int interspecies = 0;
|
protected int interspecies = 0;
|
||||||
protected int firstsextickabs = 0;
|
protected int firstSexTickAbs = 0;
|
||||||
|
|
||||||
protected string mostpartnercache = "";
|
protected string mostPartnerCache = "";
|
||||||
protected xxx.rjwSextype mostsextypecache = xxx.rjwSextype.None;
|
protected xxx.rjwSextype mostSextypeCache = xxx.rjwSextype.None;
|
||||||
protected xxx.rjwSextype mostsatsextypecache = xxx.rjwSextype.None;
|
protected xxx.rjwSextype mostSatSextypeCache = xxx.rjwSextype.None;
|
||||||
protected xxx.rjwSextype bestsextypecache = xxx.rjwSextype.None;
|
protected xxx.rjwSextype bestSextypeCache = xxx.rjwSextype.None;
|
||||||
protected float bestsextypesatcache = 0;
|
protected float bestSextypeSatCache = 0;
|
||||||
protected string bestpartnercache = "";
|
protected string bestPartnerCache = "";
|
||||||
protected int totalsexcache = 0;
|
protected int totalSexCache = 0;
|
||||||
protected int totalrapedcache = 0;
|
protected int totalRapedCache = 0;
|
||||||
protected int totalbeenrapedcache = 0;
|
protected int totalBeenRapedCache = 0;
|
||||||
protected ThingDef preferracecache = null;
|
protected ThingDef preferRaceCache = null;
|
||||||
protected int preferracesexcountcache = 0;
|
protected int preferRaceSexCountCache = 0;
|
||||||
protected Pawn preferracepawncache = null;
|
protected Pawn preferRacePawnCache = null;
|
||||||
protected float avtsatcache = 0;
|
protected int recentSexTickAbsCache = 0;
|
||||||
protected int recentsextickabscache = 0;
|
protected int mostSexTickAbsCache = 0;
|
||||||
protected int mostsextickabscache = 0;
|
protected int bestSexTickAbsCache = 0;
|
||||||
protected int bestsextickabscache = 0;
|
|
||||||
|
|
||||||
public Gizmo Gizmo { get; private set; }
|
public Gizmo Gizmo { get; private set; }
|
||||||
|
|
||||||
public SexPartnerHistoryRecord GetFirstPartnerHistory
|
public SexPartnerHistoryRecord GetFirstPartnerHistory => histories.TryGetValue(first);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
Update();
|
|
||||||
return histories.TryGetValue(first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public SexPartnerHistoryRecord GetMostPartnerHistory
|
public SexPartnerHistoryRecord GetMostPartnerHistory
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return histories.TryGetValue(mostpartnercache);
|
return histories.TryGetValue(mostPartnerCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public xxx.rjwSextype MostSextype
|
public xxx.rjwSextype MostSextype
|
||||||
|
@ -69,7 +61,7 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return mostsextypecache;
|
return mostSextypeCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public xxx.rjwSextype MostSatisfiedSex
|
public xxx.rjwSextype MostSatisfiedSex
|
||||||
|
@ -77,16 +69,16 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return mostsatsextypecache;
|
return mostSatSextypeCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SexPartnerHistoryRecord GetRecentPartnersHistory => histories.TryGetValue(recentpartner);
|
public SexPartnerHistoryRecord GetRecentPartnersHistory => histories.TryGetValue(recentPartner);
|
||||||
public SexPartnerHistoryRecord GetBestSexPartnerHistory
|
public SexPartnerHistoryRecord GetBestSexPartnerHistory
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return histories.TryGetValue(bestpartnercache);
|
return histories.TryGetValue(bestPartnerCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public float TotalSexHad
|
public float TotalSexHad
|
||||||
|
@ -94,10 +86,10 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return totalsexcache;
|
return totalSexCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int VirginsTaken => virginstaken;
|
public int VirginsTaken => virginsTaken;
|
||||||
public List<SexPartnerHistoryRecord> PartnerList
|
public List<SexPartnerHistoryRecord> PartnerList
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -125,7 +117,7 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return totalrapedcache;
|
return totalRapedCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int BeenRapedCount
|
public int BeenRapedCount
|
||||||
|
@ -133,7 +125,7 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return totalbeenrapedcache;
|
return totalBeenRapedCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ThingDef PreferRace
|
public ThingDef PreferRace
|
||||||
|
@ -141,7 +133,7 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return preferracecache;
|
return preferRaceCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int PreferRaceSexCount
|
public int PreferRaceSexCount
|
||||||
|
@ -149,7 +141,7 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
return preferracesexcountcache;
|
return preferRaceSexCountCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int BestialityCount => bestiality;
|
public int BestialityCount => bestiality;
|
||||||
|
@ -160,85 +152,47 @@ namespace RJWSexperience
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
if (totalsexcache == 0) return 0;
|
if (totalSexCache == 0) return 0;
|
||||||
return sextypesat.Sum() / totalsexcache;
|
return sextypeSat.Sum() / totalSexCache;
|
||||||
}
|
|
||||||
}
|
|
||||||
public int RecentSexElapsedTicks => GenTicks.TicksAbs - recentsextickabscache;
|
|
||||||
public string RecentSexDays
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (recentsextickabscache != 0) return GenDate.ToStringTicksToDays(RecentSexElapsedTicks) + " " + Keyed.RS_Ago;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int FirstSexElapsedTicks => GenTicks.TicksAbs - firstsextickabs;
|
|
||||||
public string FirstSexDays
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (firstsextickabs != 0) return GenDate.ToStringTicksToDays(FirstSexElapsedTicks) + " " + Keyed.RS_Ago;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int MostSexElapsedTicks => GenTicks.TicksAbs - mostsextickabscache;
|
|
||||||
public string MostSexDays
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (mostsextickabscache != 0) return GenDate.ToStringTicksToDays(MostSexElapsedTicks) + " " + Keyed.RS_Ago;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int BestSexElapsedTicks => GenTicks.TicksAbs - bestsextickabscache;
|
|
||||||
public string BestSexDays
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (bestsextickabscache != 0) return GenDate.ToStringTicksToDays(BestSexElapsedTicks) + " " + Keyed.RS_Ago;
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public int RecentSexTickAbs => recentSexTickAbsCache;
|
||||||
|
public int FirstSexTickAbs => firstSexTickAbs;
|
||||||
|
public int MostSexTickAbs => mostSexTickAbsCache;
|
||||||
|
public int BestSexTickAbs => bestSexTickAbsCache;
|
||||||
|
|
||||||
public Texture GetPreferRaceIcon(Vector2 size)
|
public Pawn PreferRacePawn
|
||||||
{
|
{
|
||||||
Update();
|
get
|
||||||
if (preferracepawncache != null) return PortraitsCache.Get(preferracepawncache, size, Rot4.South, default, 1, true, true, false, false);
|
{
|
||||||
else return HistoryUtility.UnknownPawn;
|
Update();
|
||||||
|
return preferRacePawnCache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetBestSextype(out xxx.rjwSextype sextype)
|
public float GetBestSextype(out xxx.rjwSextype sextype)
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
sextype = bestsextypecache;
|
sextype = bestSextypeCache;
|
||||||
return bestsextypesatcache;
|
return bestSextypeSatCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetRecentSextype(out xxx.rjwSextype sextype)
|
public float GetRecentSextype(out xxx.rjwSextype sextype)
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
sextype = recentsex;
|
sextype = recentSex;
|
||||||
return recentsat;
|
return recentSat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SextypeRecentDays(int sextype)
|
public int GetSextypeRecentTickAbs(int sextype) => sextypeRecentTickAbs[sextype];
|
||||||
{
|
|
||||||
int index = sextype;
|
|
||||||
if (sextyperecenttickabs[index] != 0) return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - sextyperecenttickabs[index]) + " " + Keyed.RS_Ago;
|
|
||||||
return Keyed.Unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float GetAVGSat(int index)
|
public float GetAVGSat(int index)
|
||||||
{
|
{
|
||||||
float res = sextypesat[index] / sextypecount[index];
|
float res = sextypeSat[index] / sextypeCount[index];
|
||||||
return float.IsNaN(res) ? 0f : res;
|
return float.IsNaN(res) ? 0f : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetSexCount(int index)
|
public int GetSexCount(int sextype) => sextypeCount[sextype];
|
||||||
{
|
|
||||||
return sextypecount[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void PostExposeData()
|
public override void PostExposeData()
|
||||||
{
|
{
|
||||||
|
@ -248,9 +202,9 @@ namespace RJWSexperience
|
||||||
|
|
||||||
if (Scribe.mode == LoadSaveMode.Saving)
|
if (Scribe.mode == LoadSaveMode.Saving)
|
||||||
{
|
{
|
||||||
sextypecountsave = sextypecount.ToList();
|
sextypecountsave = sextypeCount.ToList();
|
||||||
sextypesatsave = sextypesat.ToList();
|
sextypesatsave = sextypeSat.ToList();
|
||||||
sextyperecenttickabssave = sextyperecenttickabs.ToList();
|
sextyperecenttickabssave = sextypeRecentTickAbs.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -261,15 +215,15 @@ namespace RJWSexperience
|
||||||
|
|
||||||
Scribe_Collections.Look(ref histories, "histories", LookMode.Value, LookMode.Deep);
|
Scribe_Collections.Look(ref histories, "histories", LookMode.Value, LookMode.Deep);
|
||||||
Scribe_Values.Look(ref first, "first", string.Empty);
|
Scribe_Values.Look(ref first, "first", string.Empty);
|
||||||
Scribe_Values.Look(ref recentsex, "recentsex", xxx.rjwSextype.None);
|
Scribe_Values.Look(ref recentSex, "recentsex", xxx.rjwSextype.None);
|
||||||
Scribe_Values.Look(ref recentsat, "recentsat", 0);
|
Scribe_Values.Look(ref recentSat, "recentsat", 0);
|
||||||
Scribe_Values.Look(ref recentpartner, "recentpartner", string.Empty);
|
Scribe_Values.Look(ref recentPartner, "recentpartner", string.Empty);
|
||||||
Scribe_Values.Look(ref virginstaken, "virginstaken", 0);
|
Scribe_Values.Look(ref virginsTaken, "virginstaken", 0);
|
||||||
Scribe_Values.Look(ref incestuous, "incestous", 0);
|
Scribe_Values.Look(ref incestuous, "incestous", 0);
|
||||||
Scribe_Values.Look(ref bestiality, "bestiality", 0);
|
Scribe_Values.Look(ref bestiality, "bestiality", 0);
|
||||||
Scribe_Values.Look(ref corpsefuck, "corpsefuck", 0);
|
Scribe_Values.Look(ref corpsefuck, "corpsefuck", 0);
|
||||||
Scribe_Values.Look(ref interspecies, "interspecies", 0);
|
Scribe_Values.Look(ref interspecies, "interspecies", 0);
|
||||||
Scribe_Values.Look(ref firstsextickabs, "firstsextickabs", 0);
|
Scribe_Values.Look(ref firstSexTickAbs, "firstsextickabs", 0);
|
||||||
Scribe_Collections.Look(ref sextypecountsave, "sextypecountsave", LookMode.Value);
|
Scribe_Collections.Look(ref sextypecountsave, "sextypecountsave", LookMode.Value);
|
||||||
Scribe_Collections.Look(ref sextypesatsave, "sextypesatsave", LookMode.Value);
|
Scribe_Collections.Look(ref sextypesatsave, "sextypesatsave", LookMode.Value);
|
||||||
Scribe_Collections.Look(ref sextyperecenttickabssave, "sextyperecenttickabssave", LookMode.Value);
|
Scribe_Collections.Look(ref sextyperecenttickabssave, "sextyperecenttickabssave", LookMode.Value);
|
||||||
|
@ -279,9 +233,9 @@ namespace RJWSexperience
|
||||||
|
|
||||||
if (Scribe.mode == LoadSaveMode.LoadingVars)
|
if (Scribe.mode == LoadSaveMode.LoadingVars)
|
||||||
{
|
{
|
||||||
sextypecount = sextypecountsave?.ToArray() ?? new int[ARRLEN];
|
sextypeCount = sextypecountsave?.ToArray() ?? new int[ARRLEN];
|
||||||
sextypesat = sextypesatsave?.ToArray() ?? new float[ARRLEN];
|
sextypeSat = sextypesatsave?.ToArray() ?? new float[ARRLEN];
|
||||||
sextyperecenttickabs = sextyperecenttickabssave?.ToArray() ?? new int[ARRLEN];
|
sextypeRecentTickAbs = sextyperecenttickabssave?.ToArray() ?? new int[ARRLEN];
|
||||||
|
|
||||||
foreach (KeyValuePair<string, SexPartnerHistoryRecord> element in histories)
|
foreach (KeyValuePair<string, SexPartnerHistoryRecord> element in histories)
|
||||||
{
|
{
|
||||||
|
@ -291,16 +245,15 @@ namespace RJWSexperience
|
||||||
base.PostExposeData();
|
base.PostExposeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RecordHistory(Pawn partner, SexProps props)
|
public void RecordSex(Pawn partner, SexProps props)
|
||||||
{
|
{
|
||||||
Pawn pawn = parent as Pawn;
|
Pawn pawn = parent as Pawn;
|
||||||
SexPartnerHistoryRecord history = GetPartnerRecord(partner);
|
|
||||||
RecordFirst(partner, props);
|
RecordFirst(partner, props);
|
||||||
recentpartner = partner.ThingID;
|
GetPartnerRecord(partner)?.RecordSex(props);
|
||||||
history?.RecordSex(props);
|
recentPartner = partner.ThingID;
|
||||||
recentsex = props.sexType;
|
recentSex = props.sexType;
|
||||||
sextypecount[(int)props.sexType]++;
|
sextypeCount[(int)props.sexType]++;
|
||||||
sextyperecenttickabs[(int)props.sexType] = GenTicks.TicksAbs;
|
sextypeRecentTickAbs[(int)props.sexType] = GenTicks.TicksAbs;
|
||||||
if (partner.IsIncest(pawn)) incestuous++;
|
if (partner.IsIncest(pawn)) incestuous++;
|
||||||
if (partner.Dead) corpsefuck++;
|
if (partner.Dead) corpsefuck++;
|
||||||
if (props.IsBestiality()) bestiality++;
|
if (props.IsBestiality()) bestiality++;
|
||||||
|
@ -308,16 +261,26 @@ namespace RJWSexperience
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RecordSatisfactionHistory(Pawn partner, SexProps props, float satisfaction)
|
public void RecordSatisfaction(Pawn partner, SexProps props, float satisfaction)
|
||||||
{
|
{
|
||||||
SexPartnerHistoryRecord history = GetPartnerRecord(partner);
|
|
||||||
RecordFirst(partner, props);
|
RecordFirst(partner, props);
|
||||||
history?.RecordSatisfaction(props, satisfaction);
|
GetPartnerRecord(partner)?.RecordSatisfaction(props, satisfaction);
|
||||||
recentsat = satisfaction;
|
recentSat = satisfaction;
|
||||||
sextypesat[(int)props.sexType] += satisfaction;
|
sextypeSat[(int)props.sexType] += satisfaction;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RecordFirst(Pawn partner, SexProps props)
|
||||||
|
{
|
||||||
|
if (VirginCheck() && props.sexType == xxx.rjwSextype.Vaginal)
|
||||||
|
{
|
||||||
|
first = partner.ThingID;
|
||||||
|
SexPartnerHistory history = partner.TryGetComp<SexPartnerHistory>();
|
||||||
|
firstSexTickAbs = GenTicks.TicksAbs;
|
||||||
|
history?.TakeSomeonesVirgin(parent as Pawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected SexPartnerHistoryRecord GetPartnerRecord(Pawn partner)
|
protected SexPartnerHistoryRecord GetPartnerRecord(Pawn partner)
|
||||||
{
|
{
|
||||||
string partnerId = partner.ThingID;
|
string partnerId = partner.ThingID;
|
||||||
|
@ -336,25 +299,14 @@ namespace RJWSexperience
|
||||||
return newRecord;
|
return newRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RecordFirst(Pawn partner, SexProps props)
|
|
||||||
{
|
|
||||||
if (VirginCheck() && props.sexType == xxx.rjwSextype.Vaginal)
|
|
||||||
{
|
|
||||||
GetPartnerRecord(partner);
|
|
||||||
first = partner.ThingID;
|
|
||||||
SexPartnerHistory history = partner.GetPartnerHistory();
|
|
||||||
firstsextickabs = GenTicks.TicksAbs;
|
|
||||||
history?.TakeSomeonesVirgin(parent as Pawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TakeSomeonesVirgin(Pawn partner)
|
public void TakeSomeonesVirgin(Pawn partner)
|
||||||
{
|
{
|
||||||
SexPartnerHistoryRecord partnerRecord = GetPartnerRecord(partner);
|
GetPartnerRecord(partner)?.TookVirgin();
|
||||||
partnerRecord?.TookVirgin();
|
virginsTaken++;
|
||||||
virginstaken++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Cache update
|
||||||
|
|
||||||
protected void Update()
|
protected void Update()
|
||||||
{
|
{
|
||||||
if (dirty)
|
if (dirty)
|
||||||
|
@ -374,9 +326,9 @@ namespace RJWSexperience
|
||||||
string mostID = Keyed.Unknown;
|
string mostID = Keyed.Unknown;
|
||||||
string bestID = Keyed.Unknown;
|
string bestID = Keyed.Unknown;
|
||||||
|
|
||||||
totalsexcache = 0;
|
totalSexCache = 0;
|
||||||
totalrapedcache = 0;
|
totalRapedCache = 0;
|
||||||
totalbeenrapedcache = 0;
|
totalBeenRapedCache = 0;
|
||||||
Dictionary<ThingDef, int> racetotalsat = new Dictionary<ThingDef, int>();
|
Dictionary<ThingDef, int> racetotalsat = new Dictionary<ThingDef, int>();
|
||||||
List<Pawn> allpartners = new List<Pawn>();
|
List<Pawn> allpartners = new List<Pawn>();
|
||||||
|
|
||||||
|
@ -410,22 +362,22 @@ namespace RJWSexperience
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalsexcache += h.TotalSexCount;
|
totalSexCache += h.TotalSexCount;
|
||||||
totalrapedcache += h.Raped;
|
totalRapedCache += h.Raped;
|
||||||
totalbeenrapedcache += h.RapedMe;
|
totalBeenRapedCache += h.RapedMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!racetotalsat.NullOrEmpty())
|
if (!racetotalsat.NullOrEmpty())
|
||||||
{
|
{
|
||||||
KeyValuePair<ThingDef, int> prefer = racetotalsat.MaxBy(x => x.Value);
|
KeyValuePair<ThingDef, int> prefer = racetotalsat.MaxBy(x => x.Value);
|
||||||
preferracecache = prefer.Key;
|
preferRaceCache = prefer.Key;
|
||||||
preferracesexcountcache = prefer.Value;
|
preferRaceSexCountCache = prefer.Value;
|
||||||
preferracepawncache = allpartners.FirstOrDefault(x => x.def == preferracecache);
|
preferRacePawnCache = allpartners.Find(x => x.def == preferRaceCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sextypecount.Length; i++)
|
for (int i = 0; i < sextypeCount.Length; i++)
|
||||||
{
|
{
|
||||||
float avgsat = sextypesat[i] / sextypecount[i];
|
float avgsat = sextypeSat[i] / sextypeCount[i];
|
||||||
if (maxf < avgsat)
|
if (maxf < avgsat)
|
||||||
{
|
{
|
||||||
maxf = avgsat;
|
maxf = avgsat;
|
||||||
|
@ -433,14 +385,14 @@ namespace RJWSexperience
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mostsatsextypecache = (xxx.rjwSextype)maxindex;
|
mostSatSextypeCache = (xxx.rjwSextype)maxindex;
|
||||||
mostsextypecache = (xxx.rjwSextype)sextypecount.FirstIndexOf(x => x == sextypecount.Max());
|
mostSextypeCache = (xxx.rjwSextype)sextypeCount.FirstIndexOf(x => x == sextypeCount.Max());
|
||||||
mostpartnercache = mostID;
|
mostPartnerCache = mostID;
|
||||||
bestpartnercache = bestID;
|
bestPartnerCache = bestID;
|
||||||
|
|
||||||
recentsextickabscache = histories.TryGetValue(recentpartner)?.RecentSexTickAbs ?? 0;
|
recentSexTickAbsCache = histories.TryGetValue(recentPartner)?.RecentSexTickAbs ?? 0;
|
||||||
mostsextickabscache = histories.TryGetValue(mostpartnercache)?.RecentSexTickAbs ?? 0;
|
mostSexTickAbsCache = histories.TryGetValue(mostPartnerCache)?.RecentSexTickAbs ?? 0;
|
||||||
bestsextickabscache = histories.TryGetValue(bestpartnercache)?.BestSexTickAbs ?? 0;
|
bestSexTickAbsCache = histories.TryGetValue(bestPartnerCache)?.BestSexTickAbs ?? 0;
|
||||||
|
|
||||||
racetotalsat.Clear();
|
racetotalsat.Clear();
|
||||||
allpartners.Clear();
|
allpartners.Clear();
|
||||||
|
@ -451,19 +403,21 @@ namespace RJWSexperience
|
||||||
int bestindex = 0;
|
int bestindex = 0;
|
||||||
float bestsat = 0;
|
float bestsat = 0;
|
||||||
float avgsat;
|
float avgsat;
|
||||||
for (int i = 0; i < sextypecount.Length; i++)
|
for (int i = 0; i < sextypeCount.Length; i++)
|
||||||
{
|
{
|
||||||
avgsat = sextypesat[i] / sextypecount[i];
|
avgsat = sextypeSat[i] / sextypeCount[i];
|
||||||
if (bestsat < avgsat)
|
if (bestsat < avgsat)
|
||||||
{
|
{
|
||||||
bestindex = i;
|
bestindex = i;
|
||||||
bestsat = avgsat;
|
bestsat = avgsat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bestsextypecache = (xxx.rjwSextype)bestindex;
|
bestSextypeCache = (xxx.rjwSextype)bestindex;
|
||||||
bestsextypesatcache = bestsat;
|
bestSextypeSatCache = bestsat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion Cache update
|
||||||
|
|
||||||
protected bool VirginCheck()
|
protected bool VirginCheck()
|
||||||
{
|
{
|
||||||
if (histories.TryGetValue(first) != null) return false;
|
if (histories.TryGetValue(first) != null) return false;
|
||||||
|
|
|
@ -84,9 +84,18 @@ namespace RJWSexperience.UI
|
||||||
|
|
||||||
public static string GetSexDays(int absticks, bool printUnknown = false)
|
public static string GetSexDays(int absticks, bool printUnknown = false)
|
||||||
{
|
{
|
||||||
if (absticks != 0) return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago;
|
if (absticks != 0)
|
||||||
else if (printUnknown) return Keyed.Unknown;
|
return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago;
|
||||||
else return "";
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace RJWSexperience.UI
|
||||||
Pawn p = selected.First();
|
Pawn p = selected.First();
|
||||||
if (p != pawn)
|
if (p != pawn)
|
||||||
{
|
{
|
||||||
SexPartnerHistory h = p.GetPartnerHistory();
|
SexPartnerHistory h = p.TryGetComp<SexPartnerHistory>();
|
||||||
if (h != null) ChangePawn(p, h);
|
if (h != null) ChangePawn(p, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ namespace RJWSexperience.UI
|
||||||
Widgets.DrawHighlightIfMouseover(portraitRect);
|
Widgets.DrawHighlightIfMouseover(portraitRect);
|
||||||
if (Widgets.ButtonInvisible(portraitRect))
|
if (Widgets.ButtonInvisible(portraitRect))
|
||||||
{
|
{
|
||||||
SexPartnerHistory pawnhistory = partner?.GetPartnerHistory();
|
SexPartnerHistory pawnhistory = partner?.TryGetComp<SexPartnerHistory>();
|
||||||
if (pawnhistory != null)
|
if (pawnhistory != null)
|
||||||
{
|
{
|
||||||
ChangePawn(partner, pawnhistory);
|
ChangePawn(partner, pawnhistory);
|
||||||
|
@ -284,10 +284,10 @@ namespace RJWSexperience.UI
|
||||||
{
|
{
|
||||||
Listing_Standard listmain = new Listing_Standard();
|
Listing_Standard listmain = new Listing_Standard();
|
||||||
listmain.Begin(rect.ContractedBy(4f));
|
listmain.Begin(rect.ContractedBy(4f));
|
||||||
DrawSexInfoCard(listmain.GetRect(CARDHEIGHT), history.GetRecentPartnersHistory, Keyed.RS_Recent_Sex_Partner, Keyed.RS_Recent_Sex_Partner_ToolTip, history.RecentSexDays);
|
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, history.FirstSexDays);
|
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, history.MostSexDays);
|
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, history.BestSexDays);
|
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);
|
GUI.Label(listmain.GetRect(FONTHEIGHT), Keyed.RS_PreferRace, fontstyleleft);
|
||||||
DrawPreferRace(listmain.GetRect(66f + 15f));
|
DrawPreferRace(listmain.GetRect(66f + 15f));
|
||||||
listmain.GetRect(15f);
|
listmain.GetRect(15f);
|
||||||
|
@ -304,7 +304,7 @@ namespace RJWSexperience.UI
|
||||||
|
|
||||||
if (history.PreferRace != null)
|
if (history.PreferRace != null)
|
||||||
{
|
{
|
||||||
Widgets.DrawTextureFitted(portraitRect, history.GetPreferRaceIcon(portraitRect.size), 1.0f);
|
Widgets.DrawTextureFitted(portraitRect, RJWUIUtility.GetRaceIcon(history.PreferRacePawn, portraitRect.size), 1.0f);
|
||||||
GUI.Label(infoRect1, history.PreferRace?.label.CapitalizeFirst() ?? Keyed.None, fontstyleleft);
|
GUI.Label(infoRect1, history.PreferRace?.label.CapitalizeFirst() ?? Keyed.None, fontstyleleft);
|
||||||
GUI.Label(infoRect2, Keyed.RS_Sex_Count + history.PreferRaceSexCount, fontstyleleft);
|
GUI.Label(infoRect2, Keyed.RS_Sex_Count + history.PreferRaceSexCount, fontstyleleft);
|
||||||
if (history.PreferRace != pawn.def)
|
if (history.PreferRace != pawn.def)
|
||||||
|
@ -519,7 +519,7 @@ namespace RJWSexperience.UI
|
||||||
FillableBarLabeled(tmpRect, label, relativeSat, HistoryUtility.SextypeColor[sexindex], Texture2D.blackTexture, null, Keyed.RS_SAT_AVG(String.Format("{0:P2}", p)));
|
FillableBarLabeled(tmpRect, label, relativeSat, HistoryUtility.SextypeColor[sexindex], Texture2D.blackTexture, null, Keyed.RS_SAT_AVG(String.Format("{0:P2}", p)));
|
||||||
if (Mouse.IsOver(tmpRect))
|
if (Mouse.IsOver(tmpRect))
|
||||||
{
|
{
|
||||||
TooltipHandler.TipRegion(tmpRect, Keyed.RS_LastSex.CapitalizeFirst() + ": " + history.SextypeRecentDays(Sextype[i]));
|
TooltipHandler.TipRegion(tmpRect, Keyed.RS_LastSex.CapitalizeFirst() + ": " + RJWUIUtility.GetSexDays(history.GetSextypeRecentTickAbs(Sextype[i]), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
listmain.Gap(1f);
|
listmain.Gap(1f);
|
||||||
|
|
Loading…
Reference in New Issue