Add support for LocalizedDatasets to RandomMetadata (#28601)

This commit is contained in:
Tayrtahn
2024-06-06 02:37:49 -04:00
committed by GitHub
parent fea2bc9422
commit d71b88a747
2 changed files with 14 additions and 3 deletions

View File

@@ -12,9 +12,13 @@ namespace Content.Shared.Random.Helpers
return random.Pick(prototype.Values);
}
/// <summary>
/// Randomly selects an entry from <paramref name="prototype"/>, attempts to localize it, and returns the result.
/// </summary>
public static string Pick(this IRobustRandom random, LocalizedDatasetPrototype prototype)
{
return random.Pick(prototype.Values);
var index = random.Next(prototype.Values.Count);
return Loc.GetString(prototype.Values[index]);
}
public static string Pick(this IWeightedRandomPrototype prototype, System.Random random)