* Use `LocalizedDatasetPrototype` instead of `DatasetPrototype` in `RoleLoadoutPrototype`
* Localize ai names
* Replace to `LocalizedDatasetPrototype` in `NamingSystem`
* Localize arachnid first and last names
* Localize atv names
* Localize autoborg names
* Forgot to change type to localizedDataset
* Localize borer names
* Localize borg names
* Localize cargo shuttle names
* Localize clown names
* Localize death_commando names
* Localize diona names
* Localize fake_human names
* Localize first and last names
* Localize first male and female names
* Localize fortunes descriptions
* Forgot about equal sign
* Localize golem names
* Localize hologram names
* Localize military names
* Localize moth first male and female names
* Localize moth last names
* Fix autoborg name error
* Localize mushman first and last names
* Localize ninja names
* Localize operation names
* Localize regalrat names
* Fix mushman_first
* Forgot about `Loc.GetString`
* Move comments into comment section & fix names
* Localize reptilian male and female names
* Localize revenant names
* Fix locale word order in operation
* Localize rollie (btw it was never used and was added as "for the futuгe" long time ago)
* Localize skeleton_first names
* Localize syndicate names
* Localize vox names
* Localize wizard first and last names
* `{owner}-name-dataset` -> `names-{owner}-dataset`
* Change `DatasetPrototype` to `LocalizedDatasetPrototype` and make sure it works properly
GetFTLName is no more the static method, we need it to be able to use `Loc.GetString`
* I hate those mothname comments
* Combine name datasets prototypes
* Move every ftl from` /en-US/names` to ` /en-US/datasets/names`
* Remove ftl files
* Get every dataset yml back
* Remove changes for planets. Move it in another PR
* Revert these changes (Moved to another PR)
* How
* Apply suggested changes
68 lines
3.1 KiB
C#
68 lines
3.1 KiB
C#
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.Dataset;
|
|
using Content.Shared.Random.Helpers;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Enums;
|
|
|
|
namespace Content.Shared.Humanoid
|
|
{
|
|
/// <summary>
|
|
/// Figure out how to name a humanoid with these extensions.
|
|
/// </summary>
|
|
public sealed class NamingSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
public string GetName(string species, Gender? gender = null)
|
|
{
|
|
// if they have an old species or whatever just fall back to human I guess?
|
|
// Some downstream is probably gonna have this eventually but then they can deal with fallbacks.
|
|
if (!_prototypeManager.TryIndex(species, out SpeciesPrototype? speciesProto))
|
|
{
|
|
speciesProto = _prototypeManager.Index<SpeciesPrototype>("Human");
|
|
Log.Warning($"Unable to find species {species} for name, falling back to Human");
|
|
}
|
|
|
|
switch (speciesProto.Naming)
|
|
{
|
|
case SpeciesNaming.First:
|
|
return Loc.GetString("namepreset-first",
|
|
("first", GetFirstName(speciesProto, gender)));
|
|
case SpeciesNaming.TheFirstofLast:
|
|
return Loc.GetString("namepreset-thefirstoflast",
|
|
("first", GetFirstName(speciesProto, gender)), ("last", GetLastName(speciesProto)));
|
|
case SpeciesNaming.FirstDashFirst:
|
|
return Loc.GetString("namepreset-firstdashfirst",
|
|
("first1", GetFirstName(speciesProto, gender)), ("first2", GetFirstName(speciesProto, gender)));
|
|
case SpeciesNaming.FirstLast:
|
|
default:
|
|
return Loc.GetString("namepreset-firstlast",
|
|
("first", GetFirstName(speciesProto, gender)), ("last", GetLastName(speciesProto)));
|
|
}
|
|
}
|
|
|
|
public string GetFirstName(SpeciesPrototype speciesProto, Gender? gender = null)
|
|
{
|
|
switch (gender)
|
|
{
|
|
case Gender.Male:
|
|
return _random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>(speciesProto.MaleFirstNames));
|
|
case Gender.Female:
|
|
return _random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>(speciesProto.FemaleFirstNames));
|
|
default:
|
|
if (_random.Prob(0.5f))
|
|
return _random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>(speciesProto.MaleFirstNames));
|
|
else
|
|
return _random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>(speciesProto.FemaleFirstNames));
|
|
}
|
|
}
|
|
|
|
public string GetLastName(SpeciesPrototype speciesProto)
|
|
{
|
|
return Loc.GetString(_random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>(speciesProto.LastNames).Values));
|
|
}
|
|
}
|
|
}
|