Replace usages of System.Random with RW's Rand

This commit is contained in:
lutepickle 2022-07-18 07:05:39 -07:00
parent 697b837a4d
commit 8b93398466
2 changed files with 7 additions and 10 deletions

View file

@ -204,7 +204,6 @@ namespace RJW_Menstruation
List<Trait> momtraits = new List<Trait>();
List<Trait> poptraits = new List<Trait>();
List<Trait> traits_to_inherit = new List<Trait>();
System.Random rd = new System.Random();
float max_num_momtraits_inherited = RJWPregnancySettings.max_num_momtraits_inherited;
float max_num_poptraits_inherited = RJWPregnancySettings.max_num_poptraits_inherited;
float max_num_traits_inherited = max_num_momtraits_inherited + max_num_poptraits_inherited;
@ -232,7 +231,7 @@ namespace RJW_Menstruation
i = 1;
while (momtraits.Count > 0 && i <= max_num_momtraits_inherited)
{
rand_trait_index = rd.Next(0, momtraits.Count);
rand_trait_index = Rand.Range(0, momtraits.Count);
traits_to_inherit.Add(momtraits[rand_trait_index]);
momtraits.RemoveAt(rand_trait_index);
}
@ -242,7 +241,7 @@ namespace RJW_Menstruation
j = 1;
while (poptraits.Count > 0 && j <= max_num_poptraits_inherited)
{
rand_trait_index = rd.Next(0, poptraits.Count);
rand_trait_index = Rand.Range(0, poptraits.Count);
traits_to_inherit.Add(poptraits[rand_trait_index]);
poptraits.RemoveAt(rand_trait_index);
}
@ -263,7 +262,7 @@ namespace RJW_Menstruation
{
while (poptraits != null && momtraits.Count() > 0 && i <= max_num_momtraits_inherited)
{
rand_trait_index = rd.Next(0, momtraits.Count);
rand_trait_index = Rand.Range(0, momtraits.Count);
if (!traits_to_inherit.Contains(momtraits[rand_trait_index]))
{
traits_to_inherit.Add(momtraits[rand_trait_index]);
@ -275,7 +274,7 @@ namespace RJW_Menstruation
{
while (poptraits.Count > 0 && i < max_num_poptraits_inherited)
{
rand_trait_index = rd.Next(0, poptraits.Count);
rand_trait_index = Rand.Range(0, poptraits.Count);
if (!traits_to_inherit.Contains(poptraits[rand_trait_index]))
{
traits_to_inherit.Add(poptraits[rand_trait_index]);

View file

@ -47,8 +47,6 @@ namespace RJW_Menstruation
public static class Utility
{
public static System.Random random = new System.Random(Environment.TickCount);
public static PawnKindDef GetRacesPawnKind(Pawn pawn)
{
if (pawn == null) return null;
@ -404,14 +402,14 @@ namespace RJW_Menstruation
public static float RandGaussianLike(float min, float max, int iterations = 3)
{
double res = 0;
float res = 0;
for (int i = 0; i < iterations; i++)
{
res += random.NextDouble();
res += Rand.Value;
}
res /= iterations;
return (float)res * (max - min) + min;
return res * (max - min) + min;
}