diff --git a/Content.Server/RandomMetadata/RandomMetadataComponent.cs b/Content.Server/RandomMetadata/RandomMetadataComponent.cs
index dbd1e5469f..29aef86751 100644
--- a/Content.Server/RandomMetadata/RandomMetadataComponent.cs
+++ b/Content.Server/RandomMetadata/RandomMetadataComponent.cs
@@ -1,17 +1,20 @@
-using Content.Shared.Dataset;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
-
-namespace Content.Server.RandomMetadata;
+namespace Content.Server.RandomMetadata;
///
-/// Randomizes the description and/or the name for an entity by pulling from a dataset prototype.
+/// Randomizes the description and/or the name for an entity by creating it from list of dataset prototypes or strings.
///
[RegisterComponent]
public sealed class RandomMetadataComponent : Component
{
- [DataField("descriptionSet", customTypeSerializer:typeof(PrototypeIdSerializer))]
- public string? DescriptionSet;
+ [DataField("descriptionSegments")]
+ public List? DescriptionSegments;
- [DataField("nameSet", customTypeSerializer:typeof(PrototypeIdSerializer))]
- public string? NameSet;
+ [DataField("nameSegments")]
+ public List? NameSegments;
+
+ [DataField("nameSeparator")]
+ public string NameSeparator = " ";
+
+ [DataField("descriptionSeparator")]
+ public string DescriptionSeparator = " ";
}
diff --git a/Content.Server/RandomMetadata/RandomMetadataSystem.cs b/Content.Server/RandomMetadata/RandomMetadataSystem.cs
index 5b3dfa23bc..e9136f82eb 100644
--- a/Content.Server/RandomMetadata/RandomMetadataSystem.cs
+++ b/Content.Server/RandomMetadata/RandomMetadataSystem.cs
@@ -1,4 +1,5 @@
using Content.Shared.Dataset;
+using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -21,16 +22,33 @@ public sealed class RandomMetadataSystem : EntitySystem
{
var meta = MetaData(uid);
- if (component.NameSet != null)
+ if (component.NameSegments != null)
{
- var nameProto = _prototype.Index(component.NameSet);
- meta.EntityName = _random.Pick(nameProto.Values);
+ meta.EntityName = GetRandomFromSegments(component.NameSegments, component.NameSeparator);
}
- if (component.DescriptionSet != null)
+ if (component.DescriptionSegments != null)
{
- var descProto = _prototype.Index(component.DescriptionSet);
- meta.EntityDescription = _random.Pick(descProto.Values);
+ meta.EntityDescription = GetRandomFromSegments(component.DescriptionSegments, component.DescriptionSeparator);
}
}
+
+ ///
+ /// Generates a random string from segments and a separator.
+ ///
+ /// The segments that it will be generated from
+ /// The separator that will be inbetween each segment
+ /// The newly generated string
+ [PublicAPI]
+ public string GetRandomFromSegments(List segments, string? separator)
+ {
+ var outputSegments = new List();
+ foreach (var segment in segments)
+ {
+ outputSegments.Add(_prototype.TryIndex(segment, out var proto)
+ ? _random.Pick(proto.Values)
+ : segment);
+ }
+ return string.Join(separator, outputSegments);
+ }
}
diff --git a/Content.Server/RatKing/RatKingComponent.cs b/Content.Server/RatKing/RatKingComponent.cs
index 08fc92f108..d21f2383db 100644
--- a/Content.Server/RatKing/RatKingComponent.cs
+++ b/Content.Server/RatKing/RatKingComponent.cs
@@ -1,6 +1,4 @@
using Content.Shared.Actions.ActionTypes;
-using Content.Shared.Dataset;
-using Content.Shared.Disease;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -44,11 +42,5 @@ namespace Content.Server.RatKing
///
[ViewVariables, DataField("molesMiasmaPerDomain")]
public float MolesMiasmaPerDomain = 100f;
-
- // Both of these are used to generate the random name for rat king.
- [DataField("titleNameDataset", customTypeSerializer: typeof(PrototypeIdSerializer))]
- public string TitleNameDataset = "RegalRatNameTitle";
- [DataField("kingdomNameDataset", customTypeSerializer: typeof(PrototypeIdSerializer))]
- public string KingdomNameDataset = "RegalRatNameKingdom";
}
};
diff --git a/Content.Server/RatKing/RatKingSystem.cs b/Content.Server/RatKing/RatKingSystem.cs
index c4c84038db..9806024dff 100644
--- a/Content.Server/RatKing/RatKingSystem.cs
+++ b/Content.Server/RatKing/RatKingSystem.cs
@@ -1,23 +1,16 @@
using Content.Server.Actions;
using Content.Server.Atmos.EntitySystems;
-using Content.Server.Disease;
-using Content.Server.Disease.Components;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Atmos;
-using Content.Shared.Dataset;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
-using Robust.Shared.Prototypes;
-using Robust.Shared.Random;
namespace Content.Server.RatKing
{
public sealed class RatKingSystem : EntitySystem
{
- [Dependency] private readonly IPrototypeManager _proto = default!;
- [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly AtmosphereSystem _atmos = default!;
@@ -37,11 +30,6 @@ namespace Content.Server.RatKing
{
_action.AddAction(uid, component.ActionRaiseArmy, null);
_action.AddAction(uid, component.ActionDomain, null);
-
- var kingdom = _proto.Index(component.KingdomNameDataset);
- var title = _proto.Index(component.TitleNameDataset);
-
- MetaData(uid).EntityName = $"{_random.Pick(kingdom.Values)} {_random.Pick(title.Values)}";
}
///
diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml
index cd4c6f7f0b..29116df907 100644
--- a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml
+++ b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml
@@ -113,6 +113,10 @@
- TongueTwister
- type: MobPrice
price: 2500 # rat wealth
+ - type: RandomMetadata
+ nameSegments:
+ - RegalRatNameKingdom
+ - RegalRatNameTitle
- type: entity
id: MobRatKingBuff
diff --git a/Resources/Prototypes/Entities/Mobs/Player/human.yml b/Resources/Prototypes/Entities/Mobs/Player/human.yml
index a09afbbdc9..414cfbf992 100644
--- a/Resources/Prototypes/Entities/Mobs/Player/human.yml
+++ b/Resources/Prototypes/Entities/Mobs/Player/human.yml
@@ -64,7 +64,7 @@
- type: Loadout
prototype: ERTLeaderGear
- type: RandomMetadata
- nameSet: NamesFirstMilitaryLeader
+ nameSegments: [NamesFirstMilitaryLeader]
- type: RandomHumanoidAppearance
randomizeName: false
@@ -197,7 +197,7 @@
- type: Loadout
prototype: SyndicateOperativeGearExtremelyBasic
- type: RandomMetadata
- nameSet: names_death_commando
+ nameSegments: [names_death_commando]
# Nuclear Operative
- type: entity
diff --git a/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml b/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
index 994fa95561..2960fe67a5 100644
--- a/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
+++ b/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
@@ -236,7 +236,7 @@
- Cargo
- Maintenance
- type: RandomMetadata
- descriptionSet: ATVDescriptions
+ descriptionSegments: [ATVDescriptions]
- type: MovementSpeedModifier
acceleration: 1
friction: 1