This commit is contained in:
moreoreganostodump 2021-09-13 00:46:32 +09:00
parent 44bc2ae59a
commit 0381e2140f
6 changed files with 97 additions and 11 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest> <Manifest>
<identifier>RJW Sexperience</identifier> <identifier>RJW Sexperience</identifier>
<version>1.0.2.0</version> <version>1.0.1.11</version>
<dependencies> <dependencies>
</dependencies> </dependencies>
<incompatibleWith /> <incompatibleWith />

Binary file not shown.

View file

@ -12,6 +12,9 @@ namespace RJWSexperience
{ {
public class SexPartnerHistory : ThingComp public class SexPartnerHistory : ThingComp
{ {
public SexPartnerHistory() { }
//protected List<SexHistory> histories = new List<SexHistory>(); //protected List<SexHistory> histories = new List<SexHistory>();
protected Dictionary<string,SexHistory> histories = new Dictionary<string,SexHistory>(); protected Dictionary<string,SexHistory> histories = new Dictionary<string,SexHistory>();
protected string first = ""; protected string first = "";
@ -20,22 +23,49 @@ namespace RJWSexperience
protected float bestaffinitysat = 0; protected float bestaffinitysat = 0;
protected xxx.rjwSextype recentsex = xxx.rjwSextype.None; protected xxx.rjwSextype recentsex = xxx.rjwSextype.None;
protected string recentpartner = ""; protected string recentpartner = "";
protected int[] sextypecount = new int[20];
protected float[] sextypesat = new float[20];
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;
public string FirstSexInfo public string FirstSexInfo
{ {
get get
{ {
Update();
return return
"Partner: " + histories[first]?.Label ?? "Unknown" + "Partner: " + histories.TryGetValue(first)?.Label ?? "Unknown" +
"" +
"" +
""; "";
} }
} }
public string MostSexPartner
{
get
{
Update();
return histories.TryGetValue(mostpartnercache)?.Label ?? "Unknown";
}
}
public xxx.rjwSextype MostSextype
{
get
{
Update();
return mostsextypecache;
}
}
public xxx.rjwSextype MostSatisfiedSex
{
get
{
Update();
return mostsatsextypecache;
}
}
public override void PostExposeData() public override void PostExposeData()
@ -46,23 +76,30 @@ namespace RJWSexperience
Scribe_Values.Look(ref bestaffinitysat, "bestaffinitysat", bestaffinitysat, true); Scribe_Values.Look(ref bestaffinitysat, "bestaffinitysat", bestaffinitysat, true);
Scribe_Values.Look(ref recentsex, "recentsex", recentsex, true); Scribe_Values.Look(ref recentsex, "recentsex", recentsex, true);
Scribe_Values.Look(ref recentpartner, "recentpartner", recentpartner, true); Scribe_Values.Look(ref recentpartner, "recentpartner", recentpartner, true);
Scribe_Values.Look(ref sextypecount, "sextypecount", sextypecount, true);
Scribe_Values.Look(ref sextypesat, "sextypesat", sextypesat, true);
base.PostExposeData(); base.PostExposeData();
} }
public void RecordHistory(Pawn partner, SexProps props) public void RecordHistory(Pawn partner, SexProps props)
{ {
TryAddHistory(partner); TryAddHistory(partner);
recentpartner = partner.ThingID;
SexHistory history = histories[partner.ThingID]; SexHistory history = histories[partner.ThingID];
history?.RecordSex(props); history?.RecordSex(props);
recentsex = props.sexType;
sextypecount[(int)props.sexType]++;
dirty = true; dirty = true;
} }
public void RecordSatisfactionHistory(Pawn partner, SexProps props, float satisfaction) public void RecordSatisfactionHistory(Pawn partner, SexProps props, float satisfaction)
{ {
TryAddHistory(partner); TryAddHistory(partner);
RecordFirst(partner, props);
SexHistory history = histories[partner.ThingID]; SexHistory history = histories[partner.ThingID];
history?.RecordSatisfaction(props, satisfaction); history?.RecordSatisfaction(props, satisfaction);
sextypesat[(int)props.sexType] += satisfaction;
dirty = true; dirty = true;
} }
@ -91,7 +128,46 @@ namespace RJWSexperience
protected void Update() protected void Update()
{ {
dirty = false; if (dirty)
{
UpdateStatistics();
dirty = false;
}
}
protected void UpdateStatistics()
{
int max = 0;
float maxf = 0;
int maxindex = 0;
string mostID = "Unknown";
foreach (KeyValuePair<string,SexHistory> element in histories)
{
SexHistory h = element.Value;
//find most sex partner
if (max < h.TotalSexCount)
{
max = h.TotalSexCount;
mostID = element.Key;
}
}
max = 0;
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;
} }
protected bool VirginCheck() protected bool VirginCheck()
@ -146,6 +222,14 @@ namespace RJWSexperience
return bestsatisfaction; return bestsatisfaction;
} }
} }
public int TotalSexCount
{
get
{
return totalsexhad;
}
}
public SexHistory() { } public SexHistory() { }

View file

@ -3,8 +3,8 @@
<!-- Issues --> <!-- Issues -->
<IssueDef> <IssueDef>
<defName>Birth</defName> <defName>Rape</defName>
<label>birth</label> <label>rape</label>
<iconPath>UI/Issues/Rape</iconPath> <iconPath>UI/Issues/Rape</iconPath>
</IssueDef> </IssueDef>

View file

@ -1,10 +1,12 @@
Version Beta 1.0.2.0 Version Beta 1.0.2.0
- requires RimWorld 1.3.3117 or later
- requires RJW 4.8.1 or later
- added records - added records
- added sex history - added sex history
- -
Version Beta 1.0.1.11
- requires RimWorld 1.3.3117 or later
- requires RJW 4.8.1 or later
Version Beta 1.0.1.10 Version Beta 1.0.1.10
- requires RJW 4.8.0 - requires RJW 4.8.0