mirror of
https://gitgud.io/amevarashi/rjw-sexperience-ideology.git
synced 2024-08-15 00:43:19 +00:00
Fix folders and namespaces (except for the Rituals)
This commit is contained in:
parent
17a8264b49
commit
075260f091
47 changed files with 46 additions and 138 deletions
43
Source/IdeologyAddon/StatParts.cs
Normal file
43
Source/IdeologyAddon/StatParts.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using RimWorld;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Ideology
|
||||
{
|
||||
public class StatPart_GenderPrimacy : StatPart
|
||||
{
|
||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||
public float modifier;
|
||||
|
||||
public override string ExplanationPart(StatRequest req)
|
||||
{
|
||||
if (!req.HasThing || !(req.Thing is Pawn pawn))
|
||||
return null;
|
||||
|
||||
return $"{Keyed.MemeStatFactor}: x{GetModifier(pawn).ToStringPercent()}";
|
||||
}
|
||||
|
||||
public override void TransformValue(StatRequest req, ref float val)
|
||||
{
|
||||
if (!req.HasThing || !(req.Thing is Pawn pawn))
|
||||
return;
|
||||
|
||||
val *= GetModifier(pawn);
|
||||
}
|
||||
|
||||
private float GetModifier(Pawn pawn)
|
||||
{
|
||||
if (pawn.Ideo == null)
|
||||
return 1f;
|
||||
|
||||
Gender supremeGender = pawn.Ideo.SupremeGender;
|
||||
|
||||
if (pawn.gender == supremeGender)
|
||||
return modifier;
|
||||
else if (pawn.gender == supremeGender.Opposite())
|
||||
return 1f / modifier;
|
||||
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue