RJW-Sexperience/Source/RJWSexperience/StatParts.cs

56 lines
1.4 KiB
C#
Raw Normal View History

using RimWorld;
2021-07-27 14:28:31 +00:00
using Verse;
2022-03-26 18:11:59 +00:00
using System.Diagnostics.CodeAnalysis;
2021-07-27 14:28:31 +00:00
namespace RJWSexperience
{
/// <summary>
/// Lust changes SexFrequency stat
/// </summary>
public class StatPart_Lust : StatPart
{
public override string ExplanationPart(StatRequest req)
{
if (req.HasThing && (req.Thing is Pawn pawn))
{
2022-05-20 16:25:56 +00:00
return $"{Keyed.Lust.CapitalizeFirst()}: x{GetLustFactor(pawn).ToStringPercent()}";
}
return null;
}
2021-07-27 14:28:31 +00:00
public override void TransformValue(StatRequest req, ref float val)
{
if (req.HasThing && (req.Thing is Pawn pawn))
2022-05-20 16:25:56 +00:00
val *= GetLustFactor(pawn);
}
2021-07-27 14:28:31 +00:00
2022-05-20 16:25:56 +00:00
protected float GetLustFactor(Pawn pawn) => LustUtility.GetLustFactor(pawn.records.GetValue(VariousDefOf.Lust));
}
2021-07-27 14:28:31 +00:00
/// <summary>
/// Make slaves more vulnurable
/// </summary>
public class StatPart_Slave : StatPart
{
2022-03-26 18:11:59 +00:00
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
public float factor;
2021-07-27 14:28:31 +00:00
public override string ExplanationPart(StatRequest req)
{
if (req.HasThing && ((req.Thing as Pawn)?.IsSlave == true))
{
2022-05-20 16:25:56 +00:00
return $"{Keyed.Slave.CapitalizeFirst()}: x{factor.ToStringPercent()}";
}
2022-05-20 16:25:56 +00:00
return null;
}
2021-07-27 14:28:31 +00:00
public override void TransformValue(StatRequest req, ref float val)
{
if (req.HasThing && ((req.Thing as Pawn)?.IsSlave == true))
{
val *= factor;
}
}
}
2021-07-27 14:28:31 +00:00
}