[feat] Custom name for clown, mime and borgs

This commit is contained in:
rhailrake
2023-05-04 13:44:24 +06:00
committed by Aviu00
parent f04400926e
commit 68e52f60c9
18 changed files with 3124 additions and 43 deletions

View File

@@ -34,6 +34,9 @@ namespace Content.Shared.Preferences
private HumanoidCharacterProfile(
string name,
string clownName,
string mimeName,
string borgName,
string flavortext,
string species,
int age,
@@ -49,6 +52,9 @@ namespace Content.Shared.Preferences
List<string> traitPreferences)
{
Name = name;
ClownName = clownName;
MimeName = mimeName;
BorgName = borgName;
FlavorText = flavortext;
Species = species;
Voice = voice;
@@ -70,7 +76,7 @@ namespace Content.Shared.Preferences
Dictionary<string, JobPriority> jobPriorities,
List<string> antagPreferences,
List<string> traitPreferences)
: this(other.Name, other.FlavorText, other.Species, other.Voice, other.Age, other.Sex, other.Gender, other.Appearance, other.Clothing, other.Backpack,
: this(other.Name, other.ClownName, other.MimeName, other.BorgName, other.FlavorText, other.Species, other.Voice, other.Age, other.Sex, other.Gender, other.Appearance, other.Clothing, other.Backpack,
jobPriorities, other.PreferenceUnavailable, antagPreferences, traitPreferences)
{
}
@@ -83,6 +89,9 @@ namespace Content.Shared.Preferences
public HumanoidCharacterProfile(
string name,
string clownName,
string mimeName,
string borgName,
string flavortext,
string species,
string voice,
@@ -96,7 +105,7 @@ namespace Content.Shared.Preferences
PreferenceUnavailableMode preferenceUnavailable,
IReadOnlyList<string> antagPreferences,
IReadOnlyList<string> traitPreferences)
: this(name, flavortext, species, age, sex, voice, gender, appearance, clothing, backpack, new Dictionary<string, JobPriority>(jobPriorities),
: this(name, clownName, mimeName, borgName, flavortext, species, age, sex, voice, gender, appearance, clothing, backpack, new Dictionary<string, JobPriority>(jobPriorities),
preferenceUnavailable, new List<string>(antagPreferences), new List<string>(traitPreferences))
{
}
@@ -108,6 +117,9 @@ namespace Content.Shared.Preferences
/// <returns></returns>
public HumanoidCharacterProfile() : this(
"John Doe",
"HONK",
"Quiet",
"Silicon",
"",
SharedHumanoidAppearanceSystem.DefaultSpecies,
SharedHumanoidAppearanceSystem.DefaultVoice,
@@ -136,6 +148,9 @@ namespace Content.Shared.Preferences
{
return new(
"John Doe",
"HONK",
"Quiet",
"Silicon",
"",
species,
SharedHumanoidAppearanceSystem.DefaultVoice,
@@ -190,8 +205,11 @@ namespace Content.Shared.Preferences
var gender = sex == Sex.Male ? Gender.Male : Gender.Female;
var name = GetName(species, gender);
var clownName = GetClownName();
var mimeName = GetMimeName();
var borgName = GetBorgName();
return new HumanoidCharacterProfile(name, "", species, voiceId, age, sex, gender, HumanoidCharacterAppearance.Random(species, sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
return new HumanoidCharacterProfile(name, clownName, mimeName, borgName, "", species, voiceId, age, sex, gender, HumanoidCharacterAppearance.Random(species, sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
new Dictionary<string, JobPriority>
{
{SharedGameTicker.FallbackOverflowJob, JobPriority.High},
@@ -199,6 +217,9 @@ namespace Content.Shared.Preferences
}
public string Name { get; private set; }
public string ClownName { get; private set; }
public string MimeName { get; private set; }
public string BorgName { get; private set; }
public string FlavorText { get; private set; }
public string Species { get; private set; }
@@ -235,6 +256,19 @@ namespace Content.Shared.Preferences
return new(this) { Name = name };
}
public HumanoidCharacterProfile WithClownName(string name)
{
return new(this) { ClownName = name };
}
public HumanoidCharacterProfile WithMimeName(string name)
{
return new(this) { MimeName = name };
}
public HumanoidCharacterProfile WithBorgName(string name)
{
return new(this) { BorgName = name };
}
public HumanoidCharacterProfile WithFlavorText(string flavorText)
{
return new(this) { FlavorText = flavorText };
@@ -357,6 +391,9 @@ namespace Content.Shared.Preferences
{
if (maybeOther is not HumanoidCharacterProfile other) return false;
if (Name != other.Name) return false;
if (ClownName != other.ClownName) return false;
if (MimeName != other.MimeName) return false;
if (BorgName != other.BorgName) return false;
if (Age != other.Age) return false;
if (Sex != other.Sex) return false;
if (Gender != other.Gender) return false;
@@ -414,6 +451,9 @@ namespace Content.Shared.Preferences
};
string name;
string clownName;
string mimeName;
string borgName;
if (string.IsNullOrEmpty(Name))
{
name = GetName(Species, gender);
@@ -426,13 +466,55 @@ namespace Content.Shared.Preferences
{
name = Name;
}
if (string.IsNullOrEmpty(ClownName))
{
clownName = GetClownName();
}
else if (ClownName.Length > MaxNameLength)
{
clownName = ClownName[..MaxNameLength];
}
else
{
clownName = ClownName;
}
if (string.IsNullOrEmpty(MimeName))
{
mimeName = GetMimeName();
}
else if (MimeName.Length > MaxNameLength)
{
mimeName = MimeName[..MaxNameLength];
}
else
{
mimeName = MimeName;
}
if (string.IsNullOrEmpty(BorgName))
{
borgName = GetBorgName();
}
else if (BorgName.Length > MaxNameLength)
{
borgName = BorgName[..MaxNameLength];
}
else
{
borgName = BorgName;
}
name = name.Trim();
clownName = clownName.Trim();
mimeName = mimeName.Trim();
borgName = borgName.Trim();
var configManager = IoCManager.Resolve<IConfigurationManager>();
if (configManager.GetCVar(CCVars.RestrictedNames))
{
name = Regex.Replace(name, @"[^А-Я,а-я,0-9, -]", string.Empty); //WD EDIT
clownName = Regex.Replace(clownName, @"[^А-Я,а-я,0-9, -]", string.Empty);
mimeName = Regex.Replace(mimeName, @"[^А-Я,а-я,0-9, -]", string.Empty);
borgName = Regex.Replace(borgName, @"[^А-Я,а-я,0-9, -]", string.Empty);
}
if (configManager.GetCVar(CCVars.ICNameCase))
@@ -441,11 +523,23 @@ namespace Content.Shared.Preferences
name = Regex.Replace(name,
@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)",
m => m.Groups["word"].Value.ToUpper());
clownName = Regex.Replace(clownName,
@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)",
m => m.Groups["word"].Value.ToUpper());
mimeName = Regex.Replace(mimeName,
@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)",
m => m.Groups["word"].Value.ToUpper());
borgName = Regex.Replace(borgName,
@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)",
m => m.Groups["word"].Value.ToUpper());
}
if (string.IsNullOrEmpty(name))
{
name = GetName(Species, gender);
clownName = GetClownName();
mimeName = GetMimeName();
borgName = GetBorgName();
}
string flavortext;
@@ -503,6 +597,9 @@ namespace Content.Shared.Preferences
.ToList();
Name = name;
ClownName = clownName;
MimeName = mimeName;
BorgName = borgName;
FlavorText = flavortext;
Age = age;
Sex = sex;
@@ -544,6 +641,24 @@ namespace Content.Shared.Preferences
return namingSystem.GetName(species, gender);
}
public static string GetClownName()
{
var namingSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<NamingSystem>();
return namingSystem.GetClownName();
}
public static string GetMimeName()
{
var namingSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<NamingSystem>();
return namingSystem.GetMimeName();
}
public static string GetBorgName()
{
var namingSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<NamingSystem>();
return namingSystem.GetBorgName();
}
public override bool Equals(object? obj)
{
return obj is HumanoidCharacterProfile other && MemberwiseEquals(other);
@@ -562,6 +677,9 @@ namespace Content.Shared.Preferences
Clothing,
Backpack
),
ClownName,
MimeName,
BorgName,
PreferenceUnavailable,
_jobPriorities,
_antagPreferences,