Files
wwdpublic/Content.Shared/Humanoid/NamingSystem.cs
Adrian16199 b88d8663f9 Oni Morphotype from nyanotrasen (#28)
* Oni Morphotype from nyanotrasen

The big felinid destroyer has arrived.

* Added some files. changed species weight again by deletin that one space and addin vulpkanin weight.

(will have to prolly change that after felinids merge)

* Finally fixin the *reason* why it just didnt wanted to show

Also Fixed horns

* Changed localization of files.

* Changed excess to critThreshold

Also changed capitalization of oni_horns.rsi to Oni_horns.rsi.

* Leavin a comment so that someone else can do this.

* Additional merge fixes with files.

* Added THE NAMING SYSTEM!

Only touched 2 base files and summarized it because had no other choice from my understanding

* Removed erroneously named folder

* Replaced erroneously named folder

* Added link so the horns dont have file names.

---------

Signed-off-by: Adrian16199 <144424013+Adrian16199@users.noreply.github.com>
Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>
2023-09-21 21:39:49 +00:00

69 lines
3.1 KiB
C#

using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Dataset;
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)
{
//Start of Nyano code for Oni naming
case SpeciesNaming.XnoY:
return Loc.GetString("namepreset-x-no-y",
("first", GetFirstName(speciesProto, gender)), ("last", GetLastName(speciesProto)));
//End of Nyano code for Oni naming
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<DatasetPrototype>(speciesProto.MaleFirstNames).Values);
case Gender.Female:
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.FemaleFirstNames).Values);
default:
if (_random.Prob(0.5f))
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.MaleFirstNames).Values);
else
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.FemaleFirstNames).Values);
}
}
public string GetLastName(SpeciesPrototype speciesProto)
{
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.LastNames).Values);
}
}
}