remove evil shitcode from randommetadata (#36324)
* remove evil * fix non-localizeddataset uses --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
using Content.Shared.Dataset;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.RandomMetadata;
|
namespace Content.Server.RandomMetadata;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -6,15 +9,15 @@
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed partial class RandomMetadataComponent : Component
|
public sealed partial class RandomMetadataComponent : Component
|
||||||
{
|
{
|
||||||
[DataField("descriptionSegments")]
|
[DataField]
|
||||||
public List<string>? DescriptionSegments;
|
public List<ProtoId<LocalizedDatasetPrototype>>? DescriptionSegments;
|
||||||
|
|
||||||
[DataField("nameSegments")]
|
[DataField]
|
||||||
public List<string>? NameSegments;
|
public List<ProtoId<LocalizedDatasetPrototype>>? NameSegments;
|
||||||
|
|
||||||
[DataField("nameSeparator")]
|
[DataField]
|
||||||
public string NameSeparator = " ";
|
public string NameSeparator = " ";
|
||||||
|
|
||||||
[DataField("descriptionSeparator")]
|
[DataField]
|
||||||
public string DescriptionSeparator = " ";
|
public string DescriptionSeparator = " ";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public sealed class RandomMetadataSystem : EntitySystem
|
|||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||||
|
|
||||||
|
private List<string> _outputSegments = new();
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -43,28 +45,14 @@ public sealed class RandomMetadataSystem : EntitySystem
|
|||||||
/// <param name="separator">The separator that will be inbetween each segment</param>
|
/// <param name="separator">The separator that will be inbetween each segment</param>
|
||||||
/// <returns>The newly generated string</returns>
|
/// <returns>The newly generated string</returns>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public string GetRandomFromSegments(List<string> segments, string? separator)
|
public string GetRandomFromSegments(List<ProtoId<LocalizedDatasetPrototype>> segments, string? separator)
|
||||||
{
|
{
|
||||||
var outputSegments = new List<string>();
|
_outputSegments.Clear();
|
||||||
foreach (var segment in segments)
|
foreach (var segment in segments)
|
||||||
{
|
{
|
||||||
if (_prototype.TryIndex<LocalizedDatasetPrototype>(segment, out var localizedProto))
|
var localizedProto = _prototype.Index(segment);
|
||||||
{
|
_outputSegments.Add(_random.Pick(localizedProto));
|
||||||
outputSegments.Add(_random.Pick(localizedProto));
|
|
||||||
}
|
}
|
||||||
else if (_prototype.TryIndex<DatasetPrototype>(segment, out var proto))
|
return string.Join(separator, _outputSegments);
|
||||||
{
|
|
||||||
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))
|
|
||||||
outputSegments.Add(localizedSegment);
|
|
||||||
else
|
|
||||||
outputSegments.Add(segment);
|
|
||||||
}
|
|
||||||
return string.Join(separator, outputSegments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
Resources/Locale/en-US/datasets/names/joining.ftl
Normal file
2
Resources/Locale/en-US/datasets/names/joining.ftl
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
names-word-the-1 = The
|
||||||
|
names-word-of-1 = of
|
||||||
3
Resources/Locale/en-US/datasets/names/nukie_first.ftl
Normal file
3
Resources/Locale/en-US/datasets/names/nukie_first.ftl
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
names-nukie-commander-1 = Commander
|
||||||
|
names-nukie-agent-1 = Agent
|
||||||
|
names-nukie-operator-1 = Operator
|
||||||
14
Resources/Prototypes/Datasets/Names/joining.yml
Normal file
14
Resources/Prototypes/Datasets/Names/joining.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# These can be inserted inbetween name datasets
|
||||||
|
# Ideally it would be localized since just swapping words doesnt help much for a lot of languages
|
||||||
|
|
||||||
|
- type: localizedDataset
|
||||||
|
id: WordThe
|
||||||
|
values:
|
||||||
|
prefix: names-word-the-
|
||||||
|
count: 1
|
||||||
|
|
||||||
|
- type: localizedDataset
|
||||||
|
id: WordOf
|
||||||
|
values:
|
||||||
|
prefix: names-word-of-
|
||||||
|
count: 1
|
||||||
17
Resources/Prototypes/Datasets/Names/nukies.yml
Normal file
17
Resources/Prototypes/Datasets/Names/nukies.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
- type: localizedDataset
|
||||||
|
id: NamesNukieFirstCommander
|
||||||
|
values:
|
||||||
|
prefix: names-nukie-commander-
|
||||||
|
count: 1
|
||||||
|
|
||||||
|
- type: localizedDataset
|
||||||
|
id: NamesNukieFirstAgent
|
||||||
|
values:
|
||||||
|
prefix: names-nukie-agent-
|
||||||
|
count: 1
|
||||||
|
|
||||||
|
- type: localizedDataset
|
||||||
|
id: NamesNukieFirstOperator
|
||||||
|
values:
|
||||||
|
prefix: names-nukie-operator-
|
||||||
|
count: 1
|
||||||
@@ -72,9 +72,9 @@
|
|||||||
- StolenEssence
|
- StolenEssence
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
nameSegments:
|
nameSegments:
|
||||||
- The
|
- WordThe
|
||||||
- NamesRevenantType
|
- NamesRevenantType
|
||||||
- of
|
- WordOf
|
||||||
- NamesRevenantAdjective
|
- NamesRevenantAdjective
|
||||||
- NamesRevenantTheme
|
- NamesRevenantTheme
|
||||||
- type: Speech
|
- type: Speech
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
- type: NukeOperative
|
- type: NukeOperative
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
nameSegments:
|
nameSegments:
|
||||||
- nukeops-role-operator
|
- NamesNukieFirstOperator
|
||||||
- NamesSyndicateNormal
|
- NamesSyndicateNormal
|
||||||
- type: Loadout
|
- type: Loadout
|
||||||
prototypes: [SyndicateOperativeGearFullNoUplink]
|
prototypes: [SyndicateOperativeGearFullNoUplink]
|
||||||
|
|||||||
@@ -129,7 +129,7 @@
|
|||||||
- type: NukeOperative
|
- type: NukeOperative
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
nameSegments:
|
nameSegments:
|
||||||
- nukeops-role-commander
|
- NamesNukieFirstCommander
|
||||||
- NamesSyndicateElite
|
- NamesSyndicateElite
|
||||||
- type: NpcFactionMember
|
- type: NpcFactionMember
|
||||||
factions:
|
factions:
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
- type: NukeOperative
|
- type: NukeOperative
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
nameSegments:
|
nameSegments:
|
||||||
- nukeops-role-agent
|
- NamesNukieFirstAgent
|
||||||
- NamesSyndicateNormal
|
- NamesSyndicateNormal
|
||||||
- type: NpcFactionMember
|
- type: NpcFactionMember
|
||||||
factions:
|
factions:
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
- type: NukeOperative
|
- type: NukeOperative
|
||||||
- type: RandomMetadata
|
- type: RandomMetadata
|
||||||
nameSegments:
|
nameSegments:
|
||||||
- nukeops-role-operator
|
- NamesNukieFirstOperator
|
||||||
- NamesSyndicateNormal
|
- NamesSyndicateNormal
|
||||||
- type: NpcFactionMember
|
- type: NpcFactionMember
|
||||||
factions:
|
factions:
|
||||||
|
|||||||
Reference in New Issue
Block a user