Random station names! (#5548)

This commit is contained in:
Moony
2021-11-26 07:54:32 -06:00
committed by GitHub
parent 522cb3cf9c
commit f60484b15c
9 changed files with 83 additions and 10 deletions

View File

@@ -0,0 +1,9 @@
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Maps.NameGenerators;
[ImplicitDataDefinitionForInheritors]
public abstract class GameMapNameGenerator
{
public abstract string FormatName(string input);
}

View File

@@ -0,0 +1,26 @@
using JetBrains.Annotations;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Maps.NameGenerators;
[UsedImplicitly]
public class NanotrasenNameGenerator : GameMapNameGenerator
{
/// <summary>
/// Where the map comes from. Should be a two or three letter code, for example "VG" for Packedstation.
/// </summary>
[DataField("prefixCreator")] public string PrefixCreator = default!;
private string Prefix => "NT";
private string[] SuffixCodes => new []{ "LV", "NX", "EV", "QT", "PR" };
public override string FormatName(string input)
{
var random = IoCManager.Resolve<IRobustRandom>();
// No way in hell am I writing custom format code just to add nice names. You can live with {0}
return string.Format(input, $"{Prefix}{PrefixCreator}", $"{random.Pick(SuffixCodes)}-{random.Next(0, 999):D3}");
}
}