RJW-Sexperience/Source/RJWSexperience/SexHistory/SexPartnerHistoryRecord.cs

135 lines
3.4 KiB
C#
Raw Normal View History

2022-05-11 15:37:14 +00:00
using rjw;
2022-04-03 17:20:14 +00:00
using RJWSexperience.ExtensionMethods;
2021-09-24 15:14:02 +00:00
using Verse;
2022-06-13 05:51:09 +00:00
namespace RJWSexperience.SexHistory
2021-09-24 15:14:02 +00:00
{
2022-04-03 17:20:14 +00:00
public class SexPartnerHistoryRecord : IExposable
{
public string PartnerID { get; set; }
2021-10-24 10:26:59 +00:00
2022-04-03 17:20:14 +00:00
protected Pawn partner = null;
2022-05-11 15:37:14 +00:00
protected string labelCache;
protected int totalSexCount = 0;
2022-04-03 17:20:14 +00:00
protected int raped = 0;
2022-05-11 15:37:14 +00:00
protected int rapedMe = 0;
2022-04-03 17:20:14 +00:00
protected int orgasms = 0;
2022-05-11 15:37:14 +00:00
protected xxx.rjwSextype bestSextype = xxx.rjwSextype.None;
protected float bestSatisfaction = 0;
protected bool iTookVirgin = false;
2022-04-03 17:20:14 +00:00
protected bool incest = false;
2022-05-11 15:37:14 +00:00
protected int recentSexTickAbs = 0;
protected int bestSexTickAbs = 0;
2022-04-03 17:20:14 +00:00
protected bool cannotLoadPawnData = false;
2022-05-11 15:37:14 +00:00
protected ThingDef raceCache;
2021-10-24 10:26:59 +00:00
2022-05-11 15:37:14 +00:00
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;
2022-04-03 17:20:14 +00:00
public Pawn Partner
{
get
{
if (!cannotLoadPawnData && partner == null)
{
LoadPartnerPawn(PartnerID);
if (partner == null) cannotLoadPawnData = true;
}
return partner;
}
}
2022-05-11 15:37:14 +00:00
public string Label
2022-04-03 17:20:14 +00:00
{
get
{
2022-05-11 15:37:14 +00:00
if (Partner != null)
labelCache = Partner.Label;
return labelCache;
2022-04-03 17:20:14 +00:00
}
}
public ThingDef Race
{
get
{
if (Partner != null)
2022-05-11 15:37:14 +00:00
raceCache = Partner.def;
return raceCache;
2022-04-03 17:20:14 +00:00
}
}
2021-10-24 10:26:59 +00:00
2022-04-03 17:20:14 +00:00
public SexPartnerHistoryRecord() { }
2021-09-24 15:14:02 +00:00
2022-04-03 17:20:14 +00:00
public SexPartnerHistoryRecord(Pawn pawn, bool incest = false)
{
this.partner = pawn;
2022-05-11 15:37:14 +00:00
this.labelCache = pawn.Label;
2022-04-03 17:20:14 +00:00
this.incest = incest;
2022-05-11 15:37:14 +00:00
this.raceCache = pawn.def;
2022-04-03 17:20:14 +00:00
}
2021-09-24 15:14:02 +00:00
2022-04-03 17:20:14 +00:00
public void ExposeData()
{
2022-05-11 15:37:14 +00:00
Scribe_Values.Look(ref labelCache, "namecache");
Scribe_Values.Look(ref totalSexCount, "totalsexhad", 0);
Scribe_Values.Look(ref raped, "raped", 0);
2022-05-11 15:37:14 +00:00
Scribe_Values.Look(ref rapedMe, "rapedme", 0);
Scribe_Values.Look(ref orgasms, "orgasms", 0);
2022-05-11 15:37:14 +00:00
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);
2022-05-11 15:37:14 +00:00
Scribe_Values.Look(ref recentSexTickAbs, "recentsextickabs", 0);
Scribe_Values.Look(ref bestSexTickAbs, "bestsextickabs", 0);
Scribe_Defs.Look(ref raceCache, "race");
2022-04-03 17:20:14 +00:00
}
2021-09-24 15:14:02 +00:00
2022-04-03 17:20:14 +00:00
public void RecordSex(SexProps props)
{
2022-05-11 15:37:14 +00:00
totalSexCount++;
2022-04-03 17:20:14 +00:00
if (props.isRape)
{
if (partner == props.GetInteractionInitiator())
2022-05-11 15:37:14 +00:00
rapedMe++;
else
2022-04-03 17:20:14 +00:00
raped++;
}
2022-05-11 15:37:14 +00:00
recentSexTickAbs = GenTicks.TicksAbs;
2022-04-03 17:20:14 +00:00
}
2021-09-24 15:14:02 +00:00
public void RecordOrgasm(xxx.rjwSextype sextype, float satisfaction)
2022-04-03 17:20:14 +00:00
{
2022-05-11 15:37:14 +00:00
orgasms++;
if (satisfaction > bestSatisfaction)
2022-04-03 17:20:14 +00:00
{
bestSextype = sextype;
2022-05-11 15:37:14 +00:00
bestSatisfaction = satisfaction;
bestSexTickAbs = GenTicks.TicksAbs;
2022-04-03 17:20:14 +00:00
}
}
2021-09-24 15:14:02 +00:00
2022-04-03 17:20:14 +00:00
public void TookVirgin()
{
2022-05-11 15:37:14 +00:00
iTookVirgin = true;
2022-04-03 17:20:14 +00:00
}
2021-10-24 10:26:59 +00:00
2022-04-03 17:20:14 +00:00
protected void LoadPartnerPawn(string partnerID)
{
foreach (Map map in Find.Maps)
{
2022-05-11 15:37:14 +00:00
partner = map.mapPawns.AllPawns.Find(x => x.ThingID.Equals(partnerID));
2022-04-03 17:20:14 +00:00
if (partner != null) return;
}
2022-05-11 15:37:14 +00:00
partner = Find.WorldPawns.AllPawnsAliveOrDead.Find(x => x.ThingID.Equals(partnerID));
2022-04-03 17:20:14 +00:00
}
2022-05-11 15:37:14 +00:00
}
2021-09-24 15:14:02 +00:00
}