Remove some more code warnings

This commit is contained in:
amevarashi 2022-04-03 22:20:14 +05:00
parent 99d3d18d8a
commit 89439d1f32
6 changed files with 207 additions and 216 deletions

View file

@ -1,22 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using System.Reflection;
using Verse;
using HarmonyLib;
namespace RJWSexperience
{
[StaticConstructorOnStartup]
internal static class First
{
static First()
{
var har = new Harmony("RJW_Sexperience");
har.PatchAll(Assembly.GetExecutingAssembly());
}
}
[StaticConstructorOnStartup]
internal static class First
{
static First()
{
var har = new Harmony("RJW_Sexperience");
har.PatchAll(Assembly.GetExecutingAssembly());
}
}
}

View file

@ -1,16 +1,16 @@
using RimWorld;
using RJWSexperience.ExtensionMethods;
using Verse;
namespace RJWSexperience
{
public class CumOutcomeDoers : IngestionOutcomeDoer
{
public float unitAmount = 1.0f;
public class CumOutcomeDoers : IngestionOutcomeDoer
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float unitAmount = 1.0f;
protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
{
pawn.AteCum(ingested.stackCount * unitAmount);
}
}
protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
{
pawn.AteCum(ingested.stackCount * unitAmount);
}
}
}

View file

@ -282,8 +282,7 @@ namespace RJWSexperience
foreach (KeyValuePair<string, SexPartnerHistoryRecord> element in histories)
{
element.Value.parent = this;
element.Value.partnerID = element.Key;
element.Value.PartnerID = element.Key;
}
}
base.PostExposeData();

View file

