Add IRobustRandom extension to get a random value from a data set (#3260)
* Add extension to pick a random element from a dataset * Add tests
This commit is contained in:
13
Content.Shared/Utility/SharedRandomExtensions.cs
Normal file
13
Content.Shared/Utility/SharedRandomExtensions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Content.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared.Utility
|
||||
{
|
||||
public static class SharedRandomExtensions
|
||||
{
|
||||
public static string Pick(this IRobustRandom random, DatasetPrototype prototype)
|
||||
{
|
||||
return random.Pick(prototype.Values);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user