Add IRobustRandom.SetSeed() (#4606)

This commit is contained in:
Leon Friedrich
2023-11-25 18:32:16 -05:00
committed by GitHub
parent b6cadfedd5
commit 89c1e90646
2 changed files with 7 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ public interface IRobustRandom
/// </summary>
/// <returns></returns>
System.Random GetRandom();
void SetSeed(int seed);
float NextFloat();
public float NextFloat(float minValue, float maxValue)

View File

@@ -5,10 +5,15 @@ namespace Robust.Shared.Random
{
public sealed class RobustRandom : IRobustRandom
{
private readonly System.Random _random = new();
private System.Random _random = new();
public System.Random GetRandom() => _random;
public void SetSeed(int seed)
{
_random = new(seed);
}
public float NextFloat()
{
return _random.NextFloat();