* Import bird sprites and define basic mob.

* SKREEEEEEEEE

* Move hair styles to new sprite accessory prototypes.

Basic stuff, no multi-species stuff yet.

* Vox hair styles and clothes

* Make HumanoidCharacterProfile.Default() a static default to fix tests.

Usages that wanted the previous random behavior now call Random().

* Remove names from hair style prototypes.

(They're in localization files)

* Update Content.Shared/Actions/ActionType.cs

(sk)reeee github

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2021-03-28 08:26:32 +02:00
committed by GitHub
parent 5ed935f30a
commit 0ac4c0e85c
101 changed files with 2440 additions and 505 deletions

View File

@@ -7,9 +7,10 @@ namespace Content.Shared.Actions
public enum ActionType : byte
{
Error,
HumanScream,
VoxScream,
CombatMode,
Disarm,
HumanScream,
GhostBoo,
DebugInstant,
DebugToggle,

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using Content.Shared.Chemistry;
using Content.Shared.Maps;
using Content.Shared.Preferences.Appearance;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -19,6 +20,7 @@ namespace Content.Shared
public override void PreInit()
{
IoCManager.InjectDependencies(this);
SharedContentIoC.Register();
Localization.Init();
}
@@ -33,6 +35,7 @@ namespace Content.Shared
_initTileDefinitions();
CheckReactions();
IoCManager.Resolve<SpriteAccessoryManager>().Initialize();
}
private void CheckReactions()

View File

@@ -1,23 +1,41 @@
#nullable enable
using System;
using Content.Shared.Preferences;
using Content.Shared.Preferences.Appearance;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Mobs
{
public abstract class SharedHumanoidAppearanceComponent : Component
{
private HumanoidCharacterAppearance _appearance = default!;
private HumanoidCharacterAppearance _appearance = HumanoidCharacterAppearance.Default();
private Sex _sex;
private Gender _gender;
public sealed override string Name => "HumanoidAppearance";
public sealed override uint? NetID => ContentNetIDs.HUMANOID_APPEARANCE;
[DataField("categoriesHair")]
[ViewVariables]
public SpriteAccessoryCategories CategoriesHair { get; set; } = SpriteAccessoryCategories.HumanHair;
[DataField("categoriesFacialHair")]
[ViewVariables]
public SpriteAccessoryCategories CategoriesFacialHair { get; set; } = SpriteAccessoryCategories.HumanFacialHair;
[ViewVariables]
[DataField("canColorHair")]
public bool CanColorHair { get; set; } = true;
[ViewVariables]
[DataField("canColorFacialHair")]
public bool CanColorFacialHair { get; set; } = true;
[ViewVariables(VVAccess.ReadWrite)]
public virtual HumanoidCharacterAppearance Appearance
{
@@ -80,7 +98,8 @@ namespace Content.Shared.GameObjects.Components.Mobs
[NetSerializable]
private sealed class HumanoidAppearanceComponentState : ComponentState
{
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance, Sex sex, Gender gender) : base(ContentNetIDs.HUMANOID_APPEARANCE)
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance, Sex sex, Gender gender) :
base(ContentNetIDs.HUMANOID_APPEARANCE)
{
Appearance = appearance;
Sex = sex;

View File

@@ -1,5 +1,6 @@
#nullable enable
using System;
using Content.Shared.Preferences.Appearance;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
@@ -19,12 +20,12 @@ namespace Content.Shared.GameObjects.Components
[Serializable, NetSerializable]
public class HairSelectedMessage : BoundUserInterfaceMessage
{
public readonly string HairName;
public readonly string HairId;
public readonly bool IsFacialHair;
public HairSelectedMessage(string name, bool isFacialHair)
public HairSelectedMessage(string id, bool isFacialHair)
{
HairName = name;
HairId = id;
IsFacialHair = isFacialHair;
}
}
@@ -58,17 +59,25 @@ namespace Content.Shared.GameObjects.Components
{
public readonly Color HairColor;
public readonly Color FacialHairColor;
public readonly string HairName;
public readonly string FacialHairName;
public readonly string HairId;
public readonly string FacialHairId;
public readonly Color EyeColor;
public readonly SpriteAccessoryCategories CategoriesHair;
public readonly SpriteAccessoryCategories CategoriesFacialHair;
public readonly bool CanColorHair;
public readonly bool CanColorFacialHair;
public MagicMirrorInitialDataMessage(Color hairColor, Color facialHairColor, string hairName, string facialHairName, Color eyeColor)
public MagicMirrorInitialDataMessage(Color hairColor, Color facialHairColor, string hairId, string facialHairId, Color eyeColor, SpriteAccessoryCategories categoriesHair, SpriteAccessoryCategories categoriesFacialHair, bool canColorHair, bool canColorFacialHair)
{
HairColor = hairColor;
FacialHairColor = facialHairColor;
HairName = hairName;
FacialHairName = facialHairName;
HairId = hairId;
FacialHairId = facialHairId;
EyeColor = eyeColor;
CategoriesHair = categoriesHair;
CategoriesFacialHair = categoriesFacialHair;
CanColorHair = canColorHair;
CanColorFacialHair = canColorFacialHair;
}
}
}

View File

@@ -1,277 +1,16 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Maths;
namespace Content.Shared.Preferences.Appearance
{
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public static class HairStyles
{
public const string DefaultHairStyle = "Bald";
public const string DefaultFacialHairStyle = "Shaved";
public const string DefaultHairStyle = "HairBald";
public const string DefaultFacialHairStyle = "FacialHairShaved";
public static readonly Dictionary<string, string> HairStylesMap = new()
{
{"Afro", "afro"},
{"Afro 2", "afro2"},
{"Afro (Large)", "bigafro"},
{"Ahoge", "antenna"},
{"Bald", "bald"},
{"Balding Hair", "e"},
{"Bedhead", "bedhead"},
{"Bedhead 2", "bedheadv2"},
{"Bedhead 3", "bedheadv3"},
{"Long Bedhead", "long_bedhead"},
{"Floorlength Bedhead", "floorlength_bedhead"},
{"Beehive", "beehive"},
{"Beehive 2", "beehivev2"},
{"Bob Hair", "bob"},
{"Bob Hair 2", "bob2"},
{"Bob Hair 3", "bobcut"},
{"Bob Hair 4", "bob4"},
{"Bobcurl", "bobcurl"},
{"Boddicker", "boddicker"},
{"Bowlcut", "bowlcut"},
{"Bowlcut 2", "bowlcut2"},
{"Braid (Floorlength)", "braid"},
{"Braided", "braided"},
{"Braided Front", "braidfront"},
{"Braid (High)", "braid2"},
{"Braid (Low)", "hbraid"},
{"Braid (Short)", "shortbraid"},
{"Braided Tail", "braidtail"},
{"Bun Head", "bun"},
{"Bun Head 2", "bunhead2"},
{"Bun Head 3", "bun3"},
{"Bun (Large)", "largebun"},
{"Bun (Manbun)", "manbun"},
{"Bun (Tight)", "tightbun"},
{"Business Hair", "business"},
{"Business Hair 2", "business2"},
{"Business Hair 3", "business3"},
{"Business Hair 4", "business4"},
{"Buzzcut", "buzzcut"},
{"CIA", "cia"},
{"Coffee House", "coffeehouse"},
{"Combover", "combover"},
{"Cornrows", "cornrows"},
{"Cornrows 2", "cornrows2"},
{"Cornrow Bun", "cornrowbun"},
{"Cornrow Braid", "cornrowbraid"},
{"Cornrow Tail", "cornrowtail"},
{"Crewcut", "crewcut"},
{"Curls", "curls"},
{"Cut Hair", "c"},
{"Dandy Pompadour", "dandypompadour"},
{"Devil Lock", "devilock"},
{"Double Bun", "doublebun"},
{"Dreadlocks", "dreads"},
{"Drillruru", "drillruru"},
{"Drill Hair (Extended)", "drillhairextended"},
{"Emo", "emo"},
{"Emo Fringe", "emofringe"},
{"Fade (None)", "nofade"},
{"Fade (High)", "highfade"},
{"Fade (Medium)", "medfade"},
{"Fade (Low)", "lowfade"},
{"Fade (Bald)", "baldfade"},
{"Feather", "feather"},
{"Father", "father"},
{"Flat Top", "sargeant"},
{"Flair", "flair"},
{"Flat Top (Big)", "bigflattop"},
{"Flow Hair", "f"},
{"Gelled Back", "gelled"},
{"Gentle", "gentle"},
{"Half-banged Hair", "halfbang"},
{"Half-banged Hair 2", "halfbang2"},
{"Half-shaved", "halfshaved"},
{"Hedgehog Hair", "hedgehog"},
{"Hime Cut", "himecut"},
{"Hime Cut 2", "himecut2"},
{"Hime Cut (Short)", "shorthime"},
{"Hime Updo", "himeup"},
{"Hitop", "hitop"},
{"Jade", "jade"},
{"Jensen Hair", "jensen"},
{"Joestar", "joestar"},
{"Keanu Hair", "keanu"},
{"Kusanagi Hair", "kusanagi"},
{"Long Hair 1", "long"},
{"Long Hair 2", "long2"},
{"Long Hair 3", "long3"},
{"Long Over Eye", "longovereye"},
{"Long Bangs", "lbangs"},
{"Long Emo", "longemo"},
{"Long Fringe", "longfringe"},
{"Long Side Part", "longsidepart"},
{"Mega Eyebrows", "megaeyebrows"},
{"Messy", "messy"},
{"Modern", "modern"},
{"Mohawk", "d"},
{"Nitori", "nitori"},
{"Mohawk (Reverse)", "reversemohawk"},
{"Mohawk (Unshaven)", "unshaven_mohawk"},
{"Mulder", "mulder"},
{"Odango", "odango"},
{"Ombre", "ombre"},
{"One Shoulder", "oneshoulder"},
{"Over Eye", "shortovereye"},
{"Oxton", "oxton"},
{"Parted", "parted"},
{"Parted (Side)", "part"},
{"Pigtails", "kagami"},
{"Pigtails 2", "pigtails"},
{"Pigtails 3", "pigtails2"},
{"Pixie Cut", "pixie"},
{"Pompadour", "pompadour"},
{"Pompadour (Big)", "bigpompadour"},
{"Ponytail", "ponytail"},
{"Ponytail 2", "ponytail2"},
{"Ponytail 3", "ponytail3"},
{"Ponytail 4", "ponytail4"},
{"Ponytail 5", "ponytail5"},
{"Ponytail 6", "ponytail6"},
{"Ponytail 7", "ponytail7"},
{"Ponytail (High)", "highponytail"},
{"Ponytail (Short)", "stail"},
{"Ponytail (Long)", "longstraightponytail"},
{"Ponytail (Country)", "country"},
{"Ponytail (Fringe)", "fringetail"},
{"Ponytail (Side)", "sidetail"},
{"Ponytail (Side) 2", "sidetail2"},
{"Ponytail (Side) 3", "sidetail3"},
{"Ponytail (Side) 4", "sidetail4"},
{"Ponytail (Spiky)", "spikyponytail"},
{"Poofy", "poofy"},
{"Quiff", "quiff"},
{"Ronin", "ronin"},
{"Shaved", "shaved"},
{"Shaved Part", "shavedpart"},
{"Short Bangs", "shortbangs"},
{"Short Hair", "a"},
{"Short Hair 2", "shorthair2"},
{"Short Hair 3", "shorthair3"},
{"Short Hair 4", "d"},
{"Short Hair 5", "e"},
{"Short Hair 6", "f"},
{"Short Hair 7", "shorthairg"},
{"Short Hair 80s", "80s"},
{"Short Hair Rosa", "rosa"},
{"Shoulder-length Hair", "b"},
{"Sidecut", "sidecut"},
{"Skinhead", "skinhead"},
{"Slightly Long Hair", "protagonist"},
{"Spiky", "spikey"},
{"Spiky 2", "spiky"},
{"Spiky 3", "spiky2"},
{"Swept Back Hair", "swept"},
{"Swept Back Hair 2", "swept2"},
{"Thinning", "thinning"},
{"Thinning (Front)", "thinningfront"},
{"Thinning (Rear)", "thinningrear"},
{"Topknot", "topknot"},
{"Tress Shoulder", "tressshoulder"},
{"Trimmed", "trimmed"},
{"Trim Flat", "trimflat"},
{"Twintails", "twintail"},
{"Undercut", "undercut"},
{"Undercut Left", "undercutleft"},
{"Undercut Right", "undercutright"},
{"Unkept", "unkept"},
{"Updo", "updo"},
{"Very Long Hair", "vlong"},
{"Very Long Hair 2", "longest"},
{"Very Long Over Eye", "longest2"},
{"Very Short Over Eye", "veryshortovereyealternate"},
{"Very Long with Fringe", "vlongfringe"},
{"Volaju", "volaju"},
{"Wisp", "wisp"},
};
public static readonly Dictionary<string, string> FacialHairStylesMap = new()
{
{"Beard (Abraham Lincoln)", "abe"},
{"Beard (Broken Man)", "brokenman"},
{"Beard (Chinstrap)", "chin"},
{"Beard (Dwarf)", "dwarf"},
{"Beard (Full)", "fullbeard"},
{"Beard (Cropped Fullbeard)", "croppedfullbeard"},
{"Beard (Goatee)", "gt"},
{"Beard (Hipster)", "hip"},
{"Beard (Jensen)", "jensen"},
{"Beard (Neckbeard)", "neckbeard"},
{"Beard (Very Long)", "wise"},
{"Beard (Muttonmus)", "muttonmus"},
{"Beard (Martial Artist)", "martialartist"},
{"Beard (Chinless Beard)", "chinlessbeard"},
{"Beard (Moonshiner)", "moonshiner"},
{"Beard (Long)", "longbeard"},
{"Beard (Volaju)", "volaju"},
{"Beard (Three o Clock Shadow)", "3oclock"},
{"Beard (Five o Clock Shadow)", "fiveoclock"},
{"Beard (Five o Clock Moustache)", "5oclockmoustache"},
{"Beard (Seven o Clock Shadow)", "7oclock"},
{"Beard (Seven o Clock Moustache)", "7oclockmoustache"},
{"Moustache", "moustache"},
{"Moustache (Pencilstache)", "pencilstache"},
{"Moustache (Smallstache)", "smallstache"},
{"Moustache (Walrus)", "walrus"},
{"Moustache (Fu Manchu)", "fumanchu"},
{"Moustache (Hulk Hogan)", "hogan"},
{"Moustache (Selleck)", "selleck"},
{"Moustache (Square)", "chaplin"},
{"Moustache (Van Dyke)", "vandyke"},
{"Moustache (Watson)", "watson"},
{"Sideburns (Elvis)", "elvis"},
{"Sideburns (Mutton Chops)", "mutton"},
{"Sideburns", "sideburn"},
{"Shaved", "shaved"}
};
// These comparers put the default hair style (shaved/bald) at the very top.
// For in the hair style pickers.
public static readonly IComparer<KeyValuePair<string, string>> HairStyleComparer =
Comparer<KeyValuePair<string, string>>.Create((a, b) =>
{
var styleA = a.Key;
var styleB = b.Key;
if (styleA == DefaultHairStyle)
{
return -1;
}
if (styleB == DefaultHairStyle)
{
return 1;
}
return string.Compare(styleA, styleB, StringComparison.CurrentCulture);
});
public static readonly IComparer<KeyValuePair<string, string>> FacialHairStyleComparer =
Comparer<KeyValuePair<string, string>>.Create((a, b) =>
{
var styleA = a.Key;
var styleB = b.Key;
if (styleA == DefaultFacialHairStyle)
{
return -1;
}
if (styleB == DefaultFacialHairStyle)
{
return 1;
}
return string.Compare(styleA, styleB, StringComparison.CurrentCulture);
});
public static IReadOnlyList<Color> RealisticHairColors = new List<Color>
public static readonly IReadOnlyList<Color> RealisticHairColors = new List<Color>
{
Color.Yellow,
Color.Black,
@@ -280,5 +19,18 @@ namespace Content.Shared.Preferences.Appearance
Color.Wheat,
Color.Gray
};
// These comparers put the default hair style (shaved/bald) at the very top.
// For in the hair style pickers.
public static readonly IComparer<SpriteAccessoryPrototype> SpriteAccessoryComparer =
Comparer<SpriteAccessoryPrototype>.Create((a, b) =>
{
var cmp = -a.Priority.CompareTo(b.Priority);
if (cmp != 0)
return cmp;
return string.Compare(a.ID, b.ID, StringComparison.CurrentCulture);
});
}
}

View File

@@ -0,0 +1,16 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Preferences.Appearance
{
[Flags]
[Serializable, NetSerializable]
public enum SpriteAccessoryCategories
{
None = 0,
HumanHair = 1 << 0,
HumanFacialHair = 1 << 1,
VoxHair = 1 << 2,
VoxFacialHair = 1 << 3
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Shared.Preferences.Appearance
{
public sealed class SpriteAccessoryManager
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private readonly Dictionary<SpriteAccessoryCategories, List<SpriteAccessoryPrototype>> _index = new();
public void Initialize()
{
_prototypeManager.PrototypesReloaded += OnPrototypesReloaded;
foreach (var category in Enum.GetValues<SpriteAccessoryCategories>())
{
_index.Add(category, new List<SpriteAccessoryPrototype>());
}
foreach (var prototype in _prototypeManager.EnumeratePrototypes<SpriteAccessoryPrototype>())
{
AddToIndexes(prototype);
}
}
public IReadOnlyList<SpriteAccessoryPrototype> AccessoriesForCategory(SpriteAccessoryCategories categories)
{
return _index[categories];
}
public bool IsValidAccessoryInCategory(string accessory, SpriteAccessoryCategories categories)
{
return _prototypeManager.TryIndex(accessory, out SpriteAccessoryPrototype? accessoryPrototype)
&& (accessoryPrototype.Categories & categories) != 0;
}
private void OnPrototypesReloaded(PrototypesReloadedEventArgs eventArgs)
{
if (!eventArgs.ByType.TryGetValue(typeof(SpriteAccessoryPrototype), out var set))
return;
foreach (var list in _index.Values)
{
list.RemoveAll(a => set.Modified.ContainsKey(a.ID));
}
foreach (var prototype in set.Modified.Values)
{
var accessoryPrototype = (SpriteAccessoryPrototype) prototype;
AddToIndexes(accessoryPrototype);
}
}
private void AddToIndexes(SpriteAccessoryPrototype accessoryPrototype)
{
for (var i = 0; i < sizeof(SpriteAccessoryCategories) * 8; i++)
{
var flag = (SpriteAccessoryCategories) (1 << i);
if ((accessoryPrototype.Categories & flag) != 0)
_index[flag].Add(accessoryPrototype);
}
}
}
}

View File

@@ -0,0 +1,33 @@
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Shared.Preferences.Appearance
{
/// <summary>
/// Contains data for a single hair style
/// </summary>
[Prototype("spriteAccessory")]
public sealed class SpriteAccessoryPrototype : IPrototype, ISerializationHooks
{
[field: DataField("id", required: true)]
public string ID { get; } = default!;
[field: DataField("categories", required: true)]
public SpriteAccessoryCategories Categories { get; } = default!;
public string Name { get; private set; } = default!;
[field: DataField("sprite", required: true)]
public SpriteSpecifier Sprite { get; } = default!;
[field: DataField("priority")] public int Priority { get; } = 0;
void ISerializationHooks.AfterDeserialization()
{
Name = Loc.GetString($"accessory-{ID}");
}
}
}

View File

@@ -1,6 +1,5 @@
#nullable enable
using System;
using System.Linq;
using Content.Shared.Preferences.Appearance;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
@@ -12,64 +11,64 @@ namespace Content.Shared.Preferences
[Serializable, NetSerializable]
public class HumanoidCharacterAppearance : ICharacterAppearance
{
public HumanoidCharacterAppearance(string hairStyleName,
public HumanoidCharacterAppearance(string hairStyleId,
Color hairColor,
string facialHairStyleName,
string facialHairStyleId,
Color facialHairColor,
Color eyeColor,
Color skinColor)
{
HairStyleName = hairStyleName;
HairStyleId = hairStyleId;
HairColor = ClampColor(hairColor);
FacialHairStyleName = facialHairStyleName;
FacialHairStyleId = facialHairStyleId;
FacialHairColor = ClampColor(facialHairColor);
EyeColor = ClampColor(eyeColor);
SkinColor = ClampColor(skinColor);
}
public string HairStyleName { get; }
public string HairStyleId { get; }
public Color HairColor { get; }
public string FacialHairStyleName { get; }
public string FacialHairStyleId { get; }
public Color FacialHairColor { get; }
public Color EyeColor { get; }
public Color SkinColor { get; }
public HumanoidCharacterAppearance WithHairStyleName(string newName)
{
return new(newName, HairColor, FacialHairStyleName, FacialHairColor, EyeColor, SkinColor);
return new(newName, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor);
}
public HumanoidCharacterAppearance WithHairColor(Color newColor)
{
return new(HairStyleName, newColor, FacialHairStyleName, FacialHairColor, EyeColor, SkinColor);
return new(HairStyleId, newColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor);
}
public HumanoidCharacterAppearance WithFacialHairStyleName(string newName)
{
return new(HairStyleName, HairColor, newName, FacialHairColor, EyeColor, SkinColor);
return new(HairStyleId, HairColor, newName, FacialHairColor, EyeColor, SkinColor);
}
public HumanoidCharacterAppearance WithFacialHairColor(Color newColor)
{
return new(HairStyleName, HairColor, FacialHairStyleName, newColor, EyeColor, SkinColor);
return new(HairStyleId, HairColor, FacialHairStyleId, newColor, EyeColor, SkinColor);
}
public HumanoidCharacterAppearance WithEyeColor(Color newColor)
{
return new(HairStyleName, HairColor, FacialHairStyleName, FacialHairColor, newColor, SkinColor);
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, newColor, SkinColor);
}
public HumanoidCharacterAppearance WithSkinColor(Color newColor)
{
return new(HairStyleName, HairColor, FacialHairStyleName, FacialHairColor, EyeColor, newColor);
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, newColor);
}
public static HumanoidCharacterAppearance Default()
{
return new(
"Bald",
HairStyles.DefaultHairStyle,
Color.Black,
"Shaved",
HairStyles.DefaultFacialHairStyle,
Color.Black,
Color.Black,
Color.FromHex("#C0967F")
@@ -79,12 +78,15 @@ namespace Content.Shared.Preferences
public static HumanoidCharacterAppearance Random(Sex sex)
{
var random = IoCManager.Resolve<IRobustRandom>();
var prototypes = IoCManager.Resolve<SpriteAccessoryManager>();
var hairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
var facialHairStyles = prototypes.AccessoriesForCategory(SpriteAccessoryCategories.HumanHair);
var newHairStyle = random.Pick(HairStyles.HairStylesMap.Keys.ToList());
var newHairStyle = random.Pick(hairStyles).ID;
var newFacialHairStyle = sex == Sex.Female
? HairStyles.DefaultFacialHairStyle
: random.Pick(HairStyles.FacialHairStylesMap.Keys.ToList());
: random.Pick(facialHairStyles).ID;
var newHairColor = random.Pick(HairStyles.RealisticHairColors);
newHairColor = newHairColor
@@ -108,24 +110,17 @@ namespace Content.Shared.Preferences
public static HumanoidCharacterAppearance EnsureValid(HumanoidCharacterAppearance appearance)
{
string hairStyleName;
if (!HairStyles.HairStylesMap.ContainsKey(appearance.HairStyleName))
var mgr = IoCManager.Resolve<SpriteAccessoryManager>();
var hairStyleId = appearance.HairStyleId;
if (!mgr.IsValidAccessoryInCategory(hairStyleId, SpriteAccessoryCategories.HumanHair))
{
hairStyleName = HairStyles.DefaultHairStyle;
}
else
{
hairStyleName = appearance.HairStyleName;
hairStyleId = HairStyles.DefaultHairStyle;
}
string facialHairStyleName;
if (!HairStyles.FacialHairStylesMap.ContainsKey(appearance.FacialHairStyleName))
var facialHairStyleId = appearance.HairStyleId;
if (!mgr.IsValidAccessoryInCategory(hairStyleId, SpriteAccessoryCategories.HumanFacialHair))
{
facialHairStyleName = HairStyles.DefaultFacialHairStyle;
}
else
{
facialHairStyleName = appearance.FacialHairStyleName;
facialHairStyleId = HairStyles.DefaultFacialHairStyle;
}
var hairColor = ClampColor(appearance.HairColor);
@@ -134,9 +129,9 @@ namespace Content.Shared.Preferences
var skinColor = ClampColor(appearance.SkinColor);
return new HumanoidCharacterAppearance(
hairStyleName,
hairStyleId,
hairColor,
facialHairStyleName,
facialHairStyleId,
facialHairColor,
eyeColor,
skinColor);
@@ -145,9 +140,9 @@ namespace Content.Shared.Preferences
public bool MemberwiseEquals(ICharacterAppearance maybeOther)
{
if (maybeOther is not HumanoidCharacterAppearance other) return false;
if (HairStyleName != other.HairStyleName) return false;
if (HairStyleId != other.HairStyleId) return false;
if (!HairColor.Equals(other.HairColor)) return false;
if (FacialHairStyleName != other.FacialHairStyleName) return false;
if (FacialHairStyleId != other.FacialHairStyleId) return false;
if (!FacialHairColor.Equals(other.FacialHairColor)) return false;
if (!EyeColor.Equals(other.EyeColor)) return false;
if (!SkinColor.Equals(other.SkinColor)) return false;

View File

@@ -21,11 +21,12 @@ namespace Content.Shared.Preferences
[Serializable, NetSerializable]
public class HumanoidCharacterProfile : ICharacterProfile
{
public const int MinimumAge = 18;
public const int MaximumAge = 120;
public const int MaxNameLength = 32;
private readonly Dictionary<string, JobPriority> _jobPriorities;
private readonly List<string> _antagPreferences;
public static int MinimumAge = 18;
public static int MaximumAge = 120;
public static int MaxNameLength = 32;
private HumanoidCharacterProfile(
string name,
@@ -85,7 +86,20 @@ namespace Content.Shared.Preferences
public static HumanoidCharacterProfile Default()
{
return Random();
return new(
"John Doe",
MinimumAge,
Sex.Male,
Gender.Male,
HumanoidCharacterAppearance.Default(),
ClothingPreference.Jumpsuit,
BackpackPreference.Backpack,
new Dictionary<string, JobPriority>
{
{SharedGameTicker.OverflowJob, JobPriority.High}
},
PreferenceUnavailableMode.SpawnAsOverflow,
new List<string>());
}
public static HumanoidCharacterProfile Random()

View File

@@ -0,0 +1,13 @@
using Content.Shared.Preferences.Appearance;
using Robust.Shared.IoC;
namespace Content.Shared
{
public static class SharedContentIoC
{
public static void Register()
{
IoCManager.Register<SpriteAccessoryManager, SpriteAccessoryManager>();
}
}
}