mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Rename source folder
This commit is contained in:
parent
0a412a0060
commit
a4c046a841
55 changed files with 0 additions and 0 deletions
38
Source/RJWSexperience/Utility.cs
Normal file
38
Source/RJWSexperience/Utility.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public static class Utility
|
||||
{
|
||||
private static readonly Random random = new Random(Environment.TickCount);
|
||||
|
||||
public static float RandGaussianLike(float min, float max, int iterations = 3)
|
||||
{
|
||||
double res = 0;
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
res += random.NextDouble();
|
||||
}
|
||||
res /= iterations;
|
||||
|
||||
return ((float)res).Denormalization(min, max);
|
||||
}
|
||||
|
||||
public static void SetTo(this Pawn_RecordsTracker records, RecordDef record, float value)
|
||||
{
|
||||
float recordval = records.GetValue(record);
|
||||
records.AddTo(record, value - recordval);
|
||||
}
|
||||
|
||||
public static float Normalization(this float num, float min, float max)
|
||||
{
|
||||
return (num - min) / (max - min);
|
||||
}
|
||||
|
||||
public static float Denormalization(this float num, float min, float max)
|
||||
{
|
||||
return (num * (max - min)) + min;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue