Add Random.Prob extension method helper.

This commit is contained in:
Pieter-Jan Briers
2019-04-27 21:16:30 +02:00
parent b2067da28f
commit 0d00a6a659

View File

@@ -32,5 +32,15 @@ namespace Robust.Shared.Maths
{
return (float)random.NextDouble();
}
/// <summary>
/// Have a certain chance to return a boolean.
/// </summary>
/// <param name="random">The random instance to run on.</param>
/// <param name="chance">The chance to pass, from 0 to 1.</param>
public static bool Prob(this Random random, float chance)
{
return random.NextDouble() <= chance;
}
}
}