Refactored RecordRandomizer

This commit is contained in:
amevarashi 2023-12-10 11:51:29 +05:00
parent 3c4060f8bd
commit b99b74e27b
2 changed files with 130 additions and 90 deletions

View file

@ -18,13 +18,25 @@ namespace RJWSexperience
return ((float)res).Denormalization(min, max);
}
/// <summary>
/// Set exact <paramref name="value"/> for the <paramref name="record"/>
/// </summary>
public static void SetTo(this Pawn_RecordsTracker records, RecordDef record, float value)
{
float recordval = records.GetValue(record);
records.AddTo(record, value - recordval);
}
/// <summary>
/// Set exact <paramref name="value"/> for the <paramref name="record"/>
/// </summary>
public static void Set(this Pawn_RecordsTracker records, RecordDef record, int value)
{
int currentValue = records.GetAsInt(record);
records.AddTo(record, value - currentValue);
}
public static float Normalization(this float num, float min, float max)
{
return (num - min) / (max - min);