@ -1,91 +1,86 @@
using System;
using RimWorld;
using rjw;
using RJWSexperience.ExtensionMethods;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using rjw;
using UnityEngine;
using RJWSexperience.ExtensionMethods;
namespace RJWSexperience
{
public class SexPartnerHistoryRecord : IExposable
{
public SexPartnerHistory parent;
public string partnerID;
public class SexPartnerHistoryRecord : IExposable
{
public string PartnerID { get; set; }
protected Pawn partner = null;
protected string namecache;
protected int totalsexhad = 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 race;
protected Pawn partner = null;
protected string namecache;
protected int totalsexhad = 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 race;
public string Label
{
get
{
if (partner != null)
{
namecache = partner.Label;
return namecache;
}
else return namecache;
}
}
public xxx.rjwSextype BestSextype
{
get
{
return bestsextype;
}
}
public float BestSatisfaction
{
get
{
return bestsatisfaction;
}
}
public int TotalSexCount
{
get
{
return totalsexhad;
}
}
public Pawn Partner
{
get
{
if (!cannotLoadPawnData && partner == null)
{
LoadPartnerPawn(partnerID);
if (partner == null) cannotLoadPawnData = true;
}
return partner;
}
}
public string RapeInfo
{
get
{
string res = "";
if (raped > 0) res += Keyed.RS_Raped + raped + " ";
if (rapedme > 0) res += Keyed.RS_RapedMe + rapedme + " ";
return res;
}
}
public string Label
{
get
{
if (partner != null)
{
namecache = partner.Label;
return namecache;
}
else return namecache;
}
}
public xxx.rjwSextype BestSextype
{
get
{
return bestsextype;
}
}
public float BestSatisfaction
{
get
{
return bestsatisfaction;
}
}
public int TotalSexCount
{
get
{
return totalsexhad;
}
}
public Pawn Partner
{
get
{
if (!cannotLoadPawnData && partner == null)
{
LoadPartnerPawn(PartnerID);
if (partner == null) cannotLoadPawnData = true;
}
return partner;
}
}
public string RapeInfo
{
get
{
string res = "";
if (raped > 0) res += Keyed.RS_Raped + raped + " ";
if (rapedme > 0) res += Keyed.RS_RapedMe + rapedme + " ";
return res;
}
}
public int OrgasmCount => orgasms;
public bool IamFirst => itookvirgin;
public bool Incest => incest;
@ -95,118 +90,118 @@ namespace RJWSexperience
public int BestSexTickAbs => bestsextickabs;
public int BestSexElapsedTicks => GenTicks.TicksAbs - bestsextickabs;
public string BestSexDays
{
get
{
if (bestsextickabs != 0) return Keyed.RS_HadBestSexDaysAgo(GenDate.ToStringTicksToDays(BestSexElapsedTicks) + " " + Keyed.RS_Ago);
return "";
}
}
public ThingDef Race
{
get
{
if (Partner != null)
{
race = Partner.def;
return race;
}
else return race;
}
}
{
get
{
if (bestsextickabs != 0) return Keyed.RS_HadBestSexDaysAgo(GenDate.ToStringTicksToDays(BestSexElapsedTicks) + " " + Keyed.RS_Ago);
return "";
}
}
public ThingDef Race
{
get
{
if (Partner != null)
{
race = Partner.def;
return race;
}
else return race;
}
}
public SexPartnerHistoryRecord() { }
public SexPartnerHistoryRecord() { }
public SexPartnerHistoryRecord(Pawn pawn, bool incest = false)
{
this.partner = pawn;
this.namecache = pawn.Label;
this.incest = incest;
this.race = pawn.def;
}
public SexPartnerHistoryRecord(Pawn pawn, bool incest = false)
{
this.partner = pawn;
this.namecache = pawn.Label;
this.incest = incest;
this.race = pawn.def;
}
public void ExposeData()
{
Scribe_Values.Look(ref namecache, "namecache", namecache, true);
Scribe_Values.Look(ref totalsexhad, "totalsexhad", totalsexhad, true);
Scribe_Values.Look(ref raped, "raped", raped, true);
Scribe_Values.Look(ref rapedme, "rapedme", rapedme, true);
Scribe_Values.Look(ref orgasms, "orgasms", orgasms, true);
Scribe_Values.Look(ref bestsextype, "bestsextype", bestsextype, true);
Scribe_Values.Look(ref bestsatisfaction, "bestsatisfaction", bestsatisfaction, true);
Scribe_Values.Look(ref itookvirgin, "itookvirgin", itookvirgin, true);
Scribe_Values.Look(ref incest, "incest", incest, true);
Scribe_Values.Look(ref recentsextickabs, "recentsextickabs", recentsextickabs, true);
Scribe_Values.Look(ref bestsextickabs, "bestsextickabs", bestsextickabs, true);
Scribe_Defs.Look(ref race, "race");
}
public void ExposeData()
{
Scribe_Values.Look(ref namecache, "namecache", namecache, true);
Scribe_Values.Look(ref totalsexhad, "totalsexhad", totalsexhad, true);
Scribe_Values.Look(ref raped, "raped", raped, true);
Scribe_Values.Look(ref rapedme, "rapedme", rapedme, true);
Scribe_Values.Look(ref orgasms, "orgasms", orgasms, true);
Scribe_Values.Look(ref bestsextype, "bestsextype", bestsextype, true);
Scribe_Values.Look(ref bestsatisfaction, "bestsatisfaction", bestsatisfaction, true);
Scribe_Values.Look(ref itookvirgin, "itookvirgin", itookvirgin, true);
Scribe_Values.Look(ref incest, "incest", incest, true);
Scribe_Values.Look(ref recentsextickabs, "recentsextickabs", recentsextickabs, true);
Scribe_Values.Look(ref bestsextickabs, "bestsextickabs", bestsextickabs, true);
Scribe_Defs.Look(ref race, "race");
}
public void RecordSex(SexProps props)
{
totalsexhad++;
if (props.isRape)
{
if (partner == props.GetInteractionInitiator())
{
rapedme++;
}
else if (partner == props.GetInteractionRecipient())
{
raped++;
}
}
recentsextickabs = GenTicks.TicksAbs;
}
public void RecordSex(SexProps props)
{
totalsexhad++;
if (props.isRape)
{
if (partner == props.GetInteractionInitiator())
{
rapedme++;
}
else if (partner == props.GetInteractionRecipient())
{
raped++;
}
}
recentsextickabs = GenTicks.TicksAbs;
}
public void RecordSatisfaction(SexProps props, float satisfaction)
{
if (satisfaction > bestsatisfaction)
{
orgasms++;
bestsextype = props.sexType;
bestsatisfaction = satisfaction;
bestsextickabs = GenTicks.TicksAbs;
}
}
public void RecordSatisfaction(SexProps props, float satisfaction)
{
if (satisfaction > bestsatisfaction)
{
orgasms++;
bestsextype = props.sexType;
bestsatisfaction = satisfaction;
bestsextickabs = GenTicks.TicksAbs;
}
}
public void TookVirgin()
{
itookvirgin = true;
}
public void TookVirgin()
{
itookvirgin = true;
}
protected void LoadPartnerPawn(string partnerID)
{
foreach (Map map in Find.Maps)
{
partner = map.mapPawns.AllPawns.FirstOrDefault(x => x.ThingID.Equals(partnerID));
if (partner != null) return;
}
partner = Find.WorldPawns.AllPawnsAliveOrDead.FirstOrDefault(x => x.ThingID.Equals(partnerID));
}
protected void LoadPartnerPawn(string partnerID)
{
foreach (Map map in Find.Maps)
{
partner = map.mapPawns.AllPawns.FirstOrDefault(x => x.ThingID.Equals(partnerID));
if (partner != null) return;
}
partner = Find.WorldPawns.AllPawnsAliveOrDead.FirstOrDefault(x => x.ThingID.Equals(partnerID));
}
public class RecentOrderComparer : IComparer<SexPartnerHistoryRecord>
{
public int Compare(SexPartnerHistoryRecord x, SexPartnerHistoryRecord y)
{
return y.RecentSexTickAbs.CompareTo(x.RecentSexTickAbs);
}
}
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 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);
}
}
}
public class NameOrderComparer : IComparer<SexPartnerHistoryRecord>
{
public int Compare(SexPartnerHistoryRecord x, SexPartnerHistoryRecord y)
{
return x.Label.CompareTo(y.Label);
}
}
}
}

View file

@ -8,7 +8,7 @@ namespace RJWSexperience
{
get
{
if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false) return minimumValueforStage.Count;
if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false) return MinimumValueforStage.Count;
return base.CurStageIndex;
}
}

View file

@ -1,5 +1,6 @@
using RimWorld;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace RJWSexperience
{
@ -8,7 +9,9 @@ namespace RJWSexperience
/// </summary>
public class ThoughtDef_Recordbased : ThoughtDef
{
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public RecordDef recordDef;
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public List<float> minimumValueforStage = new List<float>();
}
@ -18,17 +21,17 @@ namespace RJWSexperience
public class Thought_Recordbased : Thought_Memory
{
protected ThoughtDef_Recordbased Def => (ThoughtDef_Recordbased)def;
protected RecordDef recordDef => Def.recordDef;
protected List<float> minimumValueforStage => Def.minimumValueforStage;
protected RecordDef RecordDef => Def.recordDef;
protected List<float> MinimumValueforStage => Def.minimumValueforStage;
public override int CurStageIndex
{
get
{
float value = pawn?.records?.GetValue(recordDef) ?? 0f;
for (int i = minimumValueforStage.Count - 1; i > 0; i--)
float value = pawn?.records?.GetValue(RecordDef) ?? 0f;
for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
{
if (minimumValueforStage[i] < value) return i + 1;
if (MinimumValueforStage[i] < value) return i + 1;
}
return 0;
}