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

@@ -1,4 +1,5 @@
using Content.Shared.Dataset;
using Content.Shared.Random.Helpers;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -47,13 +48,19 @@ public sealed class RandomMetadataSystem : EntitySystem
var outputSegments = new List<string>();
foreach (var segment in segments)
{
if (_prototype.TryIndex<DatasetPrototype>(segment, out var proto)) {
if (_prototype.TryIndex<LocalizedDatasetPrototype>(segment, out var localizedProto))
{
outputSegments.Add(_random.Pick(localizedProto));
}
else if (_prototype.TryIndex<DatasetPrototype>(segment, out var proto))
{
var random = _random.Pick(proto.Values);
if (Loc.TryGetString(random, out var localizedSegment))
outputSegments.Add(localizedSegment);
else
outputSegments.Add(random);
} else if (Loc.TryGetString(segment, out var localizedSegment))
}
else if (Loc.TryGetString(segment, out var localizedSegment))
outputSegments.Add(localizedSegment);
else
outputSegments.Add(segment);