mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Add Random.Prob extension method helper.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user