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:
DrSmugleaf
2021-02-16 20:14:12 +01:00
committed by GitHub
parent b48aa4d543
commit b30bccc03b
2 changed files with 51 additions and 0 deletions

View 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);
}
}
}