[feat] TTS
# Conflicts: # Content.Client/Options/UI/Tabs/AudioTab.xaml.cs # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml # Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs # Content.Server/Database/ServerDbBase.cs # Content.Server/Entry/EntryPoint.cs # Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs # Content.Server/IoC/ServerContentIoC.cs # Content.Server/VoiceMask/VoiceMaskSystem.cs # Resources/Prototypes/Entities/Mobs/Species/base.yml
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Shared.Humanoid.Prototypes;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Traits;
|
||||
using Content.Shared.White.TTS;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -37,6 +38,7 @@ namespace Content.Shared.Preferences
|
||||
string species,
|
||||
int age,
|
||||
Sex sex,
|
||||
string voice,
|
||||
Gender gender,
|
||||
HumanoidCharacterAppearance appearance,
|
||||
ClothingPreference clothing,
|
||||
@@ -49,6 +51,7 @@ namespace Content.Shared.Preferences
|
||||
Name = name;
|
||||
FlavorText = flavortext;
|
||||
Species = species;
|
||||
Voice = voice;
|
||||
Age = age;
|
||||
Sex = sex;
|
||||
Gender = gender;
|
||||
@@ -67,7 +70,7 @@ namespace Content.Shared.Preferences
|
||||
Dictionary<string, JobPriority> jobPriorities,
|
||||
List<string> antagPreferences,
|
||||
List<string> traitPreferences)
|
||||
: this(other.Name, other.FlavorText, other.Species, other.Age, other.Sex, other.Gender, other.Appearance, other.Clothing, other.Backpack,
|
||||
: this(other.Name, other.FlavorText, other.Species, other.Voice, other.Age, other.Sex, other.Gender, other.Appearance, other.Clothing, other.Backpack,
|
||||
jobPriorities, other.PreferenceUnavailable, antagPreferences, traitPreferences)
|
||||
{
|
||||
}
|
||||
@@ -82,6 +85,7 @@ namespace Content.Shared.Preferences
|
||||
string name,
|
||||
string flavortext,
|
||||
string species,
|
||||
string voice,
|
||||
int age,
|
||||
Sex sex,
|
||||
Gender gender,
|
||||
@@ -92,7 +96,7 @@ namespace Content.Shared.Preferences
|
||||
PreferenceUnavailableMode preferenceUnavailable,
|
||||
IReadOnlyList<string> antagPreferences,
|
||||
IReadOnlyList<string> traitPreferences)
|
||||
: this(name, flavortext, species, age, sex, gender, appearance, clothing, backpack, new Dictionary<string, JobPriority>(jobPriorities),
|
||||
: this(name, flavortext, species, age, sex, voice, gender, appearance, clothing, backpack, new Dictionary<string, JobPriority>(jobPriorities),
|
||||
preferenceUnavailable, new List<string>(antagPreferences), new List<string>(traitPreferences))
|
||||
{
|
||||
}
|
||||
@@ -106,6 +110,7 @@ namespace Content.Shared.Preferences
|
||||
"John Doe",
|
||||
"",
|
||||
SharedHumanoidAppearanceSystem.DefaultSpecies,
|
||||
SharedHumanoidAppearanceSystem.DefaultVoice,
|
||||
18,
|
||||
Sex.Male,
|
||||
Gender.Male,
|
||||
@@ -133,6 +138,7 @@ namespace Content.Shared.Preferences
|
||||
"John Doe",
|
||||
"",
|
||||
species,
|
||||
SharedHumanoidAppearanceSystem.DefaultVoice,
|
||||
18,
|
||||
Sex.Male,
|
||||
Gender.Male,
|
||||
@@ -176,11 +182,16 @@ namespace Content.Shared.Preferences
|
||||
age = random.Next(speciesPrototype.MinAge, speciesPrototype.OldAge); // people don't look and keep making 119 year old characters with zero rp, cap it at middle aged
|
||||
}
|
||||
|
||||
var voiceId = random.Pick(prototypeManager
|
||||
.EnumeratePrototypes<TTSVoicePrototype>()
|
||||
.Where(o => CanHaveVoice(o, sex)).ToArray()
|
||||
).ID;
|
||||
|
||||
var gender = sex == Sex.Male ? Gender.Male : Gender.Female;
|
||||
|
||||
var name = GetName(species, gender);
|
||||
|
||||
return new HumanoidCharacterProfile(name, "", species, age, sex, gender, HumanoidCharacterAppearance.Random(species, sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
|
||||
return new HumanoidCharacterProfile(name, "", species, voiceId, age, sex, gender, HumanoidCharacterAppearance.Random(species, sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
|
||||
new Dictionary<string, JobPriority>
|
||||
{
|
||||
{SharedGameTicker.FallbackOverflowJob, JobPriority.High},
|
||||
@@ -191,6 +202,8 @@ namespace Content.Shared.Preferences
|
||||
public string FlavorText { get; private set; }
|
||||
public string Species { get; private set; }
|
||||
|
||||
public string Voice { get; private set; }
|
||||
|
||||
[DataField("age")]
|
||||
public int Age { get; private set; }
|
||||
|
||||
@@ -211,6 +224,12 @@ namespace Content.Shared.Preferences
|
||||
public IReadOnlyList<string> TraitPreferences => _traitPreferences;
|
||||
public PreferenceUnavailableMode PreferenceUnavailable { get; private set; }
|
||||
|
||||
|
||||
public HumanoidCharacterProfile WithVoice(string voice)
|
||||
{
|
||||
return new(this) { Voice = voice };
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile WithName(string name)
|
||||
{
|
||||
return new(this) { Name = name };
|
||||
@@ -500,6 +519,15 @@ namespace Content.Shared.Preferences
|
||||
|
||||
_traitPreferences.Clear();
|
||||
_traitPreferences.AddRange(traits);
|
||||
|
||||
prototypeManager.TryIndex<TTSVoicePrototype>(Voice, out var voice);
|
||||
if (voice is null || !CanHaveVoice(voice, Sex))
|
||||
Voice = SharedHumanoidAppearanceSystem.DefaultSexVoice[sex];
|
||||
}
|
||||
|
||||
public static bool CanHaveVoice(TTSVoicePrototype voice, Sex sex)
|
||||
{
|
||||
return voice.RoundStart && sex == Sex.Unsexed || (voice.Sex == sex || voice.Sex == Sex.Unsexed);
|
||||
}
|
||||
|
||||
// sorry this is kind of weird and duplicated,
|
||||
|
||||
Reference in New Issue
Block a user